From: Martin Wilck <mwilck@suse.com> To: Bart Van Assche <bvanassche@acm.org>, Mike Snitzer <snitzer@redhat.com>, Alasdair G Kergon <agk@redhat.com>, dm-devel@redhat.com, Hannes Reinecke <hare@suse.de> Cc: Daniel Wagner <dwagner@suse.de>, linux-block@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>, Christoph Hellwig <hch@lst.de> Subject: Re: [dm-devel] [RFC PATCH v2 1/2] scsi: convert scsi_result_to_blk_status() to inline Date: Thu, 29 Apr 2021 22:33:27 +0200 [thread overview] Message-ID: <bb30875e11913a33bcaf491d0f752132ebb9ce5e.camel@suse.com> (raw) In-Reply-To: <08440651-6e8f-734a-ef43-561d9c2596a6@acm.org> 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@suse.com 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
WARNING: multiple messages have this Message-ID (diff)
From: Martin Wilck <mwilck@suse.com> To: Bart Van Assche <bvanassche@acm.org>, Mike Snitzer <snitzer@redhat.com>, Alasdair G Kergon <agk@redhat.com>, dm-devel@redhat.com, Hannes Reinecke <hare@suse.de> Cc: linux-block@vger.kernel.org, Bonzini <pbonzini@redhat.com>, Paolo, Christoph Hellwig <hch@lst.de>, Daniel Wagner <dwagner@suse.de> Subject: Re: [dm-devel] [RFC PATCH v2 1/2] scsi: convert scsi_result_to_blk_status() to inline Date: Thu, 29 Apr 2021 22:33:27 +0200 [thread overview] Message-ID: <bb30875e11913a33bcaf491d0f752132ebb9ce5e.camel@suse.com> (raw) In-Reply-To: <08440651-6e8f-734a-ef43-561d9c2596a6@acm.org> 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@suse.com 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@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2021-04-29 20:33 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-29 15:50 [RFC PATCH v2 0/2] dm: dm_blk_ioctl(): implement failover for SG_IO on dm-multipath mwilck 2021-04-29 15:50 ` [dm-devel] " mwilck 2021-04-29 15:50 ` [RFC PATCH v2 1/2] scsi: convert scsi_result_to_blk_status() to inline mwilck 2021-04-29 15:50 ` [dm-devel] " mwilck 2021-04-29 16:20 ` Bart Van Assche 2021-04-29 16:20 ` Bart Van Assche 2021-04-29 20:33 ` Martin Wilck [this message] 2021-04-29 20:33 ` Martin Wilck 2021-04-30 21:12 ` Bart Van Assche 2021-04-30 21:12 ` Bart Van Assche 2021-04-29 15:50 ` [RFC PATCH v2 2/2] dm: add CONFIG_DM_MULTIPATH_SG_IO - failover for SG_IO on dm-multipath mwilck 2021-04-29 15:50 ` [dm-devel] " mwilck 2021-04-29 16:32 ` Bart Van Assche 2021-04-29 16:32 ` Bart Van Assche 2021-04-29 21:08 ` Martin Wilck 2021-04-29 21:08 ` Martin Wilck
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=bb30875e11913a33bcaf491d0f752132ebb9ce5e.camel@suse.com \ --to=mwilck@suse.com \ --cc=agk@redhat.com \ --cc=bvanassche@acm.org \ --cc=dm-devel@redhat.com \ --cc=dwagner@suse.de \ --cc=hare@suse.de \ --cc=hch@lst.de \ --cc=linux-block@vger.kernel.org \ --cc=pbonzini@redhat.com \ --cc=snitzer@redhat.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.