Skip to content

Commit 9f388a6

Browse files
committed
Merge tag 'for-6.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - in tree-checker fix extref bounds check - reorder send context structure to avoid -Wflex-array-member-not-at-end warning - fix extent readahead length for compressed extents - fix memory leaks on error paths (qgroup assign ioctl, zone loading with raid stripe tree enabled) - fix how device specific mount options are applied, in particular the 'ssd' option will be set unexpectedly - fix tracking of relocation state when tasks are running and cancellation is attempted - adjust assertion condition for folios allocated for scrub - remove incorrect assertion checking for block group when populating free space tree * tag 'for-6.18-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: send: fix -Wflex-array-member-not-at-end warning in struct send_ctx btrfs: tree-checker: fix bounds check in check_inode_extref() btrfs: fix memory leaks when rejecting a non SINGLE data profile without an RST btrfs: fix incorrect readahead expansion length btrfs: do not assert we found block group item when creating free space tree btrfs: do not use folio_test_partial_kmap() in ASSERT()s btrfs: only set the device specific options after devices are opened btrfs: fix memory leak on duplicated memory in the qgroup assign ioctl btrfs: fix clearing of BTRFS_FS_RELOC_RUNNING if relocation already running
2 parents 05de41f + 8aec9db commit 9f388a6

File tree

9 files changed

+25
-22
lines changed

9 files changed

+25
-22
lines changed

fs/btrfs/extent_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ static void btrfs_readahead_expand(struct readahead_control *ractl,
973973
{
974974
const u64 ra_pos = readahead_pos(ractl);
975975
const u64 ra_end = ra_pos + readahead_length(ractl);
976-
const u64 em_end = em->start + em->ram_bytes;
976+
const u64 em_end = em->start + em->len;
977977

978978
/* No expansion for holes and inline extents. */
979979
if (em->disk_bytenr > EXTENT_MAP_LAST_BYTE)

fs/btrfs/free-space-tree.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,14 +1106,15 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
11061106
* If ret is 1 (no key found), it means this is an empty block group,
11071107
* without any extents allocated from it and there's no block group
11081108
* item (key BTRFS_BLOCK_GROUP_ITEM_KEY) located in the extent tree
1109-
* because we are using the block group tree feature, so block group
1110-
* items are stored in the block group tree. It also means there are no
1111-
* extents allocated for block groups with a start offset beyond this
1112-
* block group's end offset (this is the last, highest, block group).
1109+
* because we are using the block group tree feature (so block group
1110+
* items are stored in the block group tree) or this is a new block
1111+
* group created in the current transaction and its block group item
1112+
* was not yet inserted in the extent tree (that happens in
1113+
* btrfs_create_pending_block_groups() -> insert_block_group_item()).
1114+
* It also means there are no extents allocated for block groups with a
1115+
* start offset beyond this block group's end offset (this is the last,
1116+
* highest, block group).
11131117
*/
1114-
if (!btrfs_fs_compat_ro(trans->fs_info, BLOCK_GROUP_TREE))
1115-
ASSERT(ret == 0);
1116-
11171118
start = block_group->start;
11181119
end = block_group->start + block_group->length;
11191120
while (ret == 0) {

fs/btrfs/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3740,7 +3740,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
37403740
prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
37413741
if (!prealloc) {
37423742
ret = -ENOMEM;
3743-
goto drop_write;
3743+
goto out;
37443744
}
37453745
}
37463746

fs/btrfs/relocation.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,6 +3780,7 @@ static noinline_for_stack struct inode *create_reloc_inode(
37803780
/*
37813781
* Mark start of chunk relocation that is cancellable. Check if the cancellation
37823782
* has been requested meanwhile and don't start in that case.
3783+
* NOTE: if this returns an error, reloc_chunk_end() must not be called.
37833784
*
37843785
* Return:
37853786
* 0 success
@@ -3796,10 +3797,8 @@ static int reloc_chunk_start(struct btrfs_fs_info *fs_info)
37963797

37973798
if (atomic_read(&fs_info->reloc_cancel_req) > 0) {
37983799
btrfs_info(fs_info, "chunk relocation canceled on start");
3799-
/*
3800-
* On cancel, clear all requests but let the caller mark
3801-
* the end after cleanup operations.
3802-
*/
3800+
/* On cancel, clear all requests. */
3801+
clear_and_wake_up_bit(BTRFS_FS_RELOC_RUNNING, &fs_info->flags);
38033802
atomic_set(&fs_info->reloc_cancel_req, 0);
38043803
return -ECANCELED;
38053804
}
@@ -3808,9 +3807,11 @@ static int reloc_chunk_start(struct btrfs_fs_info *fs_info)
38083807

38093808
/*
38103809
* Mark end of chunk relocation that is cancellable and wake any waiters.
3810+
* NOTE: call only if a previous call to reloc_chunk_start() succeeded.
38113811
*/
38123812
static void reloc_chunk_end(struct btrfs_fs_info *fs_info)
38133813
{
3814+
ASSERT(test_bit(BTRFS_FS_RELOC_RUNNING, &fs_info->flags));
38143815
/* Requested after start, clear bit first so any waiters can continue */
38153816
if (atomic_read(&fs_info->reloc_cancel_req) > 0)
38163817
btrfs_info(fs_info, "chunk relocation canceled during operation");
@@ -4023,9 +4024,9 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start,
40234024
if (err && rw)
40244025
btrfs_dec_block_group_ro(rc->block_group);
40254026
iput(rc->data_inode);
4027+
reloc_chunk_end(fs_info);
40264028
out_put_bg:
40274029
btrfs_put_block_group(bg);
4028-
reloc_chunk_end(fs_info);
40294030
free_reloc_control(rc);
40304031
return err;
40314032
}
@@ -4208,8 +4209,8 @@ int btrfs_recover_relocation(struct btrfs_fs_info *fs_info)
42084209
ret = ret2;
42094210
out_unset:
42104211
unset_reloc_control(rc);
4211-
out_end:
42124212
reloc_chunk_end(fs_info);
4213+
out_end:
42134214
free_reloc_control(rc);
42144215
out:
42154216
free_reloc_roots(&reloc_roots);

fs/btrfs/scrub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ static void *scrub_stripe_get_kaddr(struct scrub_stripe *stripe, int sector_nr)
694694

695695
/* stripe->folios[] is allocated by us and no highmem is allowed. */
696696
ASSERT(folio);
697-
ASSERT(!folio_test_partial_kmap(folio));
697+
ASSERT(!folio_test_highmem(folio));
698698
return folio_address(folio) + offset_in_folio(folio, offset);
699699
}
700700

