]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
f2fs: Use mapping->gfp_mask to get file cache for writing
authorJiucheng Xu <jiucheng.xu@amlogic.com>
Fri, 10 Oct 2025 10:45:50 +0000 (10:45 +0000)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 7 Nov 2025 17:46:38 +0000 (17:46 +0000)
On 32-bit architectures, when GFP_NOFS is used, the file cache for write
operations cannot be allocated from the highmem and CMA.

Since mapping->gfp_mask is set to GFP_HIGHUSER_MOVABLE during inode
allocation, using mapping_gfp_mask(mapping) as the GFP flag of getting file
cache for writing is more efficient for 32-bit architectures.

Additionally, use FGP_NOFS to avoid potential deadlock issues caused by
GFP_FS in GFP_HIGHUSER_MOVABLE

Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 775aa4f63aa303664343f480df4fcc804c5fad42..16a713013427476fbc0d765cf913db3d6112c539 100644 (file)
@@ -3570,7 +3570,8 @@ repeat:
         * Will wait that below with our IO control.
         */
        folio = __filemap_get_folio(mapping, index,
-                               FGP_LOCK | FGP_WRITE | FGP_CREAT, GFP_NOFS);
+                               FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_NOFS,
+                               mapping_gfp_mask(mapping));
        if (IS_ERR(folio)) {
                err = PTR_ERR(folio);
                goto fail;