Hi Bart, thanks for looking at this. On Thu, 2021-04-29 at 09:20 -0700, Bart Van Assche wrote: > On 4/29/21 8:50 AM, mwilck@xxxxxxxx wrote: > > This makes it possible to use scsi_result_to_blk_status() from > > code that shouldn't depend on scsi_mod (e.g. device mapper). > > I think that's the wrong reason to make a function inline. Please > consider moving scsi_result_to_blk_status() into one of the block > layer > source code files that already deals with SG I/O, e.g. > block/scsi_ioctl.c. scsi_ioctl.c, are you certain? scsi_result_to_blk_status() is an important part of the block/scsi interface... You're right that that this function is not a prime candidate for inlining, but I'm still wondering where it belongs if we don't. Looking forward to see what others think. > > > diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h > > index 83f7e520be48..ba1e69d3bed9 100644 > > --- a/include/scsi/scsi_cmnd.h > > +++ b/include/scsi/scsi_cmnd.h > > @@ -311,24 +311,44 @@ static inline struct scsi_data_buffer > > *scsi_prot(struct scsi_cmnd *cmd) > > #define scsi_for_each_prot_sg(cmd, sg, nseg, __i) \ > > for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i) > > > > +static inline void __set_status_byte(int *result, char status) > > +{ > > + *result = (*result & 0xffffff00) | status; > > +} > > + > > static inline void set_status_byte(struct scsi_cmnd *cmd, char > > status) > > { > > - cmd->result = (cmd->result & 0xffffff00) | status; > > + __set_status_byte(&cmd->result, status); > > +} > > + > > +static inline void __set_msg_byte(int *result, char status) > > +{ > > + *result = (*result & 0xffff00ff) | (status << 8); > > } > > > > static inline void set_msg_byte(struct scsi_cmnd *cmd, char > > status) > > { > > - cmd->result = (cmd->result & 0xffff00ff) | (status << 8); > > + __set_msg_byte(&cmd->result, status); > > +} > > + > > +static inline void __set_host_byte(int *result, char status) > > +{ > > + *result = (*result & 0xff00ffff) | (status << 16); > > } > > > > static inline void set_host_byte(struct scsi_cmnd *cmd, char > > status) > > { > > - cmd->result = (cmd->result & 0xff00ffff) | (status << 16); > > + __set_host_byte(&cmd->result, status); > > +} > > + > > +static inline void __set_driver_byte(int *result, char status) > > +{ > > + *result = (*result & 0x00ffffff) | (status << 24); > > } > > > > static inline void set_driver_byte(struct scsi_cmnd *cmd, char > > status) > > { > > - cmd->result = (cmd->result & 0x00ffffff) | (status << 24); > > + __set_driver_byte(&cmd->result, status); > > } > > The layout of the SCSI result won't change since it is used in > multiple > UAPI data structures. I'd prefer to open-code host_byte() in > scsi_result_to_blk_status() instead of making the above changes. OK. I'm generally no fan of hard-coding but I guess you're right in this case. Thanks, Martin -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel