From mboxrd@z Thu Jan 1 00:00:00 1970 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 663C51E1C16 for ; Mon, 20 Jan 2025 13:45:48 +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=1737380750; cv=none; b=aFN9QpriTXJ7iC17Wdh0zDrBzlVkrD0WSfDeMMnaTl2OLEw/G7m4cNbPolB9zvgKQEss7SP3qrj77GjoejExFo1/ihI1nPeXgtxt+VHc22iMiDjpIl0ji/w95INc26blY6Ab3XEbgu/pWlQy3yg6D2WL9vZVgIpcEld9mOlevUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380750; c=relaxed/simple; bh=26B7GD5vVeZMCbGamat2oTm+gM9342CyVleW65SsGWc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Lztb5PVkeeNy66FBemDPsqxVifCKa22T+I8hMIIt+TNcvv1lIeAnlrGNwQq2zJHDEvLgJRVu1r2YNkOD5t3mGUkYWvaGWWlf4vZczqi9OIjBnpMqpuYgEr9b9zyfTsaxcyzC2XnnyExGsXu9a+9MB8wC4Hl9i7dbmVMOLI9D6Bg= 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=Axp/DLS6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=dkutcqHh; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Axp/DLS6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=dkutcqHh; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Axp/DLS6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dkutcqHh"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Axp/DLS6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dkutcqHh" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7002C2117E; Mon, 20 Jan 2025 13:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737380746; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QF1VONKnn8WOI8uNOYuFK4FFaffVTqc2ME1cDMhaWJo=; b=Axp/DLS6ufjFiiSl70ONlqqWfFr6hYHP2oliF0dEfM7bgJwmQgcjNkWkF3+3EcGVLero25 nlhjGycmwhsjfnJNJN3DJrXanMy6iXNLn7s2LjtcRTjxcW5vszLQFZW7TjwjluX/+bXiUy iJ4K0mBxGDXubxNp/B+dr3KKWFcqf9A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737380746; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QF1VONKnn8WOI8uNOYuFK4FFaffVTqc2ME1cDMhaWJo=; b=dkutcqHhoK3gP03pc9UC0OG0fo8QTyMYnjYUl+G/A4DAVUoE+OcNdqs2mJozVhk/KMjSXB JeqDiFpkXQ5pqqCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737380746; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QF1VONKnn8WOI8uNOYuFK4FFaffVTqc2ME1cDMhaWJo=; b=Axp/DLS6ufjFiiSl70ONlqqWfFr6hYHP2oliF0dEfM7bgJwmQgcjNkWkF3+3EcGVLero25 nlhjGycmwhsjfnJNJN3DJrXanMy6iXNLn7s2LjtcRTjxcW5vszLQFZW7TjwjluX/+bXiUy iJ4K0mBxGDXubxNp/B+dr3KKWFcqf9A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737380746; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QF1VONKnn8WOI8uNOYuFK4FFaffVTqc2ME1cDMhaWJo=; b=dkutcqHhoK3gP03pc9UC0OG0fo8QTyMYnjYUl+G/A4DAVUoE+OcNdqs2mJozVhk/KMjSXB JeqDiFpkXQ5pqqCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 587941393E; Mon, 20 Jan 2025 13:45:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3YMIFYpTjmeAGgAAD6G6ig (envelope-from ); Mon, 20 Jan 2025 13:45:46 +0000 Message-ID: Date: Mon, 20 Jan 2025 14:45:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 3/3] nvme-fc: do not ignore connectivity loss during connecting To: Daniel Wagner , James Smart , Keith Busch , Christoph Hellwig , Sagi Grimberg , Paul Ely Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <20250109-nvme-fc-handle-com-lost-v4-0-fe5cae17b492@kernel.org> <20250109-nvme-fc-handle-com-lost-v4-3-fe5cae17b492@kernel.org> Content-Language: en-US From: Hannes Reinecke In-Reply-To: <20250109-nvme-fc-handle-com-lost-v4-3-fe5cae17b492@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_SEVEN(0.00)[8]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo] X-Spam-Score: -4.30 X-Spam-Flag: NO On 1/9/25 14:30, Daniel Wagner wrote: > When a connectivity loss occurs while nvme_fc_create_assocation is > being executed, it's possible that the ctrl ends up stuck in the LIVE > state: > > 1) nvme nvme10: NVME-FC{10}: create association : ... > 2) nvme nvme10: NVME-FC{10}: controller connectivity lost. > Awaiting Reconnect > nvme nvme10: queue_size 128 > ctrl maxcmd 32, reducing to maxcmd > 3) nvme nvme10: Could not set queue count (880) > nvme nvme10: Failed to configure AEN (cfg 900) > 4) nvme nvme10: NVME-FC{10}: controller connect complete > 5) nvme nvme10: failed nvme_keep_alive_end_io error=4 > > A connection attempt starts 1) and the ctrl is in state CONNECTING. > Shortly after the LLDD driver detects a connection lost event and calls > nvme_fc_ctrl_connectivity_loss 2). Because we are still in CONNECTING > state, this event is ignored. > > nvme_fc_create_association continues to run in parallel and tries to > communicate with the controller and these commands will fail. Though > these errors are filtered out, e.g in 3) setting the I/O queues numbers > fails which leads to an early exit in nvme_fc_create_io_queues. Because > the number of IO queues is 0 at this point, there is nothing left in > nvme_fc_create_association which could detected the connection drop. > Thus the ctrl enters LIVE state 4). > > Eventually the keep alive handler times out 5) but because nothing is > being done, the ctrl stays in LIVE state. > > There is already the ASSOC_FAILED flag to track connectivity loss event > but this bit is set too late in the recovery code path. Move this into > the connectivity loss event handler and synchronize it with the state > change. This ensures that the ASSOC_FAILED flag is seen by > nvme_fc_create_io_queues and it does not enter the LIVE state after a > connectivity loss event. If the connectivity loss event happens after we > entered the LIVE state the normal error recovery path is executed. > > Signed-off-by: Daniel Wagner > --- > drivers/nvme/host/fc.c | 23 ++++++++++++++++++----- > 1 file changed, 18 insertions(+), 5 deletions(-) > > diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c > index 7409da42b9ee580cdd6fe78c0f93e78c4ad08675..55884d3df6f291cfddb4742e135b54a72f1cfa05 100644 > --- a/drivers/nvme/host/fc.c > +++ b/drivers/nvme/host/fc.c > @@ -781,11 +781,19 @@ nvme_fc_abort_lsops(struct nvme_fc_rport *rport) > static void > nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) > { > + enum nvme_ctrl_state state; > + unsigned long flags; > + > dev_info(ctrl->ctrl.device, > "NVME-FC{%d}: controller connectivity lost. Awaiting " > "Reconnect", ctrl->cnum); > > - switch (nvme_ctrl_state(&ctrl->ctrl)) { > + spin_lock_irqsave(&ctrl->lock, flags); > + set_bit(ASSOC_FAILED, &ctrl->flags); > + state = nvme_ctrl_state(&ctrl->ctrl); > + spin_unlock_irqrestore(&ctrl->lock, flags); > + > + switch (state) { > case NVME_CTRL_NEW: > case NVME_CTRL_LIVE: > /* > @@ -2542,7 +2550,6 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) > */ > if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { > __nvme_fc_abort_outstanding_ios(ctrl, true); > - set_bit(ASSOC_FAILED, &ctrl->flags); > dev_warn(ctrl->ctrl.device, > "NVME-FC{%d}: transport error during (re)connect\n", > ctrl->cnum); > @@ -3167,12 +3174,18 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl) > else > ret = nvme_fc_recreate_io_queues(ctrl); > } > - if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) > - ret = -EIO; > if (ret) > goto out_term_aen_ops; > > - changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); > + spin_lock_irqsave(&ctrl->lock, flags); > + if (!test_bit(ASSOC_FAILED, &ctrl->flags)) > + changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); > + else > + ret = -EIO; > + spin_unlock_irqrestore(&ctrl->lock, flags); > + > + if (ret) > + goto out_term_aen_ops; > > ctrl->ctrl.nr_reconnects = 0; > > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich