Skip to content

Commit 2760904

Browse files
Li LingfengMike Snitzer
authored andcommitted
dm: don't lock fs when the map is NULL during suspend or resume
As described in commit 38d11da ("dm: don't lock fs when the map is NULL in process of resume"), a deadlock may be triggered between do_resume() and do_mount(). This commit preserves the fix from commit 38d11da but moves it to where it also serves to fix a similar deadlock between do_suspend() and do_mount(). It does so, if the active map is NULL, by clearing DM_SUSPEND_LOCKFS_FLAG in dm_suspend() which is called by both do_suspend() and do_resume(). Fixes: 38d11da ("dm: don't lock fs when the map is NULL in process of resume") Signed-off-by: Li Lingfeng <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent f1fcbaa commit 2760904

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/md/dm-ioctl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,13 +1168,10 @@ static int do_resume(struct dm_ioctl *param)
11681168
/* Do we need to load a new map ? */
11691169
if (new_map) {
11701170
sector_t old_size, new_size;
1171-
int srcu_idx;
11721171

11731172
/* Suspend if it isn't already suspended */
1174-
old_map = dm_get_live_table(md, &srcu_idx);
1175-
if ((param->flags & DM_SKIP_LOCKFS_FLAG) || !old_map)
1173+
if (param->flags & DM_SKIP_LOCKFS_FLAG)
11761174
suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
1177-
dm_put_live_table(md, srcu_idx);
11781175
if (param->flags & DM_NOFLUSH_FLAG)
11791176
suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
11801177
if (!dm_suspended_md(md))

drivers/md/dm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,10 @@ int dm_suspend(struct mapped_device *md, unsigned int suspend_flags)
28082808
}
28092809

28102810
map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock));
2811+
if (!map) {
2812+
/* avoid deadlock with fs/namespace.c:do_mount() */
2813+
suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
2814+
}
28112815

28122816
r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE, DMF_SUSPENDED);
28132817
if (r)

0 commit comments

Comments
 (0)