aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_buf.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-04-23 01:58:56 -0400
committerBen Myers <bpm@sgi.com>2012-05-14 17:20:52 -0400
commitaa5c158ec97bd4014f47a2bc0150fb6b20e6c48b (patch)
tree8c79791167a5d659949952ad11a08ce325eb025c /fs/xfs/xfs_buf.c
parent7ca790a507a9288ebedab90a8e40b9afa8e4e949 (diff)
xfs: kill XBF_DONTBLOCK
Just about all callers of xfs_buf_read() and xfs_buf_get() use XBF_DONTBLOCK. This is used to make memory allocation use GFP_NOFS rather than GFP_KERNEL to avoid recursion through memory reclaim back into the filesystem. All the blocking get calls in growfs occur inside a transaction, even though they are no part of the transaction, so all allocation will be GFP_NOFS due to the task flag PF_TRANS being set. The blocking read calls occur during log recovery, so they will probably be unaffected by converting to GFP_NOFS allocations. Hence make XBF_DONTBLOCK behaviour always occur for buffers and kill the flag. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_buf.c')
-rw-r--r--fs/xfs/xfs_buf.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 8366348aa1f..59e39160d37 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -56,11 +56,7 @@ static struct workqueue_struct *xfslogd_workqueue;
56#endif 56#endif
57 57
58#define xb_to_gfp(flags) \ 58#define xb_to_gfp(flags) \
59 ((((flags) & XBF_READ_AHEAD) ? __GFP_NORETRY : \ 59 ((((flags) & XBF_READ_AHEAD) ? __GFP_NORETRY : GFP_NOFS) | __GFP_NOWARN)
60 ((flags) & XBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL) | __GFP_NOWARN)
61
62#define xb_to_km(flags) \
63 (((flags) & XBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
64 60
65 61
66static inline int 62static inline int
@@ -178,14 +174,14 @@ xfs_buf_alloc(
178{ 174{
179 struct xfs_buf *bp; 175 struct xfs_buf *bp;
180 176
181 bp = kmem_zone_zalloc(xfs_buf_zone, xb_to_km(flags)); 177 bp = kmem_zone_zalloc(xfs_buf_zone, KM_NOFS);
182 if (unlikely(!bp)) 178 if (unlikely(!bp))
183 return NULL; 179 return NULL;
184 180
185 /* 181 /*
186 * We don't want certain flags to appear in b_flags. 182 * We don't want certain flags to appear in b_flags.
187 */ 183 */
188 flags &= ~(XBF_MAPPED|XBF_DONT_BLOCK|XBF_READ_AHEAD); 184 flags &= ~(XBF_MAPPED|XBF_READ_AHEAD);
189 185
190 atomic_set(&bp->b_hold, 1); 186 atomic_set(&bp->b_hold, 1);
191 atomic_set(&bp->b_lru_ref, 1); 187 atomic_set(&bp->b_lru_ref, 1);
@@ -239,7 +235,7 @@ _xfs_buf_get_pages(
239 bp->b_pages = bp->b_page_array; 235 bp->b_pages = bp->b_page_array;
240 } else { 236 } else {
241 bp->b_pages = kmem_alloc(sizeof(struct page *) * 237 bp->b_pages = kmem_alloc(sizeof(struct page *) *
242 page_count, xb_to_km(flags)); 238 page_count, KM_NOFS);
243 if (bp->b_pages == NULL) 239 if (bp->b_pages == NULL)
244 return -ENOMEM; 240 return -ENOMEM;
245 } 241 }
@@ -316,7 +312,7 @@ xfs_buf_allocate_memory(
316 */ 312 */
317 size = BBTOB(bp->b_length); 313 size = BBTOB(bp->b_length);
318 if (size < PAGE_SIZE) { 314 if (size < PAGE_SIZE) {
319 bp->b_addr = kmem_alloc(size, xb_to_km(flags)); 315 bp->b_addr = kmem_alloc(size, KM_NOFS);
320 if (!bp->b_addr) { 316 if (!bp->b_addr) {
321 /* low memory - use alloc_page loop instead */ 317 /* low memory - use alloc_page loop instead */
322 goto use_alloc_page; 318 goto use_alloc_page;
@@ -659,7 +655,7 @@ xfs_buf_readahead(
659 return; 655 return;
660 656
661 xfs_buf_read(target, blkno, numblks, 657 xfs_buf_read(target, blkno, numblks,
662 XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD|XBF_DONT_BLOCK); 658 XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD);
663} 659}
664 660
665/* 661/*
@@ -750,7 +746,7 @@ xfs_buf_associate_memory(
750 bp->b_pages = NULL; 746 bp->b_pages = NULL;
751 bp->b_addr = mem; 747 bp->b_addr = mem;
752 748
753 rval = _xfs_buf_get_pages(bp, page_count, XBF_DONT_BLOCK); 749 rval = _xfs_buf_get_pages(bp, page_count, 0);
754 if (rval) 750 if (rval)
755 return rval; 751 return rval;
756 752