提交 6259f284 编写于 作者: T Tejun Heo 提交者: Jens Axboe

block/loop: implement REQ_FLUSH/FUA support

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: NTejun Heo <tj@kernel.org>
Signed-off-by: NJens Axboe <jaxboe@fusionio.com>
上级 d391a2dd
...@@ -477,17 +477,17 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) ...@@ -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; pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;
if (bio_rw(bio) == WRITE) { if (bio_rw(bio) == WRITE) {
bool barrier = (bio->bi_rw & REQ_HARDBARRIER);
struct file *file = lo->lo_backing_file; struct file *file = lo->lo_backing_file;
if (barrier) { /* REQ_HARDBARRIER is deprecated */
if (unlikely(!file->f_op->fsync)) { if (bio->bi_rw & REQ_HARDBARRIER) {
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto out; goto out;
} }
if (bio->bi_rw & REQ_FLUSH) {
ret = vfs_fsync(file, 0); ret = vfs_fsync(file, 0);
if (unlikely(ret)) { if (unlikely(ret && ret != -EINVAL)) {
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
...@@ -495,9 +495,9 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) ...@@ -495,9 +495,9 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
ret = lo_send(lo, bio, pos); ret = lo_send(lo, bio, pos);
if (barrier && !ret) { if ((bio->bi_rw & REQ_FUA) && !ret) {
ret = vfs_fsync(file, 0); ret = vfs_fsync(file, 0);
if (unlikely(ret)) if (unlikely(ret && ret != -EINVAL))
ret = -EIO; ret = -EIO;
} }
} else } else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册