Merge branch 'for-2.6.37/barrier' of git://git.kernel.dk/linux-2.6-block
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / block / loop.c
index de3083b..6c48b35 100644 (file)
@@ -479,17 +479,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;
                        }
@@ -497,9 +497,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
@@ -931,7 +931,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
        lo->lo_queue->unplug_fn = loop_unplug;
 
        if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
-               blk_queue_ordered(lo->lo_queue, QUEUE_ORDERED_DRAIN);
+               blk_queue_flush(lo->lo_queue, REQ_FLUSH);
 
        set_capacity(lo->lo_disk, size);
        bd_set_size(bdev, size << 9);