* [PATCH 2/2] Btrfs: fix wrong total device counter after removing a seed device
@ 2014-07-16 10:38 Miao Xie
2014-07-17 3:44 ` Miao Xie
0 siblings, 1 reply; 2+ messages in thread
From: Miao Xie @ 2014-07-16 10:38 UTC (permalink / raw)
To: linux-btrfs
The total device counters of all the descendant filesystem account the seed
device, so after removing a seed device, we need decrease all those counters.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
fs/btrfs/volumes.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 4cfbe76..184e1c4 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1715,12 +1715,16 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
* (super_copy) should hold the device list mutex.
*/
- cur_devices = device->fs_devices;
mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
list_del_rcu(&device->dev_list);
device->fs_devices->num_devices--;
- device->fs_devices->total_devices--;
+
+ cur_devices = root->fs_info->fs_devices;
+ do {
+ cur_devices->total_devices--;
+ cur_devices = cur_devices->seed;
+ } while (device->fs_devices != cur_devices);
if (device->missing)
device->fs_devices->missing_devices--;
@@ -1738,12 +1742,12 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
/* remove sysfs entry */
btrfs_kobj_rm_device(root->fs_info, device);
- call_rcu(&device->rcu, free_device);
-
num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1;
btrfs_set_super_num_devices(root->fs_info->super_copy, num_devices);
mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);
+ call_rcu(&device->rcu, free_device);
+
if (cur_devices->open_devices == 0) {
struct btrfs_fs_devices *fs_devices;
fs_devices = root->fs_info->fs_devices;
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] Btrfs: fix wrong total device counter after removing a seed device
2014-07-16 10:38 [PATCH 2/2] Btrfs: fix wrong total device counter after removing a seed device Miao Xie
@ 2014-07-17 3:44 ` Miao Xie
0 siblings, 0 replies; 2+ messages in thread
From: Miao Xie @ 2014-07-17 3:44 UTC (permalink / raw)
To: linux-btrfs
Please ignore this patch, the fix is not right.
Thanks
Miao
On Wed, 16 Jul 2014 18:38:37 +0800, Miao Xie wrote:
> The total device counters of all the descendant filesystem account the seed
> device, so after removing a seed device, we need decrease all those counters.
>
> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
> fs/btrfs/volumes.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 4cfbe76..184e1c4 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1715,12 +1715,16 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
> * (super_copy) should hold the device list mutex.
> */
>
> - cur_devices = device->fs_devices;
> mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
> list_del_rcu(&device->dev_list);
>
> device->fs_devices->num_devices--;
> - device->fs_devices->total_devices--;
> +
> + cur_devices = root->fs_info->fs_devices;
> + do {
> + cur_devices->total_devices--;
> + cur_devices = cur_devices->seed;
> + } while (device->fs_devices != cur_devices);
>
> if (device->missing)
> device->fs_devices->missing_devices--;
> @@ -1738,12 +1742,12 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
> /* remove sysfs entry */
> btrfs_kobj_rm_device(root->fs_info, device);
>
> - call_rcu(&device->rcu, free_device);
> -
> num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1;
> btrfs_set_super_num_devices(root->fs_info->super_copy, num_devices);
> mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);
>
> + call_rcu(&device->rcu, free_device);
> +
> if (cur_devices->open_devices == 0) {
> struct btrfs_fs_devices *fs_devices;
> fs_devices = root->fs_info->fs_devices;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-17 3:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-16 10:38 [PATCH 2/2] Btrfs: fix wrong total device counter after removing a seed device Miao Xie
2014-07-17 3:44 ` Miao Xie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).