[PATCH 6/6] nvmet: use GFP_KERNEL for PR allocations
Hannes Reinecke
hare at suse.de
Thu Nov 5 23:31:56 PST 2026
On 11/6/26 2:58 AM, Guixin Liu wrote:
> nvmet_pr_update_reg_attr() and nvmet_pr_alloc_and_insert_pc_ref()
> allocate with GFP_ATOMIC, but both run in sleepable context: the PR
> command handlers execute from the transport workqueues and take the
> pr_sem semaphore, and the pc_ref allocation is reached from the
> connect and configfs paths. The latter function even passes
> GFP_KERNEL to the percpu_ref_init() in the same scope, so the
> GFP_ATOMIC only raises the failure rate for no reason.
>
> Switch both allocations to GFP_KERNEL.
>
> Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
> Cc: stable at vger.kernel.org
> Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
> ---
> drivers/nvme/target/pr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
> index 14eaa99f98fa..026653ce338f 100644
> --- a/drivers/nvme/target/pr.c
> +++ b/drivers/nvme/target/pr.c
> @@ -335,7 +335,7 @@ static u16 nvmet_pr_update_reg_attr(struct nvmet_pr *pr,
> return NVME_SC_SUCCESS;
> }
>
> - new = kmalloc_obj(*new, GFP_ATOMIC);
> + new = kmalloc_obj(*new, GFP_KERNEL);
> if (!new)
> return NVME_SC_INTERNAL;
>
> @@ -1040,7 +1040,7 @@ static int nvmet_pr_alloc_and_insert_pc_ref(struct nvmet_ns *ns,
> struct nvmet_pr_per_ctrl_ref *pc_ref;
> int ret;
>
> - pc_ref = kmalloc_obj(*pc_ref, GFP_ATOMIC);
> + pc_ref = kmalloc_obj(*pc_ref, GFP_KERNEL);
> if (!pc_ref)
> return -ENOMEM;
>
Reviewed-by: Hannes Reinecke <hare at kernel.org>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list