Commit d51832f3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix suppression of page allocation failure warnings

Somebody somewhere is stomping on PF_NOWARN, and page allocation
failure warnings are coming out of the wrong places.

So change the handling of current->flags to be:

int pf_flags = current->flags;

current->flags |= PF_NOWARN;
...
current->flags = pf_flags;

which is a generally more robust approach.
parent d4872de3
...@@ -2453,6 +2453,7 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask) ...@@ -2453,6 +2453,7 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask)
{ {
struct scsi_host_sg_pool *sgp; struct scsi_host_sg_pool *sgp;
struct scatterlist *sgl; struct scatterlist *sgl;
int pf_flags;
BUG_ON(!SCpnt->use_sg); BUG_ON(!SCpnt->use_sg);
...@@ -2467,9 +2468,10 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask) ...@@ -2467,9 +2468,10 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask)
sgp = scsi_sg_pools + SCpnt->sglist_len; sgp = scsi_sg_pools + SCpnt->sglist_len;
pf_flags = current->flags;
current->flags |= PF_NOWARN; current->flags |= PF_NOWARN;
sgl = mempool_alloc(sgp->pool, gfp_mask); sgl = mempool_alloc(sgp->pool, gfp_mask);
current->flags &= ~PF_NOWARN; current->flags = pf_flags;
if (sgl) { if (sgl) {
memset(sgl, 0, sgp->size); memset(sgl, 0, sgp->size);
return sgl; return sgl;
......
...@@ -137,6 +137,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs) ...@@ -137,6 +137,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
{ {
struct bio *bio; struct bio *bio;
struct bio_vec *bvl = NULL; struct bio_vec *bvl = NULL;
int pf_flags = current->flags;
current->flags |= PF_NOWARN; current->flags |= PF_NOWARN;
bio = mempool_alloc(bio_pool, gfp_mask); bio = mempool_alloc(bio_pool, gfp_mask);
...@@ -153,7 +154,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs) ...@@ -153,7 +154,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
mempool_free(bio, bio_pool); mempool_free(bio, bio_pool);
bio = NULL; bio = NULL;
out: out:
current->flags &= ~PF_NOWARN; current->flags = pf_flags;
return bio; return bio;
} }
......
...@@ -936,9 +936,11 @@ create_buffers(struct page * page, unsigned long size, int retry) ...@@ -936,9 +936,11 @@ create_buffers(struct page * page, unsigned long size, int retry)
head = NULL; head = NULL;
offset = PAGE_SIZE; offset = PAGE_SIZE;
while ((offset -= size) >= 0) { while ((offset -= size) >= 0) {
int pf_flags = current->flags;
current->flags |= PF_NOWARN; current->flags |= PF_NOWARN;
bh = alloc_buffer_head(); bh = alloc_buffer_head();
current->flags &= ~PF_NOWARN; current->flags = pf_flags;
if (!bh) if (!bh)
goto no_grow; goto no_grow;
......
...@@ -187,11 +187,12 @@ void * mempool_alloc(mempool_t *pool, int gfp_mask) ...@@ -187,11 +187,12 @@ void * mempool_alloc(mempool_t *pool, int gfp_mask)
int curr_nr; int curr_nr;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO); int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
int pf_flags = current->flags;
repeat_alloc: repeat_alloc:
current->flags |= PF_NOWARN; current->flags |= PF_NOWARN;
element = pool->alloc(gfp_nowait, pool->pool_data); element = pool->alloc(gfp_nowait, pool->pool_data);
current->flags &= ~PF_NOWARN; current->flags = pf_flags;
if (likely(element != NULL)) if (likely(element != NULL))
return element; return element;
......
...@@ -119,7 +119,7 @@ void __delete_from_swap_cache(struct page *page) ...@@ -119,7 +119,7 @@ void __delete_from_swap_cache(struct page *page)
int add_to_swap(struct page * page) int add_to_swap(struct page * page)
{ {
swp_entry_t entry; swp_entry_t entry;
int flags; int pf_flags;
if (!PageLocked(page)) if (!PageLocked(page))
BUG(); BUG();
...@@ -142,7 +142,7 @@ int add_to_swap(struct page * page) ...@@ -142,7 +142,7 @@ int add_to_swap(struct page * page)
* just not all of them. * just not all of them.
*/ */
flags = current->flags; pf_flags = current->flags;
current->flags &= ~PF_MEMALLOC; current->flags &= ~PF_MEMALLOC;
current->flags |= PF_NOWARN; current->flags |= PF_NOWARN;
ClearPageUptodate(page); /* why? */ ClearPageUptodate(page); /* why? */
...@@ -154,20 +154,20 @@ int add_to_swap(struct page * page) ...@@ -154,20 +154,20 @@ int add_to_swap(struct page * page)
*/ */
switch (add_to_swap_cache(page, entry)) { switch (add_to_swap_cache(page, entry)) {
case 0: /* Success */ case 0: /* Success */
current->flags = flags; current->flags = pf_flags;
SetPageUptodate(page); SetPageUptodate(page);
set_page_dirty(page); set_page_dirty(page);
swap_free(entry); swap_free(entry);
return 1; return 1;
case -ENOMEM: /* radix-tree allocation */ case -ENOMEM: /* radix-tree allocation */
current->flags = flags; current->flags = pf_flags;
swap_free(entry); swap_free(entry);
return 0; return 0;
default: /* ENOENT: raced */ default: /* ENOENT: raced */
break; break;
} }
/* Raced with "speculative" read_swap_cache_async */ /* Raced with "speculative" read_swap_cache_async */
current->flags = flags; current->flags = pf_flags;
swap_free(entry); swap_free(entry);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment