Re: [PATCH v5] xfs: Fix false positive lockdep warning with sb_internal & fs_reclaim

From: Waiman Long
Date: Thu Jul 02 2020 - 23:05:22 EST


On 7/2/20 9:07 PM, Dave Chinner wrote:
On Wed, Jul 01, 2020 at 08:59:23PM -0400, Waiman Long wrote:
Suggested-by: Dave Chinner <david@xxxxxxxxxxxxx>
Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
fs/xfs/xfs_super.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 379cbff438bc..dcc97bad950a 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -913,11 +913,21 @@ xfs_fs_freeze(
struct super_block *sb)
{
struct xfs_mount *mp = XFS_M(sb);
+ unsigned long pflags;
+ int ret;
+ /*
+ * Disable fs reclaim in memory allocation for fs freeze to avoid
+ * causing a possible circular locking dependency lockdep splat
+ * relating to fs reclaim.
+ */
/*
* The filesystem is now frozen far enough that memory reclaim
* cannot safely operate on the filesystem. Hence we need to
* set a GFP_NOFS context here to avoid recursion deadlocks.
*/

+ current_set_flags_nested(&pflags, PF_MEMALLOC_NOFS);
memalloc_nofs_save/restore(), please.

Thanks for the comments, I will make the suggested change.

Cheers,
Longman