diff options
author | David Howells <dhowells@redhat.com> | 2012-12-20 16:52:33 -0500 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2012-12-20 16:58:25 -0500 |
commit | 5f4f9f4af185d5e76c966d2d3420a61870c856e7 (patch) | |
tree | b2f41124474891a58ec77cbbdb6adccb704073d6 /fs | |
parent | c4d6d8dbf335c7fa47341654a37c53a512b519bb (diff) |
CacheFiles: Downgrade the requirements passed to the allocator
Downgrade the requirements passed to the allocator in the gfp flags parameter.
FS-Cache/CacheFiles can handle OOM conditions simply by aborting the attempt to
store an object or a page in the cache.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cachefiles/interface.c | 8 | ||||
-rw-r--r-- | fs/cachefiles/internal.h | 2 | ||||
-rw-r--r-- | fs/cachefiles/key.c | 2 | ||||
-rw-r--r-- | fs/cachefiles/rdwr.c | 18 | ||||
-rw-r--r-- | fs/cachefiles/xattr.c | 2 | ||||
-rw-r--r-- | fs/fscache/page.c | 2 |
6 files changed, 19 insertions, 15 deletions
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 67bef6d01484..9bff0f878cfd 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c | |||
@@ -41,12 +41,12 @@ static struct fscache_object *cachefiles_alloc_object( | |||
41 | 41 | ||
42 | _enter("{%s},%p,", cache->cache.identifier, cookie); | 42 | _enter("{%s},%p,", cache->cache.identifier, cookie); |
43 | 43 | ||
44 | lookup_data = kmalloc(sizeof(*lookup_data), GFP_KERNEL); | 44 | lookup_data = kmalloc(sizeof(*lookup_data), cachefiles_gfp); |
45 | if (!lookup_data) | 45 | if (!lookup_data) |
46 | goto nomem_lookup_data; | 46 | goto nomem_lookup_data; |
47 | 47 | ||
48 | /* create a new object record and a temporary leaf image */ | 48 | /* create a new object record and a temporary leaf image */ |
49 | object = kmem_cache_alloc(cachefiles_object_jar, GFP_KERNEL); | 49 | object = kmem_cache_alloc(cachefiles_object_jar, cachefiles_gfp); |
50 | if (!object) | 50 | if (!object) |
51 | goto nomem_object; | 51 | goto nomem_object; |
52 | 52 | ||
@@ -63,7 +63,7 @@ static struct fscache_object *cachefiles_alloc_object( | |||
63 | * - stick the length on the front and leave space on the back for the | 63 | * - stick the length on the front and leave space on the back for the |
64 | * encoder | 64 | * encoder |
65 | */ | 65 | */ |
66 | buffer = kmalloc((2 + 512) + 3, GFP_KERNEL); | 66 | buffer = kmalloc((2 + 512) + 3, cachefiles_gfp); |
67 | if (!buffer) | 67 | if (!buffer) |
68 | goto nomem_buffer; | 68 | goto nomem_buffer; |
69 | 69 | ||
@@ -219,7 +219,7 @@ static void cachefiles_update_object(struct fscache_object *_object) | |||
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | auxdata = kmalloc(2 + 512 + 3, GFP_KERNEL); | 222 | auxdata = kmalloc(2 + 512 + 3, cachefiles_gfp); |
223 | if (!auxdata) { | 223 | if (!auxdata) { |
224 | _leave(" [nomem]"); | 224 | _leave(" [nomem]"); |
225 | return; | 225 | return; |
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index bd6bc1bde2d7..49382519907a 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h | |||
@@ -23,6 +23,8 @@ extern unsigned cachefiles_debug; | |||
23 | #define CACHEFILES_DEBUG_KLEAVE 2 | 23 | #define CACHEFILES_DEBUG_KLEAVE 2 |
24 | #define CACHEFILES_DEBUG_KDEBUG 4 | 24 | #define CACHEFILES_DEBUG_KDEBUG 4 |
25 | 25 | ||
26 | #define cachefiles_gfp (__GFP_WAIT | __GFP_NORETRY | __GFP_NOMEMALLOC) | ||
27 | |||
26 | /* | 28 | /* |
27 | * node records | 29 | * node records |
28 | */ | 30 | */ |
diff --git a/fs/cachefiles/key.c b/fs/cachefiles/key.c index 81b8b2b3a674..33b58c60f2d1 100644 --- a/fs/cachefiles/key.c +++ b/fs/cachefiles/key.c | |||
@@ -78,7 +78,7 @@ char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type) | |||
78 | 78 | ||
79 | _debug("max: %d", max); | 79 | _debug("max: %d", max); |
80 | 80 | ||
81 | key = kmalloc(max, GFP_KERNEL); | 81 | key = kmalloc(max, cachefiles_gfp); |
82 | if (!key) | 82 | if (!key) |
83 | return NULL; | 83 | return NULL; |
84 | 84 | ||
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index 3367abdcdac4..9108b8ea505a 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c | |||
@@ -238,7 +238,7 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object, | |||
238 | _debug("read back %p{%lu,%d}", | 238 | _debug("read back %p{%lu,%d}", |
239 | netpage, netpage->index, page_count(netpage)); | 239 | netpage, netpage->index, page_count(netpage)); |
240 | 240 | ||
241 | monitor = kzalloc(sizeof(*monitor), GFP_KERNEL); | 241 | monitor = kzalloc(sizeof(*monitor), cachefiles_gfp); |
242 | if (!monitor) | 242 | if (!monitor) |
243 | goto nomem; | 243 | goto nomem; |
244 | 244 | ||
@@ -257,13 +257,14 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object, | |||
257 | goto backing_page_already_present; | 257 | goto backing_page_already_present; |
258 | 258 | ||
259 | if (!newpage) { | 259 | if (!newpage) { |
260 | newpage = page_cache_alloc_cold(bmapping); | 260 | newpage = __page_cache_alloc(cachefiles_gfp | |
261 | __GFP_COLD); | ||
261 | if (!newpage) | 262 | if (!newpage) |
262 | goto nomem_monitor; | 263 | goto nomem_monitor; |
263 | } | 264 | } |
264 | 265 | ||
265 | ret = add_to_page_cache(newpage, bmapping, | 266 | ret = add_to_page_cache(newpage, bmapping, |
266 | netpage->index, GFP_KERNEL); | 267 | netpage->index, cachefiles_gfp); |
267 | if (ret == 0) | 268 | if (ret == 0) |
268 | goto installed_new_backing_page; | 269 | goto installed_new_backing_page; |
269 | if (ret != -EEXIST) | 270 | if (ret != -EEXIST) |
@@ -481,7 +482,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
481 | netpage, netpage->index, page_count(netpage)); | 482 | netpage, netpage->index, page_count(netpage)); |
482 | 483 | ||
483 | if (!monitor) { | 484 | if (!monitor) { |
484 | monitor = kzalloc(sizeof(*monitor), GFP_KERNEL); | 485 | monitor = kzalloc(sizeof(*monitor), cachefiles_gfp); |
485 | if (!monitor) | 486 | if (!monitor) |
486 | goto nomem; | 487 | goto nomem; |
487 | 488 | ||
@@ -496,13 +497,14 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
496 | goto backing_page_already_present; | 497 | goto backing_page_already_present; |
497 | 498 | ||
498 | if (!newpage) { | 499 | if (!newpage) { |
499 | newpage = page_cache_alloc_cold(bmapping); | 500 | newpage = __page_cache_alloc(cachefiles_gfp | |
501 | __GFP_COLD); | ||
500 | if (!newpage) | 502 | if (!newpage) |
501 | goto nomem; | 503 | goto nomem; |
502 | } | 504 | } |
503 | 505 | ||
504 | ret = add_to_page_cache(newpage, bmapping, | 506 | ret = add_to_page_cache(newpage, bmapping, |
505 | netpage->index, GFP_KERNEL); | 507 | netpage->index, cachefiles_gfp); |
506 | if (ret == 0) | 508 | if (ret == 0) |
507 | goto installed_new_backing_page; | 509 | goto installed_new_backing_page; |
508 | if (ret != -EEXIST) | 510 | if (ret != -EEXIST) |
@@ -532,7 +534,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
532 | _debug("- monitor add"); | 534 | _debug("- monitor add"); |
533 | 535 | ||
534 | ret = add_to_page_cache(netpage, op->mapping, netpage->index, | 536 | ret = add_to_page_cache(netpage, op->mapping, netpage->index, |
535 | GFP_KERNEL); | 537 | cachefiles_gfp); |
536 | if (ret < 0) { | 538 | if (ret < 0) { |
537 | if (ret == -EEXIST) { | 539 | if (ret == -EEXIST) { |
538 | page_cache_release(netpage); | 540 | page_cache_release(netpage); |
@@ -608,7 +610,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
608 | _debug("- uptodate"); | 610 | _debug("- uptodate"); |
609 | 611 | ||
610 | ret = add_to_page_cache(netpage, op->mapping, netpage->index, | 612 | ret = add_to_page_cache(netpage, op->mapping, netpage->index, |
611 | GFP_KERNEL); | 613 | cachefiles_gfp); |
612 | if (ret < 0) { | 614 | if (ret < 0) { |
613 | if (ret == -EEXIST) { | 615 | if (ret == -EEXIST) { |
614 | page_cache_release(netpage); | 616 | page_cache_release(netpage); |
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c index e18b183b47e1..73b46288b54b 100644 --- a/fs/cachefiles/xattr.c +++ b/fs/cachefiles/xattr.c | |||
@@ -174,7 +174,7 @@ int cachefiles_check_object_xattr(struct cachefiles_object *object, | |||
174 | ASSERT(dentry); | 174 | ASSERT(dentry); |
175 | ASSERT(dentry->d_inode); | 175 | ASSERT(dentry->d_inode); |
176 | 176 | ||
177 | auxbuf = kmalloc(sizeof(struct cachefiles_xattr) + 512, GFP_KERNEL); | 177 | auxbuf = kmalloc(sizeof(struct cachefiles_xattr) + 512, cachefiles_gfp); |
178 | if (!auxbuf) { | 178 | if (!auxbuf) { |
179 | _leave(" = -ENOMEM"); | 179 | _leave(" = -ENOMEM"); |
180 | return -ENOMEM; | 180 | return -ENOMEM; |
diff --git a/fs/fscache/page.c b/fs/fscache/page.c index d7c663cfc923..248a12e22532 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c | |||
@@ -759,7 +759,7 @@ int __fscache_write_page(struct fscache_cookie *cookie, | |||
759 | 759 | ||
760 | fscache_stat(&fscache_n_stores); | 760 | fscache_stat(&fscache_n_stores); |
761 | 761 | ||
762 | op = kzalloc(sizeof(*op), GFP_NOIO); | 762 | op = kzalloc(sizeof(*op), GFP_NOIO | __GFP_NOMEMALLOC | __GFP_NORETRY); |
763 | if (!op) | 763 | if (!op) |
764 | goto nomem; | 764 | goto nomem; |
765 | 765 | ||