aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/pagemap.h13
-rw-r--r--mm/filemap.c29
2 files changed, 18 insertions, 24 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 7ea069cd3257..4b3736f7065c 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -251,7 +251,7 @@ pgoff_t page_cache_prev_hole(struct address_space *mapping,
251#define FGP_NOWAIT 0x00000020 251#define FGP_NOWAIT 0x00000020
252 252
253struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, 253struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
254 int fgp_flags, gfp_t cache_gfp_mask, gfp_t radix_gfp_mask); 254 int fgp_flags, gfp_t cache_gfp_mask);
255 255
256/** 256/**
257 * find_get_page - find and get a page reference 257 * find_get_page - find and get a page reference
@@ -266,13 +266,13 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
266static inline struct page *find_get_page(struct address_space *mapping, 266static inline struct page *find_get_page(struct address_space *mapping,
267 pgoff_t offset) 267 pgoff_t offset)
268{ 268{
269 return pagecache_get_page(mapping, offset, 0, 0, 0); 269 return pagecache_get_page(mapping, offset, 0, 0);
270} 270}
271 271
272static inline struct page *find_get_page_flags(struct address_space *mapping, 272static inline struct page *find_get_page_flags(struct address_space *mapping,
273 pgoff_t offset, int fgp_flags) 273 pgoff_t offset, int fgp_flags)
274{ 274{
275 return pagecache_get_page(mapping, offset, fgp_flags, 0, 0); 275 return pagecache_get_page(mapping, offset, fgp_flags, 0);
276} 276}
277 277
278/** 278/**
@@ -292,7 +292,7 @@ static inline struct page *find_get_page_flags(struct address_space *mapping,
292static inline struct page *find_lock_page(struct address_space *mapping, 292static inline struct page *find_lock_page(struct address_space *mapping,
293 pgoff_t offset) 293 pgoff_t offset)
294{ 294{
295 return pagecache_get_page(mapping, offset, FGP_LOCK, 0, 0); 295 return pagecache_get_page(mapping, offset, FGP_LOCK, 0);
296} 296}
297 297
298/** 298/**
@@ -319,7 +319,7 @@ static inline struct page *find_or_create_page(struct address_space *mapping,
319{ 319{
320 return pagecache_get_page(mapping, offset, 320 return pagecache_get_page(mapping, offset,
321 FGP_LOCK|FGP_ACCESSED|FGP_CREAT, 321 FGP_LOCK|FGP_ACCESSED|FGP_CREAT,
322 gfp_mask, gfp_mask & GFP_RECLAIM_MASK); 322 gfp_mask);
323} 323}
324 324
325/** 325/**
@@ -340,8 +340,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
340{ 340{
341 return pagecache_get_page(mapping, index, 341 return pagecache_get_page(mapping, index,
342 FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT, 342 FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
343 mapping_gfp_mask(mapping), 343 mapping_gfp_mask(mapping));
344 GFP_NOFS);
345} 344}
346 345
347struct page *find_get_entry(struct address_space *mapping, pgoff_t offset); 346struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
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