Message ID | 20170519183016.12646-15-bart.vanassche@sandisk.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Fri, May 19, 2017 at 11:30:12AM -0700, Bart Van Assche wrote: > This simplifies the memset() call in scsi_initialize_rq() and avoids > that any stale data is left behind in struct scsi_request. > > Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> > Cc: Christoph Hellwig <hch@lst.de> > Cc: Hannes Reinecke <hare@suse.com> > --- > drivers/scsi/scsi_lib.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index eeb668935836..791bae192bfb 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -1160,11 +1160,9 @@ static void scsi_initialize_rq(struct request *rq) > void *buf = cmd->sense_buffer; > void *prot = cmd->prot_sdb; > > - /* zero out the cmd, except for the embedded scsi_request */ > - memset((char *)cmd + sizeof(cmd->req), 0, > - sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size); > + memset(cmd, 0, blk_queue_cmd_size(rq->q)); > scsi_req_init(&cmd->req); > - cmd->req.sense = cmd->sense_buffer; > + cmd->req.sense = buf; > cmd->device = dev; > cmd->sense_buffer = buf; maybe move the two sense buffer initializations together? Otherwise this looks fine: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Sun, 2017-05-21 at 08:49 +0200, Christoph Hellwig wrote: > On Fri, May 19, 2017 at 11:30:12AM -0700, Bart Van Assche wrote: > > This simplifies the memset() call in scsi_initialize_rq() and avoids > > that any stale data is left behind in struct scsi_request. > > > > Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> > > Cc: Christoph Hellwig <hch@lst.de> > > Cc: Hannes Reinecke <hare@suse.com> > > --- > > drivers/scsi/scsi_lib.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > > index eeb668935836..791bae192bfb 100644 > > --- a/drivers/scsi/scsi_lib.c > > +++ b/drivers/scsi/scsi_lib.c > > @@ -1160,11 +1160,9 @@ static void scsi_initialize_rq(struct request *rq) > > void *buf = cmd->sense_buffer; > > void *prot = cmd->prot_sdb; > > > > - /* zero out the cmd, except for the embedded scsi_request */ > > - memset((char *)cmd + sizeof(cmd->req), 0, > > - sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size); > > + memset(cmd, 0, blk_queue_cmd_size(rq->q)); > > scsi_req_init(&cmd->req); > > - cmd->req.sense = cmd->sense_buffer; > > + cmd->req.sense = buf; > > cmd->device = dev; > > cmd->sense_buffer = buf; > > maybe move the two sense buffer initializations together? Hello Christoph, That sounds like a good idea to me. I will make that change. Bart.
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index eeb668935836..791bae192bfb 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1160,11 +1160,9 @@ static void scsi_initialize_rq(struct request *rq) void *buf = cmd->sense_buffer; void *prot = cmd->prot_sdb; - /* zero out the cmd, except for the embedded scsi_request */ - memset((char *)cmd + sizeof(cmd->req), 0, - sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size); + memset(cmd, 0, blk_queue_cmd_size(rq->q)); scsi_req_init(&cmd->req); - cmd->req.sense = cmd->sense_buffer; + cmd->req.sense = buf; cmd->device = dev; cmd->sense_buffer = buf; cmd->prot_sdb = prot;
This simplifies the memset() call in scsi_initialize_rq() and avoids that any stale data is left behind in struct scsi_request. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.com> --- drivers/scsi/scsi_lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)