From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: [PATCH 9/9] btrfs: fold repair_io_failure into btrfs_repair_eb_io_failure
Date: Fri, 27 May 2022 10:43:20 +0200 [thread overview]
Message-ID: <20220527084320.2130831-10-hch@lst.de> (raw)
In-Reply-To: <20220527084320.2130831-1-hch@lst.de>
Fold repair_io_failure into the only remaining caller.
This is still inefficient with single page I/Os, but I have some ideas
on how to improve the metadata repair in the future.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/extent_io.c | 51 +++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 34 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index c0cb3d4f5440f..57a709262b730 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2225,35 +2225,6 @@ int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
return bitset;
}
-static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
- u64 length, u64 logical, struct page *page,
- unsigned int pg_offset, int mirror_num)
-{
- struct bio_vec bvec;
- struct bio bio;
- int ret;
-
- ASSERT(!(fs_info->sb->s_flags & SB_RDONLY));
- BUG_ON(!mirror_num);
-
- if (btrfs_repair_one_zone(fs_info, logical))
- return 0;
-
- bio_init(&bio, NULL, &bvec, 1, REQ_OP_WRITE | REQ_SYNC);
- bio.bi_iter.bi_sector = logical >> 9;
- __bio_add_page(&bio, page, length, pg_offset);
- ret = btrfs_map_repair_bio(fs_info, &bio, mirror_num);
- bio_uninit(&bio);
-
- if (ret)
- return ret;
-
- btrfs_info_rl_in_rcu(fs_info,
- "read error corrected: ino %llu off %llu (logical %llu)",
- ino, start, logical);
- return 0;
-}
-
int btrfs_repair_eb_io_failure(const struct extent_buffer *eb, int mirror_num)
{
struct btrfs_fs_info *fs_info = eb->fs_info;
@@ -2261,20 +2232,32 @@ int btrfs_repair_eb_io_failure(const struct extent_buffer *eb, int mirror_num)
int i, num_pages = num_extent_pages(eb);
int ret = 0;
+ WARN_ON_ONCE(!mirror_num);
+
if (sb_rdonly(fs_info->sb))
return -EROFS;
+ if (btrfs_repair_one_zone(fs_info, eb->start))
+ return 0;
+
for (i = 0; i < num_pages; i++) {
struct page *p = eb->pages[i];
+ struct bio_vec bvec;
+ struct bio bio;
+
+ bio_init(&bio, NULL, &bvec, 1, REQ_OP_WRITE | REQ_SYNC);
+ bio.bi_iter.bi_sector = start >> 9;
+ __bio_add_page(&bio, p, PAGE_SIZE, start - page_offset(p));
+ ret = btrfs_map_repair_bio(fs_info, &bio, mirror_num);
+ bio_uninit(&bio);
- ret = repair_io_failure(fs_info, 0, start, PAGE_SIZE, start, p,
- start - page_offset(p), mirror_num);
if (ret)
- break;
- start += PAGE_SIZE;
+ return ret;
}
- return ret;
+ btrfs_info_rl_in_rcu(fs_info,
+ "metadata read error corrected: logical %llu.", eb->start);
+ return 0;
}
static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len)
--
2.30.2
next prev parent reply other threads:[~2022-05-27 8:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 8:43 simple synchronous read repair v2 Christoph Hellwig
2022-05-27 8:43 ` [PATCH 1/9] btrfs: save the original bi_iter into btrfs_bio for buffered read Christoph Hellwig
2022-05-27 8:43 ` [PATCH 2/9] btrfs: set ->file_offset in end_bio_extent_readpage Christoph Hellwig
2022-05-27 8:43 ` [PATCH 3/9] btrfs: factor out a btrfs_map_repair_bio helper Christoph Hellwig
2022-05-27 8:43 ` [PATCH 4/9] btrfs: support read bios in btrfs_map_repair_bio Christoph Hellwig
2022-05-27 8:43 ` [PATCH 5/9] btrfs: add new read repair infrastructure Christoph Hellwig
2022-05-27 8:43 ` [PATCH 6/9] btrfs: use the new read repair code for direct I/O Christoph Hellwig
2022-05-27 8:43 ` [PATCH 7/9] btrfs: use the new read repair code for buffered reads Christoph Hellwig
2022-06-14 16:25 ` Josef Bacik
2022-05-27 8:43 ` [PATCH 8/9] btrfs: remove io_failure_record infrastructure completely Christoph Hellwig
2022-05-27 8:43 ` Christoph Hellwig [this message]
2022-06-06 21:25 ` simple synchronous read repair v2 David Sterba
2022-06-06 22:53 ` Qu Wenruo
2022-06-07 6:16 ` Christoph Hellwig
2022-06-07 6:34 ` Qu Wenruo
2022-06-07 6:45 ` Christoph Hellwig
2022-06-07 8:13 ` Qu Wenruo
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=20220527084320.2130831-10-hch@lst.de \
--to=hch@lst.de \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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.