From patchwork Wed Jan 31 08:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758561dyb; Wed, 31 Jan 2024 01:02:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/m++L0X1EyWBlWSUz86eXk/h4BEbe3O6DmU+ZXcxOBKA+6sa3xuRvR7gl46ZHZqyhn73T X-Received: by 2002:ad4:5f08:0:b0:68c:4f4d:ccea with SMTP id fo8-20020ad45f08000000b0068c4f4dcceamr1390774qvb.23.1706691733018; Wed, 31 Jan 2024 01:02:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691733; cv=pass; d=google.com; s=arc-20160816; b=lUc7v//NaFVofDSRVUsoVtj5mk4LDm4HCabb9bXB6qkW9wuN+NpxSXdjZwGrwudLOT xh8Wdn5C6fKn+NSDNaIuzBFStTZBhnxZe3h+ubKhIDm9KvsRbl9yOvHinl4dNyK5gkuQ 0UxXocd8U8C7DVGrykR0bKwNbnloJWsx9dY604E2R5Kz4mHSzpYhHlnhRNRpazc6eb2n ygu7ROX0Vigyog2UuQJ3sodTwMlDnbY9sIMdAVxotwNGw7NB/qFtxQT+Y+x/jrVOdUTZ ZhZxFi37RM6k3fiptaeTAI7DzpjZfTi1BXFGYVuVFWI9wm4VaK07ufTk6AAa+4Uaks14 N+Hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; fh=UCEiZW6+W139Xf+aF+M5V29+oiHNfSn6l5otQe1fYyE=; b=04g1cWScC9sSnoHdw9qnP0S4TAjWw4qDaKYFObMg6xMNPmDF1yUWU0MhB8TUTiMtus +o7wX5d2NGuS3IKCVxNrECGJ2Bap0PQlwcqP9RuLySrAKi8nuJ5WcBU15I7TY01dYIry PKjXDaXivnrI8ZAE7Q39cgvzHkgre+mTPPeahWBnWTw2jgIy5QaVujb7sUuWAdtauepL yL8okiCW5AJoKF/i167X3UxMnEEkaowcxm8/GE6bIeOQ9yK3kr81z0L/NGGHyNpN6BdY 6odW66SBNBtNgWGkoBm66vM9NL2mFM1trxxNgONuOqJqOL8ApQFiaNuAuJXLMYq0eMHv 0Cvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-46077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCV3Wglyxa0aPMjMJfrqEAd8q/eOwfBaUcxxHfo3l91/LdtW5MrPuiKDEqRNjWYYMpdqnCCtXgTpWFjd1Xrst5fBUchSKw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y3-20020a05620a09c300b00783f9bb4c80si6840509qky.727.2024.01.31.01.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-46077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BD1391C21313 for ; Wed, 31 Jan 2024 09:02:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08C6E8287C; Wed, 31 Jan 2024 08:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="F4ls8Pzs"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nFBuAX1k"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="F4ls8Pzs"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nFBuAX1k" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 306087AE73 for ; Wed, 31 Jan 2024 08:51:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691091; cv=none; b=DR8eqkv2LLghlk9o2dkCQeXbRU9FOTTXGlZqYHq024BDSkzpI+QhEA6HXHT3iA0h8sKzVjA5G4M6xV1V1fy+B7LuKYXKb92i2Do9fwGoPrLyN116FKV07cyuuQ0BJOvbVxeRB6SPfo1HbrdwL/tlIagnBUdfayTOgdStx0cpiOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691091; c=relaxed/simple; bh=Xmqcw6mQjBwq1kAAoPhA0A+6YrUm6EiMG1QwvIgOy/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G9XUzLujgUht7uLQYu2Doa/7F6x5Cp0lrsA9QEh5ub4+jy+ED8E8G/nOdL5oEB8OYIe+VUmCXjJPnZTiRT6IyC2p+8j1cR0OMI4ZHhlIx8zpYH22T8m8aGCser8a7tbIqtguePCykpMXR+sFCKNjy3wCn22Zyv/cRVEMPUpITic= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=F4ls8Pzs; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=nFBuAX1k; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=F4ls8Pzs; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=nFBuAX1k; arc=none smtp.client-ip=195.135.223.130 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 imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (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-out1.suse.de (Postfix) with ESMTPS id 9C80721FDD; Wed, 31 Jan 2024 08:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=F4ls8PzsAVqNmD2rN5KZC/qhkGMcj0GmU1/sgf7itY7ojfY9Lq5q/6QglJvwPRKiYm1S7p BDmlB52pJS2/+HiEUArV3KaClZPWHSqd1twClA4RSahSUSD/aqtwC7Tv6n7GJW9rrXRrsz vYnQ8NB942ZyO5YESNXUQY1ZekXrMro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=nFBuAX1kzm3wpfeGapQPi6szPKsUDFJpkdD46vsGYhmdOKv9yfxDrEmxeTQdvNJCTnXb7c +VEz0WHk+A+pP2CQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=F4ls8PzsAVqNmD2rN5KZC/qhkGMcj0GmU1/sgf7itY7ojfY9Lq5q/6QglJvwPRKiYm1S7p BDmlB52pJS2/+HiEUArV3KaClZPWHSqd1twClA4RSahSUSD/aqtwC7Tv6n7GJW9rrXRrsz vYnQ8NB942ZyO5YESNXUQY1ZekXrMro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=nFBuAX1kzm3wpfeGapQPi6szPKsUDFJpkdD46vsGYhmdOKv9yfxDrEmxeTQdvNJCTnXb7c +VEz0WHk+A+pP2CQ== Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 89A2B132FA; Wed, 31 Jan 2024 08:51:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id Bu0mIA8KumWaHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:27 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 10/12] nvmet-fc: avoid deadlock on delete association path Date: Wed, 31 Jan 2024 09:51:10 +0100 Message-ID: <20240131085112.21668-11-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [3.07 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-1.83)[94.03%] X-Spam-Level: *** X-Spam-Score: 3.07 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789595990634043471 X-GMAIL-MSGID: 1789595990634043471 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. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index c80b8a066fd1..3e0d391e631b 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 { @@ -247,6 +249,13 @@ 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); static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue); static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport); +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 int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport); static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, struct nvmet_fc_fcp_iod *fod); @@ -358,7 +367,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) if (!lsop->req_queued) { spin_unlock_irqrestore(&tgtport->lock, flags); - goto out_puttgtport; + goto out_putwork; } list_del(&lsop->lsreq_list); @@ -371,8 +380,8 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); -out_puttgtport: - nvmet_fc_tgtport_put(tgtport); +out_putwork: + queue_work(nvmet_wq, &tgtport->put_work); } static int @@ -1396,6 +1405,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) {