Message ID | 20210811063708.2520540-1-naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: zoned: fix ordered extent boundary calculation | expand |
On 2021/8/11 下午2:37, Naohiro Aota wrote: > btrfs_lookup_ordered_extent() should be queried with the offset in a file > instead of the logical address. Pass the file offset from > submit_extent_page() to calc_bio_boundaries(). > > Also, calc_bio_boundaries() relies on the bio's operation flag, so move the > call site after setting it. > > Fixes: 390ed29b817e ("btrfs: refactor submit_extent_page() to make bio and its flag tracing easier") > Cc: Qu Wenruo <wqu@suse.com> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/extent_io.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 7d4c03762374..c353bfd89dfc 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -3241,7 +3241,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl, > } > > static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, > - struct btrfs_inode *inode) > + struct btrfs_inode *inode, u64 file_offset) > { > struct btrfs_fs_info *fs_info = inode->root->fs_info; > struct btrfs_io_geometry geom; > @@ -3283,7 +3283,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, > } > > /* Ordered extent not yet created, so we're good */ > - ordered = btrfs_lookup_ordered_extent(inode, logical); > + ordered = btrfs_lookup_ordered_extent(inode, file_offset); > if (!ordered) { > bio_ctrl->len_to_oe_boundary = U32_MAX; > return 0; > @@ -3300,7 +3300,7 @@ static int alloc_new_bio(struct btrfs_inode *inode, > struct writeback_control *wbc, > unsigned int opf, > bio_end_io_t end_io_func, > - u64 disk_bytenr, u32 offset, > + u64 disk_bytenr, u32 offset, u64 file_offset, > unsigned long bio_flags) > { > struct btrfs_fs_info *fs_info = inode->root->fs_info; > @@ -3317,13 +3317,13 @@ static int alloc_new_bio(struct btrfs_inode *inode, > bio = btrfs_bio_alloc(disk_bytenr + offset); > bio_ctrl->bio = bio; > bio_ctrl->bio_flags = bio_flags; > - ret = calc_bio_boundaries(bio_ctrl, inode); > - if (ret < 0) > - goto error; > bio->bi_end_io = end_io_func; > bio->bi_private = &inode->io_tree; > bio->bi_write_hint = inode->vfs_inode.i_write_hint; > bio->bi_opf = opf; > + ret = calc_bio_boundaries(bio_ctrl, inode, file_offset); > + if (ret < 0) > + goto error; > if (wbc) { > struct block_device *bdev; > > @@ -3398,6 +3398,7 @@ static int submit_extent_page(unsigned int opf, > if (!bio_ctrl->bio) { > ret = alloc_new_bio(inode, bio_ctrl, wbc, opf, > end_io_func, disk_bytenr, offset, > + page_offset(page) + cur, > bio_flags); > if (ret < 0) > return ret; >
On Wed, Aug 11, 2021 at 03:37:08PM +0900, Naohiro Aota wrote: > btrfs_lookup_ordered_extent() should be queried with the offset in a file > instead of the logical address. Pass the file offset from > submit_extent_page() to calc_bio_boundaries(). > > Also, calc_bio_boundaries() relies on the bio's operation flag, so move the > call site after setting it. > > Fixes: 390ed29b817e ("btrfs: refactor submit_extent_page() to make bio and its flag tracing easier") > Cc: Qu Wenruo <wqu@suse.com> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Added to misc-next, thanks.
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 7d4c03762374..c353bfd89dfc 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3241,7 +3241,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl, } static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, - struct btrfs_inode *inode) + struct btrfs_inode *inode, u64 file_offset) { struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_io_geometry geom; @@ -3283,7 +3283,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, } /* Ordered extent not yet created, so we're good */ - ordered = btrfs_lookup_ordered_extent(inode, logical); + ordered = btrfs_lookup_ordered_extent(inode, file_offset); if (!ordered) { bio_ctrl->len_to_oe_boundary = U32_MAX; return 0; @@ -3300,7 +3300,7 @@ static int alloc_new_bio(struct btrfs_inode *inode, struct writeback_control *wbc, unsigned int opf, bio_end_io_t end_io_func, - u64 disk_bytenr, u32 offset, + u64 disk_bytenr, u32 offset, u64 file_offset, unsigned long bio_flags) { struct btrfs_fs_info *fs_info = inode->root->fs_info; @@ -3317,13 +3317,13 @@ static int alloc_new_bio(struct btrfs_inode *inode, bio = btrfs_bio_alloc(disk_bytenr + offset); bio_ctrl->bio = bio; bio_ctrl->bio_flags = bio_flags; - ret = calc_bio_boundaries(bio_ctrl, inode); - if (ret < 0) - goto error; bio->bi_end_io = end_io_func; bio->bi_private = &inode->io_tree; bio->bi_write_hint = inode->vfs_inode.i_write_hint; bio->bi_opf = opf; + ret = calc_bio_boundaries(bio_ctrl, inode, file_offset); + if (ret < 0) + goto error; if (wbc) { struct block_device *bdev; @@ -3398,6 +3398,7 @@ static int submit_extent_page(unsigned int opf, if (!bio_ctrl->bio) { ret = alloc_new_bio(inode, bio_ctrl, wbc, opf, end_io_func, disk_bytenr, offset, + page_offset(page) + cur, bio_flags); if (ret < 0) return ret;
btrfs_lookup_ordered_extent() should be queried with the offset in a file instead of the logical address. Pass the file offset from submit_extent_page() to calc_bio_boundaries(). Also, calc_bio_boundaries() relies on the bio's operation flag, so move the call site after setting it. Fixes: 390ed29b817e ("btrfs: refactor submit_extent_page() to make bio and its flag tracing easier") Cc: Qu Wenruo <wqu@suse.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/extent_io.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)