From: Christoph Hellwig <hch@lst.de>
To: Benjamin Block <bblock@linux.vnet.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
Johannes Thumshirn <jthumshirn@suse.de>
Subject: Re: [PATCH 9/9] bsg: split handling of SCSI CDBs vs transport requeues
Date: Fri, 20 Oct 2017 18:26:30 +0200 [thread overview]
Message-ID: <20171020162630.GA14277@lst.de> (raw)
In-Reply-To: <20171019155933.GE26185@bblock-ThinkPad-W530>
On Thu, Oct 19, 2017 at 05:59:33PM +0200, Benjamin Block wrote:
> > +#define ptr64(val) ((void __user *)(uintptr_t)(val))
>
> Better to reflect the special property, that it is a user pointer, in
> the name of the macro. Maybe something like user_ptr(64). The same
> comment for the same macro in bsg.c.
Not sure it's worth it especially now that Martin has merged the patch.
But given how many interface we have all over the kernel that use a u64
to store a user pointer in ioctls and similar it might make sense to
lift a helper like this to a generic header. In that case we'll need
a more descriptive name for sure.
> > +static int bsg_transport_check_proto(struct sg_io_v4 *hdr)
> > +{
> > + if (hdr->protocol != BSG_PROTOCOL_SCSI ||
> > + hdr->subprotocol != BSG_SUB_PROTOCOL_SCSI_TRANSPORT)
> > + return -EINVAL;
> > + if (!capable(CAP_SYS_RAWIO))
> > + return -EPERM;
>
> Any particular reason why this is not symmetric with bsg_scsi? IOW
> permission checking done in bsg_transport_fill_hdr(), like it is done in
> bsg_scsi_fill_hdr()?
>
> We might save some time copying memory with this (we also only talk
> about ~20 bytes here), but on the other hand the interface would be more
> clean otherwise IMO (if we already do restructure the interface) -
> similar callbacks have similar responsibilities.
I could move the capable check around, no sure why I had done it that
way, it's been a while. Probably because blk_verify_command needs the
CDB while a simple capable() check does not.
> If I understand this right, the this reflects the old code, if only
> written down a little different.
>
> But I wonder why we do that? Wouldn't that be interesting to know for
> uspace, if more was received than it allocated space for? Isn't that the
> typical residual over run case (similar to LUN scanning in SCSI common
> code), and din_resid is signed after all? Well I guess it could be an
> ABI break, I don't know.
>
> Ah well, at least the documentation for 'struct sg_io_v4' makes no such
> restrictions (that it can not be below 0).
>
> Just a thought I had while reading it.
Maybe it would, but I really didn't want to change behavior. If we
were to redo transport passthrough I would do it totally different today.
> > + job->reply = kzalloc(SCSI_SENSE_BUFFERSIZE, gfp);
>
> One suggestion here. Maybe we could get rid of this implicit knowledge
> about SCSI_SENSE_BUFFERSIZE being the max size for a bsg-reply?
> Especially if we use this patch and get rid of other similarities (like
> using scsi_request).
>
> Maybe we can just define a extra macro in bsg-lib.c, or in one of the
> headers, and define its size to be SCSI_SENSE_BUFFERSIZE (for now) and
> then use that in all cases.
>
> I tried something similar some time ego if you remember, but I couldn't
> follow up because other stuff got more important in the meantime. One
> could also static check the transport reply-types against that.
>
> This way, should need to change that value for a sepcific transport, we
> only need to change one knob, and not 10 (I guess SCSI_SENSE_BUFFERSIZE
> could not be changed for such cases ;) ).
There shouldn't be any dependencies on SCSI_SENSE_BUFFERSIZE left,
so yes, this could be cleaned up. Great opportunity for a follow on
patch.
> > - /* if the LLD has been removed then the bsg_unregister_queue will
> > - * eventually be called and the class_dev was freed, so we can no
> > - * longer use this request_queue. Return no such address.
> > - */
>
> Why remove the comment? Has that changed?
Nothing, but then again it's standard behavior so the comment doesn't
really add any value.
> > + rq->timeout = msecs_to_jiffies(hdr->timeout);
> > + if (!rq->timeout)
> > + rq->timeout = rq->q->sg_timeout;
>
> No need to use the rq pointer, you already have a variable q with the
> same content.
True.
> > - ret = blk_rq_map_user(q, rq, NULL, dxferp, dxfer_len,
> > - GFP_KERNEL);
> > - if (ret)
> > - goto out;
> > + ret = blk_rq_map_user(q, rq, NULL, ptr64(hdr->din_xferp),
> > + hdr->din_xfer_len, GFP_KERNEL);
> > + } else {
> > + ret = blk_rq_map_user(q, rq, NULL, NULL, 0, GFP_KERNEL);
>
> Why do we behave differently in this case now? To prevent special
> handling elsewhere? Otherwise it seems a bit pointless/error-prone
> mapping zero length to nothing.
Yes, this could be removed again. I'll send a follow up.
next prev parent reply other threads:[~2017-10-20 16:26 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 10:48 [RFC] bsg-lib interface cleanup Christoph Hellwig
2017-10-03 10:48 ` [PATCH 1/9] bsg-lib: fix use-after-free under memory-pressure Christoph Hellwig
2017-10-04 6:16 ` Hannes Reinecke
2017-10-04 8:54 ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 2/9] bfa: don't reset max_segments for every bsg request Christoph Hellwig
2017-10-04 6:16 ` Hannes Reinecke
2017-10-04 8:54 ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 3/9] libfc: don't assign resid_len in fc_lport_bsg_request Christoph Hellwig
2017-10-04 6:17 ` Hannes Reinecke
2017-10-04 8:54 ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 4/9] qla2xxx: don't break the bsg-lib abstractions Christoph Hellwig
2017-10-04 6:20 ` Hannes Reinecke
2017-10-04 8:54 ` Johannes Thumshirn
2017-10-05 16:58 ` Madhani, Himanshu
2017-10-03 10:48 ` [PATCH 5/9] scsi_transport_sas: check reply payload length instead of bidi request Christoph Hellwig
2017-10-04 6:21 ` Hannes Reinecke
2017-10-04 8:53 ` Johannes Thumshirn
2017-10-03 10:48 ` [PATCH 6/9] bsg-lib: introduce a timeout field in struct bsg_job Christoph Hellwig
2017-10-04 6:21 ` Hannes Reinecke
2017-10-04 8:53 ` Johannes Thumshirn
2017-10-16 16:30 ` Benjamin Block
2017-10-03 10:48 ` [PATCH 7/9] bsg-lib: remove bsg_job.req Christoph Hellwig
2017-10-04 6:22 ` Hannes Reinecke
2017-10-04 8:52 ` Johannes Thumshirn
2017-10-16 16:36 ` Benjamin Block
2017-10-03 10:48 ` [PATCH 8/9] block: pass full fmode_t to blk_verify_command Christoph Hellwig
2017-10-04 6:23 ` Hannes Reinecke
2017-10-04 8:52 ` Johannes Thumshirn
2017-10-16 16:50 ` Benjamin Block
2017-10-03 10:48 ` [PATCH 9/9] bsg: split handling of SCSI CDBs vs transport requeues Christoph Hellwig
2017-10-04 6:26 ` Hannes Reinecke
2017-10-04 7:18 ` Johannes Thumshirn
2017-10-04 7:20 ` Christoph Hellwig
2017-10-04 8:52 ` Johannes Thumshirn
2017-10-04 7:18 ` Johannes Thumshirn
2017-10-19 15:59 ` Benjamin Block
2017-10-20 16:26 ` Christoph Hellwig [this message]
2017-10-20 16:47 ` Benjamin Block
2017-10-23 6:16 ` Martin K. Petersen
2017-10-23 6:29 ` Christoph Hellwig
2017-10-23 7:17 ` Martin K. Petersen
2017-10-24 17:46 ` Jens Axboe
2017-10-24 16:58 ` Benjamin Block
2017-10-04 14:35 ` [RFC] bsg-lib interface cleanup Jens Axboe
2017-10-17 3:50 ` Martin K. Petersen
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=20171020162630.GA14277@lst.de \
--to=hch@lst.de \
--cc=bblock@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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).