Skip to content

Commit 8cd26fd

Browse files
committed
Merge tag 'for-6.9-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - fixup in zoned mode for out-of-order writes of metadata that are no longer necessary, this used to be tracked in a separate list but now the old locaion needs to be zeroed out, also add assertions - fix bulk page allocation retry, this may stall after first failure for compression read/write * tag 'for-6.9-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: do not wait for short bulk allocation btrfs: zoned: add ASSERT and WARN for EXTENT_BUFFER_ZONED_ZEROOUT handling btrfs: zoned: do not flag ZEROOUT on non-dirty extent buffer
2 parents 4b6b513 + 1db7959 commit 8cd26fd

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

fs/btrfs/extent-tree.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,14 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
34643464
if (root_id != BTRFS_TREE_LOG_OBJECTID) {
34653465
struct btrfs_ref generic_ref = { 0 };
34663466

3467+
/*
3468+
* Assert that the extent buffer is not cleared due to
3469+
* EXTENT_BUFFER_ZONED_ZEROOUT. Please refer
3470+
* btrfs_clear_buffer_dirty() and btree_csum_one_bio() for
3471+
* detail.
3472+
*/
3473+
ASSERT(btrfs_header_bytenr(buf) != 0);
3474+
34673475
btrfs_init_generic_ref(&generic_ref, BTRFS_DROP_DELAYED_REF,
34683476
buf->start, buf->len, parent,
34693477
btrfs_header_owner(buf));

fs/btrfs/extent_io.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -681,31 +681,21 @@ static void end_bbio_data_read(struct btrfs_bio *bbio)
681681
int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
682682
gfp_t extra_gfp)
683683
{
684+
const gfp_t gfp = GFP_NOFS | extra_gfp;
684685
unsigned int allocated;
685686

686687
for (allocated = 0; allocated < nr_pages;) {
687688
unsigned int last = allocated;
688689

689-
allocated = alloc_pages_bulk_array(GFP_NOFS | extra_gfp,
690-
nr_pages, page_array);
691-
692-
if (allocated == nr_pages)
693-
return 0;
694-
695-
/*
696-
* During this iteration, no page could be allocated, even
697-
* though alloc_pages_bulk_array() falls back to alloc_page()
698-
* if it could not bulk-allocate. So we must be out of memory.
699-
*/
700-
if (allocated == last) {
690+
allocated = alloc_pages_bulk_array(gfp, nr_pages, page_array);
691+
if (unlikely(allocated == last)) {
692+
/* No progress, fail and do cleanup. */
701693
for (int i = 0; i < allocated; i++) {
702694
__free_page(page_array[i]);
703695
page_array[i] = NULL;
704696
}
705697
return -ENOMEM;
706698
}
707-
708-
memalloc_retry_wait(GFP_NOFS);
709699
}
710700
return 0;
711701
}
@@ -4154,7 +4144,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
41544144
* The actual zeroout of the buffer will happen later in
41554145
* btree_csum_one_bio.
41564146
*/
4157-
if (btrfs_is_zoned(fs_info)) {
4147+
if (btrfs_is_zoned(fs_info) && test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)) {
41584148
set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags);
41594149
return;
41604150
}
@@ -4193,6 +4183,7 @@ void set_extent_buffer_dirty(struct extent_buffer *eb)
41934183
num_folios = num_extent_folios(eb);
41944184
WARN_ON(atomic_read(&eb->refs) == 0);
41954185
WARN_ON(!test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags));
4186+
WARN_ON(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags));
41964187

41974188
if (!was_dirty) {
41984189
bool subpage = eb->fs_info->nodesize < PAGE_SIZE;

0 commit comments

Comments
 (0)