static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size)
{
- struct rbd_image_header *header = &rbd_dev->header;
- struct ceph_snap_context *snapc = header->snapc;
- int ret = -ENOENT;
+ int ret;
down_write(&rbd_dev->header_rwsem);
if (!memcmp(rbd_dev->snap_name, RBD_SNAP_HEAD_NAME,
sizeof (RBD_SNAP_HEAD_NAME))) {
- if (header->total_snaps)
- snapc->seq = header->snap_seq;
- else
- snapc->seq = 0;
rbd_dev->snap_id = CEPH_NOSNAP;
rbd_dev->snap_exists = false;
rbd_dev->read_only = 0;
if (size)
- *size = header->image_size;
+ *size = rbd_dev->header.image_size;
} else {
- ret = snap_by_name(header, rbd_dev->snap_name,
- &snapc->seq, size);
+ u64 snap_id = 0;
+
+ ret = snap_by_name(&rbd_dev->header, rbd_dev->snap_name,
+ &snap_id, size);
if (ret < 0)
goto done;
- rbd_dev->snap_id = snapc->seq;
+ rbd_dev->snap_id = snap_id;
rbd_dev->snap_exists = true;
rbd_dev->read_only = 1;
}