stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "block: loop: fix filesystem corruption in case of aio/dio" has been added to the 4.4-stable tree
@ 2016-04-28  0:06 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2016-04-28  0:06 UTC (permalink / raw)
  To: ming.lei, axboe, gregkh, keith.busch, viro; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    block: loop: fix filesystem corruption in case of aio/dio

to the 4.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     block-loop-fix-filesystem-corruption-in-case-of-aio-dio.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From a7297a6a3a3322b054592e8e988981d2f5f29cc4 Mon Sep 17 00:00:00 2001
From: Ming Lei <ming.lei@canonical.com>
Date: Fri, 15 Apr 2016 18:51:28 +0800
Subject: block: loop: fix filesystem corruption in case of aio/dio

From: Ming Lei <ming.lei@canonical.com>

commit a7297a6a3a3322b054592e8e988981d2f5f29cc4 upstream.

Starting from commit e36f620428(block: split bios to max possible length),
block core starts to split bio in the middle of bvec.

Unfortunately loop dio/aio doesn't consider this situation, and
always treat 'iter.iov_offset' as zero. Then filesystem corruption
is observed.

This patch figures out the offset of the base bvevc via
'bio->bi_iter.bi_bvec_done' and fixes the issue by passing the offset
to iov iterator.

Fixes: e36f6204288088f (block: split bios to max possible length)
Cc: Keith Busch <keith.busch@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 423f4ca7d712..80cf8add46ff 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -488,6 +488,12 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 	bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
 	iov_iter_bvec(&iter, ITER_BVEC | rw, bvec,
 		      bio_segments(bio), blk_rq_bytes(cmd->rq));
+	/*
+	 * This bio may be started from the middle of the 'bvec'
+	 * because of bio splitting, so offset from the bvec must
+	 * be passed to iov iterator
+	 */
+	iter.iov_offset = bio->bi_iter.bi_bvec_done;
 
 	cmd->iocb.ki_pos = pos;
 	cmd->iocb.ki_filp = file;


Patches currently in stable-queue which might be from ming.lei@canonical.com are

queue-4.4/block-partition-initialize-percpuref-before-sending-out-kobj_add.patch
queue-4.4/block-loop-fix-filesystem-corruption-in-case-of-aio-dio.patch

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-28  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28  0:06 Patch "block: loop: fix filesystem corruption in case of aio/dio" has been added to the 4.4-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).