* [PATCH v2 1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
@ 2026-07-07 11:39 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2026-07-07 11:39 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, Jan Kara, Matthew Wilcox
Commit 02117b8ae9c0 ("f2fs: Set GF_NOFS in read_cache_page_gfp while doing
f2fs_quota_read") adds GFP_NOFS in f2fs_quota_read() to avoid below deadlock:
- do_sys_open
- vfs_open
- dquot_file_open
- dquot_initialize
- dqget
- dquot_acquire
: locks &dqopt->dqio_mutex (VFS Quota Mutex)
- qtree_read_dquot
- f2fs_quota_read
- read_mapping_page (GFP_KERNEL / allows GFP_FS)
- __alloc_pages_nodemask
- try_to_free_pages (Direct Reclaim)
- prune_icache_sb
- evict
- f2fs_evict_inode
- dquot_drop
- dqput
- dquot_commit
: tries to lock &dqopt->dqio_mutex again
==> DEADLOCK (waiting for itself)
As Jan Kara mentioned, quota system has fixed this issue w/ commit
537e11cdc7a6 ("quota: Prevent memory allocation recursion while holding
dq_lock"), so this GFP_NOFS flag should be relic, let's use GFP_KERNEL
instead.
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- fix to use GFP_KERNEL instead of 0.
fs/f2fs/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index da468df058eb..b1725ca68010 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3168,7 +3168,7 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
repeat:
folio = mapping_read_folio_gfp(mapping, off >> PAGE_SHIFT,
- GFP_NOFS);
+ GFP_KERNEL);
if (IS_ERR(folio)) {
if (PTR_ERR(folio) == -ENOMEM) {
memalloc_retry_wait(GFP_NOFS);
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [f2fs-dev] [PATCH v2 2/2] f2fs: drop FGP_NOFS in f2fs_write_begin()
2026-07-07 11:39 ` Chao Yu
@ 2026-07-07 11:39 ` Chao Yu
-1 siblings, 0 replies; 8+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-07-07 11:39 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, Matthew Wilcox, linux-f2fs-devel
This patch proposes to drop FGP_NOFS from f2fs_filemap_get_folio()
in f2fs_write_begin(), I don't see there is potential deadlock issue
when __filemap_get_folio() calling into filesystem reclaim interfaces,
e.g. .writepages, evict_inode, shrinker.
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- just drop FGP_NOFS rather than use memalloc_nofs_* helpers.
fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 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);
--
2.49.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 2/2] f2fs: drop FGP_NOFS in f2fs_write_begin()
@ 2026-07-07 11:39 ` Chao Yu
0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2026-07-07 11:39 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, Matthew Wilcox
This patch proposes to drop FGP_NOFS from f2fs_filemap_get_folio()
in f2fs_write_begin(), I don't see there is potential deadlock issue
when __filemap_get_folio() calling into filesystem reclaim interfaces,
e.g. .writepages, evict_inode, shrinker.
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v2:
- just drop FGP_NOFS rather than use memalloc_nofs_* helpers.
fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 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);
--
2.49.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
2026-07-07 11:39 ` Chao Yu
@ 2026-07-08 16:01 ` Jan Kara
-1 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2026-07-08 16:01 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel, Jan Kara, Matthew Wilcox
On Tue 07-07-26 19:39:33, Chao Yu wrote:
> Commit 02117b8ae9c0 ("f2fs: Set GF_NOFS in read_cache_page_gfp while doing
> f2fs_quota_read") adds GFP_NOFS in f2fs_quota_read() to avoid below deadlock:
>
> - do_sys_open
> - vfs_open
> - dquot_file_open
> - dquot_initialize
> - dqget
> - dquot_acquire
> : locks &dqopt->dqio_mutex (VFS Quota Mutex)
> - qtree_read_dquot
> - f2fs_quota_read
> - read_mapping_page (GFP_KERNEL / allows GFP_FS)
> - __alloc_pages_nodemask
> - try_to_free_pages (Direct Reclaim)
> - prune_icache_sb
> - evict
> - f2fs_evict_inode
> - dquot_drop
> - dqput
> - dquot_commit
> : tries to lock &dqopt->dqio_mutex again
> ==> DEADLOCK (waiting for itself)
>
> As Jan Kara mentioned, quota system has fixed this issue w/ commit
> 537e11cdc7a6 ("quota: Prevent memory allocation recursion while holding
> dq_lock"), so this GFP_NOFS flag should be relic, let's use GFP_KERNEL
> instead.
>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Chao Yu <chao@kernel.org>
Looks sound to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v2:
> - fix to use GFP_KERNEL instead of 0.
> fs/f2fs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index da468df058eb..b1725ca68010 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -3168,7 +3168,7 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
>
> repeat:
> folio = mapping_read_folio_gfp(mapping, off >> PAGE_SHIFT,
> - GFP_NOFS);
> + GFP_KERNEL);
> if (IS_ERR(folio)) {
> if (PTR_ERR(folio) == -ENOMEM) {
> memalloc_retry_wait(GFP_NOFS);
> --
> 2.49.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [f2fs-dev] [PATCH v2 1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
@ 2026-07-08 16:01 ` Jan Kara
0 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2026-07-08 16:01 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, Jan Kara, linux-kernel, Matthew Wilcox, linux-f2fs-devel
On Tue 07-07-26 19:39:33, Chao Yu wrote:
> Commit 02117b8ae9c0 ("f2fs: Set GF_NOFS in read_cache_page_gfp while doing
> f2fs_quota_read") adds GFP_NOFS in f2fs_quota_read() to avoid below deadlock:
>
> - do_sys_open
> - vfs_open
> - dquot_file_open
> - dquot_initialize
> - dqget
> - dquot_acquire
> : locks &dqopt->dqio_mutex (VFS Quota Mutex)
> - qtree_read_dquot
> - f2fs_quota_read
> - read_mapping_page (GFP_KERNEL / allows GFP_FS)
> - __alloc_pages_nodemask
> - try_to_free_pages (Direct Reclaim)
> - prune_icache_sb
> - evict
> - f2fs_evict_inode
> - dquot_drop
> - dqput
> - dquot_commit
> : tries to lock &dqopt->dqio_mutex again
> ==> DEADLOCK (waiting for itself)
>
> As Jan Kara mentioned, quota system has fixed this issue w/ commit
> 537e11cdc7a6 ("quota: Prevent memory allocation recursion while holding
> dq_lock"), so this GFP_NOFS flag should be relic, let's use GFP_KERNEL
> instead.
>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: Chao Yu <chao@kernel.org>
Looks sound to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v2:
> - fix to use GFP_KERNEL instead of 0.
> fs/f2fs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index da468df058eb..b1725ca68010 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -3168,7 +3168,7 @@ static ssize_t f2fs_quota_read(struct super_block *sb, int type, char *data,
>
> repeat:
> folio = mapping_read_folio_gfp(mapping, off >> PAGE_SHIFT,
> - GFP_NOFS);
> + GFP_KERNEL);
> if (IS_ERR(folio)) {
> if (PTR_ERR(folio) == -ENOMEM) {
> memalloc_retry_wait(GFP_NOFS);
> --
> 2.49.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] [PATCH v2 1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
2026-07-07 11:39 ` Chao Yu
@ 2026-07-14 3:00 ` patchwork-bot+f2fs
-1 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2026-07-14 3:00 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, jack, linux-kernel, willy, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Tue, 7 Jul 2026 19:39:33 +0800 you wrote:
> Commit 02117b8ae9c0 ("f2fs: Set GF_NOFS in read_cache_page_gfp while doing
> f2fs_quota_read") adds GFP_NOFS in f2fs_quota_read() to avoid below deadlock:
>
> - do_sys_open
> - vfs_open
> - dquot_file_open
> - dquot_initialize
> - dqget
> - dquot_acquire
> : locks &dqopt->dqio_mutex (VFS Quota Mutex)
> - qtree_read_dquot
> - f2fs_quota_read
> - read_mapping_page (GFP_KERNEL / allows GFP_FS)
> - __alloc_pages_nodemask
> - try_to_free_pages (Direct Reclaim)
> - prune_icache_sb
> - evict
> - f2fs_evict_inode
> - dquot_drop
> - dqput
> - dquot_commit
> : tries to lock &dqopt->dqio_mutex again
> ==> DEADLOCK (waiting for itself)
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2,1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
https://git.kernel.org/jaegeuk/f2fs/c/9f3a37815818
- [f2fs-dev,v2,2/2] f2fs: drop FGP_NOFS in f2fs_write_begin()
https://git.kernel.org/jaegeuk/f2fs/c/6e7205a702e2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [f2fs-dev] [PATCH v2 1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
@ 2026-07-14 3:00 ` patchwork-bot+f2fs
0 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+f2fs @ 2026-07-14 3:00 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, jack, linux-kernel, willy, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Tue, 7 Jul 2026 19:39:33 +0800 you wrote:
> Commit 02117b8ae9c0 ("f2fs: Set GF_NOFS in read_cache_page_gfp while doing
> f2fs_quota_read") adds GFP_NOFS in f2fs_quota_read() to avoid below deadlock:
>
> - do_sys_open
> - vfs_open
> - dquot_file_open
> - dquot_initialize
> - dqget
> - dquot_acquire
> : locks &dqopt->dqio_mutex (VFS Quota Mutex)
> - qtree_read_dquot
> - f2fs_quota_read
> - read_mapping_page (GFP_KERNEL / allows GFP_FS)
> - __alloc_pages_nodemask
> - try_to_free_pages (Direct Reclaim)
> - prune_icache_sb
> - evict
> - f2fs_evict_inode
> - dquot_drop
> - dqput
> - dquot_commit
> : tries to lock &dqopt->dqio_mutex again
> ==> DEADLOCK (waiting for itself)
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2,1/2] f2fs: quota: do not use GFP_NOFS in f2fs_quota_read()
https://git.kernel.org/jaegeuk/f2fs/c/9f3a37815818
- [f2fs-dev,v2,2/2] f2fs: drop FGP_NOFS in f2fs_write_begin()
https://git.kernel.org/jaegeuk/f2fs/c/6e7205a702e2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread