Skip to content

Commit

Permalink
block/loop: implement REQ_FLUSH/FUA support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Sep 10, 2010
1 parent d391a2d commit 6259f28
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,27 +477,27 @@ 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;
}
}

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
Expand Down

0 comments on commit 6259f28

Please sign in to comment.