diff options
author | Alex Elder <elder@inktank.com> | 2013-05-06 18:40:33 -0400 |
---|---|---|
committer | Alex Elder <elder@inktank.com> | 2013-05-08 21:16:50 -0400 |
commit | 7ce4eef7b5fad73b365b7e4b8892af3af72d4bd3 (patch) | |
tree | cde113dd54f09cac813475c111be21e3500f4252 /drivers/block | |
parent | 5b2ab72d367d2682c1a237448fbc1595881a88fa (diff) |
rbd: set mapping read-only flag in rbd_add()
The rbd_dev->mapping field for a parent image is not meaningful.
Since rbd_image_probe() is used both for images being mapped and
their parents, it doesn't make sense to set that flag in that
function.
So move the setting of the mapping.read_only flag out of
rbd_dev_image_probe() and into rbd_add() instead.
This resolves:
http://tracker.ceph.com/issues/4940
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/rbd.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 2a0e9b81be48..dbfc44a9defd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -358,7 +358,7 @@ static ssize_t rbd_add(struct bus_type *bus, const char *buf, | |||
358 | size_t count); | 358 | size_t count); |
359 | static ssize_t rbd_remove(struct bus_type *bus, const char *buf, | 359 | static ssize_t rbd_remove(struct bus_type *bus, const char *buf, |
360 | size_t count); | 360 | size_t count); |
361 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only); | 361 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev); |
362 | 362 | ||
363 | static struct bus_attribute rbd_bus_attrs[] = { | 363 | static struct bus_attribute rbd_bus_attrs[] = { |
364 | __ATTR(add, S_IWUSR, NULL, rbd_add), | 364 | __ATTR(add, S_IWUSR, NULL, rbd_add), |
@@ -4549,7 +4549,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev) | |||
4549 | if (!parent) | 4549 | if (!parent) |
4550 | goto out_err; | 4550 | goto out_err; |
4551 | 4551 | ||
4552 | ret = rbd_dev_image_probe(parent, true); | 4552 | ret = rbd_dev_image_probe(parent); |
4553 | if (ret < 0) | 4553 | if (ret < 0) |
4554 | goto out_err; | 4554 | goto out_err; |
4555 | rbd_dev->parent = parent; | 4555 | rbd_dev->parent = parent; |
@@ -4671,10 +4671,9 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev) | |||
4671 | 4671 | ||
4672 | /* | 4672 | /* |
4673 | * Probe for the existence of the header object for the given rbd | 4673 | * Probe for the existence of the header object for the given rbd |
4674 | * device. For format 2 images this includes determining the image | 4674 | * device. |
4675 | * id. | ||
4676 | */ | 4675 | */ |
4677 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only) | 4676 | static int rbd_dev_image_probe(struct rbd_device *rbd_dev) |
4678 | { | 4677 | { |
4679 | int ret; | 4678 | int ret; |
4680 | int tmp; | 4679 | int tmp; |
@@ -4709,12 +4708,6 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only) | |||
4709 | if (ret) | 4708 | if (ret) |
4710 | goto err_out_probe; | 4709 | goto err_out_probe; |
4711 | 4710 | ||
4712 | /* If we are mapping a snapshot it must be marked read-only */ | ||
4713 | |||
4714 | if (rbd_dev->spec->snap_id != CEPH_NOSNAP) | ||
4715 | read_only = true; | ||
4716 | rbd_dev->mapping.read_only = read_only; | ||
4717 | |||
4718 | ret = rbd_dev_probe_parent(rbd_dev); | 4711 | ret = rbd_dev_probe_parent(rbd_dev); |
4719 | if (ret) | 4712 | if (ret) |
4720 | goto err_out_probe; | 4713 | goto err_out_probe; |
@@ -4795,10 +4788,16 @@ static ssize_t rbd_add(struct bus_type *bus, | |||
4795 | rbdc = NULL; /* rbd_dev now owns this */ | 4788 | rbdc = NULL; /* rbd_dev now owns this */ |
4796 | spec = NULL; /* rbd_dev now owns this */ | 4789 | spec = NULL; /* rbd_dev now owns this */ |
4797 | 4790 | ||
4798 | rc = rbd_dev_image_probe(rbd_dev, read_only); | 4791 | rc = rbd_dev_image_probe(rbd_dev); |
4799 | if (rc < 0) | 4792 | if (rc < 0) |
4800 | goto err_out_rbd_dev; | 4793 | goto err_out_rbd_dev; |
4801 | 4794 | ||
4795 | /* If we are mapping a snapshot it must be marked read-only */ | ||
4796 | |||
4797 | if (rbd_dev->spec->snap_id != CEPH_NOSNAP) | ||
4798 | read_only = true; | ||
4799 | rbd_dev->mapping.read_only = read_only; | ||
4800 | |||
4802 | rc = rbd_dev_device_setup(rbd_dev); | 4801 | rc = rbd_dev_device_setup(rbd_dev); |
4803 | if (!rc) | 4802 | if (!rc) |
4804 | return count; | 4803 | return count; |