All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Yan <yanaijie@huawei.com>
To: <axboe@kernel.dk>, <linux-block@vger.kernel.org>
Cc: <miaoxie@huawei.com>, <zhaohongjiang@huawei.com>,
	Jason Yan <yanaijie@huawei.com>,
	Kent Overstreet <kent.overstreet@gmail.com>,
	"Christoph Hellwig" <hch@lst.de>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: [PATCH] block: only rewind to last split
Date: Wed, 1 Aug 2018 17:33:57 +0800	[thread overview]
Message-ID: <20180801093357.18417-1-yanaijie@huawei.com> (raw)

Commit 63573e359d05 ("bio-integrity: Restore original iterator on verify
stage") made the bio-integrity verify function works fine when the bio
is smaller than the queue limit.

But since commit 54efd50bfd87 ("block: make generic_make_request handle
arbitrarily sized bios") the bio will split in block layer if the size
of bio is larger than the max length of the queue limit. This will make
the bio-integrity verify function do not work. We will see such error
log with splited bios:

[69163.386065] sda: ref tag error at location 0 (rcvd 1024)

Suppose we have a bio of size 1024k submitted and the driver can only
accept bio of max size 512k.

The original bio:

          bi_sector         1024k
     bio      +-------------------------------+

After the split we have two bios:

          bi_sector  512k
     split    +---------------+
                           bi_sector  512k
     bio      +---------------+---------------+

The new split bio is cloned from the first 512k of the original bio. And
the original bio is advanced to the next 512k(that is 512k~1024k). The
we submit these two requests to the driver.

After the these two bios are complete and we rewind the original bio in
bio_integrity_verify_fn(), the bio restored to the beginnig, but it does
not match the data we submitted to the driver:

          bi_sector         1024k
     bio      +-------------------------------+

When the split bio is complete the verify works fine. But when the whole
original bio is complete we just rewind the whole bio, which makes the
seed does not match the ref tag at all. So we see the above error log.

Fix this by clear the bi_iter.bi_done after split, so that we will only
rewind to the last sector we last start to split.

Fixes: 63573e359d05 ("bio-integrity: Restore original iterator on verify stage")
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Reported-by: Zhang Liao <zhangliao2@huawei.com>
Tested-by: Li Chunjiang <lichunjiang2@huawei.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: Kent Overstreet <kent.overstreet@gmail.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: Miao Xie <miaoxie@huawei.com>
CC: Zhaohongjiang <zhaohongjiang@huawei.com>
---
 block/bio.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index 67eff5eddc49..afa4f408b9dc 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1867,6 +1867,14 @@ struct bio *bio_split(struct bio *bio, int sectors,
 
 	bio_advance(bio, split->bi_iter.bi_size);
 
+	/*
+	 * Now bi_iter.bi_done is only used for bio-integrity to verify
+	 * the data come up from the driver. If we don't clear bi_done
+	 * here, the original bio will rewind to the beginning and the
+	 * seed is error. Please check bio_integrity_verify_fn().
+	 */
+	bio->bi_iter.bi_done = 0;
+
 	if (bio_flagged(bio, BIO_TRACE_COMPLETION))
 		bio_set_flag(split, BIO_TRACE_COMPLETION);
 
-- 
2.13.6

             reply	other threads:[~2018-08-01  9:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01  9:33 Jason Yan [this message]
2018-08-01  9:32 ` [PATCH] block: only rewind to last split Jason Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180801093357.18417-1-yanaijie@huawei.com \
    --to=yanaijie@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=miaoxie@huawei.com \
    --cc=zhaohongjiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.