From: Alex Elder <elder@inktank.com>
To: ceph-devel <ceph-devel@vger.kernel.org>
Subject: [PATCH 2/5] rbd: protect against concurrent unmaps
Date: Fri, 31 May 2013 20:20:26 -0500 [thread overview]
Message-ID: <51A94C5A.20807@inktank.com> (raw)
In-Reply-To: <51A94BC0.4080703@inktank.com>
Make sure two concurrent unmap operations on the same rbd device
won't collide, by only proceeding with the removal and cleanup of a
device if is not already underway.
Signed-off-by: Alex Elder <elder@inktank.com>
---
drivers/block/rbd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 716ef1f..380940d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5153,6 +5153,7 @@ static ssize_t rbd_remove(struct bus_type *bus,
struct list_head *tmp;
int dev_id;
unsigned long ul;
+ bool already = false;
int ret;
ret = strict_strtoul(buf, 10, &ul);
@@ -5180,11 +5181,12 @@ static ssize_t rbd_remove(struct bus_type *bus,
if (rbd_dev->open_count)
ret = -EBUSY;
else
- set_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags);
+ already = test_and_set_bit(RBD_DEV_FLAG_REMOVING,
+ &rbd_dev->flags);
spin_unlock_irq(&rbd_dev->lock);
}
spin_unlock(&rbd_dev_list_lock);
- if (ret < 0)
+ if (ret < 0 || already)
goto done;
rbd_bus_del_dev(rbd_dev);
--
1.7.9.5
next prev parent reply other threads:[~2013-06-01 1:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-01 1:17 [PATCH 0/5] rbd: clean up use of ctl_mutex Alex Elder
2013-06-01 1:18 ` [PATCH 1/5] rbd: set removing flag while holding list lock Alex Elder
2013-06-07 17:41 ` Josh Durgin
2013-06-01 1:20 ` Alex Elder [this message]
2013-06-07 17:42 ` [PATCH 2/5] rbd: protect against concurrent unmaps Josh Durgin
2013-06-01 1:20 ` [PATCH 3/5] rbd: don't hold ctl_mutex to get/put device Alex Elder
2013-06-07 17:44 ` Josh Durgin
2013-06-01 1:20 ` [PATCH 4/5] rbd: use rwsem to protect header updates Alex Elder
2013-06-07 18:25 ` Josh Durgin
2013-06-01 1:20 ` [PATCH 5/5] rbd: take a little credit Alex Elder
2013-06-07 17:48 ` Josh Durgin
2013-06-01 1:23 ` [PATCH 0/5] rbd: clean up use of ctl_mutex Alex Elder
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=51A94C5A.20807@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.