linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Scott Bauer <sbauer@plzdonthack.me>
To: David Kozub <zub@linux.fjfi.cvut.cz>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	hch@infradead.org, jonathan.derrick@intel.com
Subject: Re: [PATCH v2 15/16] block: sed-opal: don't repeat opal_discovery0 in each steps array
Date: Sat, 19 Jan 2019 12:46:33 -0500	[thread overview]
Message-ID: <20190119174633.GA15276@hacktheplanet> (raw)
In-Reply-To: <1547760716-7304-16-git-send-email-zub@linux.fjfi.cvut.cz>

On Thu, Jan 17, 2019 at 09:31:55PM +0000, David Kozub wrote:

> -	for (state = 0; !error && state < n_steps; state++) {
> -		step = &steps[state];
> -
> -		error = step->fn(dev, step->data);
> -		if (error) {
> -			pr_debug("Step %zu (%pS) failed with error %d: %s\n",
> -				 state, step->fn, error,
> -				 opal_error_to_human(error));
> -
> -			/* For each OPAL command we do a discovery0 then we
> -			 * start some sort of session.
> -			 * If we haven't passed state 1 then there was an error
> -			 * on discovery0 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 (state > 1) {
> -				end_opal_session_error(dev);
> -				return error;
> -			}




> +	/* 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 stopped the loop in state 0 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 > 0)
> +		end_opal_session_error(dev);


This is subtly wrong. There was some state that was encoded by having the
loop the way we did.

the tl;dr is the check needs to be if (error && state > 1) still.

The why is that in the previous implementation we wanted to end_opal_session_error
only if a successful discovery0 AND a successful start_*_session. In the previous loop,
discovery0 would complete, we'd do state++, then we'd go and attempt to start our
session. If we failed on that session starting we'd still be in state 1, and wouldn't
attempt to close the session.

In the current form, discovery0 is gone, so start session is on state 0. If we fail
on the start session, we set error = true, state gets ++'d, then we look at !error
and we don't loop again.

We go down to the check and attempt to end a session that was never started.




> -- 
> 2.20.1
> 
> 

  reply	other threads:[~2019-01-19 17:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 21:31 [PATCH v2 00/16] block: sed-opal: support shadow MBR done flag and write David Kozub
2019-01-17 21:31 ` [PATCH v2 01/16] block: sed-opal: fix typos and formatting David Kozub
2019-01-17 21:31 ` [PATCH v2 02/16] block: sed-opal: use correct macro for method length David Kozub
2019-01-17 21:31 ` [PATCH v2 03/16] block: sed-opal: unify space check in add_token_* David Kozub
2019-01-17 21:31 ` [PATCH v2 04/16] block: sed-opal: close parameter list in cmd_finalize David Kozub
2019-01-17 21:31 ` [PATCH v2 05/16] block: sed-opal: unify cmd start David Kozub
2019-01-17 21:31 ` [PATCH v2 06/16] block: sed-opal: unify error handling of responses David Kozub
2019-01-17 21:31 ` [PATCH v2 07/16] block: sed-opal: reuse response_get_token to decrease code duplication David Kozub
2019-01-17 21:31 ` [PATCH v2 08/16] block: sed-opal: print failed function address David Kozub
2019-01-17 21:31 ` [PATCH v2 09/16] block: sed-opal: split generation of bytestring header and content David Kozub
2019-01-17 21:31 ` [PATCH v2 10/16] block: sed-opal: add ioctl for done-mark of shadow mbr David Kozub
2019-01-17 21:31 ` [PATCH v2 11/16] block: sed-opal: ioctl for writing to " David Kozub
2019-01-17 21:31 ` [PATCH v2 12/16] block: sed-opal: unify retrieval of table columns David Kozub
2019-01-17 21:31 ` [PATCH v2 13/16] block: sed-opal: check size of shadow mbr David Kozub
2019-01-19 17:29   ` Scott Bauer
2019-01-17 21:31 ` [PATCH v2 14/16] block: sed-opal: pass steps via argument rather than via opal_dev David Kozub
2019-01-17 21:31 ` [PATCH v2 15/16] block: sed-opal: don't repeat opal_discovery0 in each steps array David Kozub
2019-01-19 17:46   ` Scott Bauer [this message]
2019-01-20 20:23     ` David Kozub
2019-01-17 21:31 ` [PATCH v2 16/16] block: sed-opal: rename next to execute_steps David Kozub
2019-01-19 17:53 ` [PATCH v2 00/16] block: sed-opal: support shadow MBR done flag and write Scott Bauer
2019-01-20 20:28   ` David Kozub

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190119174633.GA15276@hacktheplanet \
    --to=sbauer@plzdonthack.me \
    --cc=hch@infradead.org \
    --cc=jonathan.derrick@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zub@linux.fjfi.cvut.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).