From: Ilya Dryomov <idryomov@gmail.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 2/9] rbd: move rbd_unregister_watch() call into rbd_dev_image_release()
Date: Tue, 25 Apr 2017 11:33:38 +0200 [thread overview]
Message-ID: <1493112825-16403-3-git-send-email-idryomov@gmail.com> (raw)
In-Reply-To: <1493112825-16403-1-git-send-email-idryomov@gmail.com>
rbd_dev->disk tear down vs rbd_watch_cb() race shouldn't be a problem
anymore thanks to EXISTS and REMOVING checks in rbd_dev_update_size().
A similar race could occur on "rbd map", see commit 811c66887746
("rbd: fix rbd map vs notify races").
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
drivers/block/rbd.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 2effa3e8f96c..a21587732749 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5964,6 +5964,8 @@ static int rbd_dev_header_name(struct rbd_device *rbd_dev)
static void rbd_dev_image_release(struct rbd_device *rbd_dev)
{
rbd_dev_unprobe(rbd_dev);
+ if (rbd_dev->opts)
+ rbd_unregister_watch(rbd_dev);
rbd_dev->image_format = 0;
kfree(rbd_dev->spec->image_id);
rbd_dev->spec->image_id = NULL;
@@ -6126,15 +6128,8 @@ static ssize_t do_rbd_add(struct bus_type *bus,
rbd_dev->mapping.read_only = read_only;
rc = rbd_dev_device_setup(rbd_dev);
- if (rc) {
- /*
- * rbd_unregister_watch() can't be moved into
- * rbd_dev_image_release() without refactoring, see
- * commit 1f3ef78861ac.
- */
- rbd_unregister_watch(rbd_dev);
+ if (rc)
goto err_out_image_probe;
- }
rc = count;
out:
@@ -6275,14 +6270,7 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
if (__rbd_is_lock_owner(rbd_dev))
rbd_unlock(rbd_dev);
up_write(&rbd_dev->lock_rwsem);
- rbd_unregister_watch(rbd_dev);
- /*
- * Don't free anything from rbd_dev->disk until after all
- * notifies are completely processed. Otherwise
- * rbd_bus_del_dev() will race with rbd_watch_cb(), resulting
- * in a potential use after free of rbd_dev->disk or rbd_dev.
- */
rbd_dev_device_release(rbd_dev);
rbd_dev_image_release(rbd_dev);
rbd_dev_destroy(rbd_dev);
--
2.4.3
next prev parent reply other threads:[~2017-04-25 9:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 9:33 [PATCH 0/9] rbd: support for rbd map --exclusive Ilya Dryomov
2017-04-25 9:33 ` [PATCH 1/9] rbd: move rbd_dev_destroy() call out of rbd_dev_image_release() Ilya Dryomov
2017-04-25 9:33 ` Ilya Dryomov [this message]
2017-04-25 9:33 ` [PATCH 3/9] rbd: fix error handling around rbd_init_disk() Ilya Dryomov
2017-04-25 9:33 ` [PATCH 4/9] rbd: ignore unlock errors Ilya Dryomov
2017-04-25 9:33 ` [PATCH 5/9] rbd: store lock cookie Ilya Dryomov
2017-04-25 9:33 ` [PATCH 6/9] rbd: support updating the lock cookie without releasing the lock Ilya Dryomov
2017-04-25 9:33 ` [PATCH 7/9] rbd: kill rbd_is_lock_supported() Ilya Dryomov
2017-04-25 9:33 ` [PATCH 8/9] rbd: return ResponseMessage result from rbd_handle_request_lock() Ilya Dryomov
2017-04-25 9:33 ` [PATCH 9/9] rbd: exclusive map option Ilya Dryomov
2017-05-03 19:16 ` [PATCH 0/9] rbd: support for rbd map --exclusive Jason Dillaman
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=1493112825-16403-3-git-send-email-idryomov@gmail.com \
--to=idryomov@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox