Skip to content

Commit 661e504

Browse files
committed
Merge tag 'for-6.10-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - fix folio refcounting when releasing them (encoded write, dummy extent buffer) - fix out of bounds read when checking qgroup inherit data - fix how configurable chunk size is handled in zoned mode - in the ref-verify tool, fix uninitialized return value when checking extent owner ref and simple quota are not enabled * tag 'for-6.10-rc6-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix folio refcount in __alloc_dummy_extent_buffer() btrfs: fix folio refcount in btrfs_do_encoded_write() btrfs: fix uninitialized return value in the ref-verify tool btrfs: always do the basic checks for btrfs_qgroup_inherit structure btrfs: zoned: fix calc_available_free_space() for zoned mode
2 parents 033771c + a56c85f commit 661e504

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

fs/btrfs/extent_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3553,7 +3553,7 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
35533553
for (int i = 0; i < num_folios; i++) {
35543554
if (eb->folios[i]) {
35553555
detach_extent_buffer_folio(eb, eb->folios[i]);
3556-
__folio_put(eb->folios[i]);
3556+
folio_put(eb->folios[i]);
35573557
}
35583558
}
35593559
__free_extent_buffer(eb);

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10385,7 +10385,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
1038510385
out_folios:
1038610386
for (i = 0; i < nr_folios; i++) {
1038710387
if (folios[i])
10388-
__folio_put(folios[i]);
10388+
folio_put(folios[i]);
1038910389
}
1039010390
kvfree(folios);
1039110391
out:

fs/btrfs/qgroup.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,8 +3062,6 @@ int btrfs_qgroup_check_inherit(struct btrfs_fs_info *fs_info,
30623062
struct btrfs_qgroup_inherit *inherit,
30633063
size_t size)
30643064
{
3065-
if (!btrfs_qgroup_enabled(fs_info))
3066-
return 0;
30673065
if (inherit->flags & ~BTRFS_QGROUP_INHERIT_FLAGS_SUPP)
30683066
return -EOPNOTSUPP;
30693067
if (size < sizeof(*inherit) || size > PAGE_SIZE)
@@ -3084,6 +3082,14 @@ int btrfs_qgroup_check_inherit(struct btrfs_fs_info *fs_info,
30843082
if (size != struct_size(inherit, qgroups, inherit->num_qgroups))
30853083
return -EINVAL;
30863084

3085+
/*
3086+
* Skip the inherit source qgroups check if qgroup is not enabled.
3087+
* Qgroup can still be later enabled causing problems, but in that case
3088+
* btrfs_qgroup_inherit() would just ignore those invalid ones.
3089+
*/
3090+
if (!btrfs_qgroup_enabled(fs_info))
3091+
return 0;
3092+
30873093
/*
30883094
* Now check all the remaining qgroups, they should all:
30893095
*

fs/btrfs/ref-verify.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ static int process_extent_item(struct btrfs_fs_info *fs_info,
441441
u32 item_size = btrfs_item_size(leaf, slot);
442442
unsigned long end, ptr;
443443
u64 offset, flags, count;
444-
int type, ret;
444+
int type;
445+
int ret = 0;
445446

446447
ei = btrfs_item_ptr(leaf, slot, struct btrfs_extent_item);
447448
flags = btrfs_extent_flags(leaf, ei);
@@ -486,7 +487,11 @@ static int process_extent_item(struct btrfs_fs_info *fs_info,
486487
key->objectid, key->offset);
487488
break;
488489
case BTRFS_EXTENT_OWNER_REF_KEY:
489-
WARN_ON(!btrfs_fs_incompat(fs_info, SIMPLE_QUOTA));
490+
if (!btrfs_fs_incompat(fs_info, SIMPLE_QUOTA)) {
491+
btrfs_err(fs_info,
492+
"found extent owner ref without simple quotas enabled");
493+
ret = -EINVAL;
494+
}
490495
break;
491496
default:
492497
btrfs_err(fs_info, "invalid key type in iref");

fs/btrfs/space-info.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,18 @@ static u64 calc_available_free_space(struct btrfs_fs_info *fs_info,
373373
* "optimal" chunk size based on the fs size. However when we actually
374374
* allocate the chunk we will strip this down further, making it no more
375375
* than 10% of the disk or 1G, whichever is smaller.
376+
*
377+
* On the zoned mode, we need to use zone_size (=
378+
* data_sinfo->chunk_size) as it is.
376379
*/
377380
data_sinfo = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA);
378-
data_chunk_size = min(data_sinfo->chunk_size,
379-
mult_perc(fs_info->fs_devices->total_rw_bytes, 10));
380-
data_chunk_size = min_t(u64, data_chunk_size, SZ_1G);
381+
if (!btrfs_is_zoned(fs_info)) {
382+
data_chunk_size = min(data_sinfo->chunk_size,
383+
mult_perc(fs_info->fs_devices->total_rw_bytes, 10));
384+
data_chunk_size = min_t(u64, data_chunk_size, SZ_1G);
385+
} else {
386+
data_chunk_size = data_sinfo->chunk_size;
387+
}
381388

382389
/*
383390
* Since data allocations immediately use block groups as part of the
@@ -405,6 +412,17 @@ static u64 calc_available_free_space(struct btrfs_fs_info *fs_info,
405412
avail >>= 3;
406413
else
407414
avail >>= 1;
415+
416+
/*
417+
* On the zoned mode, we always allocate one zone as one chunk.
418+
* Returning non-zone size alingned bytes here will result in
419+
* less pressure for the async metadata reclaim process, and it
420+
* will over-commit too much leading to ENOSPC. Align down to the
421+
* zone size to avoid that.
422+
*/
423+
if (btrfs_is_zoned(fs_info))
424+
avail = ALIGN_DOWN(avail, fs_info->zone_size);
425+
408426
return avail;
409427
}
410428

0 commit comments

Comments
 (0)