rbd: set snapc->seq only when refreshing header
In rbd_header_add_snap() there is code to set snapc->seq to the just-added snapshot id. This is the only remnant left of the use of that field for recording which snapshot an rbd_dev was associated with. That functionality is no longer supported, so get rid of that final bit of code. Doing so means we never actually set snapc->seq any more. On the server, the snapshot context's sequence value represents the highest snapshot id ever issued for a particular rbd image. So we'll make it have that meaning here as well. To do so, set this value whenever the rbd header is (re-)read. That way it will always be consistent with the rest of the snapshot context we maintain. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
parent
78dc447d3c
commit
505cbb9bed
1 changed files with 2 additions and 8 deletions
|
@ -537,6 +537,7 @@ static int rbd_header_from_disk(struct rbd_image_header *header,
|
||||||
|
|
||||||
atomic_set(&header->snapc->nref, 1);
|
atomic_set(&header->snapc->nref, 1);
|
||||||
header->snap_seq = le64_to_cpu(ondisk->snap_seq);
|
header->snap_seq = le64_to_cpu(ondisk->snap_seq);
|
||||||
|
header->snapc->seq = le64_to_cpu(ondisk->snap_seq);
|
||||||
header->snapc->num_snaps = snap_count;
|
header->snapc->num_snaps = snap_count;
|
||||||
header->total_snaps = snap_count;
|
header->total_snaps = snap_count;
|
||||||
|
|
||||||
|
@ -1685,14 +1686,7 @@ static int rbd_header_add_snap(struct rbd_device *rbd_dev,
|
||||||
|
|
||||||
kfree(data);
|
kfree(data);
|
||||||
|
|
||||||
if (ret < 0)
|
return ret < 0 ? ret : 0;
|
||||||
return ret;
|
|
||||||
|
|
||||||
down_write(&rbd_dev->header_rwsem);
|
|
||||||
rbd_dev->header.snapc->seq = new_snapid;
|
|
||||||
up_write(&rbd_dev->header_rwsem);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
bad:
|
bad:
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue