Commit 20dafeef authored by Byoungyoung Lee's avatar Byoungyoung Lee Committed by Dave Chinner

xfs: xfs_mru_cache_insert() should use GFP_NOFS

xfs_mru_cache_insert() can be called from within transaction context
during block allocation like so:

write(2)
  ....
    xfs_get_blocks
      xfs_iomap_write_direct
        start transaction
        xfs_bmapi_write
          xfs_bmapi_allocate
            xfs_bmap_btalloc
              xfs_bmap_btalloc_filestreams
                xfs_filestream_new_ag
                  xfs_filestream_pick_ag
                    xfs_mru_cache_insert
                      radix_tree_preload(GFP_KERNEL)

In this case, GFP_KERNEL is incorrect and can potentially lead to
deadlocks in memory reclaim. It should use GFP_NOFS allocations to
avoid lock recursion problems.

[dchinner: rewrote commit message]
Signed-off-by: default avatarByoungyoung Lee <blee@gatech.edu>
Signed-off-by: default avatarSanidhya Kashyap <sanidhya.gatech@gmail.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 65dd297a
...@@ -437,7 +437,7 @@ xfs_mru_cache_insert( ...@@ -437,7 +437,7 @@ xfs_mru_cache_insert(
if (!mru || !mru->lists) if (!mru || !mru->lists)
return -EINVAL; return -EINVAL;
if (radix_tree_preload(GFP_KERNEL)) if (radix_tree_preload(GFP_NOFS))
return -ENOMEM; return -ENOMEM;
INIT_LIST_HEAD(&elem->list_node); INIT_LIST_HEAD(&elem->list_node);
......
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