[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH 1 of 2] DM Exception Store: return zero when empty



Patch name: dm-exception-store-return-zero-when-empty.patch

When the snapshot is empty, return 0 as the number of allocated sectors.
This will be needed to properly notify userspace that merging is finished.

Signed-off-by: Mikulas Patocka <mpatocka redhat com>
Reviewed-by: Mike Snitzer <snitzer redhat com>
Reviewed-by: Jonathan Brassow <jbrassow redhat com>
Index: linux-2.6/drivers/md/dm-snap-persistent.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-snap-persistent.c
+++ linux-2.6/drivers/md/dm-snap-persistent.c
@@ -492,8 +492,12 @@ static struct pstore *get_info(struct dm
 static void persistent_fraction_full(struct dm_exception_store *store,
 				     sector_t *numerator, sector_t *denominator)
 {
-	*numerator = get_info(store)->next_free * store->chunk_size;
-	*denominator = get_dev_size(store->cow->bdev);
+	/*
+	 * Compensate for the first two chunks that are always allocated.
+	 * Make sure that we return 0 when there are no exceptions.
+	 */
+	*numerator = (get_info(store)->next_free - 2) * store->chunk_size;
+	*denominator = get_dev_size(store->cow->bdev) - 2 * store->chunk_size;
 }
 
 static void persistent_dtr(struct dm_exception_store *store)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]