return -ENOENT;
}
-static int rbd_dev_set_mapping(struct rbd_device *rbd_dev, char *snap_name)
+static int rbd_dev_set_mapping(struct rbd_device *rbd_dev)
{
int ret;
- if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME,
+ if (!memcmp(rbd_dev->snap_name, RBD_SNAP_HEAD_NAME,
sizeof (RBD_SNAP_HEAD_NAME))) {
rbd_dev->snap_id = CEPH_NOSNAP;
rbd_dev->mapping.size = rbd_dev->header.image_size;
rbd_dev->mapping.features = rbd_dev->header.features;
ret = 0;
} else {
- ret = snap_by_name(rbd_dev, snap_name);
+ ret = snap_by_name(rbd_dev, rbd_dev->snap_name);
if (ret < 0)
goto done;
rbd_dev->mapping.read_only = true;
}
- rbd_dev->snap_name = snap_name;
rbd_dev->exists = true;
done:
return ret;
* Note: rbd_dev is assumed to have been initially zero-filled.
*/
static struct ceph_options *rbd_add_parse_args(struct rbd_device *rbd_dev,
- const char *buf,
- char **snap_name)
+ const char *buf)
{
size_t len;
const char *mon_addrs;
err_ptr = ERR_PTR(-ENAMETOOLONG);
goto out_err;
}
- *snap_name = kmalloc(len + 1, GFP_KERNEL);
- if (!*snap_name)
+ rbd_dev->snap_name = kmalloc(len + 1, GFP_KERNEL);
+ if (!rbd_dev->snap_name)
goto out_mem;
- memcpy(*snap_name, buf, len);
- *(*snap_name + len) = '\0';
+ memcpy(rbd_dev->snap_name, buf, len);
+ *(rbd_dev->snap_name + len) = '\0';
/* Initialize all rbd options to the defaults */
size_t count)
{
struct rbd_device *rbd_dev = NULL;
- char *snap_name;
struct ceph_options *ceph_opts;
struct ceph_osd_client *osdc;
int rc = -ENOMEM;
init_rwsem(&rbd_dev->header_rwsem);
/* parse add command */
- ceph_opts = rbd_add_parse_args(rbd_dev, buf, &snap_name);
+ ceph_opts = rbd_add_parse_args(rbd_dev, buf);
if (IS_ERR(ceph_opts)) {
rc = PTR_ERR(ceph_opts);
goto err_out_mem;
if (rc)
goto err_out_probe;
- rc = rbd_dev_set_mapping(rbd_dev, snap_name);
+ rc = rbd_dev_set_mapping(rbd_dev);
if (rc)
goto err_out_snaps;