Skip to content

Commit 5073616

Browse files
committed
Merge tag 'for-6.10-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - fix potential infinite loop when doing block grou reclaim - fix crash on emulated zoned device and NOCOW files * tag 'for-6.10-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: zoned: allocate dummy checksums for zoned NODATASUM writes btrfs: retry block group reclaim without infinite loop
2 parents d5a7fc5 + cebae29 commit 5073616

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

fs/btrfs/bio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,9 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
741741
ret = btrfs_bio_csum(bbio);
742742
if (ret)
743743
goto fail_put_bio;
744-
} else if (use_append) {
744+
} else if (use_append ||
745+
(btrfs_is_zoned(fs_info) && inode &&
746+
inode->flags & BTRFS_INODE_NODATASUM)) {
745747
ret = btrfs_alloc_dummy_sum(bbio);
746748
if (ret)
747749
goto fail_put_bio;

fs/btrfs/block-group.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
17851785
container_of(work, struct btrfs_fs_info, reclaim_bgs_work);
17861786
struct btrfs_block_group *bg;
17871787
struct btrfs_space_info *space_info;
1788+
LIST_HEAD(retry_list);
17881789

17891790
if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags))
17901791
return;
@@ -1921,8 +1922,11 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
19211922
}
19221923

19231924
next:
1924-
if (ret)
1925-
btrfs_mark_bg_to_reclaim(bg);
1925+
if (ret) {
1926+
/* Refcount held by the reclaim_bgs list after splice. */
1927+
btrfs_get_block_group(bg);
1928+
list_add_tail(&bg->bg_list, &retry_list);
1929+
}
19261930
btrfs_put_block_group(bg);
19271931

19281932
mutex_unlock(&fs_info->reclaim_bgs_lock);
@@ -1942,6 +1946,9 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
19421946
spin_unlock(&fs_info->unused_bgs_lock);
19431947
mutex_unlock(&fs_info->reclaim_bgs_lock);
19441948
end:
1949+
spin_lock(&fs_info->unused_bgs_lock);
1950+
list_splice_tail(&retry_list, &fs_info->reclaim_bgs);
1951+
spin_unlock(&fs_info->unused_bgs_lock);
19451952
btrfs_exclop_finish(fs_info);
19461953
sb_end_write(fs_info->sb);
19471954
}

0 commit comments

Comments
 (0)