FAILED: patch "[PATCH] btrfs: protect space cache inode alloc with GFP_NOFS" failed to apply to 4.9-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
84de76a2fb217dc1b6bc2965cc397d1648aa1404Mon Sep 17 00:00:00 2001
From: Josef Bacik <[email protected]>
Date: Fri, 28 Sep 2018 07:17:49 -0400
Subject: [PATCH] btrfs: protect space cache inode alloc with GFP_NOFS
If we're allocating a new space cache inode it's likely going to be under a transaction handle, so we need to use memalloc_nofs_save() in order to avoid deadlocks, and more importantly lockdep messages that make xfstests fail.
CC [email protected] # 4.4+
Reviewed-by Omar Sandoval <[email protected]>
Signed-off-by Josef Bacik <[email protected]>
Reviewed-by David Sterba <[email protected]>
Signed-off-by David Sterba <[email protected]>
fs/btrfs/free-space-cache.c +8 -0
@@ -10,6 +10,7 @@#include <linux/math64.h> #include <linux/ratelimit.h> #include <linux/error-injection.h> +#include <linux/sched/mm.h> #include "ctree.h" #include "free-space-cache.h" #include "transaction.h"
@@ -47,6 +48,7 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,struct btrfs_free_space_header *header;struct extent_buffer *leaf;struct inode *inode =NULL ; +unsigned nofs_flag;int ret; key.objectid =BTRFS_FREE_SPACE_OBJECTID ;
@@ -68,7 +70,13 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,btrfs_disk_key_to_cpu (&location, &disk_key);btrfs_release_path (path); +/* +* We are often under a trans handle at this point, so we need to make +* sure NOFS is set to keep us from deadlocking. +*/ + nofs_flag =memalloc_nofs_save (); inode =btrfs_iget (fs_info->sb, &location, root,NULL ); +memalloc_nofs_restore (nofs_flag);if (IS_ERR (inode))return inode;