@@ -707,7 +707,7 @@ static phys_addr_t scrub_stripe_get_paddr(struct scrub_stripe *stripe, int secto
707707

708708
/* stripe->folios[] is allocated by us and no highmem is allowed. */
709709
ASSERT(folio);
710-
ASSERT(!folio_test_partial_kmap(folio));
710+
ASSERT(!folio_test_highmem(folio));
711711
/* And the range must be contained inside the folio. */
712712
ASSERT(offset_in_folio(folio, offset) + fs_info->sectorsize <= folio_size(folio));
713713
return page_to_phys(folio_page(folio, 0)) + offset_in_folio(folio, offset);

fs/btrfs/send.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ struct send_ctx {
178178
u64 cur_inode_rdev;
179179
u64 cur_inode_last_extent;
180180
u64 cur_inode_next_write_offset;
181-
struct fs_path cur_inode_path;
182181
bool cur_inode_new;
183182
bool cur_inode_new_gen;
184183
bool cur_inode_deleted;
@@ -305,6 +304,9 @@ struct send_ctx {
305304

306305
struct btrfs_lru_cache dir_created_cache;
307306
struct btrfs_lru_cache dir_utimes_cache;
307+
308+
/* Must be last as it ends in a flexible-array member. */
309+
struct fs_path cur_inode_path;
308310
};
309311

310312
struct pending_dir_move {

fs/btrfs/super.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,8 +1900,6 @@ static int btrfs_get_tree_super(struct fs_context *fc)
19001900
return PTR_ERR(sb);
19011901
}
19021902

1903-
set_device_specific_options(fs_info);
1904-
19051903
if (sb->s_root) {
19061904
/*
19071905
* Not the first mount of the fs thus got an existing super block.
@@ -1946,6 +1944,7 @@ static int btrfs_get_tree_super(struct fs_context *fc)
19461944
deactivate_locked_super(sb);
19471945
return -EACCES;
19481946
}
1947+
set_device_specific_options(fs_info);
19491948
bdev = fs_devices->latest_dev->bdev;
19501949
snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev);
19511950
shrinker_debugfs_rename(sb->s_shrink, "sb-btrfs:%s", sb->s_id);

fs/btrfs/tree-checker.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ static int check_inode_extref(struct extent_buffer *leaf,
17971797
struct btrfs_inode_extref *extref = (struct btrfs_inode_extref *)ptr;
17981798
u16 namelen;
17991799

1800-
if (unlikely(ptr + sizeof(*extref)) > end) {
1800+
if (unlikely(ptr + sizeof(*extref) > end)) {
18011801
inode_ref_err(leaf, slot,
18021802
"inode extref overflow, ptr %lu end %lu inode_extref size %zu",
18031803
ptr, end, sizeof(*extref));

fs/btrfs/zoned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
17531753
!fs_info->stripe_root) {
17541754
btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree",
17551755
btrfs_bg_type_to_raid_name(map->type));
1756-
return -EINVAL;
1756+
ret = -EINVAL;
17571757
}
17581758

17591759
if (unlikely(cache->alloc_offset > cache->zone_capacity)) {

0 commit comments

Comments
 (0)