From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Chris Mason <chris.mason@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, BTRFS <linux-btrfs@vger.kernel.org>
Subject: [PATCH 3/5] Btrfs: fix the race between remove dev and alloc chunk
Date: Wed, 20 Apr 2011 18:08:16 +0800 [thread overview]
Message-ID: <4DAEB090.20609@cn.fujitsu.com> (raw)
In-Reply-To: <4DAEB030.1070303@cn.fujitsu.com>
On remove device path, it updates device->dev_alloc_list but does not hold
chunk lock
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
fs/btrfs/volumes.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index a672249..d20351f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1325,7 +1325,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
}
if (device->writeable) {
+ lock_chunks(root);
list_del_init(&device->dev_alloc_list);
+ unlock_chunks(root);
root->fs_info->fs_devices->rw_devices--;
}
@@ -1379,7 +1381,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
}
fs_devices->seed = device->fs_devices->seed;
device->fs_devices->seed = NULL;
+ lock_chunks(root);
__btrfs_close_devices(device->fs_devices);
+ unlock_chunks(root);
free_fs_devices(device->fs_devices);
}
@@ -1411,8 +1415,10 @@ out:
return ret;
error_undo:
if (device->writeable) {
+ lock_chunks(root);
list_add(&device->dev_alloc_list,
&root->fs_info->fs_devices->alloc_list);
+ unlock_chunks(root);
root->fs_info->fs_devices->rw_devices++;
}
goto error_brelse;
--
1.7.4.4
next prev parent reply other threads:[~2011-04-20 10:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 10:06 [PATCH 1/5] Btrfs: fix bh leak on __btrfs_open_devices path Xiao Guangrong
2011-04-20 10:07 ` [PATCH 2/5] Btrfs: fix the race between reading and updating devices Xiao Guangrong
2011-04-20 10:08 ` Xiao Guangrong [this message]
2011-04-20 10:08 ` [PATCH 4/5] Btrfs: drop unnecessary device lock Xiao Guangrong
2011-04-20 10:09 ` [PATCH 5/5] Btrfs: using rcu lock in the reader side of devices list Xiao Guangrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DAEB090.20609@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=chris.mason@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).