Skip to content

Commit 9fc9a5a

Browse files
committed
btrfs: open code rcu_string_free() and remove it
The helper is trivial and we can simply use kfree_rcu() if needed. In our case it's just one place where we rename a device in device_list_add() and the old name can still be used until the end of the RCU grace period. The other case is freeing a device and there nothing should reach the device, so we can use plain kfree(). Reviewed-by: Daniel Vacek <neelx@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 3dac103 commit 9fc9a5a

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

fs/btrfs/rcu-string.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ static inline struct rcu_string *rcu_string_strdup(const char *src, gfp_t mask)
3232
return ret;
3333
}
3434

35-
static inline void rcu_string_free(struct rcu_string *str)
36-
{
37-
if (str)
38-
kfree_rcu(str, rcu);
39-
}
40-
4135
#define printk_in_rcu(fmt, ...) do { \
4236
rcu_read_lock(); \
4337
printk(fmt, __VA_ARGS__); \

fs/btrfs/volumes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ static struct btrfs_fs_devices *alloc_fs_devices(const u8 *fsid)
403403
static void btrfs_free_device(struct btrfs_device *device)
404404
{
405405
WARN_ON(!list_empty(&device->post_commit_list));
406-
rcu_string_free(device->name);
406+
/* No need to call kfree_rcu(), nothing is reading the device name. */
407+
kfree(device->name);
407408
btrfs_extent_io_tree_release(&device->alloc_state);
408409
btrfs_destroy_dev_zone_info(device);
409410
kfree(device);
@@ -962,7 +963,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
962963
mutex_unlock(&fs_devices->device_list_mutex);
963964
return ERR_PTR(-ENOMEM);
964965
}
965-
rcu_string_free(device->name);
966+
kfree_rcu(device->name, rcu);
966967
rcu_assign_pointer(device->name, name);
967968
if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)) {
968969
fs_devices->missing_devices--;

0 commit comments

Comments
 (0)