]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] fix suppression of page allocation failure warnings
authorAndrew Morton <akpm@digeo.com>
Thu, 19 Sep 2002 15:36:52 +0000 (08:36 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 19 Sep 2002 15:36:52 +0000 (08:36 -0700)
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.

drivers/scsi/scsi.c
fs/bio.c
fs/buffer.c
mm/mempool.c
mm/swap_state.c

index 2e591f846b9a3e0e551dc0febcf4dccdb19bf5f4..78003c4c1a67e60586354769a634e5679453d935 100644 (file)
@@ -2453,6 +2453,7 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask)
 {
        struct scsi_host_sg_pool *sgp;
        struct scatterlist *sgl;
+       int pf_flags;
 
        BUG_ON(!SCpnt->use_sg);
 
@@ -2467,9 +2468,10 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask)
 
        sgp = scsi_sg_pools + SCpnt->sglist_len;
 
+       pf_flags = current->flags;
        current->flags |= PF_NOWARN;
        sgl = mempool_alloc(sgp->pool, gfp_mask);
-       current->flags &= ~PF_NOWARN;
+       current->flags = pf_flags;
        if (sgl) {
                memset(sgl, 0, sgp->size);
                return sgl;
index fcfa61afb14902a89931a8c3a51eddb2862d679f..643b77eaa1d64a15cd846a56acf7323751f54d49 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -137,6 +137,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
 {
        struct bio *bio;
        struct bio_vec *bvl = NULL;
+       int pf_flags = current->flags;
 
        current->flags |= PF_NOWARN;
        bio = mempool_alloc(bio_pool, gfp_mask);
@@ -153,7 +154,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
        mempool_free(bio, bio_pool);
        bio = NULL;
 out:
-       current->flags &= ~PF_NOWARN;
+       current->flags = pf_flags;
        return bio;
 }
 
index 22272f97b0e4dda09486cad35d50aeafb3e4104b..496cafae8cf8248c478c1ca67b547ab280b6352b 100644 (file)
@@ -936,9 +936,11 @@ try_again:
        head = NULL;
        offset = PAGE_SIZE;
        while ((offset -= size) >= 0) {
+               int pf_flags = current->flags;
+
                current->flags |= PF_NOWARN;
                bh = alloc_buffer_head();
-               current->flags &= ~PF_NOWARN;
+               current->flags = pf_flags;
                if (!bh)
                        goto no_grow;
 
index b92e72b211d3f55bfeb9d5111f6c4f5369ff284b..a201059c12645d00cc65ca014dcbc2e77b0fec84 100644 (file)
@@ -187,11 +187,12 @@ void * mempool_alloc(mempool_t *pool, int gfp_mask)
        int curr_nr;
        DECLARE_WAITQUEUE(wait, current);
        int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
+       int pf_flags = current->flags;
 
 repeat_alloc:
        current->flags |= PF_NOWARN;
        element = pool->alloc(gfp_nowait, pool->pool_data);
-       current->flags &= ~PF_NOWARN;
+       current->flags = pf_flags;
        if (likely(element != NULL))
                return element;
 
index d07f8db1f7c72b5613bdcd28546d035956a6dfe7..2c393fe1fd8e6ecf25e87c374f815dafebac8634 100644 (file)
@@ -119,7 +119,7 @@ void __delete_from_swap_cache(struct page *page)
 int add_to_swap(struct page * page)
 {
        swp_entry_t entry;
-       int flags;
+       int pf_flags;
 
        if (!PageLocked(page))
                BUG();
@@ -142,7 +142,7 @@ int add_to_swap(struct page * page)
                 * just not all of them.
                 */
 
-               flags = current->flags;
+               pf_flags = current->flags;
                current->flags &= ~PF_MEMALLOC;
                current->flags |= PF_NOWARN;
                ClearPageUptodate(page);                /* why? */
@@ -154,20 +154,20 @@ int add_to_swap(struct page * page)
                 */
                switch (add_to_swap_cache(page, entry)) {
                case 0:                         /* Success */
-                       current->flags = flags;
+                       current->flags = pf_flags;
                        SetPageUptodate(page);
                        set_page_dirty(page);
                        swap_free(entry);
                        return 1;
                case -ENOMEM:                   /* radix-tree allocation */
-                       current->flags = flags;
+                       current->flags = pf_flags;
                        swap_free(entry);
                        return 0;
                default:                        /* ENOENT: raced */
                        break;
                }
                /* Raced with "speculative" read_swap_cache_async */
-               current->flags = flags;
+               current->flags = pf_flags;
                swap_free(entry);
        }
 }