Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp438122rdh; Tue, 19 Dec 2023 03:44:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyNCHbg/F6LlmX9mxSusy873UMmaG4CtzbgFf64+qkrzprRBTuYRAQY6ipEVvLqolVmrLf X-Received: by 2002:a17:906:3f46:b0:a1d:b0c7:90a3 with SMTP id f6-20020a1709063f4600b00a1db0c790a3mr8659847ejj.93.1702986239927; Tue, 19 Dec 2023 03:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702986239; cv=none; d=google.com; s=arc-20160816; b=p3UlL1TZ4KR7VVXjyWyJXcRtEysX3NlPfDfrCDix4njFssrP3gvPRu8GPgUAQ2Kiif zQhKNwxdQwwDCHA9v5zaev8HoqhLl+LfeoXwIo7DPzr+GXWcNL+vKJhHK3GzeNRxS7Yg wwnihfKcHIzldaGHJYg24jH1MKQKshZIuXki+ZRJQ/xAwet4fEYhL/uw9GR4hgAxhK0o 6oc8yd0wWrBDgvRRtR2KCL0XsTFc63pWM1zC/C5ZWrVVLlF48HeubyB/vkhj5dgSzPzF +TDDAqD9L0gMhdk7AC1PUMY6oTrL3GJ+y27Zcy1dxUJkmeGRyM4w/O99D8+rdSXEFj5z JKJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=fafTMXnOq5GdsynhgtOPXxA6FeNGcov92dOpw5cyEwM=; fh=Ob8FspbdAv2lvfy9oyzcNqJb9FlG/MYewgbmONDw7dw=; b=rYom7S4exfLI/+3qMOet3c8WixgKPRdHFR51BqFp4RzrqlXedWDAjToHqP9/0iwW7e ltNGX7KGjXR6j9hNvPWJTmmbZ5hOp6Qnki1VFqrUWCzC90SHqOC2tbvZpWe3Xr7fR0r+ ntx9rwZkdBlATW7Q0QSsihZiJLVsAIOCjEdud4WoC+mgAdWEbtNCu5ce6DdGVTpIqt4W QFrP3diyWqULSeHL1l92avRuhZk+dgIOXG3+ce0LaADWoXWlrncPCp2FYji0m+9QAzVN MlDrguzAFBKDQp6z7fKp6F4AsYhyjkumnwUjepT9fJBfdKVzY6McbX37Xo9zBLP+gFUM OCoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5097-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5097-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r12-20020a170906c28c00b00a2353a78718si1945226ejz.995.2023.12.19.03.43.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 03:43:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5097-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5097-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5097-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 754AD1F22AB8 for ; Tue, 19 Dec 2023 11:43:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C33D1862E; Tue, 19 Dec 2023 11:43:51 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A428418622 for ; Tue, 19 Dec 2023 11:43:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E48B51FD54; Tue, 19 Dec 2023 11:43:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 963EA1375D; Tue, 19 Dec 2023 11:43:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id Otm0IfOBgWURNwAAD6G6ig (envelope-from ); Tue, 19 Dec 2023 11:43:47 +0000 Message-ID: <662c46d9-d342-47c3-9048-9d73d8e745a5@suse.de> Date: Tue, 19 Dec 2023 12:43:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 15/16] nvmet-fc: avoid deadlock on delete association path Content-Language: en-US To: Daniel Wagner , linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Keith Busch , James Smart References: <20231218153105.12717-1-dwagner@suse.de> <20231218153105.12717-16-dwagner@suse.de> From: Hannes Reinecke In-Reply-To: <20231218153105.12717-16-dwagner@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: E48B51FD54 X-Spam-Flag: NO On 12/18/23 16:31, Daniel Wagner wrote: > When deleting an association the shutdown path is deadlocking because we > try to flush the nvmet_wq nested. Avoid this by deadlock by deferring > the put work into its own work item. > Maybe deleting the first 'by' ? > Signed-off-by: Daniel Wagner > --- > drivers/nvme/target/fc.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c > index 23d8779dc221..30ba4ede333f 100644 > --- a/drivers/nvme/target/fc.c > +++ b/drivers/nvme/target/fc.c > @@ -111,6 +111,8 @@ struct nvmet_fc_tgtport { > struct nvmet_fc_port_entry *pe; > struct kref ref; > u32 max_sg_cnt; > + > + struct work_struct put_work; > }; > > struct nvmet_fc_port_entry { > @@ -243,6 +245,13 @@ static LIST_HEAD(nvmet_fc_portentry_list); > > static void nvmet_fc_handle_ls_rqst_work(struct work_struct *work); > static void nvmet_fc_fcp_rqst_op_defer_work(struct work_struct *work); > +static void nvmet_fc_put_tgtport_work(struct work_struct *work) > +{ > + struct nvmet_fc_tgtport *tgtport = > + container_of(work, struct nvmet_fc_tgtport, put_work); > + > + nvmet_fc_tgtport_put(tgtport); > +} > static void nvmet_fc_tgt_a_put(struct nvmet_fc_tgt_assoc *assoc); > static int nvmet_fc_tgt_a_get(struct nvmet_fc_tgt_assoc *assoc); > static void nvmet_fc_tgt_q_put(struct nvmet_fc_tgt_queue *queue); > @@ -359,7 +368,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) > > if (!lsop->req_queued) { > spin_unlock_irqrestore(&tgtport->lock, flags); > - nvmet_fc_tgtport_put(tgtport); > + queue_work(nvmet_wq, &tgtport->put_work); > return; > } > > @@ -373,7 +382,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) > (lsreq->rqstlen + lsreq->rsplen), > DMA_BIDIRECTIONAL); > > - nvmet_fc_tgtport_put(tgtport); > + queue_work(nvmet_wq, &tgtport->put_work); > } > > static int > @@ -1402,6 +1411,7 @@ nvmet_fc_register_targetport(struct nvmet_fc_port_info *pinfo, > kref_init(&newrec->ref); > ida_init(&newrec->assoc_cnt); > newrec->max_sg_cnt = template->max_sgl_segments; > + INIT_WORK(&newrec->put_work, nvmet_fc_put_tgtport_work); > > ret = nvmet_fc_alloc_ls_iodlist(newrec); > if (ret) { Otherwise: Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Ivo Totev, Andrew McDonald, Werner Knoblich