提交 1d573a70 编写于 作者: B Brian Foster 提交者: Yang Yingliang

xfs: acquire superblock freeze protection on eofblocks scans

stable inclusion
from linux-4.19.120
commit 88e28547f049536c589579a3f8bfa1291f2c5251

--------------------------------

commit 4b674b9a upstream.

The filesystem freeze sequence in XFS waits on any background
eofblocks or cowblocks scans to complete before the filesystem is
quiesced. At this point, the freezer has already stopped the
transaction subsystem, however, which means a truncate or cowblock
cancellation in progress is likely blocked in transaction
allocation. This results in a deadlock between freeze and the
associated scanner.

Fix this problem by holding superblock write protection across calls
into the block reapers. Since protection for background scans is
acquired from the workqueue task context, trylock to avoid a similar
deadlock between freeze and blocking on the write lock.

Fixes: d6b636eb ("xfs: halt auto-reclamation activities while rebuilding rmap")
Reported-by: NPaul Furtado <paulfurtado91@gmail.com>
Signed-off-by: NBrian Foster <bfoster@redhat.com>
Reviewed-by: NChandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NAllison Collins <allison.henderson@oracle.com>
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 e8521415
...@@ -902,7 +902,12 @@ xfs_eofblocks_worker( ...@@ -902,7 +902,12 @@ xfs_eofblocks_worker(
{ {
struct xfs_mount *mp = container_of(to_delayed_work(work), struct xfs_mount *mp = container_of(to_delayed_work(work),
struct xfs_mount, m_eofblocks_work); struct xfs_mount, m_eofblocks_work);
if (!sb_start_write_trylock(mp->m_super))
return;
xfs_icache_free_eofblocks(mp, NULL); xfs_icache_free_eofblocks(mp, NULL);
sb_end_write(mp->m_super);
xfs_queue_eofblocks(mp); xfs_queue_eofblocks(mp);
} }
...@@ -929,7 +934,12 @@ xfs_cowblocks_worker( ...@@ -929,7 +934,12 @@ xfs_cowblocks_worker(
{ {
struct xfs_mount *mp = container_of(to_delayed_work(work), struct xfs_mount *mp = container_of(to_delayed_work(work),
struct xfs_mount, m_cowblocks_work); struct xfs_mount, m_cowblocks_work);
if (!sb_start_write_trylock(mp->m_super))
return;
xfs_icache_free_cowblocks(mp, NULL); xfs_icache_free_cowblocks(mp, NULL);
sb_end_write(mp->m_super);
xfs_queue_cowblocks(mp); xfs_queue_cowblocks(mp);
} }
......
...@@ -2182,7 +2182,10 @@ xfs_file_ioctl( ...@@ -2182,7 +2182,10 @@ xfs_file_ioctl(
if (error) if (error)
return error; return error;
return xfs_icache_free_eofblocks(mp, &keofb); sb_start_write(mp->m_super);
error = xfs_icache_free_eofblocks(mp, &keofb);
sb_end_write(mp->m_super);
return error;
} }
default: default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册