diff options
author | Alex Elder <elder@inktank.com> | 2012-07-19 08:49:18 -0500 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-30 18:15:42 -0700 |
commit | 78dc447d3ca3701206a1dd813c901556a3fad451 (patch) | |
tree | 244df3c3450069bc09a39fea87a634f93e911227 | |
parent | 75fe9e19816d6ed3e90f1bd3b741f99bf030e848 (diff) |
rbd: preserve snapc->seq in rbd_header_set_snap()
In rbd_header_set_snap(), there is logic to make the snap context's
seq field get set to a particular snapshot id, or 0 if there is no
snapshot for the rbd image.
This seems to be an artifact of how the current snapshot id for an
rbd_dev was recorded before the rbd_dev->snap_id field began to be
used for that purpose.
There's no need to update the value of snapc->seq here any more, so
stop doing it. Tidy up a few local variables in that function
while we're at it.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | drivers/block/rbd.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8a4659997e05..ac8a83fc2ad9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -588,29 +588,25 @@ static int snap_by_name(struct rbd_image_header *header, const char *snap_name, 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; } |