Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 375591
b: refs/heads/master
c: 51344a3
h: refs/heads/master
i:
  375589: 0e3386a
  375587: 9ab3b4f
  375583: d8609ce
v: v3
  • Loading branch information
Alex Elder committed May 8, 2013
1 parent 9c53bb2 commit 013e476
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6d80b130d516deef51666e210fde674c947b8b5c
refs/heads/master: 51344a38ba2033be18a4ec23e318845caeccdc04
28 changes: 14 additions & 14 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static ssize_t rbd_add(struct bus_type *bus, const char *buf,
size_t count);
static ssize_t rbd_remove(struct bus_type *bus, const char *buf,
size_t count);
static int rbd_dev_image_probe(struct rbd_device *rbd_dev);
static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only);

static struct bus_attribute rbd_bus_attrs[] = {
__ATTR(add, S_IWUSR, NULL, rbd_add),
Expand Down Expand Up @@ -951,19 +951,13 @@ static int rbd_dev_mapping_set(struct rbd_device *rbd_dev)
rbd_dev->mapping.size = size;
rbd_dev->mapping.features = features;

/* If we are mapping a snapshot it must be marked read-only */

if (snap_id != CEPH_NOSNAP)
rbd_dev->mapping.read_only = true;

return 0;
}

static void rbd_dev_mapping_clear(struct rbd_device *rbd_dev)
{
rbd_dev->mapping.size = 0;
rbd_dev->mapping.features = 0;
rbd_dev->mapping.read_only = true;
}

static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
Expand Down Expand Up @@ -4620,7 +4614,7 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev)
if (!parent)
goto out_err;

ret = rbd_dev_image_probe(parent);
ret = rbd_dev_image_probe(parent, true);
if (ret < 0)
goto out_err;
rbd_dev->parent = parent;
Expand Down Expand Up @@ -4743,7 +4737,7 @@ static void rbd_dev_image_release(struct rbd_device *rbd_dev)
* device. For format 2 images this includes determining the image
* id.
*/
static int rbd_dev_image_probe(struct rbd_device *rbd_dev)
static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool read_only)
{
int ret;
int tmp;
Expand Down Expand Up @@ -4778,6 +4772,12 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev)
if (ret)
goto err_out_probe;

/* If we are mapping a snapshot it must be marked read-only */

if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
read_only = true;
rbd_dev->mapping.read_only = read_only;

ret = rbd_dev_probe_parent(rbd_dev);
if (!ret)
return 0;
Expand Down Expand Up @@ -4811,6 +4811,7 @@ static ssize_t rbd_add(struct bus_type *bus,
struct rbd_spec *spec = NULL;
struct rbd_client *rbdc;
struct ceph_osd_client *osdc;
bool read_only;
int rc = -ENOMEM;

if (!try_module_get(THIS_MODULE))
Expand All @@ -4820,6 +4821,9 @@ static ssize_t rbd_add(struct bus_type *bus,
rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec);
if (rc < 0)
goto err_out_module;
read_only = rbd_opts->read_only;
kfree(rbd_opts);
rbd_opts = NULL; /* done with this */

rbdc = rbd_get_client(ceph_opts);
if (IS_ERR(rbdc)) {
Expand Down Expand Up @@ -4850,11 +4854,7 @@ static ssize_t rbd_add(struct bus_type *bus,
rbdc = NULL; /* rbd_dev now owns this */
spec = NULL; /* rbd_dev now owns this */

rbd_dev->mapping.read_only = rbd_opts->read_only;
kfree(rbd_opts);
rbd_opts = NULL; /* done with this */

rc = rbd_dev_image_probe(rbd_dev);
rc = rbd_dev_image_probe(rbd_dev, read_only);
if (rc < 0)
goto err_out_rbd_dev;

Expand Down

0 comments on commit 013e476

Please sign in to comment.