===================================================================
@@ -83,8 +83,9 @@ struct dm_snapshot {
* 'handover' is set during a new snapshot's constructor if it finds
* a single old snapshot is using the same cow block device as it.
* Handover operation is performed, and 'handover' is cleared,
- * when either of the following occurs:
+ * when one of the following occurs:
* - old snapshot, that is handing over, is destructed
+ * - old snapshot, that is handing over, is resumed
* - new snapshot, that is accepting the handover, is resumed
*/
int handover;
@@ -1268,16 +1269,27 @@ static void snapshot_resume(struct dm_ta
struct dm_snapshot *s = ti->private;
down_write(&s->lock);
- if (s->handover) {
- /* Get exception store from another snapshot */
+ if (s->handover_snap) {
+ /*
+ * Initially assumes this snapshot will get
+ * exception store from another snapshot
+ */
struct dm_snapshot *old_snap = s->handover_snap;
- BUG_ON(!old_snap);
- down_write_nested(&old_snap->lock, SINGLE_DEPTH_NESTING);
- handover_exceptions(old_snap, s);
- up_write(&old_snap->lock);
+ struct dm_snapshot *new_snap = s;
+ struct dm_snapshot *lock_snap = old_snap;
+ if (!s->handover) {
+ /* Handover exceptions to another snapshot */
+ old_snap = s;
+ new_snap = s->handover_snap;
+ lock_snap = new_snap;
+ }
+ down_write_nested(&lock_snap->lock,
+ SINGLE_DEPTH_NESTING);
+ handover_exceptions(old_snap, new_snap);
+ up_write(&lock_snap->lock);
}
/* An incomplete exception handover is not allowed */
- BUG_ON(s->handover || s->handover_snap);
+ BUG_ON(s->handover_snap);
s->active = 1;
s->suspended = 0;
up_write(&s->lock);