btrfs: simplify subpage handling of read_extent_buffer_pages_nowait()
By using a shared bio_add_folio_nofail() with calculated range_start/range_len, so no more explicit subpage routine needed. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
+8
-13
@@ -3494,8 +3494,8 @@ static void end_bbio_meta_read(struct btrfs_bio *bbio)
|
||||
int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num,
|
||||
const struct btrfs_tree_parent_check *check)
|
||||
{
|
||||
const int num_folios = num_extent_folios(eb);
|
||||
struct btrfs_bio *bbio;
|
||||
bool ret;
|
||||
|
||||
if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
|
||||
return 0;
|
||||
@@ -3535,19 +3535,14 @@ int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num,
|
||||
bbio->inode = BTRFS_I(eb->fs_info->btree_inode);
|
||||
bbio->file_offset = eb->start;
|
||||
memcpy(&bbio->parent_check, check, sizeof(*check));
|
||||
if (btrfs_meta_is_subpage(eb->fs_info)) {
|
||||
ret = bio_add_folio(&bbio->bio, eb->folios[0], eb->len,
|
||||
eb->start - folio_pos(eb->folios[0]));
|
||||
ASSERT(ret);
|
||||
} else {
|
||||
int num_folios = num_extent_folios(eb);
|
||||
for (int i = 0; i < num_folios; i++) {
|
||||
struct folio *folio = eb->folios[i];
|
||||
u64 range_start = max_t(u64, eb->start, folio_pos(folio));
|
||||
u32 range_len = min_t(u64, folio_pos(folio) + folio_size(folio),
|
||||
eb->start + eb->len) - range_start;
|
||||
|
||||
for (int i = 0; i < num_folios; i++) {
|
||||
struct folio *folio = eb->folios[i];
|
||||
|
||||
ret = bio_add_folio(&bbio->bio, folio, eb->folio_size, 0);
|
||||
ASSERT(ret);
|
||||
}
|
||||
bio_add_folio_nofail(&bbio->bio, folio, range_len,
|
||||
offset_in_folio(folio, range_start));
|
||||
}
|
||||
btrfs_submit_bbio(bbio, mirror_num);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user