Commit 9f5316c1 authored by Liu Bo's avatar Liu Bo Committed by David Sterba

Btrfs: free btrfs_device in place

It's pointless to defer it to a kthread helper as we're not under a
special context.

For reference, commit 1f78160c ("Btrfs: using rcu lock in the reader
side of devices list") introduced RCU freeing for device structures.

Originally the blkdev_put was called from free_device and rcu_barrier had
to be called. This is no longer required, bdev and our device structures
are now freed separately.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ enhance changelog ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 1805f2ca
...@@ -824,26 +824,16 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step) ...@@ -824,26 +824,16 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step)
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
} }
static void __free_device(struct work_struct *work) static void free_device(struct rcu_head *head)
{ {
struct btrfs_device *device; struct btrfs_device *device;
device = container_of(work, struct btrfs_device, rcu_work); device = container_of(head, struct btrfs_device, rcu);
rcu_string_free(device->name); rcu_string_free(device->name);
bio_put(device->flush_bio); bio_put(device->flush_bio);
kfree(device); kfree(device);
} }
static void free_device(struct rcu_head *head)
{
struct btrfs_device *device;
device = container_of(head, struct btrfs_device, rcu);
INIT_WORK(&device->rcu_work, __free_device);
schedule_work(&device->rcu_work);
}
static void btrfs_close_bdev(struct btrfs_device *device) static void btrfs_close_bdev(struct btrfs_device *device)
{ {
if (device->bdev && device->writeable) { if (device->bdev && device->writeable) {
......
...@@ -133,7 +133,6 @@ struct btrfs_device { ...@@ -133,7 +133,6 @@ struct btrfs_device {
struct btrfs_work work; struct btrfs_work work;
struct rcu_head rcu; struct rcu_head rcu;
struct work_struct rcu_work;
/* readahead state */ /* readahead state */
spinlock_t reada_lock; spinlock_t reada_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment