Skip to contentSkip to conversation

master - snapshot: fix max size limit check for COW device

PATCH Zdenek Kabelac 1 participant 1 message Jun 17, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4308a558d93bf5ed4b61f65b12f4f0fdfc45102
Commit:        d4308a558d93bf5ed4b61f65b12f4f0fdfc45102
Parent:        2f334b16d2d89c85d1bd46538c80729c490df7f9
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sun Jun 16 21:32:11 2013 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Mon Jun 17 09:37:50 2013 +0200

snapshot: fix max size limit check for COW device

Use proper max size as a multiple of extent size. And use 64bit arithmentic for validation of minsize. (in release fix).

---
 lib/metadata/lv_manip.c       |    3 +-
 lib/metadata/snapshot_manip.c |    5 +-
 test/shell/snapshot-usage.sh  |   87 +++++++++++++++++++++++++++++++++++++++++
 test/shell/snapshots-usage.sh |   87 -----------------------------------------
 4 files changed, 92 insertions(+), 90 deletions(-)
lib/metadata/lv_manip.c +2 -1
index 966b8fa..b7c538b 100644
@@ -4544,7 +4544,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
 	}
 
 	if (lp->snapshot && !seg_is_thin(lp) &&
-	    ((uint64_t)(lp->extents * vg->extent_size) < (SNAPSHOT_MIN_CHUNKS * lp->chunk_size))) {
+	    (((uint64_t)lp->extents * vg->extent_size) <
+	     (SNAPSHOT_MIN_CHUNKS * lp->chunk_size))) {
 		log_error("Unable to create a snapshot smaller than "
 			  DM_TO_STRING(SNAPSHOT_MIN_CHUNKS) " chunks (%u extents, %s).",
 			  (unsigned) (((uint64_t) SNAPSHOT_MIN_CHUNKS * lp->chunk_size +
lib/metadata/snapshot_manip.c +3 -2
index c3d1112..e0d2f5b 100644
@@ -56,12 +56,13 @@ uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_siz
 {
 	uint64_t size = _cow_max_size(origin->size, chunk_size);
 	uint32_t extent_size = origin->vg->extent_size;
+	uint64_t max_size = (uint64_t) MAX_EXTENT_COUNT * extent_size;
 
 	if (size % extent_size)
 		size += extent_size - size % extent_size;
 
-	if (size > UINT32_MAX)
-		size = UINT32_MAX; /* Origin is too big for 100% snapshot anyway */
+	if (size > max_size)
+		size = max_size; /* Origin is too big for 100% snapshot anyway */
 
 	return (uint32_t) (size / extent_size);
 }
test/shell/snapshot-usage.sh new file +87 -0

87 lines not on this page · raw message

test/shell/snapshots-usage.sh deleted +0 -87

87 lines not on this page · raw message