@@ -192,7 +192,7 @@ xfs_buf_get_maps(
bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map),
KM_NOFS);
if (!bp->b_maps)
- return -ENOMEM;
+ return bp->b_flags & XBF_NOWAIT ? -EAGAIN : -ENOMEM;
return 0;
}
@@ -339,7 +339,7 @@ xfs_buf_alloc_kmem(
bp->b_addr = kmem_alloc(size, kmflag_mask);
if (!bp->b_addr)
- return -ENOMEM;
+ return flags & XBF_NOWAIT ? -EAGAIN : -ENOMEM;
if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
((unsigned long)bp->b_addr & PAGE_MASK)) {
@@ -363,6 +363,7 @@ xfs_buf_alloc_pages(
{
gfp_t gfp_mask = __GFP_NOWARN;
long filled = 0;
+ bool nowait = flags & XBF_NOWAIT;
if (flags & XBF_READ_AHEAD)
gfp_mask |= __GFP_NORETRY;
@@ -377,7 +378,7 @@ xfs_buf_alloc_pages(
bp->b_pages = kzalloc(sizeof(struct page *) * bp->b_page_count,
gfp_mask);
if (!bp->b_pages)
- return -ENOMEM;
+ return nowait ? -EAGAIN : -ENOMEM;
}
bp->b_flags |= _XBF_PAGES;
@@ -451,7 +452,7 @@ _xfs_buf_map_pages(
memalloc_nofs_restore(nofs_flag);
if (!bp->b_addr)
- return -ENOMEM;
+ return flags & XBF_NOWAIT ? -EAGAIN : -ENOMEM;
}
return 0;