* [PATCH 1/9] mm: Improve memalloc_nofs_save() documentation
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 9:59 ` Jan Kara
2026-08-30 4:18 ` [PATCH 2/9] ext4: Remove uses of FGP_NOFS Matthew Wilcox (Oracle)
` (7 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
Talk about why someone should call this function instead of
what this function does. This makes the long comment in mm/readahead.c
obsolete; replace it with a comment about which case we're protecting
against.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/sched/mm.h | 31 +++++++++++++++++++++++--------
mm/readahead.c | 14 ++------------
2 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index d7c6a942aa7e..f76be1141b06 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -372,13 +372,26 @@ static inline void memalloc_noio_restore(unsigned int flags)
}
/**
- * memalloc_nofs_save - Marks implicit GFP_NOFS allocation scope.
+ * memalloc_nofs_save - Prevent recursion into the filesystem.
*
- * This functions marks the beginning of the GFP_NOFS allocation scope.
- * All further allocations will implicitly drop __GFP_FS flag and so
- * they are safe for the FS critical section from the allocation recursion
- * point of view. Use memalloc_nofs_restore to end the scope with flags
- * returned by this function.
+ * All memory allocations between calling this function and calling
+ * memalloc_nofs_restore() will be prevented from calling into filesystems
+ * to reclaim memory. Clean page cache memory can still be reclaimed,
+ * but (for example) inodes will not be.
+ *
+ * The primary reason to do this is that the caller has taken a lock
+ * which would be needed by FS reclaim. While we could theoretically
+ * call into a different filesystem in this case, it can be a deep call
+ * stack so it is better to avoid all filesystems.
+ *
+ * Filesystems often choose to incorporate a call to this function as part
+ * of starting a journal transaction. While not a lock in the normal
+ * sense, it has much the same effect as nested journal transactions
+ * are either prohibited or expensive.
+ *
+ * Also call this function if you need to allocate memory while holding
+ * a file folio locked. High order allocations (such as those requested
+ * by slab) can trigger compaction which will attempt to lock the folio.
*
* Context: This function is safe to be used from any context.
* Return: The saved flags to be passed to memalloc_nofs_restore.
@@ -389,10 +402,12 @@ static inline unsigned int memalloc_nofs_save(void)
}
/**
- * memalloc_nofs_restore - Ends the implicit GFP_NOFS scope.
+ * memalloc_nofs_restore - End filesystem reclaim scope.
* @flags: Flags to restore.
*
- * Ends the implicit GFP_NOFS scope started by memalloc_nofs_save function.
+ * Ends the implicit memory allocation scope started by
+ * memalloc_nofs_save(). This may not enable access to filesystem reclaim
+ * if it was already disabled at the time memalloc_nofs_save() was called.
* Always make sure that the given flags is the return value from the
* pairing memalloc_nofs_save call.
*/
diff --git a/mm/readahead.c b/mm/readahead.c
index 6e5563290287..9c116d4ba963 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -227,17 +227,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
gfp_t gfp_mask = readahead_gfp_mask(mapping);
unsigned long mark = ULONG_MAX, i = 0;
unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
-
- /*
- * Partway through the readahead operation, we will have added
- * locked pages to the page cache, but will not yet have submitted
- * them for I/O. Adding another page may need to allocate memory,
- * which can trigger memory reclaim. Telling the VM we're in
- * the middle of a filesystem operation will cause it to not
- * touch file-backed pages, preventing a deadlock. Most (all?)
- * filesystems already specify __GFP_NOFS in their mapping's
- * gfp_mask, but let's be explicit here.
- */
+ /* Allocating with locked folios */
unsigned int nofs = memalloc_nofs_save();
lockdep_assert_held(&mapping->invalidate_lock);
@@ -512,7 +502,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
ra->order = new_order;
- /* See comment in page_cache_ra_unbounded() */
+ /* Allocating with locked folios */
nofs = memalloc_nofs_save();
filemap_invalidate_lock_shared(mapping);
/*
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 1/9] mm: Improve memalloc_nofs_save() documentation
2026-08-30 4:18 ` [PATCH 1/9] mm: Improve memalloc_nofs_save() documentation Matthew Wilcox (Oracle)
@ 2026-08-31 9:59 ` Jan Kara
0 siblings, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 9:59 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:48, Matthew Wilcox (Oracle) wrote:
> Talk about why someone should call this function instead of
> what this function does. This makes the long comment in mm/readahead.c
> obsolete; replace it with a comment about which case we're protecting
> against.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Yeah, I think the documentation is better. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/sched/mm.h | 31 +++++++++++++++++++++++--------
> mm/readahead.c | 14 ++------------
> 2 files changed, 25 insertions(+), 20 deletions(-)
>
> diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
> index d7c6a942aa7e..f76be1141b06 100644
> --- a/include/linux/sched/mm.h
> +++ b/include/linux/sched/mm.h
> @@ -372,13 +372,26 @@ static inline void memalloc_noio_restore(unsigned int flags)
> }
>
> /**
> - * memalloc_nofs_save - Marks implicit GFP_NOFS allocation scope.
> + * memalloc_nofs_save - Prevent recursion into the filesystem.
> *
> - * This functions marks the beginning of the GFP_NOFS allocation scope.
> - * All further allocations will implicitly drop __GFP_FS flag and so
> - * they are safe for the FS critical section from the allocation recursion
> - * point of view. Use memalloc_nofs_restore to end the scope with flags
> - * returned by this function.
> + * All memory allocations between calling this function and calling
> + * memalloc_nofs_restore() will be prevented from calling into filesystems
> + * to reclaim memory. Clean page cache memory can still be reclaimed,
> + * but (for example) inodes will not be.
> + *
> + * The primary reason to do this is that the caller has taken a lock
> + * which would be needed by FS reclaim. While we could theoretically
> + * call into a different filesystem in this case, it can be a deep call
> + * stack so it is better to avoid all filesystems.
> + *
> + * Filesystems often choose to incorporate a call to this function as part
> + * of starting a journal transaction. While not a lock in the normal
> + * sense, it has much the same effect as nested journal transactions
> + * are either prohibited or expensive.
> + *
> + * Also call this function if you need to allocate memory while holding
> + * a file folio locked. High order allocations (such as those requested
> + * by slab) can trigger compaction which will attempt to lock the folio.
> *
> * Context: This function is safe to be used from any context.
> * Return: The saved flags to be passed to memalloc_nofs_restore.
> @@ -389,10 +402,12 @@ static inline unsigned int memalloc_nofs_save(void)
> }
>
> /**
> - * memalloc_nofs_restore - Ends the implicit GFP_NOFS scope.
> + * memalloc_nofs_restore - End filesystem reclaim scope.
> * @flags: Flags to restore.
> *
> - * Ends the implicit GFP_NOFS scope started by memalloc_nofs_save function.
> + * Ends the implicit memory allocation scope started by
> + * memalloc_nofs_save(). This may not enable access to filesystem reclaim
> + * if it was already disabled at the time memalloc_nofs_save() was called.
> * Always make sure that the given flags is the return value from the
> * pairing memalloc_nofs_save call.
> */
> diff --git a/mm/readahead.c b/mm/readahead.c
> index 6e5563290287..9c116d4ba963 100644
> --- a/mm/readahead.c
> +++ b/mm/readahead.c
> @@ -227,17 +227,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
> gfp_t gfp_mask = readahead_gfp_mask(mapping);
> unsigned long mark = ULONG_MAX, i = 0;
> unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
> -
> - /*
> - * Partway through the readahead operation, we will have added
> - * locked pages to the page cache, but will not yet have submitted
> - * them for I/O. Adding another page may need to allocate memory,
> - * which can trigger memory reclaim. Telling the VM we're in
> - * the middle of a filesystem operation will cause it to not
> - * touch file-backed pages, preventing a deadlock. Most (all?)
> - * filesystems already specify __GFP_NOFS in their mapping's
> - * gfp_mask, but let's be explicit here.
> - */
> + /* Allocating with locked folios */
> unsigned int nofs = memalloc_nofs_save();
>
> lockdep_assert_held(&mapping->invalidate_lock);
> @@ -512,7 +502,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
>
> ra->order = new_order;
>
> - /* See comment in page_cache_ra_unbounded() */
> + /* Allocating with locked folios */
> nofs = memalloc_nofs_save();
> filemap_invalidate_lock_shared(mapping);
> /*
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 2/9] ext4: Remove uses of FGP_NOFS
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30 4:18 ` [PATCH 1/9] mm: Improve memalloc_nofs_save() documentation Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 10:03 ` Jan Kara
` (2 more replies)
2026-08-30 4:18 ` [PATCH 3/9] erofs: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
` (6 subsequent siblings)
8 siblings, 3 replies; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
Both of these locations are called while a transaction is in progress.
Starting a transaction uses memalloc_nofs_save(), so we are already
prevented from recursing into the filesystem and using GFP_NOFS was
unnecessary.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ext4/inline.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index ceee69a66482..1884abb09614 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -601,9 +601,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
goto out;
}
- /* We cannot recurse into the filesystem as the transaction is already
- * started */
- folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
+ folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
mapping_gfp_mask(mapping));
if (IS_ERR(folio)) {
ret = PTR_ERR(folio);
@@ -734,7 +732,7 @@ int ext4_generic_write_inline_data(struct address_space *mapping,
goto out_release_bh;
}
- folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
+ folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
mapping_gfp_mask(mapping));
if (IS_ERR(folio)) {
ret = PTR_ERR(folio);
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 2/9] ext4: Remove uses of FGP_NOFS
2026-08-30 4:18 ` [PATCH 2/9] ext4: Remove uses of FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-31 10:03 ` Jan Kara
2026-08-31 12:32 ` Baokun Li
2026-09-01 2:17 ` Zhang Yi
2 siblings, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 10:03 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:49, Matthew Wilcox (Oracle) wrote:
> Both of these locations are called while a transaction is in progress.
> Starting a transaction uses memalloc_nofs_save(), so we are already
> prevented from recursing into the filesystem and using GFP_NOFS was
> unnecessary.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/inline.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index ceee69a66482..1884abb09614 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -601,9 +601,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
> goto out;
> }
>
> - /* We cannot recurse into the filesystem as the transaction is already
> - * started */
> - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
> @@ -734,7 +732,7 @@ int ext4_generic_write_inline_data(struct address_space *mapping,
> goto out_release_bh;
> }
>
> - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 2/9] ext4: Remove uses of FGP_NOFS
2026-08-30 4:18 ` [PATCH 2/9] ext4: Remove uses of FGP_NOFS Matthew Wilcox (Oracle)
2026-08-31 10:03 ` Jan Kara
@ 2026-08-31 12:32 ` Baokun Li
2026-09-01 2:17 ` Zhang Yi
2 siblings, 0 replies; 22+ messages in thread
From: Baokun Li @ 2026-08-31 12:32 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On 2026/8/30 12:18, Matthew Wilcox (Oracle) wrote:
> Both of these locations are called while a transaction is in progress.
> Starting a transaction uses memalloc_nofs_save(), so we are already
> prevented from recursing into the filesystem and using GFP_NOFS was
> unnecessary.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me.
Reviewed-by: Baokun Li <libaokun@linux.alibaba.com>
> ---
> fs/ext4/inline.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index ceee69a66482..1884abb09614 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -601,9 +601,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
> goto out;
> }
>
> - /* We cannot recurse into the filesystem as the transaction is already
> - * started */
> - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
> @@ -734,7 +732,7 @@ int ext4_generic_write_inline_data(struct address_space *mapping,
> goto out_release_bh;
> }
>
> - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 2/9] ext4: Remove uses of FGP_NOFS
2026-08-30 4:18 ` [PATCH 2/9] ext4: Remove uses of FGP_NOFS Matthew Wilcox (Oracle)
2026-08-31 10:03 ` Jan Kara
2026-08-31 12:32 ` Baokun Li
@ 2026-09-01 2:17 ` Zhang Yi
2 siblings, 0 replies; 22+ messages in thread
From: Zhang Yi @ 2026-09-01 2:17 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On 8/30/2026 12:18 PM, Matthew Wilcox (Oracle) wrote:
> Both of these locations are called while a transaction is in progress.
> Starting a transaction uses memalloc_nofs_save(), so we are already
> prevented from recursing into the filesystem and using GFP_NOFS was
> unnecessary.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good to me.
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
> ---
> fs/ext4/inline.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index ceee69a66482..1884abb09614 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -601,9 +601,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
> goto out;
> }
>
> - /* We cannot recurse into the filesystem as the transaction is already
> - * started */
> - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
> @@ -734,7 +732,7 @@ int ext4_generic_write_inline_data(struct address_space *mapping,
> goto out_release_bh;
> }
>
> - folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> + folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio)) {
> ret = PTR_ERR(folio);
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 3/9] erofs: Remove redundant FGP_NOFS
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30 4:18 ` [PATCH 1/9] mm: Improve memalloc_nofs_save() documentation Matthew Wilcox (Oracle)
2026-08-30 4:18 ` [PATCH 2/9] ext4: Remove uses of FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 10:08 ` Jan Kara
2026-09-01 5:55 ` Gao Xiang
2026-08-30 4:18 ` [PATCH 4/9] nfs: " Matthew Wilcox (Oracle)
` (5 subsequent siblings)
8 siblings, 2 replies; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
The flags already include FGP_NOWAIT which prohibits all reclaim, not
just reclaiming from the filesystem.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/erofs/internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 65974e57aebf..84b3cdc8e88f 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -327,7 +327,7 @@ static inline struct folio *erofs_grab_folio_nowait(struct address_space *as,
pgoff_t index)
{
return __filemap_get_folio(as, index,
- FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
+ FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
readahead_gfp_mask(as) & ~__GFP_RECLAIM);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 3/9] erofs: Remove redundant FGP_NOFS
2026-08-30 4:18 ` [PATCH 3/9] erofs: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-31 10:08 ` Jan Kara
2026-09-01 5:55 ` Gao Xiang
1 sibling, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 10:08 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:50, Matthew Wilcox (Oracle) wrote:
> The flags already include FGP_NOWAIT which prohibits all reclaim, not
> just reclaiming from the filesystem.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/erofs/internal.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 65974e57aebf..84b3cdc8e88f 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -327,7 +327,7 @@ static inline struct folio *erofs_grab_folio_nowait(struct address_space *as,
> pgoff_t index)
> {
> return __filemap_get_folio(as, index,
> - FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
> + FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
> readahead_gfp_mask(as) & ~__GFP_RECLAIM);
> }
>
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: [PATCH 3/9] erofs: Remove redundant FGP_NOFS
2026-08-30 4:18 ` [PATCH 3/9] erofs: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
2026-08-31 10:08 ` Jan Kara
@ 2026-09-01 5:55 ` Gao Xiang
1 sibling, 0 replies; 22+ messages in thread
From: Gao Xiang @ 2026-09-01 5:55 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun, Aug 30, 2026 at 05:18:50AM +0100, Matthew Wilcox (Oracle) wrote:
> The flags already include FGP_NOWAIT which prohibits all reclaim, not
> just reclaiming from the filesystem.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Gao Xiang <xiang@kernel.org>
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 4/9] nfs: Remove redundant FGP_NOFS
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
` (2 preceding siblings ...)
2026-08-30 4:18 ` [PATCH 3/9] erofs: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 10:07 ` Jan Kara
2026-08-30 4:18 ` [PATCH 5/9] ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite() Matthew Wilcox (Oracle)
` (4 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
The flags already include FGP_NOWAIT which prohibits all reclaim, not
just reclaiming from the filesystem.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/nfs/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 49394123bd09..e34125a8a2e2 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -447,7 +447,7 @@ static struct folio *nfs_readdir_folio_get_next(struct address_space *mapping,
struct folio *folio;
folio = __filemap_get_folio(mapping, index,
- FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
+ FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
mapping_gfp_mask(mapping));
if (IS_ERR(folio))
return NULL;
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 4/9] nfs: Remove redundant FGP_NOFS
2026-08-30 4:18 ` [PATCH 4/9] nfs: " Matthew Wilcox (Oracle)
@ 2026-08-31 10:07 ` Jan Kara
0 siblings, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 10:07 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:51, Matthew Wilcox (Oracle) wrote:
> The flags already include FGP_NOWAIT which prohibits all reclaim, not
> just reclaiming from the filesystem.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Obvious enough :) feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/nfs/dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 49394123bd09..e34125a8a2e2 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -447,7 +447,7 @@ static struct folio *nfs_readdir_folio_get_next(struct address_space *mapping,
> struct folio *folio;
>
> folio = __filemap_get_folio(mapping, index,
> - FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
> + FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
> mapping_gfp_mask(mapping));
> if (IS_ERR(folio))
> return NULL;
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 5/9] ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite()
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
` (3 preceding siblings ...)
2026-08-30 4:18 ` [PATCH 4/9] nfs: " Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 23:34 ` Namjae Jeon
2026-08-30 4:18 ` [PATCH 6/9] ntfs: Remove redundant FGP_NOFS from ntfs_wof_collect_dest() Matthew Wilcox (Oracle)
` (3 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
I do not believe that FGP_NOFS is needed here. This function is called
from one place (ntfs_inode_attr_pwrite) which calls either this function
or __ntfs_inode_non_resident_attr_pwrite(). The latter function does not
use FGP_NOFS in its calls to allocate pagecaache memory, so it should not
be needed here either. If it turns out to be needed by both functions,
then we should use memalloc_nofs_save at a higher level to protect both
of them.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ntfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 32edb4045178..36a0d6b26c02 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -3676,7 +3676,7 @@ static s64 __ntfs_inode_resident_attr_pwrite(struct inode *vi,
mark_mft_record_dirty(ctx->ntfs_ino);
/* Keep the first page clean and uptodate */
- folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
+ folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
mapping_gfp_mask(mapping));
if (IS_ERR(folio)) {
err = PTR_ERR(folio);
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 5/9] ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite()
2026-08-30 4:18 ` [PATCH 5/9] ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite() Matthew Wilcox (Oracle)
@ 2026-08-31 23:34 ` Namjae Jeon
0 siblings, 0 replies; 22+ messages in thread
From: Namjae Jeon @ 2026-08-31 23:34 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Hyunchul Lee, Phillip Lougher,
linux-erofs, linux-kernel, linux-ext4, linux-nfs, ntfs,
linux-fsdevel, linux-mm
On Sun, Aug 30, 2026 at 1:19 PM Matthew Wilcox (Oracle)
<willy@infradead.org> wrote:
>
> I do not believe that FGP_NOFS is needed here. This function is called
> from one place (ntfs_inode_attr_pwrite) which calls either this function
> or __ntfs_inode_non_resident_attr_pwrite(). The latter function does not
> use FGP_NOFS in its calls to allocate pagecaache memory, so it should not
> be needed here either. If it turns out to be needed by both functions,
> then we should use memalloc_nofs_save at a higher level to protect both
> of them.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 6/9] ntfs: Remove redundant FGP_NOFS from ntfs_wof_collect_dest()
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
` (4 preceding siblings ...)
2026-08-30 4:18 ` [PATCH 5/9] ntfs: Remove FGP_NOFS from __ntfs_inode_resident_attr_pwrite() Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 23:31 ` Namjae Jeon
2026-08-30 4:18 ` [PATCH 7/9] squashfs: Remove use of FGP_NOFS Matthew Wilcox (Oracle)
` (2 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
The flags already include FGP_NOWAIT which prohibits all reclaim, not
just reclaiming from the filesystem. Use mapping_gfp_mask() instead of
GFP_NOFS as this will preserve flags like GFP_MOVABLE.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ntfs/wof.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/ntfs/wof.c b/fs/ntfs/wof.c
index 8f84c2212eee..c981b4a3b695 100644
--- a/fs/ntfs/wof.c
+++ b/fs/ntfs/wof.c
@@ -464,10 +464,9 @@ static int ntfs_wof_collect_dest(struct address_space *mapping,
folio = target;
is_target = true;
} else {
- folio = __filemap_get_folio(
- mapping, index,
- FGP_LOCK | FGP_CREAT | FGP_NOFS | FGP_NOWAIT,
- GFP_NOFS);
+ folio = __filemap_get_folio(mapping, index,
+ FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
+ mapping_gfp_mask(mapping));
if (IS_ERR(folio))
return PTR_ERR(folio);
is_target = false;
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 6/9] ntfs: Remove redundant FGP_NOFS from ntfs_wof_collect_dest()
2026-08-30 4:18 ` [PATCH 6/9] ntfs: Remove redundant FGP_NOFS from ntfs_wof_collect_dest() Matthew Wilcox (Oracle)
@ 2026-08-31 23:31 ` Namjae Jeon
0 siblings, 0 replies; 22+ messages in thread
From: Namjae Jeon @ 2026-08-31 23:31 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Hyunchul Lee, Phillip Lougher,
linux-erofs, linux-kernel, linux-ext4, linux-nfs, ntfs,
linux-fsdevel, linux-mm
On Sun, Aug 30, 2026 at 1:19 PM Matthew Wilcox (Oracle)
<willy@infradead.org> wrote:
>
> The flags already include FGP_NOWAIT which prohibits all reclaim, not
> just reclaiming from the filesystem. Use mapping_gfp_mask() instead of
> GFP_NOFS as this will preserve flags like GFP_MOVABLE.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 7/9] squashfs: Remove use of FGP_NOFS
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
` (5 preceding siblings ...)
2026-08-30 4:18 ` [PATCH 6/9] ntfs: Remove redundant FGP_NOFS from ntfs_wof_collect_dest() Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 10:11 ` Jan Kara
2026-08-30 4:18 ` [PATCH 8/9] filemap: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
2026-08-30 4:18 ` [PATCH 9/9] filemap: Remove FGP_NOFS Matthew Wilcox (Oracle)
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
Since we can allocate memory while holding a folio locked, we cannot
allow page reclaim to call into the filesystem and attempt to compact
the folio we're currently holding locked. Use memalloc_nofs_save()
instead of FGP_NOFS here.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/squashfs/file.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index d83594ce91d2..34c550a266bc 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -398,6 +398,7 @@ void squashfs_copy_cache(struct folio *folio,
struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
int start_index = folio->index & ~mask, end_index = start_index | mask;
+ unsigned int nofs = memalloc_nofs_save();
/*
* Loop copying datablock into pages. As the datablock likely covers
@@ -415,7 +416,7 @@ void squashfs_copy_cache(struct folio *folio,
push_folio = (i == folio->index) ? folio :
__filemap_get_folio(mapping, i,
- FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
+ FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
mapping_gfp_mask(mapping));
if (IS_ERR(push_folio))
@@ -430,6 +431,8 @@ void squashfs_copy_cache(struct folio *folio,
if (i != folio->index)
folio_put(push_folio);
}
+
+ memalloc_nofs_restore(nofs);
}
/* Read datablock stored packed inside a fragment (tail-end packed block) */
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 7/9] squashfs: Remove use of FGP_NOFS
2026-08-30 4:18 ` [PATCH 7/9] squashfs: Remove use of FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-31 10:11 ` Jan Kara
0 siblings, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 10:11 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:54, Matthew Wilcox (Oracle) wrote:
> Since we can allocate memory while holding a folio locked, we cannot
> allow page reclaim to call into the filesystem and attempt to compact
> the folio we're currently holding locked. Use memalloc_nofs_save()
> instead of FGP_NOFS here.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
> fs/squashfs/file.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
> index d83594ce91d2..34c550a266bc 100644
> --- a/fs/squashfs/file.c
> +++ b/fs/squashfs/file.c
> @@ -398,6 +398,7 @@ void squashfs_copy_cache(struct folio *folio,
> struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
> int i, mask = (1 << (msblk->block_log - PAGE_SHIFT)) - 1;
> int start_index = folio->index & ~mask, end_index = start_index | mask;
> + unsigned int nofs = memalloc_nofs_save();
Why do you need this? The only allocation I can see is the one using
FGP_NOWAIT below...
Honza
>
> /*
> * Loop copying datablock into pages. As the datablock likely covers
> @@ -415,7 +416,7 @@ void squashfs_copy_cache(struct folio *folio,
>
> push_folio = (i == folio->index) ? folio :
> __filemap_get_folio(mapping, i,
> - FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
> + FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
> mapping_gfp_mask(mapping));
>
> if (IS_ERR(push_folio))
> @@ -430,6 +431,8 @@ void squashfs_copy_cache(struct folio *folio,
> if (i != folio->index)
> folio_put(push_folio);
> }
> +
> + memalloc_nofs_restore(nofs);
> }
>
> /* Read datablock stored packed inside a fragment (tail-end packed block) */
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 8/9] filemap: Remove redundant FGP_NOFS
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
` (6 preceding siblings ...)
2026-08-30 4:18 ` [PATCH 7/9] squashfs: Remove use of FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 10:06 ` Jan Kara
2026-08-30 4:18 ` [PATCH 9/9] filemap: Remove FGP_NOFS Matthew Wilcox (Oracle)
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
The flags already include FGP_NOWAIT which prohibits all reclaim, not
just reclaiming from the filesystem.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 0adfa6605653..3974b063a049 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -929,7 +929,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
pgoff_t index)
{
return pagecache_get_page(mapping, index,
- FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
+ FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
mapping_gfp_mask(mapping));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 8/9] filemap: Remove redundant FGP_NOFS
2026-08-30 4:18 ` [PATCH 8/9] filemap: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-31 10:06 ` Jan Kara
0 siblings, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 10:06 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:55, Matthew Wilcox (Oracle) wrote:
> The flags already include FGP_NOWAIT which prohibits all reclaim, not
> just reclaiming from the filesystem.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/pagemap.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 0adfa6605653..3974b063a049 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -929,7 +929,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
> pgoff_t index)
> {
> return pagecache_get_page(mapping, index,
> - FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
> + FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
> mapping_gfp_mask(mapping));
> }
>
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 9/9] filemap: Remove FGP_NOFS
2026-08-30 4:18 [PATCH 0/9] Remove FGP_NOFS Matthew Wilcox (Oracle)
` (7 preceding siblings ...)
2026-08-30 4:18 ` [PATCH 8/9] filemap: Remove redundant FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-30 4:18 ` Matthew Wilcox (Oracle)
2026-08-31 10:07 ` Jan Kara
8 siblings, 1 reply; 22+ messages in thread
From: Matthew Wilcox (Oracle) @ 2026-08-30 4:18 UTC (permalink / raw)
To: Christian Brauner
Cc: Matthew Wilcox (Oracle), Jan Kara, Gao Xiang, Chao Yu,
Theodore Tso, Trond Myklebust, Anna Schumaker, Namjae Jeon,
Hyunchul Lee, Phillip Lougher, linux-erofs, linux-kernel,
linux-ext4, linux-nfs, ntfs, linux-fsdevel, linux-mm
There are no more users of FGP_NOFS. Remove it.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/pagemap.h | 10 ++++------
mm/filemap.c | 2 --
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 3974b063a049..bff8b7264fb0 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -697,7 +697,6 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping,
* folio is already in cache. If the folio was allocated, unlock it
* before returning so the caller can do the same dance.
* * %FGP_WRITE - The folio will be written to by the caller.
- * * %FGP_NOFS - __GFP_FS will get cleared in gfp.
* * %FGP_NOWAIT - Don't block on the folio lock.
* * %FGP_STABLE - Wait for the folio to be stable (finished writeback)
* * %FGP_DONTCACHE - Uncached buffered IO
@@ -710,11 +709,10 @@ typedef unsigned int __bitwise fgf_t;
#define FGP_LOCK ((__force fgf_t)0x00000002)
#define FGP_CREAT ((__force fgf_t)0x00000004)
#define FGP_WRITE ((__force fgf_t)0x00000008)
-#define FGP_NOFS ((__force fgf_t)0x00000010)
-#define FGP_NOWAIT ((__force fgf_t)0x00000020)
-#define FGP_FOR_MMAP ((__force fgf_t)0x00000040)
-#define FGP_STABLE ((__force fgf_t)0x00000080)
-#define FGP_DONTCACHE ((__force fgf_t)0x00000100)
+#define FGP_NOWAIT ((__force fgf_t)0x00000010)
+#define FGP_FOR_MMAP ((__force fgf_t)0x00000020)
+#define FGP_STABLE ((__force fgf_t)0x00000040)
+#define FGP_DONTCACHE ((__force fgf_t)0x00000080)
#define FGF_GET_ORDER(fgf) (((__force unsigned)fgf) >> 26) /* top 6 bits */
#define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE)
diff --git a/mm/filemap.c b/mm/filemap.c
index 6afec636881f..e6580291f218 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1994,8 +1994,6 @@ struct folio *__filemap_get_folio_mpol(struct address_space *mapping,
if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping))
gfp |= __GFP_WRITE;
- if (fgp_flags & FGP_NOFS)
- gfp &= ~__GFP_FS;
if (fgp_flags & FGP_NOWAIT) {
gfp &= ~GFP_KERNEL;
gfp |= GFP_NOWAIT;
--
2.47.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re: [PATCH 9/9] filemap: Remove FGP_NOFS
2026-08-30 4:18 ` [PATCH 9/9] filemap: Remove FGP_NOFS Matthew Wilcox (Oracle)
@ 2026-08-31 10:07 ` Jan Kara
0 siblings, 0 replies; 22+ messages in thread
From: Jan Kara @ 2026-08-31 10:07 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Christian Brauner, Jan Kara, Gao Xiang, Chao Yu, Theodore Tso,
Trond Myklebust, Anna Schumaker, Namjae Jeon, Hyunchul Lee,
Phillip Lougher, linux-erofs, linux-kernel, linux-ext4, linux-nfs,
ntfs, linux-fsdevel, linux-mm
On Sun 30-08-26 05:18:56, Matthew Wilcox (Oracle) wrote:
> There are no more users of FGP_NOFS. Remove it.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/pagemap.h | 10 ++++------
> mm/filemap.c | 2 --
> 2 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
> index 3974b063a049..bff8b7264fb0 100644
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -697,7 +697,6 @@ pgoff_t page_cache_prev_miss(struct address_space *mapping,
> * folio is already in cache. If the folio was allocated, unlock it
> * before returning so the caller can do the same dance.
> * * %FGP_WRITE - The folio will be written to by the caller.
> - * * %FGP_NOFS - __GFP_FS will get cleared in gfp.
> * * %FGP_NOWAIT - Don't block on the folio lock.
> * * %FGP_STABLE - Wait for the folio to be stable (finished writeback)
> * * %FGP_DONTCACHE - Uncached buffered IO
> @@ -710,11 +709,10 @@ typedef unsigned int __bitwise fgf_t;
> #define FGP_LOCK ((__force fgf_t)0x00000002)
> #define FGP_CREAT ((__force fgf_t)0x00000004)
> #define FGP_WRITE ((__force fgf_t)0x00000008)
> -#define FGP_NOFS ((__force fgf_t)0x00000010)
> -#define FGP_NOWAIT ((__force fgf_t)0x00000020)
> -#define FGP_FOR_MMAP ((__force fgf_t)0x00000040)
> -#define FGP_STABLE ((__force fgf_t)0x00000080)
> -#define FGP_DONTCACHE ((__force fgf_t)0x00000100)
> +#define FGP_NOWAIT ((__force fgf_t)0x00000010)
> +#define FGP_FOR_MMAP ((__force fgf_t)0x00000020)
> +#define FGP_STABLE ((__force fgf_t)0x00000040)
> +#define FGP_DONTCACHE ((__force fgf_t)0x00000080)
> #define FGF_GET_ORDER(fgf) (((__force unsigned)fgf) >> 26) /* top 6 bits */
>
> #define FGP_WRITEBEGIN (FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE)
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 6afec636881f..e6580291f218 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1994,8 +1994,6 @@ struct folio *__filemap_get_folio_mpol(struct address_space *mapping,
>
> if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping))
> gfp |= __GFP_WRITE;
> - if (fgp_flags & FGP_NOFS)
> - gfp &= ~__GFP_FS;
> if (fgp_flags & FGP_NOWAIT) {
> gfp &= ~GFP_KERNEL;
> gfp |= GFP_NOWAIT;
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 22+ messages in thread