Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1765607imj; Sun, 10 Feb 2019 09:47:47 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia7rekGM+ACycebXjUxAPxIRxba3aBBOKTQBzwJ+ELzm1vSY+BRCBDyGYyhUfTGNFUTmTs1 X-Received: by 2002:a63:1cd:: with SMTP id 196mr6023688pgb.58.1549820867820; Sun, 10 Feb 2019 09:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549820867; cv=none; d=google.com; s=arc-20160816; b=iY1gmg81qz3zrvp5sqDXk/e2YnkLYKtY7RvlZ5igApXbetnyagXOSJoOX1slPSw3JW 561xBuRK7VowMeNHcngcu80foPcQ0+HsCpj417AV15MKG3Z5hYIPQsLVko0F1pFVbxTs ws1/5bdYRRcR6oCSXsbpU/hLIDvNtzThMRpW4sH0+dGiywRa9sGbsZRrCyHByqcKShzG a3kEs0FOfFmyalD7m6cIidnkeh++bySOmxAXwInVMFtg7G4p8dd3i7qn7Hz7l5DaAORg VeX9yoz0GTO8d8CwLiMKL+tEPSizQJtSbCSwHzk759hgaCQQ8CscNBCCdK5qshwdqWD8 MeyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-filter :dkim-signature; bh=0nviwiTjbKqCgLvjB3i/IvE9KpLn1tfKfIa0mw0Dfgo=; b=FDZnpGamJQhiKYWtAx05gd86sV50Y86EJNi/N+HoqIa70t4Ah1JYpvMIgPYUHA3MRl A5JWFPXvRM6BqgD5wi+rqX6yDdoBtSfgpc0otGiUUh+qOIz6QCG2/YTzuXZrecO56NFk bN4HdTM9vNX3Hhl+iGOXlOOtVOxlIR6ZiT5hfT90vpmLVAF6NUl9lh2PWECmLpuOCTSF EEBdj5jKXgHfFcK+S8c41OWiapLdhb+zB37S7t1YmfnZed/bRHfDIuweJgm4UCFfBAiz UcR32+z22G6GCbJ3G3k19sW6SVfIycov8HX1HHp+Q/7UetGynJt3pY0AzFExbQ1/5mCt V18Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fjfi.cvut.cz header.s=20151024 header.b=JEJf9iuq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si8181041plc.332.2019.02.10.09.47.31; Sun, 10 Feb 2019 09:47:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fjfi.cvut.cz header.s=20151024 header.b=JEJf9iuq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbfBJRqx (ORCPT + 99 others); Sun, 10 Feb 2019 12:46:53 -0500 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:42732 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbfBJRqw (ORCPT ); Sun, 10 Feb 2019 12:46:52 -0500 Received: from localhost (localhost [127.0.0.1]) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTP id DBB66A0FE8; Sun, 10 Feb 2019 18:46:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fjfi.cvut.cz; s=20151024; t=1549820810; i=@fjfi.cvut.cz; bh=0nviwiTjbKqCgLvjB3i/IvE9KpLn1tfKfIa0mw0Dfgo=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=JEJf9iuqlurIiqbyrB+Bl6bDCKFJFLN1Z5kcFJO41S1C1lXOeAKqKycUM1exSEGYO sZv2MkGr1+TzRnpabHDdQxhrUlyQFqyGfSMhVatMlDwZLy6dxwSQg0d4qANkgejSiJ rMDAyzNbUs7VLP/8CooSoRjVGtFqnBJbfmHHlmO0= X-CTU-FNSPE-Virus-Scanned: amavisd-new at fjfi.cvut.cz Received: from mailgw1.fjfi.cvut.cz ([127.0.0.1]) by localhost (mailgw1.fjfi.cvut.cz [127.0.0.1]) (amavisd-new, port 10022) with ESMTP id sDMAb4WvOfG2; Sun, 10 Feb 2019 18:46:43 +0100 (CET) Received: from linux.fjfi.cvut.cz (linux.fjfi.cvut.cz [147.32.5.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTPS id BD025A14F1; Sun, 10 Feb 2019 18:46:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz BD025A14F1 Received: by linux.fjfi.cvut.cz (Postfix, from userid 1001) id 8CF526004E; Sun, 10 Feb 2019 18:46:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by linux.fjfi.cvut.cz (Postfix) with ESMTP id 79E886004D; Sun, 10 Feb 2019 18:46:18 +0100 (CET) Date: Sun, 10 Feb 2019 18:46:18 +0100 (CET) From: David Kozub To: "Derrick, Jonathan" cc: "hch@infradead.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "sbauer@plzdonthack.me" , "jonas.rabenstein@studium.uni-erlangen.de" , "axboe@kernel.dk" Subject: Re: [PATCH v4 15/16] block: sed-opal: don't repeat opal_discovery0 in each steps array In-Reply-To: <1549666749.10972.62.camel@intel.com> Message-ID: References: <1549054223-12220-1-git-send-email-zub@linux.fjfi.cvut.cz> <1549054223-12220-16-git-send-email-zub@linux.fjfi.cvut.cz> <20190204150132.GM31132@infradead.org> <1549666749.10972.62.camel@intel.com> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 8 Feb 2019, Derrick, Jonathan wrote: > On Mon, 2019-02-04 at 23:44 +0100, David Kozub wrote: >> On Mon, 4 Feb 2019, Christoph Hellwig wrote: >> >>>> + /* first do a discovery0 */ >>>> + error = opal_discovery0_step(dev); >>>> >>>> + for (state = 0; !error && state < n_steps; state++) >>>> + error = execute_step(dev, &steps[state], state); >>>> + >>>> + /* >>>> + * For each OPAL command the first step in steps starts some sort of >>>> + * session. If an error occurred in the initial discovery0 or if an >>>> + * error occurred in the first step (and thus stopping the loop with >>>> + * state == 1) then there was an error before or during the attempt to >>>> + * start a session. Therefore we shouldn't attempt to terminate a >>>> + * session, as one has not yet been created. >>>> + */ >>>> + if (error && state > 1) >>>> + end_opal_session_error(dev); >>>> >>>> return error; >>> >>> The flow here is a little too condensed for my taste. Why not the >>> plain obvoious, if a little longer: >>> >>> error = error = opal_discovery0_step(dev); >>> if (error) >>> return error; >>> >>> for (state = 0; state < n_steps; state++) { >>> error = execute_step(dev, &steps[state], state); >>> if (error) >>> goto out_error; >>> } >>> >>> return 0; >>> >>> out_error: >>> if (state > 1) >>> end_opal_session_error(dev); >>> return error; >> >> No problem, I can use this version. But I think there is a minor issue - >> the same one I hit in my original change, just from the other direction: >> >> If the loop succeds for the 0-th element of steps, and then fails for the >> 1st element, then state equals 1 yet the session has been started, so we >> should close it. >> >> I think the condition in out_error should be if (state > 0). >> >> Best regards, >> David > Looks good with Christoph's suggestion (for 14/16) and your state check fix > > > Reviewed-by: Jon Derrick Hi Jon, What suggestion by Christoph you have in mind? I don't see any for 14/16. Currently, in my git repo, for this patch, I applied Christoph suggestion for this (15/16) patch + the "state > 0" fix. Is this what you mean? Best regards, David