FAILED: patch "[PATCH] Btrfs: setup a nofs context for memory allocation at" 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 ------------------
From a0873490660246db587849a9e172f2b7b21fa88a Mon Sep 17 00:00:00 2001
From: Filipe Manana <[email protected]>
Date: Thu, 13 Dec 2018 21:16:56 +0000
Subject: [PATCH] Btrfs: setup a nofs context for memory allocation at
__btrfs_set_acl
We are holding a transaction handle when setting an acl, therefore we can not allocate the xattr value buffer using GFP_KERNEL, as we could deadlock if reclaim is triggered by the allocation, therefore setup a nofs context.
fs/btrfs/acl.c +9 -0
@@ -9,6 +9,7 @@#include <linux/posix_acl_xattr.h> #include <linux/posix_acl.h> #include <linux/sched.h> +#include <linux/sched/mm.h> #include <linux/slab.h> #include "ctree.h"
@@ -72,8 +73,16 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans, }if (acl) { +unsigned int nofs_flag; + size =posix_acl_xattr_size (acl->a_count); +/* +* We're holding a transaction handle, so use a NOFS memory +* allocation context to avoid deadlock if reclaim happens. +*/ + nofs_flag =memalloc_nofs_save (); value =kmalloc (size,GFP_KERNEL ); +memalloc_nofs_restore (nofs_flag);if (!value) { ret = -ENOMEM ; goto out;