aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.cz>2014-12-29 14:30:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-29 15:45:45 -0500
commit45f87de57f8fad59302fd263dd81ffa4843b5b24 (patch)
tree4c92e7d997c86700828c11c1b4b5d247e8b7e9f9 /mm/filemap.c
parentb7392d2247cfe6771f95d256374f1a8e6a6f48d6 (diff)
mm: get rid of radix tree gfp mask for pagecache_get_page
Commit 2457aec63745 ("mm: non-atomically mark page accessed during page cache allocation where possible") has added a separate parameter for specifying gfp mask for radix tree allocations. Not only this is less than optimal from the API point of view because it is error prone, it is also buggy currently because grab_cache_page_write_begin is using GFP_KERNEL for radix tree and if fgp_flags doesn't contain FGP_NOFS (mostly controlled by fs by AOP_FLAG_NOFS flag) but the mapping_gfp_mask has __GFP_FS cleared then the radix tree allocation wouldn't obey the restriction and might recurse into filesystem and cause deadlocks. This is the case for most filesystems unfortunately because only ext4 and gfs2 are using AOP_FLAG_NOFS. Let's simply remove radix_gfp_mask parameter because the allocation context is same for both page cache and for the radix tree. Just make sure that the radix tree gets only the sane subset of the mask (e.g. do not pass __GFP_WRITE). Long term it is more preferable to convert remaining users of AOP_FLAG_NOFS to use mapping_gfp_mask instead and simplify this interface even further. Reported-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Michal Hocko <mhocko@suse.cz> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index bd8543c6508f..673e4581a2e5 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1046,8 +1046,7 @@ EXPORT_SYMBOL(find_lock_entry);
1046 * @mapping: the address_space to search 1046 * @mapping: the address_space to search
1047 * @offset: the page index 1047 * @offset: the page index
1048 * @fgp_flags: PCG flags 1048 * @fgp_flags: PCG flags
1049 * @cache_gfp_mask: gfp mask to use for the page cache data page allocation 1049 * @gfp_mask: gfp mask to use for the page cache data page allocation
1050 * @radix_gfp_mask: gfp mask to use for radix tree node allocation
1051 * 1050 *
1052 * Looks up the page cache slot at @mapping & @offset. 1051 * Looks up the page cache slot at @mapping & @offset.
1053 * 1052 *
@@ -1056,11 +1055,9 @@ EXPORT_SYMBOL(find_lock_entry);
1056 * FGP_ACCESSED: the page will be marked accessed 1055 * FGP_ACCESSED: the page will be marked accessed
1057 * FGP_LOCK: Page is return locked 1056 * FGP_LOCK: Page is return locked
1058 * FGP_CREAT: If page is not present then a new page is allocated using 1057 * FGP_CREAT: If page is not present then a new page is allocated using
1059 * @cache_gfp_mask and added to the page cache and the VM's LRU 1058 * @gfp_mask and added to the page cache and the VM's LRU
1060 * list. If radix tree nodes are allocated during page cache 1059 * list. The page is returned locked and with an increased
1061 * insertion then @radix_gfp_mask is used. The page is returned 1060 * refcount. Otherwise, %NULL is returned.
1062 * locked and with an increased refcount. Otherwise, %NULL is
1063 * returned.
1064 * 1061 *
1065 * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even 1062 * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even
1066 * if the GFP flags specified for FGP_CREAT are atomic. 1063 * if the GFP flags specified for FGP_CREAT are atomic.
@@ -1068,7 +1065,7 @@ EXPORT_SYMBOL(find_lock_entry);
1068 * If there is a page cache page, it is returned with an increased refcount. 1065 * If there is a page cache page, it is returned with an increased refcount.
1069 */ 1066 */
1070struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, 1067struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
1071 int fgp_flags, gfp_t cache_gfp_mask, gfp_t radix_gfp_mask) 1068 int fgp_flags, gfp_t gfp_mask)
1072{ 1069{
1073 struct page *page; 1070 struct page *page;
1074 1071
@@ -1105,13 +1102,11 @@ no_page:
1105 if (!page && (fgp_flags & FGP_CREAT)) { 1102 if (!page && (fgp_flags & FGP_CREAT)) {
1106 int err; 1103 int err;
1107 if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping)) 1104 if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping))
1108 cache_gfp_mask |= __GFP_WRITE; 1105 gfp_mask |= __GFP_WRITE;
1109 if (fgp_flags & FGP_NOFS) { 1106 if (fgp_flags & FGP_NOFS)
1110 cache_gfp_mask &= ~__GFP_FS; 1107 gfp_mask &= ~__GFP_FS;
1111 radix_gfp_mask &= ~__GFP_FS;
1112 }
1113 1108
1114 page = __page_cache_alloc(cache_gfp_mask); 1109 page = __page_cache_alloc(gfp_mask);
1115 if (!page) 1110 if (!page)
1116 return NULL; 1111 return NULL;
1117 1112
@@ -1122,7 +1117,8 @@ no_page:
1122 if (fgp_flags & FGP_ACCESSED) 1117 if (fgp_flags & FGP_ACCESSED)
1123 __SetPageReferenced(page); 1118 __SetPageReferenced(page);
1124 1119
1125 err = add_to_page_cache_lru(page, mapping, offset, radix_gfp_mask); 1120 err = add_to_page_cache_lru(page, mapping, offset,
1121 gfp_mask & GFP_RECLAIM_MASK);
1126 if (unlikely(err)) { 1122 if (unlikely(err)) {
1127 page_cache_release(page); 1123 page_cache_release(page);
1128 page = NULL; 1124 page = NULL;
@@ -2443,8 +2439,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
2443 fgp_flags |= FGP_NOFS; 2439 fgp_flags |= FGP_NOFS;
2444 2440
2445 page = pagecache_get_page(mapping, index, fgp_flags, 2441 page = pagecache_get_page(mapping, index, fgp_flags,
2446 mapping_gfp_mask(mapping), 2442 mapping_gfp_mask(mapping));
2447 GFP_KERNEL);
2448 if (page) 2443 if (page)
2449 wait_for_stable_page(page); 2444 wait_for_stable_page(page);
2450 2445