Split the origin_resume() code which calculates the minimum chunk size of all related snapshots into a separate function, min_chunk_size(). This function will be used by the resume() function for the merged target. Index: linux-2.6.16.i686/drivers/md/dm-snap.c =================================================================== --- linux-2.6.16.i686.orig/drivers/md/dm-snap.c 2006-05-04 12:50:43.000000000 +0100 +++ linux-2.6.16.i686/drivers/md/dm-snap.c 2006-05-05 14:20:58.000000000 +0100 @@ -1218,15 +1218,10 @@ static int origin_map(struct dm_target * #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r)) -/* - * Set the target "split_io" field to the minimum of all the snapshots' - * chunk sizes. - */ -static void origin_resume(struct dm_target *ti) +static inline chunk_t min_chunk_size(struct dm_dev *dev) { - struct dm_dev *dev = (struct dm_dev *) ti->private; - struct dm_snapshot *snap; struct origin *o; + struct dm_snapshot *snap; chunk_t chunk_size = 0; down_read(&_origins_lock); @@ -1236,7 +1231,18 @@ static void origin_resume(struct dm_targ chunk_size = min_not_zero(chunk_size, snap->chunk_size); up_read(&_origins_lock); - ti->split_io = chunk_size; + return chunk_size; +} + +/* + * Set the target "split_io" field to the minimum of all the snapshots' + * chunk sizes. + */ +static void origin_resume(struct dm_target *ti) +{ + struct dm_dev *dev = (struct dm_dev *) ti->private; + + ti->split_io = min_chunk_size(dev); } static int origin_status(struct dm_target *ti, status_type_t type, char *result,