mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-11 09:02:35 +00:00
dm: don't lock fs when the map is NULL during suspend or resume
[ Upstream commit2760904d89
] As described in commit38d11da522
("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 commit38d11da522
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:38d11da522
("dm: don't lock fs when the map is NULL in process of resume") Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a9d27dd08b
commit
b908f98d3a
2 changed files with 5 additions and 4 deletions
|
@ -1145,13 +1145,10 @@ static int do_resume(struct dm_ioctl *param)
|
||||||
/* Do we need to load a new map ? */
|
/* Do we need to load a new map ? */
|
||||||
if (new_map) {
|
if (new_map) {
|
||||||
sector_t old_size, new_size;
|
sector_t old_size, new_size;
|
||||||
int srcu_idx;
|
|
||||||
|
|
||||||
/* Suspend if it isn't already suspended */
|
/* Suspend if it isn't already suspended */
|
||||||
old_map = dm_get_live_table(md, &srcu_idx);
|
if (param->flags & DM_SKIP_LOCKFS_FLAG)
|
||||||
if ((param->flags & DM_SKIP_LOCKFS_FLAG) || !old_map)
|
|
||||||
suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
|
suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
|
||||||
dm_put_live_table(md, srcu_idx);
|
|
||||||
if (param->flags & DM_NOFLUSH_FLAG)
|
if (param->flags & DM_NOFLUSH_FLAG)
|
||||||
suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
|
suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
|
||||||
if (!dm_suspended_md(md))
|
if (!dm_suspended_md(md))
|
||||||
|
|
|
@ -2526,6 +2526,10 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock));
|
map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock));
|
||||||
|
if (!map) {
|
||||||
|
/* avoid deadlock with fs/namespace.c:do_mount() */
|
||||||
|
suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE, DMF_SUSPENDED);
|
r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE, DMF_SUSPENDED);
|
||||||
if (r)
|
if (r)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue