Commit 8db50e8b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] make alloc_buffer_head take gfp_flags

- alloc_buffer_head() should take the allocation mode as an arg, and not
  assume.

- Use __GFP_NOFAIL in JBD's call to alloc_buffer_head().

- Remove all the retry code from jbd_kmalloc() - do it via page allocator
  controls.
parent 75908778
...@@ -995,7 +995,7 @@ create_buffers(struct page * page, unsigned long size, int retry) ...@@ -995,7 +995,7 @@ 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) {
bh = alloc_buffer_head(); bh = alloc_buffer_head(GFP_NOFS);
if (!bh) if (!bh)
goto no_grow; goto no_grow;
...@@ -2346,7 +2346,7 @@ int nobh_prepare_write(struct page *page, unsigned from, unsigned to, ...@@ -2346,7 +2346,7 @@ int nobh_prepare_write(struct page *page, unsigned from, unsigned to,
if (buffer_uptodate(&map_bh)) if (buffer_uptodate(&map_bh))
continue; /* reiserfs does this */ continue; /* reiserfs does this */
if (block_start < from || block_end > to) { if (block_start < from || block_end > to) {
struct buffer_head *bh = alloc_buffer_head(); struct buffer_head *bh = alloc_buffer_head(GFP_NOFS);
if (!bh) { if (!bh) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -2905,9 +2905,9 @@ static void recalc_bh_state(void) ...@@ -2905,9 +2905,9 @@ static void recalc_bh_state(void)
buffer_heads_over_limit = (tot > max_buffer_heads); buffer_heads_over_limit = (tot > max_buffer_heads);
} }
struct buffer_head *alloc_buffer_head(void) struct buffer_head *alloc_buffer_head(int gfp_flags)
{ {
struct buffer_head *ret = kmem_cache_alloc(bh_cachep, GFP_NOFS); struct buffer_head *ret = kmem_cache_alloc(bh_cachep, gfp_flags);
if (ret) { if (ret) {
preempt_disable(); preempt_disable();
__get_cpu_var(bh_accounting).nr++; __get_cpu_var(bh_accounting).nr++;
......
...@@ -457,14 +457,8 @@ int journal_write_metadata_buffer(transaction_t *transaction, ...@@ -457,14 +457,8 @@ int journal_write_metadata_buffer(transaction_t *transaction,
/* /*
* Right, time to make up the new buffer_head. * Right, time to make up the new buffer_head.
*/ */
do { new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL);
new_bh = alloc_buffer_head();
if (!new_bh) {
printk (KERN_NOTICE "%s: ENOMEM at alloc_buffer_head, "
"trying again.\n", __FUNCTION__);
yield();
}
} while (!new_bh);
/* keep subsequent assertions sane */ /* keep subsequent assertions sane */
new_bh->b_state = 0; new_bh->b_state = 0;
init_buffer(new_bh, NULL, NULL); init_buffer(new_bh, NULL, NULL);
...@@ -1613,28 +1607,7 @@ void shrink_journal_memory(void) ...@@ -1613,28 +1607,7 @@ void shrink_journal_memory(void)
*/ */
void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry) void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry)
{ {
void *p; return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
static unsigned long last_warning;
while (1) {
p = kmalloc(size, flags);
if (p)
return p;
if (!retry)
return NULL;
/* Log every retry for debugging. Also log them to the
* syslog, but do rate-limiting on the non-debugging
* messages. */
jbd_debug(1, "ENOMEM in %s, retrying.\n", where);
if (time_after(jiffies, last_warning + 5*HZ)) {
printk(KERN_NOTICE
"ENOMEM in %s, retrying.\n", where);
last_warning = jiffies;
}
yield();
}
} }
/* /*
......
...@@ -172,7 +172,7 @@ struct buffer_head * __getblk(struct block_device *, sector_t, int); ...@@ -172,7 +172,7 @@ struct buffer_head * __getblk(struct block_device *, sector_t, int);
void __brelse(struct buffer_head *); void __brelse(struct buffer_head *);
void __bforget(struct buffer_head *); void __bforget(struct buffer_head *);
struct buffer_head *__bread(struct block_device *, sector_t block, int size); struct buffer_head *__bread(struct block_device *, sector_t block, int size);
struct buffer_head *alloc_buffer_head(void); struct buffer_head *alloc_buffer_head(int gfp_flags);
void free_buffer_head(struct buffer_head * bh); void free_buffer_head(struct buffer_head * bh);
void FASTCALL(unlock_buffer(struct buffer_head *bh)); void FASTCALL(unlock_buffer(struct buffer_head *bh));
void ll_rw_block(int, int, struct buffer_head * bh[]); void ll_rw_block(int, int, struct buffer_head * bh[]);
......
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