]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm snapshot: suspend merging snapshot when doing exception handover
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 26 Feb 2015 16:41:28 +0000 (11:41 -0500)
committerSasha Levin <sasha.levin@oracle.com>
Fri, 17 Apr 2015 00:13:10 +0000 (20:13 -0400)
commitc280422c2775755ffd3ca1c078ae3acb52752e25
treeea0ec0989b0df47afc3ceab705646bc49910e097
parent306d712286708209b85062762e188e68084026a3
dm snapshot: suspend merging snapshot when doing exception handover

[ Upstream commit 09ee96b21456883e108c3b00597bb37ec512151b ]

The "dm snapshot: suspend origin when doing exception handover" commit
fixed a exception store handover bug associated with pending exceptions
to the "snapshot-origin" target.

However, a similar problem exists in snapshot merging.  When snapshot
merging is in progress, we use the target "snapshot-merge" instead of
"snapshot-origin".  Consequently, during exception store handover, we
must find the snapshot-merge target and suspend its associated
mapped_device.

To avoid lockdep warnings, the target must be suspended and resumed
without holding _origins_lock.

Introduce a dm_hold() function that grabs a reference on a
mapped_device, but unlike dm_get(), it doesn't crash if the device has
the DMF_FREEING flag set, it returns an error in this case.

In snapshot_resume() we grab the reference to the origin device using
dm_hold() while holding _origins_lock (_origins_lock guarantees that the
device won't disappear).  Then we release _origins_lock, suspend the
device and grab _origins_lock again.

NOTE to stable@ people:
When backporting to kernels 3.18 and older, use dm_internal_suspend and
dm_internal_resume instead of dm_internal_suspend_fast and
dm_internal_resume_fast.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/md/dm-snap.c
drivers/md/dm.c
include/linux/device-mapper.h