From patchwork Fri Feb 16 08:45:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 201997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp380739dyb; Fri, 16 Feb 2024 00:49:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbJlDpE7LFpHFVhep3Ray7OB69EJmWYiK8H0/WeyYbATRajhnznigcP0x/EBbKU87Cjsgq18o9UuZVi9iB8NgpmuPBrw== X-Google-Smtp-Source: AGHT+IF4CehqSOfT/ZGVDhNDg2mRVytu4qhoNDDUnb7HUT8UgsqQK/f34hlnOmRPZijsQpb2PhjX X-Received: by 2002:a17:906:b847:b0:a3c:f0ec:cff6 with SMTP id ga7-20020a170906b84700b00a3cf0eccff6mr2494006ejb.53.1708073385229; Fri, 16 Feb 2024 00:49:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708073385; cv=pass; d=google.com; s=arc-20160816; b=Vo/UYGm1x2127QieUJjQMcoQSEh/9o/2hGghSCwqNLDtnnHEFA9ZrzeGHn223f9YjD +enuJC2OEqMa9UZTXV2yGUnndtnAlrHB0REXWWWSZshsgxvT6HjdaD10ZcdNpppE4WOO TtkweuUzxcwEIAgwJkbeN/xk2ymnG3w8Am6qQpYW9KmrGH1qTSjJRtBMdK4d/r91tWQ2 G1Yza+BUGn39NT0YE9+LbmOZrgk3cGh/afSWjOR46kogylP1H+gtPhHW2h2U7WzNWvOy iFeVJdjZhU0TkaTSMjwMhIiSLAHqosMMamMCiYY5rWlQcozeB7NI04nG5IBhTF3/Basj b/+w== 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=yTXpAiEpJ8wDgeOJl+hhqk7EFIqi9rB5Yokta6R/OiA=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=wmD3XkHAsPcgdPhsP0RVTjratWZeNYxilC6k3meA1zqpX5pnf0jPSUX8Asv5RSqk6N iSF9LxskBH1XnvqnY+RZxCMspU+EiXGO2AAHwgLej/AHIBMSwLLh4FeUpSucpBu6nJHS WIcrGc07K1b5zAVmr41HH8itX9hzl1c4+FJKbXKnTxZQfO7b9HFQfuJr67+fYpuaouZg 2VIfD5tSmOjICoVhgLCMeYt6oAM430X7F5KswjY6ZLhmn8czCrVtK/7XXX3yYKXnscdG PtQ17jR31HETfPig321fcCsxDKVejF5THMTfQ/6jD2mYvl1K2sXz9UqUX8JJ97jxZjFR 5Hag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=zoqV4ddp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=zoqV4ddp; 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-68261-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68261-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dk7-20020a170907940700b00a3d6f1ccea1si1533460ejc.854.2024.02.16.00.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68261-ouuuleilei=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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=zoqV4ddp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=zoqV4ddp; 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-68261-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68261-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A8D0E1F21784 for ; Fri, 16 Feb 2024 08:49:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3006D1DDF1; Fri, 16 Feb 2024 08:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zoqV4ddp"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6j7XmLkw"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zoqV4ddp"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6j7XmLkw" 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 467B01804F for ; Fri, 16 Feb 2024 08:45:42 +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=1708073145; cv=none; b=Wief8Iu7zRitEa+LKCrGIyX4+aKFm1ByYBODfCBczIOu4fajc9qDhyiXrwmHHDDvAiyMZ7b8eEohRmDHOt85PgJdKJ9z3aM9G+4RgnwlkHN82cCRhrDyCT/ZGmBvA4UZ8wMscvYI12JlORJjoJQDuSMv3XS0qP+iW7ig9DBx5BQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073145; c=relaxed/simple; bh=dxyqoBlToMlpFGgTCP/YtH2AdtfWA6pmR+U0ABbo54k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M8ycdH7ncrj+wRab3drQT65GzmahRyALOvVzRFimYsnR/QpIk0BJ/vstlZcCQxCzWI+QFWAFUOBSr3g3FMZ3nfEs9otFAavi3kCg28Yt4+UKq9bN7BdMTRZOZpFGMqOUYMNmXFMp+ITSDWG6W48z5efv4TLw6x83TBQs7dYq4VU= 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=zoqV4ddp; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6j7XmLkw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=zoqV4ddp; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6j7XmLkw; 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 [IPv6:2a07:de40:b281:104: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 7314F22053; Fri, 16 Feb 2024 08:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073139; 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=yTXpAiEpJ8wDgeOJl+hhqk7EFIqi9rB5Yokta6R/OiA=; b=zoqV4ddpP9CWbGZYDQSBiCaO8S7n4uNm61O9cmscp48+rcZzQYPMcTcHEAAmHnb4Lja/6K F9820rQfcOv9C81+ZPoZaf2BXn4NvFIha+Vglbd97I++3pUP/nzmcs8XktPdxJGWZmKPSN k3J1Uku8+213u2qgdFy92r1N5knKysI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073139; 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=yTXpAiEpJ8wDgeOJl+hhqk7EFIqi9rB5Yokta6R/OiA=; b=6j7XmLkwCvYgb8hH3ErKDUKpdntt4lhCjycCJGEP5N9m6XzjvysF/b8G7dFSHqGbH8AvUR tyZJhWALpfJ37PBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073139; 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=yTXpAiEpJ8wDgeOJl+hhqk7EFIqi9rB5Yokta6R/OiA=; b=zoqV4ddpP9CWbGZYDQSBiCaO8S7n4uNm61O9cmscp48+rcZzQYPMcTcHEAAmHnb4Lja/6K F9820rQfcOv9C81+ZPoZaf2BXn4NvFIha+Vglbd97I++3pUP/nzmcs8XktPdxJGWZmKPSN k3J1Uku8+213u2qgdFy92r1N5knKysI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073139; 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=yTXpAiEpJ8wDgeOJl+hhqk7EFIqi9rB5Yokta6R/OiA=; b=6j7XmLkwCvYgb8hH3ErKDUKpdntt4lhCjycCJGEP5N9m6XzjvysF/b8G7dFSHqGbH8AvUR tyZJhWALpfJ37PBA== 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 5F0CE13343; Fri, 16 Feb 2024 08:45:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id +TnBFbMgz2WYcwAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 08:45:39 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v0 1/6] nvme-fabrics: introduce connect_sync option Date: Fri, 16 Feb 2024 09:45:21 +0100 Message-ID: <20240216084526.14133-2-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216084526.14133-1-dwagner@suse.de> References: <20240216084526.14133-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=zoqV4ddp; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=6j7XmLkw X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-1.51 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; 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)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -1.51 X-Rspamd-Queue-Id: 7314F22053 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791044757992964800 X-GMAIL-MSGID: 1791044757992964800 The TCP and RDMA transport are doing a synchronous connect, meaning the syscal returns with the final result, that is. it either failed or succeeded. This isn't the case for FC. This transport just setups and triggers the connect and returns without waiting on the result. Introduce a flag to allow user space to control the behavior, wait or don't wait. Signed-off-by: Daniel Wagner Signed-off-by: Daniel Wagner --- drivers/nvme/host/fabrics.c | 6 +++++- drivers/nvme/host/fabrics.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 3499acbf6a82..7d33f0f5824f 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -678,6 +678,7 @@ static const match_table_t opt_tokens = { #ifdef CONFIG_NVME_TCP_TLS { NVMF_OPT_TLS, "tls" }, #endif + { NVMF_OPT_CONNECT_SYNC, "connect_sync" }, { NVMF_OPT_ERR, NULL } }; @@ -1024,6 +1025,9 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tls = true; break; + case NVMF_OPT_CONNECT_SYNC: + opts->connect_sync = true; + break; default: pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", p); @@ -1245,7 +1249,7 @@ EXPORT_SYMBOL_GPL(nvmf_free_options); NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ NVMF_OPT_DISABLE_SQFLOW | NVMF_OPT_DISCOVERY |\ NVMF_OPT_FAIL_FAST_TMO | NVMF_OPT_DHCHAP_SECRET |\ - NVMF_OPT_DHCHAP_CTRL_SECRET) + NVMF_OPT_DHCHAP_CTRL_SECRET | NVMF_OPT_CONNECT_SYNC) static struct nvme_ctrl * nvmf_create_ctrl(struct device *dev, const char *buf) diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index 06cc54851b1b..01d3ef545f14 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -73,6 +73,7 @@ enum { NVMF_OPT_TLS = 1 << 25, NVMF_OPT_KEYRING = 1 << 26, NVMF_OPT_TLS_KEY = 1 << 27, + NVMF_OPT_CONNECT_SYNC = 1 << 28, }; /** @@ -115,6 +116,7 @@ enum { * @nr_poll_queues: number of queues for polling I/O * @tos: type of service * @fast_io_fail_tmo: Fast I/O fail timeout in seconds + * @connect_sync: wait for connect attempt(s) to succeed or fail */ struct nvmf_ctrl_options { unsigned mask; @@ -144,6 +146,7 @@ struct nvmf_ctrl_options { unsigned int nr_poll_queues; int tos; int fast_io_fail_tmo; + bool connect_sync; }; /* From patchwork Fri Feb 16 08:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 201998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp380827dyb; Fri, 16 Feb 2024 00:50:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbZ9uv4Uj3+J8Hof6KfG6pS/mnxEJmmF6DEJQ3LRM53Roml98hLnSL8ASJA7JQ1KJumxWVWI8EUkZi2rzG037PvdiTmw== X-Google-Smtp-Source: AGHT+IG9kWmuEHT9RZp5M4Rd7XhHyNEUSQszq4pwsqtGApJi/caFO1OS0K18g9Gfztg8XKfVqZeC X-Received: by 2002:a17:902:650e:b0:1db:a0f0:ffea with SMTP id b14-20020a170902650e00b001dba0f0ffeamr2018333plk.36.1708073404254; Fri, 16 Feb 2024 00:50:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708073404; cv=pass; d=google.com; s=arc-20160816; b=yNWELtOB+OnUU56dO3BZo444K3WnBF4BAYtjljugExhd9wK460W7wY/WBJmN6V+ImT aI/+jyUdMMW6CfMOTtH/X/SeU/+rDuomd+98Rqgl4W5T8zaebXGKOtR4rceLOZMEekNV PJ1qxvpc+28xiDD5oqwW/ASFHh2mCCN/9ZKNiuJleL1dmAIEcWzNF7Qil9WgUIoheEV8 ra4b810fCbSOyHscVdCnGD9Bc/s283Ue+UNXWUTfPXHnK7yMOBMplAK29xqsNWipDcHR tS11rOzdRNHpXBSvY0HLBOjzkv+F+sYj36+HBvtPJoY3RRkIoWbg5pYckY+MfK+NKIJA qaiw== 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=/NOGbUlrDJJ5ltMa3j0eq+WSmfrFXg34PHU5GrpGC/U=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=d2VdVyyxyDjusSwXpjFMUjwFIH69E9IWjNpUiyHAbW03WxlK4r5J16+Gz9P2Dx+8u8 jNU6PvFsngpjN6RQ47ShdPd0nABwtta41p+X5Eh3KUmbZNyWtCiyz6PkdCE5R49TcmNs QxMqi+45OJvo8i7/EuLQJTo9ahE7bIKwL9lO+hrsaOUyokJabuPAS4d2snr8T8EtMOjK iCLtcsaNwjFau0UsCdmTiJkBs/QBN3YbKVPzsHQ8As5wnZ/aaD9azxpsTi2nMdrLLnYn khIraOJ42sswgYQb4ho7dyrE3+jx+/WGCb1KmpOMpGxICD/yPlW/v82cVUWpo6ycatM2 Zmaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMtjZeHt; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMtjZeHt; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="CKBy/lAg"; 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-68262-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68262-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f9-20020a170902684900b001db8cd74953si2348847pln.112.2024.02.16.00.50.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:50:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68262-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMtjZeHt; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=yMtjZeHt; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b="CKBy/lAg"; 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-68262-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68262-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2ED2C28440D for ; Fri, 16 Feb 2024 08:50:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F19621EB3A; Fri, 16 Feb 2024 08:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="yMtjZeHt"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CKBy/lAg"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="yMtjZeHt"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CKBy/lAg" 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 62AA91B956 for ; Fri, 16 Feb 2024 08:45:44 +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=1708073146; cv=none; b=ou7bCSvAXh+azvzbYIs3i27vsKA613ESWCqRQtcmuTZlOLX8gBLznIY7Kfzq+V/vyMDwN3oiDEf8iQIFOVBIK90fYwgkIFa+qE9z9QnBM/t3f5r9O/mq6+9EALm7o1OVcSIL4eXxjLrlAkHCxZIizAZ7qkiDsPuuMUl8+PTeE+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073146; c=relaxed/simple; bh=jy9DRC7+SqxK5oZyWV+pslfAXvoKWnsiJbMrB40vPrk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=brjdXilkSICtiDdt3VEhkfVOjLGuEsI6KtxJAzjqQfPT95oBBSyV8vFAdawbZ3N14yVRYoWkXKG0qxUoORySq5AUCfYpceLugukeMM5cZ4WLtEwk4uJeY7ftnGbGwV7jn7DeoT3e63eEC5GqwMl18q7PxthbPSBCwyoJ0+vCyYg= 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=yMtjZeHt; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=CKBy/lAg; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=yMtjZeHt; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=CKBy/lAg; 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 [IPv6:2a07:de40:b281:104: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 144E6220AF; Fri, 16 Feb 2024 08:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073140; 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=/NOGbUlrDJJ5ltMa3j0eq+WSmfrFXg34PHU5GrpGC/U=; b=yMtjZeHtBdy5mRNq3iVV588twq2GI2NrED5PiZEWo3OrRDGEWRf3mn88ZUnEAqh18wIqMK WHmD4XY/tjv6b3VnLQ8OcoFhP3BXCDLw8Ap3XJFo9Cm2wU/BuNnSA0ojlJmTTZmNwbpFRU hVKTW3dII0XRcvmFSCgdEkoPv6277P0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073140; 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=/NOGbUlrDJJ5ltMa3j0eq+WSmfrFXg34PHU5GrpGC/U=; b=CKBy/lAg3pqUxByHrHiSxT/XORtei7uCkCnsOCKwlfWy53sCPT5UFvuA5BDpDHQVXRR8Bv /dsbtulbTUKrTJDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073140; 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=/NOGbUlrDJJ5ltMa3j0eq+WSmfrFXg34PHU5GrpGC/U=; b=yMtjZeHtBdy5mRNq3iVV588twq2GI2NrED5PiZEWo3OrRDGEWRf3mn88ZUnEAqh18wIqMK WHmD4XY/tjv6b3VnLQ8OcoFhP3BXCDLw8Ap3XJFo9Cm2wU/BuNnSA0ojlJmTTZmNwbpFRU hVKTW3dII0XRcvmFSCgdEkoPv6277P0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073140; 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=/NOGbUlrDJJ5ltMa3j0eq+WSmfrFXg34PHU5GrpGC/U=; b=CKBy/lAg3pqUxByHrHiSxT/XORtei7uCkCnsOCKwlfWy53sCPT5UFvuA5BDpDHQVXRR8Bv /dsbtulbTUKrTJDg== 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 014C113343; Fri, 16 Feb 2024 08:45:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id SpN3OrMgz2WacwAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 08:45:39 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v0 2/6] nvme-fc: rename free_ctrl callback to match name pattern Date: Fri, 16 Feb 2024 09:45:22 +0100 Message-ID: <20240216084526.14133-3-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216084526.14133-1-dwagner@suse.de> References: <20240216084526.14133-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: * X-Spamd-Bar: + Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yMtjZeHt; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="CKBy/lAg" X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [1.15 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; 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)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.34)[76.24%] X-Spam-Score: 1.15 X-Rspamd-Queue-Id: 144E6220AF X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791044778029285490 X-GMAIL-MSGID: 1791044778029285490 Rename nvme_fc_nvme_ctrl_freed to nvme_fc_free_ctrl to match the name pattern for the callback. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/host/fc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 68a5d971657b..a5b29e9ad342 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2428,7 +2428,7 @@ nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) * controller. Called after last nvme_put_ctrl() call */ static void -nvme_fc_nvme_ctrl_freed(struct nvme_ctrl *nctrl) +nvme_fc_free_ctrl(struct nvme_ctrl *nctrl) { struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); @@ -3384,7 +3384,7 @@ static const struct nvme_ctrl_ops nvme_fc_ctrl_ops = { .reg_read32 = nvmf_reg_read32, .reg_read64 = nvmf_reg_read64, .reg_write32 = nvmf_reg_write32, - .free_ctrl = nvme_fc_nvme_ctrl_freed, + .free_ctrl = nvme_fc_free_ctrl, .submit_async_event = nvme_fc_submit_async_event, .delete_ctrl = nvme_fc_delete_ctrl, .get_address = nvmf_get_address, From patchwork Fri Feb 16 08:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 201999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp380836dyb; Fri, 16 Feb 2024 00:50:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUeRK/06fuIlxg+tAamEoGgFIAn1u4PV24FZTno21zzJKLH7IQyzBW4KcgjUlXzxbbJJ0Bp/Q9Rk612SYQQIwY9DU+t3A== X-Google-Smtp-Source: AGHT+IG0BpKDJp/IClN+8KH4XnGmfD7+1iTUzIU95gqenXl6o1Yrvc+T4wTnoYGzj1rDbahWemqg X-Received: by 2002:a05:6a21:1518:b0:19e:cf31:6a04 with SMTP id nq24-20020a056a21151800b0019ecf316a04mr5216985pzb.59.1708073405550; Fri, 16 Feb 2024 00:50:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708073405; cv=pass; d=google.com; s=arc-20160816; b=oNW9fT0BWeiZS6UX3m3e8fwDZsiWvYPyhZZ6FvBykxq6OLTKNvwc/aF5glSBtNqcZM r8/a3q9oUwjAjark9TutrmX7uQ9LmtXkpWzr3A2h3XUKOgAaRL0CHL1/aHNS+AxMzHZH cCcpTHxPQFXBf/adtydBuy9cOKB+stzz+r4xYClSZ6hQih76egmIOD6FeTQIReZSyLB1 3PM3OQ3k30sf3brYGTOelqwLFucS0pQ0sdyX5YNnTIH8pHY1F/uQEQNK6FvrhYMfAWAP WEnWyt+pgK7RK6Y4FiD0K/bjmctaIT7VzoYme4mZLTZDr8qVUuE9t1i1vOANKudQUIgJ t3ig== 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=1vZAwwN5v7M2QsLQcS5Sny5saf5uh8b6XoVupT450oA=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=TpakNGpnOdTDU/wvUrtWx1FsN0//cntOAWvbFSkqmt/GbLdcUq9Qc5DMT0wtGMopOr QCsF1sGTU77D8O9t/p6no2PuxWOiXkmHpiRc/KU8B3dho6+MZ1ESWDOuUEV8dF6Fzj01 DcVngBpmvuI5b1OwPmVxCDVfk3/t2Yp/LN+rcgzt7P0CGoMzwHkOomkGqf1jh+ap8o/8 dBQ7elkfVFeIIJ6/JLO+A9qFCl8uCOziVHtOz3bU8Ocojh/8b0SmYOzQyyXbFutGRZoS i7zpcOz2Kl1Elk+WHGZbMVxPTpbzgNKmZPZhS2vzIIVQG3vssVUIbVe+pGVdISfqIULg 0awQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="oGmZ/pgL"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="oGmZ/pgL"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=PlBPCkFL; 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-68263-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68263-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id hg6-20020a17090b300600b00298db6cd2b5si4209464pjb.43.2024.02.16.00.50.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:50:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68263-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="oGmZ/pgL"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="oGmZ/pgL"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=PlBPCkFL; 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-68263-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68263-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C2E312818D8 for ; Fri, 16 Feb 2024 08:50:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AF6B1EB44; Fri, 16 Feb 2024 08:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oGmZ/pgL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="PlBPCkFL"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oGmZ/pgL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="PlBPCkFL" 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 6C9771B95B for ; Fri, 16 Feb 2024 08:45:44 +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=1708073146; cv=none; b=Szh9dH5sn9hL5qfga4hoFPZPMO+qNxgc2OCwIzjLQ59Uwd13JbVpKeZQcuXf2hkr/SbNsms6RBVARyF42UaHG69SNIeUcpb3kiVEDXOnqtsYSGdNQC/m2jlG7/WtJZEptLPzl6gvSbAgi5j51u9WrRoIGloBDlCt5U9hIXJ4uCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073146; c=relaxed/simple; bh=AmBehZ5DjuPHaP/AQs1fixAgjbcdEg6oKvv5GCgMlqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p+BvaA7TrG6Ve21BTfVUXWtlExBIqTO0mWZiP5YCgOreWI29n0r6SsYxBwOxOWKhg3oIe0UlqPHUATWoUS/jTbJGJE3vmGyqQuvJ6WIo569Tf4m5iM0KESp3BA8OV8+Y/K+3Htpb9JjwjxJ4hUHZ8gMzm8R3ePJXmArsu4u9tC8= 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=oGmZ/pgL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=PlBPCkFL; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=oGmZ/pgL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=PlBPCkFL; 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 ABAB2220C9; Fri, 16 Feb 2024 08:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073140; 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=1vZAwwN5v7M2QsLQcS5Sny5saf5uh8b6XoVupT450oA=; b=oGmZ/pgLPXXIqg5PJg5IICrS7lcXzZPrhgF5ZZaDAzecPsx3bHJimDJRZgkz14T4Z+YjjO qefg6v+g+wi72ALfCB+zcdcmMWgO7hYw85jR5iE/8FSlL044yNAzLRoyK+SJnOFVmu6hXS TEO9P5XgQeR/9NAnSRYHfg7sDuT4jq8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073140; 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=1vZAwwN5v7M2QsLQcS5Sny5saf5uh8b6XoVupT450oA=; b=PlBPCkFLZgBA+CGTDdAI4ZNYR2Nb2hvshPJQpjW0R+WpsDX9WSBTKtpt+EhlSxjHrq8eIv NMjX1osvgsJT0SDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073140; 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=1vZAwwN5v7M2QsLQcS5Sny5saf5uh8b6XoVupT450oA=; b=oGmZ/pgLPXXIqg5PJg5IICrS7lcXzZPrhgF5ZZaDAzecPsx3bHJimDJRZgkz14T4Z+YjjO qefg6v+g+wi72ALfCB+zcdcmMWgO7hYw85jR5iE/8FSlL044yNAzLRoyK+SJnOFVmu6hXS TEO9P5XgQeR/9NAnSRYHfg7sDuT4jq8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073140; 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=1vZAwwN5v7M2QsLQcS5Sny5saf5uh8b6XoVupT450oA=; b=PlBPCkFLZgBA+CGTDdAI4ZNYR2Nb2hvshPJQpjW0R+WpsDX9WSBTKtpt+EhlSxjHrq8eIv NMjX1osvgsJT0SDQ== 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 999BB13343; Fri, 16 Feb 2024 08:45:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id fGwHJLQgz2WccwAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 08:45:40 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v0 3/6] nvme-fc: do not retry when auth fails or connection is refused Date: Fri, 16 Feb 2024 09:45:23 +0100 Message-ID: <20240216084526.14133-4-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216084526.14133-1-dwagner@suse.de> References: <20240216084526.14133-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 [4.45 / 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)[8]; 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(-0.45)[78.89%] X-Spam-Level: **** X-Spam-Score: 4.45 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791044779659115773 X-GMAIL-MSGID: 1791044779659115773 The is no point in retrying to connect if the authentication fails. Connection refused is also issued from the authentication path, thus also do not retry. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/host/fc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index a5b29e9ad342..b81046c9f171 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -3312,6 +3312,8 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) ctrl->cnum, status); if (status > 0 && (status & NVME_SC_DNR)) recon = false; + if (status == NVME_SC_AUTH_REQUIRED || status == -ECONNREFUSED) + recon = false; } else if (time_after_eq(jiffies, rport->dev_loss_end)) recon = false; From patchwork Fri Feb 16 08:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 202001 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp381017dyb; Fri, 16 Feb 2024 00:50:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW+UYb9sWn4RPjP77ggJ7BUTwU+r5JiwXjuCozyEJqNb03p/rmnHUphIYJxueA+88Vw6jg8bdg8ppRGuM6yozVffsQrjg== X-Google-Smtp-Source: AGHT+IFuDijopp5lurMVLNluomV737Mm5Ed8Jd0mv4wPkRU+7dIly76iml+2vFVW7FanB8iV0/To X-Received: by 2002:a17:902:e84e:b0:1da:2a3e:4c62 with SMTP id t14-20020a170902e84e00b001da2a3e4c62mr5707391plg.14.1708073435511; Fri, 16 Feb 2024 00:50:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708073435; cv=pass; d=google.com; s=arc-20160816; b=NTHpNJp34Wxkc/DI3utO/joVkHWifGwhzPOwWsD8jKlUQRpBSAeOB1kIf3M1aI/ahH 2QqeyD0SAnwi+lkjdafeIVpmayInDzKBngkaGiMz2fT3OKrGOwzLWUMhwjRBvgie3/6c t5qqTNuA5VShF33uS2eiYcnXXNHDpU4bB7tov7usQmCKupjlBgRFww8XRyvRQVu9mCiS IYksxuUtWiSfdMPpxaCZC4TYTQmFDXuFzqIQ7WJ5YGoWaJoRXH0015hCDIDyCMIV1JxK IgHWNAtyA/PO8EvdbCOLGozj9T/fKhdvJRkJ7FCxHHu1bsHS7xTJdxzDO+ENZDd0oqld R78A== 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=3LgX0EmsF8tNacURGXPjooZUpT8DZo0vHxjxmTZL79s=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=Dy+2BO/pT/KS/qERNR3YW9KBTUgEnrR5MRZKAYV/aupvn0SnMWpvV0rzGVCiF/k75G H6H4gT3TGjEz4sNcb+Q+ExEsNoMKhYsmwAYveXMcdAbWVp7UEAZrsgYt1HUAqvgKRX8b QyRhtDRN8G1aOnp9v+AzCQ/+AuK+LJ4cAiAc0LTPL3FMuZ7wJKJeou/T9vn0T++XBr79 2tbq5wcsHoaoIfO1ksh2t9s2YJWapKszJqdFOEdeJUDnrtcqR6GgffWintbhKV41HlPP qmF6dYT68UznSiB1UskYDzNbPXLdsCIbh3D6rpgVuGRAkGKQfMK7/oin8brt+EvwbxKD 9o/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Bq+2f572; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Bq+2f572; 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-68265-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68265-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d7-20020a170902cec700b001db63a7c8c4si2323196plg.283.2024.02.16.00.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:50:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68265-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Bq+2f572; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Bq+2f572; 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-68265-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68265-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4A231284893 for ; Fri, 16 Feb 2024 08:50:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAC8D200D5; Fri, 16 Feb 2024 08:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Bq+2f572"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="xv/ZxzvO"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Bq+2f572"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="xv/ZxzvO" 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 6C9A31B966 for ; Fri, 16 Feb 2024 08:45:44 +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=1708073148; cv=none; b=Fxi70ZPCip/bIavvjxFpSx/R3V0oqBEJbXltCAkPQ3QSVa4mj3fhpl98WqwskVLqcYX/qHvfScUP3dqF0/higau28whcLTWus7eBjiIok1Jo1v2cvaTAZHxNwfaKBR94JZ6SxSSn/BUYg3PoQrtcxToTG92iv8XKLMEVI3zyOXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073148; c=relaxed/simple; bh=uOM0sHRzbWr5aGXnazykGQYnLpNToGdxiZhhWj//4wk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pb/OTyBGryKxFzT0LeGAtE2NWKDrJ5KwkBbiTnlf2EUf5X3Jgu+nsz/IjlQNtpNiJsQBAnyubNndEhnDh5ocT2OLb04cjw7AIVomnKqCXArzI1SYUgi5VeG53UY1y7KmGJaJxd3IhgMVthtD3KGLXyvVH6BrAIfBGm3Tt0L3z2s= 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=Bq+2f572; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=xv/ZxzvO; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Bq+2f572; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=xv/ZxzvO; 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 5BB7E220CC; Fri, 16 Feb 2024 08:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073141; 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=3LgX0EmsF8tNacURGXPjooZUpT8DZo0vHxjxmTZL79s=; b=Bq+2f572QA7cBdOKL6DTsrJw48ZAaOh9kYKYwFaAH6K617bW12AiBnnuPBm06znMr4wRna wm+pGe4F06dpnnDiW1zslmjrS9f/5BSyBM0Gqer+m51uh0wL3Zbz3Nif9o3//P1VhP6wkp tOfAX4jCq4Kj4H7k9PKBRLQ8bJtZTn4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073141; 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=3LgX0EmsF8tNacURGXPjooZUpT8DZo0vHxjxmTZL79s=; b=xv/ZxzvO3dDnPO918p+WrTsj6rl52MZSFPu82tkfLjXW16LjnJP4bQViYn5ynlFrG5D75g jpepvDP3K+wyP7Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073141; 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=3LgX0EmsF8tNacURGXPjooZUpT8DZo0vHxjxmTZL79s=; b=Bq+2f572QA7cBdOKL6DTsrJw48ZAaOh9kYKYwFaAH6K617bW12AiBnnuPBm06znMr4wRna wm+pGe4F06dpnnDiW1zslmjrS9f/5BSyBM0Gqer+m51uh0wL3Zbz3Nif9o3//P1VhP6wkp tOfAX4jCq4Kj4H7k9PKBRLQ8bJtZTn4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073141; 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=3LgX0EmsF8tNacURGXPjooZUpT8DZo0vHxjxmTZL79s=; b=xv/ZxzvO3dDnPO918p+WrTsj6rl52MZSFPu82tkfLjXW16LjnJP4bQViYn5ynlFrG5D75g jpepvDP3K+wyP7Bw== 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 4783F13343; Fri, 16 Feb 2024 08:45:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id ptAFELUgz2WfcwAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 08:45:41 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v0 4/6] nvme-fabrics: introduce ref counting for nvmf_ctrl_options Date: Fri, 16 Feb 2024 09:45:24 +0100 Message-ID: <20240216084526.14133-5-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216084526.14133-1-dwagner@suse.de> References: <20240216084526.14133-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 [1.90 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_SEVEN(0.00)[8]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: * X-Spam-Score: 1.90 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791044810646949475 X-GMAIL-MSGID: 1791044810646949475 The FC transport is offloading the connect attempt to a workqueue. When the attempt fails the transport is starting to cleanup resources. It is possible for user space to trigger a crash because nvmf_ctrl_options are exposed to sysfs. This crash wasn't observed with blktests nvme/041 until now because the retry loop was usually trying for several times (e.g. with defaults 600s) and the test would trigger the cleanup itself. Though we the recent change not retrying to use invalid credentials the crash can be easily triggered. The simplest way to control the life time of nvmf_ctrl_options is by using ref counting. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fabrics.c | 22 +++++++++++++++++++--- drivers/nvme/host/fabrics.h | 6 +++++- drivers/nvme/host/fc.c | 14 +++++++++----- drivers/nvme/host/rdma.c | 18 +++++++++++++----- drivers/nvme/host/tcp.c | 21 ++++++++++++++------- drivers/nvme/target/loop.c | 19 +++++++++++++------ 6 files changed, 73 insertions(+), 27 deletions(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 7d33f0f5824f..3d775718cff7 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -1226,8 +1226,11 @@ static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts, return 0; } -void nvmf_free_options(struct nvmf_ctrl_options *opts) +static void nvmf_free_options(struct kref *ref) { + struct nvmf_ctrl_options *opts = + container_of(ref, struct nvmf_ctrl_options, ref); + nvmf_host_put(opts->host); key_put(opts->keyring); key_put(opts->tls_key); @@ -1241,7 +1244,18 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts) kfree(opts->dhchap_ctrl_secret); kfree(opts); } -EXPORT_SYMBOL_GPL(nvmf_free_options); + +int nvmf_ctrl_options_get(struct nvmf_ctrl_options *opts) +{ + return kref_get_unless_zero(&opts->ref); +} +EXPORT_SYMBOL_GPL(nvmf_ctrl_options_get); + +void nvmf_ctrl_options_put(struct nvmf_ctrl_options *opts) +{ + kref_put(&opts->ref, nvmf_free_options); +} +EXPORT_SYMBOL_GPL(nvmf_ctrl_options_put); #define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN) #define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ @@ -1263,6 +1277,8 @@ nvmf_create_ctrl(struct device *dev, const char *buf) if (!opts) return ERR_PTR(-ENOMEM); + kref_init(&opts->ref); + ret = nvmf_parse_options(opts, buf); if (ret) goto out_free_opts; @@ -1318,7 +1334,7 @@ nvmf_create_ctrl(struct device *dev, const char *buf) out_unlock: up_read(&nvmf_transports_rwsem); out_free_opts: - nvmf_free_options(opts); + nvmf_ctrl_options_put(opts); return ERR_PTR(ret); } diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index 01d3ef545f14..67882e4cbe46 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -79,6 +79,7 @@ enum { /** * struct nvmf_ctrl_options - Used to hold the options specified * with the parsing opts enum. + * @ref: for reference count of the data structure * @mask: Used by the fabrics library to parse through sysfs options * on adding a NVMe controller. * @max_reconnects: maximum number of allowed reconnect attempts before removing @@ -119,6 +120,7 @@ enum { * @connect_sync: wait for connect attempt(s) to succeed or fail */ struct nvmf_ctrl_options { + struct kref ref; unsigned mask; int max_reconnects; char *transport; @@ -149,6 +151,9 @@ struct nvmf_ctrl_options { bool connect_sync; }; +int nvmf_ctrl_options_get(struct nvmf_ctrl_options *opts); +void nvmf_ctrl_options_put(struct nvmf_ctrl_options *opts); + /* * struct nvmf_transport_ops - used to register a specific * fabric implementation of NVMe fabrics. @@ -231,7 +236,6 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl); int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid); int nvmf_register_transport(struct nvmf_transport_ops *ops); void nvmf_unregister_transport(struct nvmf_transport_ops *ops); -void nvmf_free_options(struct nvmf_ctrl_options *opts); int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size); bool nvmf_should_reconnect(struct nvme_ctrl *ctrl); bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b81046c9f171..ddbc5b21af5b 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2406,8 +2406,7 @@ nvme_fc_ctrl_free(struct kref *ref) nvme_fc_rport_put(ctrl->rport); ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); - if (ctrl->ctrl.opts) - nvmf_free_options(ctrl->ctrl.opts); + nvmf_ctrl_options_put(ctrl->ctrl.opts); kfree(ctrl); } @@ -3474,10 +3473,15 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, goto out_fail; } + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + idx = ida_alloc(&nvme_fc_ctrl_cnt, GFP_KERNEL); if (idx < 0) { ret = -ENOSPC; - goto out_free_ctrl; + goto out_free_opts; } /* @@ -3583,8 +3587,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, cancel_work_sync(&ctrl->ctrl.reset_work); cancel_delayed_work_sync(&ctrl->connect_work); - ctrl->ctrl.opts = NULL; - /* initiate nvme ctrl ref counting teardown */ nvme_uninit_ctrl(&ctrl->ctrl); @@ -3607,6 +3609,8 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, out_free_ida: put_device(ctrl->dev); ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); +out_free_opts: + nvmf_ctrl_options_put(opts); out_free_ctrl: kfree(ctrl); out_fail: diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 20fdd40b1879..d3747795ad80 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -976,8 +976,8 @@ static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl) list_del(&ctrl->list); mutex_unlock(&nvme_rdma_ctrl_mutex); - nvmf_free_options(nctrl->opts); free_ctrl: + nvmf_ctrl_options_put(nctrl->opts); kfree(ctrl->queues); kfree(ctrl); } @@ -2236,6 +2236,12 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); if (!ctrl) return ERR_PTR(-ENOMEM); + + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + ctrl->ctrl.opts = opts; INIT_LIST_HEAD(&ctrl->list); @@ -2244,7 +2250,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, kstrdup(__stringify(NVME_RDMA_IP_PORT), GFP_KERNEL); if (!opts->trsvcid) { ret = -ENOMEM; - goto out_free_ctrl; + goto out_free_opts; } opts->mask |= NVMF_OPT_TRSVCID; } @@ -2263,13 +2269,13 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, if (ret) { pr_err("malformed src address passed: %s\n", opts->host_traddr); - goto out_free_ctrl; + goto out_free_opts; } } if (!opts->duplicate_connect && nvme_rdma_existing_controller(opts)) { ret = -EALREADY; - goto out_free_ctrl; + goto out_free_opts; } INIT_DELAYED_WORK(&ctrl->reconnect_work, @@ -2286,7 +2292,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), GFP_KERNEL); if (!ctrl->queues) - goto out_free_ctrl; + goto out_free_opts; ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops, 0 /* no quirks, we're perfect! */); @@ -2317,6 +2323,8 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, return ERR_PTR(ret); out_kfree_queues: kfree(ctrl->queues); +out_free_opts: + nvmf_ctrl_options_put(opts); out_free_ctrl: kfree(ctrl); return ERR_PTR(ret); diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index a6d596e05602..3b20c5ed033f 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -2349,8 +2349,8 @@ static void nvme_tcp_free_ctrl(struct nvme_ctrl *nctrl) list_del(&ctrl->list); mutex_unlock(&nvme_tcp_ctrl_mutex); - nvmf_free_options(nctrl->opts); free_ctrl: + nvmf_ctrl_options_put(nctrl->opts); kfree(ctrl->queues); kfree(ctrl); } @@ -2678,6 +2678,11 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, if (!ctrl) return ERR_PTR(-ENOMEM); + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + INIT_LIST_HEAD(&ctrl->list); ctrl->ctrl.opts = opts; ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + @@ -2695,7 +2700,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, kstrdup(__stringify(NVME_TCP_DISC_PORT), GFP_KERNEL); if (!opts->trsvcid) { ret = -ENOMEM; - goto out_free_ctrl; + goto out_free_opts; } opts->mask |= NVMF_OPT_TRSVCID; } @@ -2705,7 +2710,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, if (ret) { pr_err("malformed address passed: %s:%s\n", opts->traddr, opts->trsvcid); - goto out_free_ctrl; + goto out_free_opts; } if (opts->mask & NVMF_OPT_HOST_TRADDR) { @@ -2714,7 +2719,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, if (ret) { pr_err("malformed src address passed: %s\n", opts->host_traddr); - goto out_free_ctrl; + goto out_free_opts; } } @@ -2723,20 +2728,20 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, pr_err("invalid interface passed: %s\n", opts->host_iface); ret = -ENODEV; - goto out_free_ctrl; + goto out_free_opts; } } if (!opts->duplicate_connect && nvme_tcp_existing_controller(opts)) { ret = -EALREADY; - goto out_free_ctrl; + goto out_free_opts; } ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), GFP_KERNEL); if (!ctrl->queues) { ret = -ENOMEM; - goto out_free_ctrl; + goto out_free_opts; } ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); @@ -2770,6 +2775,8 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, return ERR_PTR(ret); out_kfree_queues: kfree(ctrl->queues); +out_free_opts: + nvmf_ctrl_options_put(opts); out_free_ctrl: kfree(ctrl); return ERR_PTR(ret); diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index e589915ddef8..de2ff7ed0657 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -283,8 +283,8 @@ static void nvme_loop_free_ctrl(struct nvme_ctrl *nctrl) if (nctrl->tagset) nvme_remove_io_tag_set(nctrl); kfree(ctrl->queues); - nvmf_free_options(nctrl->opts); free_ctrl: + nvmf_ctrl_options_put(nctrl->opts); kfree(ctrl); } @@ -543,6 +543,12 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); if (!ctrl) return ERR_PTR(-ENOMEM); + + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + ctrl->ctrl.opts = opts; INIT_LIST_HEAD(&ctrl->list); @@ -550,10 +556,8 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops, 0 /* no quirks, we're perfect! */); - if (ret) { - kfree(ctrl); - goto out; - } + if (ret) + goto out_free_opts; if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) WARN_ON_ONCE(1); @@ -612,7 +616,10 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, out_uninit_ctrl: nvme_uninit_ctrl(&ctrl->ctrl); nvme_put_ctrl(&ctrl->ctrl); -out: +out_free_opts: + nvmf_ctrl_options_put(opts); +out_free_ctrl: + kfree(ctrl); if (ret > 0) ret = -EIO; return ERR_PTR(ret); From patchwork Fri Feb 16 08:45:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 202000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp380994dyb; Fri, 16 Feb 2024 00:50:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvKT/ig1lvKX+h6P7s0cxj5/ikbiu0Oc+ClzosnTYd/Of3dkovdO1iwnHTkqsoqA2tbTv8RXVa1wB/RO0cP0Ke9PSPXw== X-Google-Smtp-Source: AGHT+IFltucwW73QUeOMENhDeck12f14bgXgIsiEbxvFn4AR3eTaMX3OLWh9GNfYFTTA0/ijM09i X-Received: by 2002:a17:90a:d48d:b0:299:2214:5398 with SMTP id s13-20020a17090ad48d00b0029922145398mr2765286pju.13.1708073431612; Fri, 16 Feb 2024 00:50:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708073431; cv=pass; d=google.com; s=arc-20160816; b=kWI9pfmjPBlvgaUF65fSKam3WkBcksfOycIIYwIXHGS/Qkc9BrVH2EGT9gpz53gJYs zd1WS7ZoA3zTbLeqVtW9vrjmTsKCaiNLbwJQqt7QvW2ZsO2smqhjzgfjqsevR+xTw7fM HnUPQpinkMHodVoZpnBVpI2XSba+FNYwqpdOM9nBPHgRxuhMJFVjLUC7wxon20cHcwTM 3+WCjD0cGTZa4LZq9zsyN/HspEa4OF31TFBRfuMMYsDvZixwZQaqa1SiRzd+fZ8j3mBf fGN3wwKYRaaqCxXUXsArMMoXo9rGonB/w11aZNGjxFf+A/elKe6SYMOcPRBoevhUHUnc NS6w== 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=KOMF03VoR44oi8HBDybO4VHaz2uWr0tXKdQfzeE88jU=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=Ne4z1rE9cK7acnvPmXDP+HC2g/nGnKNs/hzQqtrKkbz9KFJrtqDq5gmd6SxBoFJzNv jlhazlCQ3aIu0fMtOdDRmOL5JPwgk/PHgNDT4BtOgPO6gZvW8wx+WrrO7iIdl5YQWCvz r5rdl1x3pz1KJvQJviGRDdyuwSzFhb7XCPvsa2JXtLHmW7CCZLc0zK3UHTpACi6ORu4u KxASH7Qhlg30gGCz/+3yuIhLSowX41yJcTPKTD25gm02jmc7dnLXDN8vCBSJcaeKzECR hLr0pawRPUYbXs5vaegjzyjc9s7RjdArG9XbrczYkkG32jQylbPamJMCRfn26ti3tDPE 7IPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kYf5PqOc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kYf5PqOc; 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-68264-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68264-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y12-20020a17090aa40c00b00290cf479691si4504285pjp.93.2024.02.16.00.50.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:50:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68264-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kYf5PqOc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kYf5PqOc; 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-68264-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68264-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61620280EA6 for ; Fri, 16 Feb 2024 08:50:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14420200C4; Fri, 16 Feb 2024 08:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kYf5PqOc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="YtqxCydH"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kYf5PqOc"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="YtqxCydH" 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 EFC091BC3E for ; Fri, 16 Feb 2024 08:45:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073147; cv=none; b=IS5GHqLz6fAhHwxy7n1XirM0l8G3ncwmM1aEimxJkjUSKNrn0Y8DmGAAZufpiSMZ/HIslsSNPim9q6pZwGT9QFRgBvM6XCBh+jJYnnt5nDpJLDbssf+siVPHQa//2lqTzAknrqPkP3JPURPrfH/aSLz//2HukpBd35WgnfOaYuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073147; c=relaxed/simple; bh=ZQqWgSE8R5Qshr1qfw0l31ynIeWNLu5UYlIa9dfmPDw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FJAa8c6+v9HhfOxYKdZqFC/3EAm+XSaboV+KFpiZAO+WBcxjDIYQ/y3zyUbG5qM5zZjudbdj2M+Q8xUUMN21vBvriXcHsup6brrx1b5J3b8OL9ydo/n2h0GTTLtYVMsPCpAQ0GiXvZrdDJPopj460vxOdpbiz4ghwuq89+/HQsg= 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=kYf5PqOc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=YtqxCydH; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kYf5PqOc; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=YtqxCydH; arc=none smtp.client-ip=195.135.223.131 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-out2.suse.de (Postfix) with ESMTPS id 000601FB5B; Fri, 16 Feb 2024 08:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073142; 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=KOMF03VoR44oi8HBDybO4VHaz2uWr0tXKdQfzeE88jU=; b=kYf5PqOcqoHsPCA/qVHThVdNHh3ePxwkMACcTtEupis528qr+jTGO4k+0e48VNtEG8ck6y pBB9vJFbWYbGruvzodR6oGscuU78WsbHfTI1GMZ8rkSGxhnKIMNB3Zna7yFK/8dBaTQzYp nqQ7I1RLi4wO1+5t00hCKZSXjKaAy9g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073142; 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=KOMF03VoR44oi8HBDybO4VHaz2uWr0tXKdQfzeE88jU=; b=YtqxCydHQhlozWU3aHBNT/6zHHzsTimDCx+z1JUUUAsnDJKDl/2EL1k7ma1ptu34w6Ww41 e3rC6Iq8o8WqLBDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073142; 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=KOMF03VoR44oi8HBDybO4VHaz2uWr0tXKdQfzeE88jU=; b=kYf5PqOcqoHsPCA/qVHThVdNHh3ePxwkMACcTtEupis528qr+jTGO4k+0e48VNtEG8ck6y pBB9vJFbWYbGruvzodR6oGscuU78WsbHfTI1GMZ8rkSGxhnKIMNB3Zna7yFK/8dBaTQzYp nqQ7I1RLi4wO1+5t00hCKZSXjKaAy9g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073142; 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=KOMF03VoR44oi8HBDybO4VHaz2uWr0tXKdQfzeE88jU=; b=YtqxCydHQhlozWU3aHBNT/6zHHzsTimDCx+z1JUUUAsnDJKDl/2EL1k7ma1ptu34w6Ww41 e3rC6Iq8o8WqLBDw== 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 E0F4013343; Fri, 16 Feb 2024 08:45:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id w2dyNbUgz2WicwAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 08:45:41 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v0 5/6] nvme-fc: redesign locking and refcounting Date: Fri, 16 Feb 2024 09:45:25 +0100 Message-ID: <20240216084526.14133-6-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216084526.14133-1-dwagner@suse.de> References: <20240216084526.14133-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-out2.suse.de; none X-Spam-Level: X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 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)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791044806779563712 X-GMAIL-MSGID: 1791044806779563712 The life time of the controller is managed by the upper layers. Thus just ref counting the controller when creating it and giving the ref back on the cleanup path. This is how the other transport are managed as well. Until now, the ref count has been taken per LS request which is not really necessary as the core guarantees that there is no in flight request when shuting down (if we use the nvme APIs are used correctly). In fact we don't really need the ref count for nvme_fc_ctrl at this point. Though, the FC transport is offloading the connect attempt to a workqueue and in the next patch we introduce a sync option for which the ref counter is necessary. So let's keep it around. Also take a ref for lport and rport when creating the controller and give it back when we destroy the controller. This means these refs are tied to the life time of the controller and not the other way around. We have also to reorder the cleanup code in nvme_fc_delete_ctrl and nvme_fc_free_ctrl so that we do not expose resources too long and run into use after free situations which are currently possible. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 136 +++++++++++++---------------------------- 1 file changed, 41 insertions(+), 95 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index ddbc5b21af5b..7f9edab57550 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -229,6 +229,9 @@ static struct device *fc_udev_device; static void nvme_fc_complete_rq(struct request *rq); +static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *); +static int nvme_fc_ctrl_get(struct nvme_fc_ctrl *); + /* *********************** FC-NVME Port Management ************************ */ static void __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *, @@ -800,7 +803,7 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: Couldn't schedule reset.\n", ctrl->cnum); - nvme_delete_ctrl(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); } break; @@ -868,7 +871,7 @@ nvme_fc_unregister_remoteport(struct nvme_fc_remote_port *portptr) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: controller connectivity lost.\n", ctrl->cnum); - nvme_delete_ctrl(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); } else nvme_fc_ctrl_connectivity_loss(ctrl); } @@ -1022,9 +1025,6 @@ fc_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, /* *********************** FC-NVME LS Handling **************************** */ -static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *); -static int nvme_fc_ctrl_get(struct nvme_fc_ctrl *); - static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg); static void @@ -1050,8 +1050,6 @@ __nvme_fc_finish_ls_req(struct nvmefc_ls_req_op *lsop) fc_dma_unmap_single(rport->dev, lsreq->rqstdma, (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); - - nvme_fc_rport_put(rport); } static int @@ -1066,9 +1064,6 @@ __nvme_fc_send_ls_req(struct nvme_fc_rport *rport, if (rport->remoteport.port_state != FC_OBJSTATE_ONLINE) return -ECONNREFUSED; - if (!nvme_fc_rport_get(rport)) - return -ESHUTDOWN; - lsreq->done = done; lsop->rport = rport; lsop->req_queued = false; @@ -1078,10 +1073,8 @@ __nvme_fc_send_ls_req(struct nvme_fc_rport *rport, lsreq->rqstdma = fc_dma_map_single(rport->dev, lsreq->rqstaddr, lsreq->rqstlen + lsreq->rsplen, DMA_BIDIRECTIONAL); - if (fc_dma_mapping_error(rport->dev, lsreq->rqstdma)) { - ret = -EFAULT; - goto out_putrport; - } + if (fc_dma_mapping_error(rport->dev, lsreq->rqstdma)) + return -EFAULT; lsreq->rspdma = lsreq->rqstdma + lsreq->rqstlen; spin_lock_irqsave(&rport->lock, flags); @@ -1108,9 +1101,6 @@ __nvme_fc_send_ls_req(struct nvme_fc_rport *rport, fc_dma_unmap_single(rport->dev, lsreq->rqstdma, (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); -out_putrport: - nvme_fc_rport_put(rport); - return ret; } @@ -1471,8 +1461,6 @@ nvme_fc_xmt_ls_rsp_done(struct nvmefc_ls_rsp *lsrsp) kfree(lsop->rspbuf); kfree(lsop->rqstbuf); kfree(lsop); - - nvme_fc_rport_put(rport); } static void @@ -1511,8 +1499,6 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, spin_lock_irqsave(&rport->lock, flags); list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { - if (!nvme_fc_ctrl_get(ctrl)) - continue; spin_lock(&ctrl->lock); if (association_id == ctrl->association_id) { oldls = ctrl->rcv_disconn; @@ -1520,10 +1506,6 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, ret = ctrl; } spin_unlock(&ctrl->lock); - if (ret) - /* leave the ctrl get reference */ - break; - nvme_fc_ctrl_put(ctrl); } spin_unlock_irqrestore(&rport->lock, flags); @@ -1602,9 +1584,6 @@ nvme_fc_ls_disconnect_assoc(struct nvmefc_ls_rcv_op *lsop) /* fail the association */ nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); - /* release the reference taken by nvme_fc_match_disconn_ls() */ - nvme_fc_ctrl_put(ctrl); - return false; } @@ -1734,16 +1713,13 @@ nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *portptr, unsigned long flags; int ret; - nvme_fc_rport_get(rport); - /* validate there's a routine to transmit a response */ if (!lport->ops->xmt_ls_rsp) { dev_info(lport->dev, "RCV %s LS failed: no LLDD xmt_ls_rsp\n", (w0->ls_cmd <= NVME_FC_LAST_LS_CMD_VALUE) ? nvmefc_ls_names[w0->ls_cmd] : ""); - ret = -EINVAL; - goto out_put; + return -EINVAL; } if (lsreqbuf_len > sizeof(union nvmefc_ls_requests)) { @@ -1751,15 +1727,13 @@ nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *portptr, "RCV %s LS failed: payload too large\n", (w0->ls_cmd <= NVME_FC_LAST_LS_CMD_VALUE) ? nvmefc_ls_names[w0->ls_cmd] : ""); - ret = -E2BIG; - goto out_put; + return -E2BIG; } lsop = kzalloc(sizeof(*lsop), GFP_KERNEL); if (!lsop) { nvme_fc_rcv_ls_req_err_msg(lport, w0); - ret = -ENOMEM; - goto out_put; + return -ENOMEM; } lsop->rqstbuf = kzalloc(sizeof(*lsop->rqstbuf), GFP_KERNEL); @@ -1808,8 +1782,6 @@ nvme_fc_rcv_ls_req(struct nvme_fc_remote_port *portptr, kfree(lsop->rspbuf); kfree(lsop->rqstbuf); kfree(lsop); -out_put: - nvme_fc_rport_put(rport); return ret; } EXPORT_SYMBOL_GPL(nvme_fc_rcv_ls_req); @@ -2071,7 +2043,6 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); atomic_set(&op->state, FCPOP_STATE_IDLE); op->flags = FCOP_FLAGS_AEN; /* clear other flags */ - nvme_fc_ctrl_put(ctrl); goto check_error; } @@ -2383,37 +2354,18 @@ nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) } static void -nvme_fc_ctrl_free(struct kref *ref) +nvme_fc_ctrl_delete(struct kref *ref) { struct nvme_fc_ctrl *ctrl = container_of(ref, struct nvme_fc_ctrl, ref); - unsigned long flags; - - if (ctrl->ctrl.tagset) - nvme_remove_io_tag_set(&ctrl->ctrl); - - /* remove from rport list */ - spin_lock_irqsave(&ctrl->rport->lock, flags); - list_del(&ctrl->ctrl_list); - spin_unlock_irqrestore(&ctrl->rport->lock, flags); - - nvme_unquiesce_admin_queue(&ctrl->ctrl); - nvme_remove_admin_tag_set(&ctrl->ctrl); - - kfree(ctrl->queues); - - put_device(ctrl->dev); - nvme_fc_rport_put(ctrl->rport); - ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); - nvmf_ctrl_options_put(ctrl->ctrl.opts); - kfree(ctrl); + nvme_delete_ctrl(&ctrl->ctrl); } static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) { - kref_put(&ctrl->ref, nvme_fc_ctrl_free); + kref_put(&ctrl->ref, nvme_fc_ctrl_delete); } static int @@ -2431,9 +2383,18 @@ nvme_fc_free_ctrl(struct nvme_ctrl *nctrl) { struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); - WARN_ON(nctrl != &ctrl->ctrl); - nvme_fc_ctrl_put(ctrl); + if (ctrl->ctrl.tagset) + nvme_remove_io_tag_set(&ctrl->ctrl); + + nvme_unquiesce_admin_queue(&ctrl->ctrl); + nvme_remove_admin_tag_set(&ctrl->ctrl); + + kfree(ctrl->queues); + + ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); + nvmf_ctrl_options_put(ctrl->ctrl.opts); + kfree(ctrl); } /* @@ -2682,9 +2643,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) return BLK_STS_RESOURCE; - if (!nvme_fc_ctrl_get(ctrl)) - return BLK_STS_IOERR; - /* format the FC-NVME CMD IU and fcp_req */ cmdiu->connection_id = cpu_to_be64(queue->connection_id); cmdiu->data_len = cpu_to_be32(data_len); @@ -2729,7 +2687,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, ret = nvme_fc_map_data(ctrl, op->rq, op); if (ret < 0) { nvme_cleanup_cmd(op->rq); - nvme_fc_ctrl_put(ctrl); if (ret == -ENOMEM || ret == -EAGAIN) return BLK_STS_RESOURCE; return BLK_STS_IOERR; @@ -2770,8 +2727,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, nvme_cleanup_cmd(op->rq); } - nvme_fc_ctrl_put(ctrl); - if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && ret != -EBUSY) return BLK_STS_IOERR; @@ -2855,7 +2810,6 @@ nvme_fc_complete_rq(struct request *rq) nvme_fc_unmap_data(ctrl, rq, op); nvme_complete_rq(rq); - nvme_fc_ctrl_put(ctrl); } static void nvme_fc_map_queues(struct blk_mq_tag_set *set) @@ -3284,14 +3238,24 @@ static void nvme_fc_delete_ctrl(struct nvme_ctrl *nctrl) { struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); + unsigned long flags; cancel_work_sync(&ctrl->ioerr_work); cancel_delayed_work_sync(&ctrl->connect_work); + + /* remove from rport list */ + spin_lock_irqsave(&ctrl->rport->lock, flags); + list_del(&ctrl->ctrl_list); + spin_unlock_irqrestore(&ctrl->rport->lock, flags); + /* * kill the association on the link side. this will block * waiting for io to terminate */ nvme_fc_delete_association(ctrl); + + nvme_fc_rport_put(ctrl->rport); + nvme_fc_lport_put(ctrl->lport); } static void @@ -3344,7 +3308,7 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) ctrl->cnum, min_t(int, portptr->dev_loss_tmo, (ctrl->ctrl.opts->max_reconnects * ctrl->ctrl.opts->reconnect_delay))); - WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); + nvme_fc_ctrl_put(ctrl); } } @@ -3502,12 +3466,13 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, INIT_LIST_HEAD(&ctrl->ctrl_list); ctrl->lport = lport; ctrl->rport = rport; + nvme_fc_lport_get(lport); + nvme_fc_rport_get(rport); ctrl->dev = lport->dev; ctrl->cnum = idx; ctrl->ioq_live = false; init_waitqueue_head(&ctrl->ioabort_wait); - get_device(ctrl->dev); kref_init(&ctrl->ref); INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); @@ -3582,32 +3547,13 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, return &ctrl->ctrl; fail_ctrl: - nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); - cancel_work_sync(&ctrl->ioerr_work); - cancel_work_sync(&ctrl->ctrl.reset_work); - cancel_delayed_work_sync(&ctrl->connect_work); - - /* initiate nvme ctrl ref counting teardown */ - nvme_uninit_ctrl(&ctrl->ctrl); - - /* Remove core ctrl ref. */ - nvme_put_ctrl(&ctrl->ctrl); - - /* as we're past the point where we transition to the ref - * counting teardown path, if we return a bad pointer here, - * the calling routine, thinking it's prior to the - * transition, will do an rport put. Since the teardown - * path also does a rport put, we do an extra get here to - * so proper order/teardown happens. - */ - nvme_fc_rport_get(rport); + nvme_fc_ctrl_put(ctrl); return ERR_PTR(-EIO); out_free_queues: kfree(ctrl->queues); out_free_ida: - put_device(ctrl->dev); ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); out_free_opts: nvmf_ctrl_options_put(opts); @@ -3724,8 +3670,8 @@ nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts) spin_unlock_irqrestore(&nvme_fc_lock, flags); ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); - if (IS_ERR(ctrl)) - nvme_fc_rport_put(rport); + nvme_fc_rport_put(rport); + return ctrl; } } @@ -3950,7 +3896,7 @@ nvme_fc_delete_controllers(struct nvme_fc_rport *rport) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: transport unloading: deleting ctrl\n", ctrl->cnum); - nvme_delete_ctrl(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); } spin_unlock(&rport->lock); } From patchwork Fri Feb 16 08:45:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 202002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp381164dyb; Fri, 16 Feb 2024 00:50:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVkKZoiGDLMj/HWiJvpgQXJOluKstceI01BPYe0PIE1nuCDnKVkqgUCgvyMK98durzI/N3Pzrr6PNY7zVlazXq//K7X+w== X-Google-Smtp-Source: AGHT+IHbTD7oZq2FrN3dSgmp2DvlZovOmyCHlnBwrqdvz1HqPm/kb3pK72Vb73nYrNI5KEuuMv3r X-Received: by 2002:a17:906:b30a:b0:a31:3f4f:bea7 with SMTP id n10-20020a170906b30a00b00a313f4fbea7mr2626714ejz.39.1708073459421; Fri, 16 Feb 2024 00:50:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708073459; cv=pass; d=google.com; s=arc-20160816; b=lGLi8/Qvok3u9B0tTaUF8BUtJx0mgrnGuo+DC6T5Ouaqiqf2AlpBc0kIb7qac3aJAH HWGtIGE1V5/+rxXC+4E8ygiJFg7mkFFOkzxDjhd1MEBq7H1mkTimoCKDUbxsl/qKiQ+r DERl+4WBmDrtkLlFiEvv0pQSiUAfUTgOnZhklEk2lCpjm1YFYXPcfFHWjIAwpkFPFtbB YK07WX0KafZrTMohgEMNVZWEKRlxeKP5+OEXsR3ypjYji8Vp+wyhiCNrSIhgO3IPaaoG a4GPBe2YpDlVy4QRmU9dswUXr8/5pB4fi4otivK52cz7HXrp5GlnHVaCwu0+megQHucK ZLpA== 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=+ln0/p56v08h7XC7KQd0rPI4W6I85T5TW2n6DbRALBw=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=V0SZLgty9C3/4lUJ4KI6GAd65NHhlc9PqFtngx7C0nlxYb4EEqPNqEvE8GORIb7qTH difETJocEEIQGFyWcvZg774AbOAk9Y6JFK+hBL5HOlYAtNDHAUOKCBIXyJo1AS2L/7rd TkTH45v5U1aG+51++lbANGb0FXVnVDvX51PJwGWYp0LVH7UeDpuu25ycV1FimrN+5yVn OGykq/tJMTcFZUp57SWZ2Xl4+SH0F5Vj9EmNa3K9o7aZfaHF+5thq6EOTSXIpsPVjJBS dcdaVOG9izH0OfhF13vCm2XIil/Qt/SVuuuDqQ6QMg1Q999hO1gkVT/GVM54A7tu6AzW zthQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qsGDjjR6; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=6vfR1zgl; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qsGDjjR6; 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-68266-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68266-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k14-20020a170906054e00b00a3daa03c4e3si1064994eja.503.2024.02.16.00.50.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 00:50:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68266-ouuuleilei=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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qsGDjjR6; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=6vfR1zgl; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qsGDjjR6; 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-68266-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68266-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9EB331F231C9 for ; Fri, 16 Feb 2024 08:50:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7EB41C693; Fri, 16 Feb 2024 08:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qsGDjjR6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6vfR1zgl"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qsGDjjR6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6vfR1zgl" 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 2A2281804F for ; Fri, 16 Feb 2024 08:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073192; cv=none; b=HGzpqLIw+4T8rV8t4texIshOeuAAkyiU0PLPTAir7YKhp8P48HtmJMze6rsIaVNGcM03rTDoPC2iYRnuEpn6Cy807y7k9VYxmdE1dwIU4rgUBo0D7tDBwLn/fHVgWYUj3IQNLx4zTR48IB2lyZHF/Vx41zjY+bc0+qffgI2vKlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708073192; c=relaxed/simple; bh=YagyPAfDnoFU77qHOmhwEj7+kuL7vzLXYFYM63g5bUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BJDVh2G+aUbxuPYgx+wZ8k5v3I7VDumYEL3l1MZ6q9LHscBgPh44DRt10vCcjpe20WXFQKAKKIiJrmmcc+D1O2zG8preqSx87W3SR0LlOIOIEmjpSxy/FasgzGoN1r7fdYexcLi+ZtCCQIIRQIh0pXBB3vp3KePGR33hSPEDod8= 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=qsGDjjR6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6vfR1zgl; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qsGDjjR6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6vfR1zgl; arc=none smtp.client-ip=195.135.223.131 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-out2.suse.de (Postfix) with ESMTPS id 986D41FB5E; Fri, 16 Feb 2024 08:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073142; 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=+ln0/p56v08h7XC7KQd0rPI4W6I85T5TW2n6DbRALBw=; b=qsGDjjR6RWHS6wvVHRy06j9OsYh09g6Z/FVGZHA7+cYTIBBXYC8jJbgX06z+rS+gWaK2JP zaPZKLVhB84ra17WipVmELeKkr85O/KJXavnpsHZ+Z05R1ey+mqyvawFl3qFsrYgLDbFQE eHB4z4rN1+/gLIynmuQUvDkYV2UMGHE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073142; 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=+ln0/p56v08h7XC7KQd0rPI4W6I85T5TW2n6DbRALBw=; b=6vfR1zglVmifiPJVIi0wbOhF3PlsP/jyRfkbREnJHBJXe9Wo9glBJodyyUJ3vhauzqlzEh 5jAxCPIqWribJaDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708073142; 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=+ln0/p56v08h7XC7KQd0rPI4W6I85T5TW2n6DbRALBw=; b=qsGDjjR6RWHS6wvVHRy06j9OsYh09g6Z/FVGZHA7+cYTIBBXYC8jJbgX06z+rS+gWaK2JP zaPZKLVhB84ra17WipVmELeKkr85O/KJXavnpsHZ+Z05R1ey+mqyvawFl3qFsrYgLDbFQE eHB4z4rN1+/gLIynmuQUvDkYV2UMGHE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708073142; 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=+ln0/p56v08h7XC7KQd0rPI4W6I85T5TW2n6DbRALBw=; b=6vfR1zglVmifiPJVIi0wbOhF3PlsP/jyRfkbREnJHBJXe9Wo9glBJodyyUJ3vhauzqlzEh 5jAxCPIqWribJaDA== 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 8510E13343; Fri, 16 Feb 2024 08:45:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id VzkHH7Ygz2WlcwAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 08:45:42 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v0 6/6] nvme-fc: wait for connect attempt to finish Date: Fri, 16 Feb 2024 09:45:26 +0100 Message-ID: <20240216084526.14133-7-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216084526.14133-1-dwagner@suse.de> References: <20240216084526.14133-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-out2.suse.de; none X-Spam-Level: *** X-Spam-Score: 3.70 X-Spamd-Result: default: False [3.70 / 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)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[14.81%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791044835793890837 X-GMAIL-MSGID: 1791044835793890837 The FC transport offloads the connect attempt to a workqueue. Thus userspace is not able to wait on the result. Thus, allow userspace to wait on the connect result by honnering the 'connect_sync' connect option. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 7f9edab57550..5f1d0165de40 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -169,6 +169,7 @@ struct nvme_fc_ctrl { struct work_struct ioerr_work; struct delayed_work connect_work; + struct completion connect_completion; struct kref ref; unsigned long flags; @@ -803,6 +804,7 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: Couldn't schedule reset.\n", ctrl->cnum); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } break; @@ -871,6 +873,7 @@ nvme_fc_unregister_remoteport(struct nvme_fc_remote_port *portptr) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: controller connectivity lost.\n", ctrl->cnum); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } else nvme_fc_ctrl_connectivity_loss(ctrl); @@ -3308,6 +3311,7 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) ctrl->cnum, min_t(int, portptr->dev_loss_tmo, (ctrl->ctrl.opts->max_reconnects * ctrl->ctrl.opts->reconnect_delay))); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } } @@ -3367,10 +3371,12 @@ nvme_fc_connect_ctrl_work(struct work_struct *work) ret = nvme_fc_create_association(ctrl); if (ret) nvme_fc_reconnect_or_delete(ctrl, ret); - else + else { dev_info(ctrl->ctrl.device, "NVME-FC{%d}: controller connect complete\n", ctrl->cnum); + complete(&ctrl->connect_completion); + } } @@ -3477,6 +3483,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); + init_completion(&ctrl->connect_completion); INIT_WORK(&ctrl->ioerr_work, nvme_fc_ctrl_ioerr_work); spin_lock_init(&ctrl->lock); @@ -3524,6 +3531,9 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); spin_unlock_irqrestore(&rport->lock, flags); + if (opts->connect_sync) + nvme_fc_ctrl_get(ctrl); + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) || !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { dev_err(ctrl->ctrl.device, @@ -3540,6 +3550,19 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, flush_delayed_work(&ctrl->connect_work); + if (opts->connect_sync) { + enum nvme_ctrl_state state; + + wait_for_completion(&ctrl->connect_completion); + state = nvme_ctrl_state(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); + + if (state != NVME_CTRL_LIVE) { + /* Cleanup is handled by the connect state machine */ + return ERR_PTR(-EIO); + } + } + dev_info(ctrl->ctrl.device, "NVME-FC{%d}: new ctrl: NQN \"%s\", hostnqn: %s\n", ctrl->cnum, nvmf_ctrl_subsysnqn(&ctrl->ctrl), opts->host->nqn); @@ -3896,6 +3919,7 @@ nvme_fc_delete_controllers(struct nvme_fc_rport *rport) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: transport unloading: deleting ctrl\n", ctrl->cnum); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } spin_unlock(&rport->lock);