Skip to content

Commit 939c7fe

Browse files
naotakdave
authored andcommitted
btrfs: zoned: fix ordered extent boundary calculation
btrfs_lookup_ordered_extent() is supposed to query 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: 390ed29 ("btrfs: refactor submit_extent_page() to make bio and its flag tracing easier") Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 1146239 commit 939c7fe

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/btrfs/extent_io.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,7 +3241,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,
32413241
}
32423242

32433243
static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,
3244-
struct btrfs_inode *inode)
3244+
struct btrfs_inode *inode, u64 file_offset)
32453245
{
32463246
struct btrfs_fs_info *fs_info = inode->root->fs_info;
32473247
struct btrfs_io_geometry geom;
@@ -3283,7 +3283,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,
32833283
}
32843284

32853285
/* Ordered extent not yet created, so we're good */
3286-
ordered = btrfs_lookup_ordered_extent(inode, logical);
3286+
ordered = btrfs_lookup_ordered_extent(inode, file_offset);
32873287
if (!ordered) {
32883288
bio_ctrl->len_to_oe_boundary = U32_MAX;
32893289
return 0;
@@ -3300,7 +3300,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,
33003300
struct writeback_control *wbc,
33013301
unsigned int opf,
33023302
bio_end_io_t end_io_func,
3303-
u64 disk_bytenr, u32 offset,
3303+
u64 disk_bytenr, u32 offset, u64 file_offset,
33043304
unsigned long bio_flags)
33053305
{
33063306
struct btrfs_fs_info *fs_info = inode->root->fs_info;
@@ -3317,13 +3317,13 @@ static int alloc_new_bio(struct btrfs_inode *inode,
33173317
bio = btrfs_bio_alloc(disk_bytenr + offset);
33183318
bio_ctrl->bio = bio;
33193319
bio_ctrl->bio_flags = bio_flags;
3320-
ret = calc_bio_boundaries(bio_ctrl, inode);
3321-
if (ret < 0)
3322-
goto error;
33233320
bio->bi_end_io = end_io_func;
33243321
bio->bi_private = &inode->io_tree;
33253322
bio->bi_write_hint = inode->vfs_inode.i_write_hint;
33263323
bio->bi_opf = opf;
3324+
ret = calc_bio_boundaries(bio_ctrl, inode, file_offset);
3325+
if (ret < 0)
3326+
goto error;
33273327
if (wbc) {
33283328
struct block_device *bdev;
33293329

@@ -3398,6 +3398,7 @@ static int submit_extent_page(unsigned int opf,
33983398
if (!bio_ctrl->bio) {
33993399
ret = alloc_new_bio(inode, bio_ctrl, wbc, opf,
34003400
end_io_func, disk_bytenr, offset,
3401+
page_offset(page) + cur,
34013402
bio_flags);
34023403
if (ret < 0)
34033404
return ret;

0 commit comments

Comments
 (0)