[dm-devel] [PATCH v3 13/12] dm snapshot: avoid __minimum_chunk_size() during merge

Mike Snitzer snitzer at redhat.com
Tue Nov 17 20:35:37 UTC 2009


The merging snapshot already has the origin's __minimum_chunk_size()
stored in the target's 'split_io'.  Avoid rediscovering it every call to
snapshot_merge_process().

Signed-off-by: Mike Snitzer <snitzer at redhat.com>

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 34d8c3f..f91ee08 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -730,20 +730,25 @@ static void snapshot_merge_process(struct dm_snapshot *s)
 
 test_again:
 	/* Reallocate other snapshots; must account for all 'linear_chunks' */
-	down_read(&_origins_lock);
-	o = __lookup_origin(s->origin->bdev);
 	must_wait = 0;
-	min_chunksize = __minimum_chunk_size(o);
+	/*
+	 * Merging snapshot already has the origin's __minimum_chunk_size()
+	 * stored in split_io (see: snapshot_merge_resume); avoid rediscovery
+	 */
+	min_chunksize = s->ti->split_io;
 	if (min_chunksize) {
 		chunk_t n;
+
+		down_read(&_origins_lock);
+		o = __lookup_origin(s->origin->bdev);
 		for (n = 0; n < io_size; n += min_chunksize) {
 			r = __origin_write(&o->snapshots, dest.sector + n,
 					   NULL);
 			if (r == DM_MAPIO_SUBMITTED)
 				must_wait = 1;
 		}
+		up_read(&_origins_lock);
 	}
-	up_read(&_origins_lock);
 	if (must_wait) {
 		sleep_on_timeout(&_pending_exception_done, HZ / 100 + 1);
 		goto test_again;




More information about the dm-devel mailing list