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

[dm-devel] [PATCH] 2.4: dm-exception-store.c: Correct "enough-room-left" check



In persistent_prepare(), the "enough-room-left" check only verifies that the
start of the next-free chunk is within the cow device. If the cow device
is not an even multiple of the chunk-size, the snapshot code will eventually
try to write off the end of the cow device.

Check that the entire next-free chunk is within the cow device. 

--- linux-2.4.20a/drivers/md/dm-exception-store.c	2003/02/26 14:50:56
+++ linux-2.4.20b/drivers/md/dm-exception-store.c	2003/03/25 19:02:24
@@ -449,7 +449,7 @@
 	sector_t size = get_dev_size(store->snap->cow->dev);
 
 	/* Is there enough room ? */
-	if (size <= (ps->next_free * store->snap->chunk_size))
+	if (size < ((ps->next_free + 1) * store->snap->chunk_size))
 		return -ENOSPC;
 
 	e->new_chunk = ps->next_free;



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