[dm-devel] [PATCH v9] dm snapshot: allow live exception store handover between tables

Mikulas Patocka mpatocka at redhat.com
Fri Nov 20 18:00:15 UTC 2009



On Thu, 19 Nov 2009, Mike Snitzer wrote:

> Permit in-use snapshot exception data to be 'handed over' from one
> snapshot instance to another.  This is a pre-requisite for patches
> that allow the changes made in a snapshot device to be merged back into
> its origin device and also allows device resizing.
> 
> The basic call sequence is:
> 
>   dmsetup load new_snapshot (referencing the existing in-use cow device)
>      - the ctr code detects that the cow is already in use and allows the
>        two snapshot target instances to be linked together
>   dmsetup suspend original_snapshot
>   dmsetup resume new_snapshot
>      - the new_snapshot becomes live, and if anything now tries to access
>        the original one it will receive -EIO
>   dmsetup remove original_snapshot
> 
> (There can only be two snapshot targets referencing the same cow device
> simultaneously.)
> 
> Signed-off-by: Mike Snitzer <snitzer at redhat.com>

Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
Acked-by: Mikulas Patocka <mpatocka at redhat.com>

> +	down_read(&_origins_lock);
> +	(void) __find_snapshots_sharing_cow(s, &snap_src, &snap_dest);
> +	if (snap_src && snap_dest) {
> +		down_write_nested(&snap_src->lock, SINGLE_DEPTH_NESTING);
> +		down_write(&snap_dest->lock);

I'd suggest to use the "_nested" version for the nested lock, it is a 
convention.

down_write(&snap_src->lock);
down_write_nested(&snap_dest->lock, SINGLE_DEPTH_NESTING);

Mikulas

> +		__handover_exceptions(snap_src, snap_dest);
> +		up_write(&snap_dest->lock);
> +		up_write(&snap_src->lock);
> +	}
> +	up_read(&_origins_lock);




More information about the dm-devel mailing list