From: Liu Bo <bo.li.liu@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 7/7] Btrfs: retry the whole bio on write error
Date: Tue, 21 Nov 2017 17:35:58 -0700 [thread overview]
Message-ID: <20171122003558.28722-8-bo.li.liu@oracle.com> (raw)
In-Reply-To: <20171122003558.28722-1-bo.li.liu@oracle.com>
Since we haven't included badblocks support in our retry path, instead
of retry sector by sector only retry the whole bio to give it an extra
chance.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/volumes.c | 72 ++++++++++--------------------------------------------
1 file changed, 13 insertions(+), 59 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c11db0b..395b03c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6033,74 +6033,28 @@ static inline struct btrfs_device *get_device_from_bio(struct bio *bio)
}
/*
- * return 1 if every sector retry returns successful.
- * return 0 if one or more sector retries fails.
+ * Return 1 if retry returns successful.
+ * Return 0 otherwise.
*/
int btrfs_narrow_write_error(struct bio *bio, struct btrfs_device *dev)
{
struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
- u64 sectors_to_write;
- u64 offset;
- u64 orig;
- u64 unit;
- u64 block_sectors;
- int ok = 1;
+ int ret = 1;
struct bio *wbio;
- /* offset and unit are bytes aligned, not 512-bytes aligned. */
- sectors_to_write = io_bio->iter.bi_size >> 9;
- orig = io_bio->iter.bi_sector;
- offset = 0;
- block_sectors = bdev_logical_block_size(dev->bdev) >> 9;
- unit = block_sectors;
- ASSERT(unit == 1);
-
- while (1) {
- if (!sectors_to_write)
- break;
- /*
- * LIUBO: I don't think unit > sectors_to_write could
- * happen, sectors_to_write should be aligned to PAGE_SIZE
- * which is > unit. Just in case.
- */
- if (unit > sectors_to_write) {
- WARN_ONCE(1, "unit %llu > sectors_to_write (%llu)\n", unit, sectors_to_write);
- unit = sectors_to_write;
- }
-
- /* write @unit bytes at @offset */
- /* this would never fail, check btrfs_bio_clone(). */
- wbio = btrfs_bio_clone(bio);
- wbio->bi_opf = REQ_OP_WRITE;
- wbio->bi_iter = io_bio->iter;
+ /* this would never fail, check btrfs_bio_clone(). */
+ wbio = btrfs_bio_clone(bio);
+ wbio->bi_opf = REQ_OP_WRITE;
+ wbio->bi_iter = io_bio->iter;
- bio_trim(wbio, offset, unit);
- bio_copy_dev(wbio, bio);
+ bio_copy_dev(wbio, bio);
- /* submit in sync way */
- /*
- * LIUBO: There is an issue, if this bio is quite
- * large, say 1M or 2M, and sector size is just 512,
- * then this may take a while.
- *
- * May need to schedule the job to workqueue.
- */
- if (submit_bio_wait(wbio) < 0) {
- ok = 0 && ok;
- /*
- * This is not correct if badblocks is enabled
- * as we need to record every bad sector by
- * trying sectors one by one.
- */
- break;
- }
+ /* submit in sync way */
+ if (submit_bio_wait(wbio) < 0)
+ ret = 0;
- bio_put(wbio);
- offset += unit;
- sectors_to_write -= unit;
- unit = block_sectors;
- }
- return ok;
+ bio_put(wbio);
+ return ret;
}
void btrfs_record_bio_error(struct bio *bio, struct btrfs_device *dev)
--
2.9.4
next prev parent reply other threads:[~2017-11-22 1:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 0:35 [PATCH 0/7] retry write on error Liu Bo
2017-11-22 0:35 ` [PATCH 1/7] Btrfs: keep a copy of bi_iter in btrfs_io_bio Liu Bo
2017-11-22 0:35 ` [PATCH 2/7] Btrfs: add helper __btrfs_end_bio Liu Bo
2017-11-22 0:35 ` [PATCH 3/7] Btrfs: retry write for non-raid56 Liu Bo
2017-11-22 14:41 ` Nikolay Borisov
2017-11-28 23:01 ` Liu Bo
2017-11-22 0:35 ` [PATCH 4/7] Btrfs: get rbio inside fail_bio_stripe Liu Bo
2017-11-22 0:35 ` [PATCH 5/7] Btrfs: add helper __raid_write_end_io Liu Bo
2017-11-22 0:35 ` [PATCH 6/7] Btrfs: retry write for raid56 Liu Bo
2017-11-22 0:35 ` Liu Bo [this message]
2017-11-28 19:22 ` [PATCH 0/7] retry write on error David Sterba
2017-11-28 22:07 ` Edmund Nadolski
2017-11-28 23:41 ` Peter Grandi
2017-11-29 4:09 ` Anand Jain
2017-11-29 16:47 ` David Sterba
2017-11-30 20:22 ` Liu Bo
2017-12-03 21:00 ` Peter Grandi
2017-12-04 9:14 ` Anand Jain
2017-12-04 20:49 ` Edmund Nadolski
2017-12-05 18:57 ` David Sterba
2017-11-29 18:09 ` Liu Bo
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=20171122003558.28722-8-bo.li.liu@oracle.com \
--to=bo.li.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/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 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).