On Fri, Sep 17, 2021 at 05:04:44PM -0700, Bart Van Assche wrote: > Conditional statements are faster than indirect calls. Use a member variable > to track the SCSI command submitter such that later patches can call > scsi_done(scmd) instead of scmd->scsi_done(scmd). > > The asymmetric behavior that scsi_send_eh_cmnd() sets the submission > context to the SCSI error handler and that it does not restore the > submission context to the SCSI core is retained. > > Cc: Hannes Reinecke <hare@xxxxxxxx> > Cc: Ming Lei <ming.lei@xxxxxxxxxx> > Cc: Christoph Hellwig <hch@xxxxxx> > Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> > --- > drivers/scsi/scsi_error.c | 18 +++++++----------- > drivers/scsi/scsi_lib.c | 9 +++++++++ > drivers/scsi/scsi_priv.h | 1 + > include/scsi/scsi_cmnd.h | 7 +++++++ > 4 files changed, 24 insertions(+), 11 deletions(-) > > diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h > index eaf04c9a1dfc..365d47a66c18 100644 > --- a/include/scsi/scsi_cmnd.h > +++ b/include/scsi/scsi_cmnd.h > @@ -65,6 +65,12 @@ struct scsi_pointer { > #define SCMD_STATE_COMPLETE 0 > #define SCMD_STATE_INFLIGHT 1 > > +enum scsi_cmnd_submitter { > + BLOCK_LAYER = 0, > + SCSI_ERROR_HANDLER = 1, > + SCSI_RESET_IOCTL = 2, > +} __packed; > + Might be prudent to not make them as generic, especially `BLOCK_LAYER` might easily clash without namespace. `SUBMITTED_BY_...`? > struct scsi_cmnd { > struct scsi_request req; > struct scsi_device *device; > @@ -90,6 +96,7 @@ struct scsi_cmnd { > unsigned char prot_op; > unsigned char prot_type; > unsigned char prot_flags; > + enum scsi_cmnd_submitter submitter; Do you think it'd make much of a difference, if you initialized this in scsi_init_command(), or somewhere around there, explicitly to `BLOCK_LAYER`? Makes it easier to maintain, and to not forget, that it needs to be done, if the memset() to 0 ever changes... after the memset() the memory should be hot. I just had to search a bit where this gets set to 0, as I didn't remember exactly where it was. > > unsigned short cmd_len; > enum dma_data_direction sc_data_direction; -- Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Systems IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy Vorsitz. AufsR.: Gregor Pillen / Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294