提交 a5aa7ab6 编写于 作者: C Christoph Hellwig 提交者: David Sterba

btrfs: factor out a helper to end a single sector buffer I/O

Add a helper to end I/O on a single sector, which will come in handy
with the new read repair code.
Reviewed-by: NJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: NQu Wenruo <wqu@suse.com>
Reviewed-by: NNikolay Borisov <nborisov@suse.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 fd5a6f63
...@@ -2727,6 +2727,20 @@ static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len) ...@@ -2727,6 +2727,20 @@ static void end_page_read(struct page *page, bool uptodate, u64 start, u32 len)
btrfs_subpage_end_reader(fs_info, page, start, len); btrfs_subpage_end_reader(fs_info, page, start, len);
} }
static void end_sector_io(struct page *page, u64 offset, bool uptodate)
{
struct btrfs_inode *inode = BTRFS_I(page->mapping->host);
const u32 sectorsize = inode->root->fs_info->sectorsize;
struct extent_state *cached = NULL;
end_page_read(page, uptodate, offset, sectorsize);
if (uptodate)
set_extent_uptodate(&inode->io_tree, offset,
offset + sectorsize - 1, &cached, GFP_ATOMIC);
unlock_extent_cached_atomic(&inode->io_tree, offset,
offset + sectorsize - 1, &cached);
}
static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio, static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio,
u32 bio_offset, const struct bio_vec *bvec, u32 bio_offset, const struct bio_vec *bvec,
int failed_mirror, unsigned int error_bitmap) int failed_mirror, unsigned int error_bitmap)
...@@ -2757,7 +2771,6 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio, ...@@ -2757,7 +2771,6 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio,
/* Iterate through all the sectors in the range */ /* Iterate through all the sectors in the range */
for (i = 0; i < nr_bits; i++) { for (i = 0; i < nr_bits; i++) {
const unsigned int offset = i * sectorsize; const unsigned int offset = i * sectorsize;
struct extent_state *cached = NULL;
bool uptodate = false; bool uptodate = false;
int ret; int ret;
...@@ -2788,16 +2801,7 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio, ...@@ -2788,16 +2801,7 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio,
* will not be properly unlocked. * will not be properly unlocked.
*/ */
next: next:
end_page_read(page, uptodate, start + offset, sectorsize); end_sector_io(page, start + offset, uptodate);
if (uptodate)
set_extent_uptodate(&BTRFS_I(inode)->io_tree,
start + offset,
start + offset + sectorsize - 1,
&cached, GFP_ATOMIC);
unlock_extent_cached_atomic(&BTRFS_I(inode)->io_tree,
start + offset,
start + offset + sectorsize - 1,
&cached);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册