Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+38 -9
+1 -1
fs/btrfs/extent_io.c
··· 3553 3553 for (int i = 0; i < num_folios; i++) { 3554 3554 if (eb->folios[i]) { 3555 3555 detach_extent_buffer_folio(eb, eb->folios[i]); 3556 - __folio_put(eb->folios[i]); 3556 + folio_put(eb->folios[i]); 3557 3557 } 3558 3558 } 3559 3559 __free_extent_buffer(eb);
+1 -1
fs/btrfs/inode.c
··· 10385 10385 out_folios: 10386 10386 for (i = 0; i < nr_folios; i++) { 10387 10387 if (folios[i]) 10388 - __folio_put(folios[i]); 10388 + folio_put(folios[i]); 10389 10389 } 10390 10390 kvfree(folios); 10391 10391 out:
+8 -2
fs/btrfs/qgroup.c
··· 3062 3062 struct btrfs_qgroup_inherit *inherit, 3063 3063 size_t size) 3064 3064 { 3065 - if (!btrfs_qgroup_enabled(fs_info)) 3066 - return 0; 3067 3065 if (inherit->flags & ~BTRFS_QGROUP_INHERIT_FLAGS_SUPP) 3068 3066 return -EOPNOTSUPP; 3069 3067 if (size < sizeof(*inherit) || size > PAGE_SIZE) ··· 3081 3083 3082 3084 if (size != struct_size(inherit, qgroups, inherit->num_qgroups)) 3083 3085 return -EINVAL; 3086 + 3087 + /* 3088 + * Skip the inherit source qgroups check if qgroup is not enabled. 3089 + * Qgroup can still be later enabled causing problems, but in that case 3090 + * btrfs_qgroup_inherit() would just ignore those invalid ones. 3091 + */ 3092 + if (!btrfs_qgroup_enabled(fs_info)) 3093 + return 0; 3084 3094 3085 3095 /* 3086 3096 * Now check all the remaining qgroups, they should all:
+7 -2
fs/btrfs/ref-verify.c
··· 441 441 u32 item_size = btrfs_item_size(leaf, slot); 442 442 unsigned long end, ptr; 443 443 u64 offset, flags, count; 444 - int type, ret; 444 + int type; 445 + int ret = 0; 445 446 446 447 ei = btrfs_item_ptr(leaf, slot, struct btrfs_extent_item); 447 448 flags = btrfs_extent_flags(leaf, ei); ··· 487 486 key->objectid, key->offset); 488 487 break; 489 488 case BTRFS_EXTENT_OWNER_REF_KEY: 490 - WARN_ON(!btrfs_fs_incompat(fs_info, SIMPLE_QUOTA)); 489 + if (!btrfs_fs_incompat(fs_info, SIMPLE_QUOTA)) { 490 + btrfs_err(fs_info, 491 + "found extent owner ref without simple quotas enabled"); 492 + ret = -EINVAL; 493 + } 491 494 break; 492 495 default: 493 496 btrfs_err(fs_info, "invalid key type in iref");
+21 -3
fs/btrfs/space-info.c
··· 373 373 * "optimal" chunk size based on the fs size. However when we actually 374 374 * allocate the chunk we will strip this down further, making it no more 375 375 * 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. 376 379 */ 377 380 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 + } 381 388 382 389 /* 383 390 * Since data allocations immediately use block groups as part of the ··· 412 405 avail >>= 3; 413 406 else 414 407 avail >>= 1; 408 + 409 + /* 410 + * On the zoned mode, we always allocate one zone as one chunk. 411 + * Returning non-zone size alingned bytes here will result in 412 + * less pressure for the async metadata reclaim process, and it 413 + * will over-commit too much leading to ENOSPC. Align down to the 414 + * zone size to avoid that. 415 + */ 416 + if (btrfs_is_zoned(fs_info)) 417 + avail = ALIGN_DOWN(avail, fs_info->zone_size); 418 + 415 419 return avail; 416 420 } 417 421