block/loop: implement REQ_FLUSH/FUA support
authorTejun Heo <tj@kernel.org>
Fri, 3 Sep 2010 09:56:17 +0000 (11:56 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 10 Sep 2010 10:35:37 +0000 (12:35 +0200)
Deprecate REQ_HARDBARRIER and implement REQ_FLUSH/FUA instead.  Also,
instead of checking file->f_op->fsync() directly, look at the value of
vfs_fsync() and ignore -EINVAL return.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
drivers/block/loop.c

index 953d1e12f4d401cf6a1d5a74423ce631ec76a92c..5d27bc6596de01f179251b951ec292cfd181a917 100644 (file)
@@ -477,17 +477,17 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
        pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
 
        if (bio_rw(bio) == WRITE) {
-               bool barrier = (bio->bi_rw & REQ_HARDBARRIER);
                struct file *file = lo->lo_backing_file;
 
-               if (barrier) {
-                       if (unlikely(!file->f_op->fsync)) {
-                               ret = -EOPNOTSUPP;
-                               goto out;
-                       }
+               /* REQ_HARDBARRIER is deprecated */
+               if (bio->bi_rw & REQ_HARDBARRIER) {
+                       ret = -EOPNOTSUPP;
+                       goto out;
+               }
 
+               if (bio->bi_rw & REQ_FLUSH) {
                        ret = vfs_fsync(file, 0);
-                       if (unlikely(ret)) {
+                       if (unlikely(ret && ret != -EINVAL)) {
                                ret = -EIO;
                                goto out;
                        }
@@ -495,9 +495,9 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
 
                ret = lo_send(lo, bio, pos);
 
-               if (barrier && !ret) {
+               if ((bio->bi_rw & REQ_FUA) && !ret) {
                        ret = vfs_fsync(file, 0);
-                       if (unlikely(ret))
+                       if (unlikely(ret && ret != -EINVAL))
                                ret = -EIO;
                }
        } else