From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B55072F7F00 for ; Mon, 6 Jul 2026 09:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783331996; cv=none; b=a8ngcjO4WVQsGrmzMLUWx4BG1k55JDrcb/c35/AwJk1rafC5EL7vCL2TCocpFuNIXwTaU5B5kQ4pqKx7K+BOmq+ELHlanVu3xwNPg6tibxTJuSeMe0t0wcQajPFbhMaRcRPNnaRqhzl8C9DoMwfthH0xTUsG54SIg+vhjSPrGKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783331996; c=relaxed/simple; bh=uw6c+YXjvgY+9m0/0qs+R33bxcXKxZV5fc6wX+gjmoc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JeMzu19mMpOpLiAVscJWhor+fqc7+P7RqaRtgWnWJ6cKYhF6E3TwfPMV9+8NHZFJsI3HWCCYgeiS/4l6yTc94GfQhl2JQqWtWo5VUWZspo5DRk3QwKZsZ3dUI1h+QNne1CBw9d7gkEOu8wCCRq+/f193l4b54OB28HsnqCqlyK8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PatjLqz2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PatjLqz2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8744D1F000E9; Mon, 6 Jul 2026 09:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783331993; bh=wf7Dq7ZqF+IRc2k6+6jGgcdA/x5diupooyaJLVZLXnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PatjLqz2mTLY0lljSlcPYbNFfrh2RdF0MTVmVLFGoXRxdAwgaImraeFlJvzrNpxKh gSCZ5CNu/krOBa+tRAeuWOQfeRvhei+7sqImPwzIoRJSdpfr1RP5mVN9HVkx3vi8Ji UAMfLdwdTFKoRQJK7tN+lf8z2rJNiApaPZz01qDr1WzKj01Q+a9z9Ny37KoZ70sJ9t 5wcH9pxuRdtJypH/hzZ9ySn3U/6hXCSmhkDz81VeOUuX0ZGuwRIZmuEXVyoYMvBl0z d+nXjnJhm5CjO0pjUYXqRe2lXcrzFESYid+5mTGnTdg4AHbOGx7riXqwaw4IX1B3qH XhWiBayIgwtgQ== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu , Matthew Wilcox Subject: [PATCH 2/2] f2fs: quota: use memalloc_nofs_{save,restore} instead of FGP_NOFS Date: Mon, 6 Jul 2026 17:59:43 +0800 Message-ID: <20260706095943.2560208-2-chao@kernel.org> X-Mailer: git-send-email 2.55.0.rc2.803.g1fd1e6609c-goog In-Reply-To: <20260706095943.2560208-1-chao@kernel.org> References: <20260706095943.2560208-1-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit FGP_NOFS could be removed later, let's use memalloc_nofs_{save,restore} instead, which is recommended to be used to avoid potential deadlock when memory allocation in f2fs_quota_write() will call into filesystem interface again, e.g. .writepages, evict_inode, shrinker due to complicated lock race condition. Cc: Matthew Wilcox Signed-off-by: Chao Yu --- fs/f2fs/data.c | 2 +- fs/f2fs/super.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index ac1cf4de3d62..be4c1d4ed6b2 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3994,7 +3994,7 @@ static int f2fs_write_begin(const struct kiocb *iocb, * Will wait that below with our IO control. */ folio = f2fs_filemap_get_folio(mapping, index, - FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_NOFS, + FGP_LOCK | FGP_WRITE | FGP_CREAT, mapping_gfp_mask(mapping)); if (IS_ERR(folio)) { err = PTR_ERR(folio); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index fdfd6a7203dd..d28a93657658 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3215,13 +3215,16 @@ static ssize_t f2fs_quota_write(struct super_block *sb, int type, void *fsdata = NULL; int err = 0; int tocopy; + unsigned int nofs_flags; while (towrite > 0) { tocopy = min_t(unsigned long, sb->s_blocksize - offset, towrite); retry: + nofs_flags = memalloc_nofs_save(); err = a_ops->write_begin(NULL, mapping, off, tocopy, &folio, &fsdata); + memalloc_nofs_restore(nofs_flags); if (unlikely(err)) { if (err == -ENOMEM) { memalloc_retry_wait(GFP_NOFS); -- 2.49.0