From: Hao Xu <howe...@tencent.com>

Choose different gfp flags to support nowait memory allocation in
_xfs_buf_alloc().

Signed-off-by: Hao Xu <howe...@tencent.com>
---
 fs/xfs/xfs_buf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 9f84bc3b802c..8b800ce28996 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -220,9 +220,14 @@ _xfs_buf_alloc(
        struct xfs_buf          *bp;
        int                     error;
        int                     i;
+       bool                    nowait = flags & XBF_NOWAIT;
+       gfp_t                   gfp_flags = GFP_NOFS |
+                                           (nowait ? 0 : __GFP_NOFAIL);
 
        *bpp = NULL;
-       bp = kmem_cache_zalloc(xfs_buf_cache, GFP_NOFS | __GFP_NOFAIL);
+       bp = kmem_cache_zalloc(xfs_buf_cache, gfp_flags);
+       if (!bp)
+               return -EAGAIN;
 
        /*
         * We don't want certain flags to appear in b_flags unless they are
-- 
2.25.1

--
Linux-cachefs mailing list
Linux-cachefs@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-cachefs

Reply via email to