Skip to content

Commit 154f7cb

Browse files
adam900710kdave
authored andcommitted
btrfs: add owner and fs_info to alloc_state io_tree
Commit 1c11b63 ("btrfs: replace pending/pinned chunks lists with io tree") introduced btrfs_device::alloc_state extent io tree, but it doesn't initialize the fs_info and owner member. This means the following features are not properly supported: - Fs owner report for insert_state() error Without fs_info initialized, although btrfs_err() won't panic, it won't output which fs is causing the error. - Wrong owner for trace events alloc_state will get the owner as pinned extents. Fix this by assiging proper fs_info and owner for btrfs_device::alloc_state. Fixes: 1c11b63 ("btrfs: replace pending/pinned chunks lists with io tree") Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 4c448ce commit 154f7cb

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎fs/btrfs/extent-io-tree.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum {
4848
IO_TREE_INODE_FILE_EXTENT,
4949
IO_TREE_LOG_CSUM_RANGE,
5050
IO_TREE_SELFTEST,
51+
IO_TREE_DEVICE_ALLOC_STATE,
5152
};
5253

5354
struct extent_io_tree {

‎fs/btrfs/volumes.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ void __exit btrfs_cleanup_fs_uuids(void)
406406
* Returned struct is not linked onto any lists and must be destroyed using
407407
* btrfs_free_device.
408408
*/
409-
static struct btrfs_device *__alloc_device(void)
409+
static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info)
410410
{
411411
struct btrfs_device *dev;
412412

@@ -433,7 +433,8 @@ static struct btrfs_device *__alloc_device(void)
433433
btrfs_device_data_ordered_init(dev);
434434
INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
435435
INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
436-
extent_io_tree_init(NULL, &dev->alloc_state, 0, NULL);
436+
extent_io_tree_init(fs_info, &dev->alloc_state,
437+
IO_TREE_DEVICE_ALLOC_STATE, NULL);
437438

438439
return dev;
439440
}
@@ -6532,7 +6533,7 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
65326533
if (WARN_ON(!devid && !fs_info))
65336534
return ERR_PTR(-EINVAL);
65346535

6535-
dev = __alloc_device();
6536+
dev = __alloc_device(fs_info);
65366537
if (IS_ERR(dev))
65376538
return dev;
65386539

0 commit comments

Comments
 (0)