Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: no need to initialize rq->cmd with blk_get_request

blk_get_request initializes rq->cmd (rq_init does) so the users don't
need to do that.

The purpose of this patch is to remove sizeof(rq->cmd) and &rq->cmd,
as a preparation for large command support, which changes rq->cmd from
the static array to a pointer. sizeof(rq->cmd) will not make sense and
&rq->cmd won't work.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

authored by

FUJITA Tomonori and committed by
Jens Axboe
992b5bce 4917fa29

-10
-3
block/scsi_ioctl.c
··· 217 217 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq, 218 218 struct sg_io_hdr *hdr, int has_write_perm) 219 219 { 220 - memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ 221 - 222 220 if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len)) 223 221 return -EFAULT; 224 222 if (blk_verify_command(rq->cmd, has_write_perm)) ··· 529 531 rq->data_len = 0; 530 532 rq->extra_len = 0; 531 533 rq->timeout = BLK_DEFAULT_SG_TIMEOUT; 532 - memset(rq->cmd, 0, sizeof(rq->cmd)); 533 534 rq->cmd[0] = cmd; 534 535 rq->cmd[4] = data; 535 536 rq->cmd_len = 6;
-2
drivers/block/pktcdvd.c
··· 776 776 777 777 rq->cmd_len = COMMAND_SIZE(cgc->cmd[0]); 778 778 memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE); 779 - if (sizeof(rq->cmd) > CDROM_PACKET_SIZE) 780 - memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); 781 779 782 780 rq->timeout = 60*HZ; 783 781 rq->cmd_type = REQ_TYPE_BLOCK_PC;
-1
drivers/cdrom/cdrom.c
··· 2194 2194 if (ret) 2195 2195 break; 2196 2196 2197 - memset(rq->cmd, 0, sizeof(rq->cmd)); 2198 2197 rq->cmd[0] = GPCMD_READ_CD; 2199 2198 rq->cmd[1] = 1 << 2; 2200 2199 rq->cmd[2] = (lba >> 24) & 0xff;
-2
drivers/md/dm-emc.c
··· 110 110 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); 111 111 rq->sense_len = 0; 112 112 113 - memset(&rq->cmd, 0, BLK_MAX_CDB); 114 - 115 113 rq->timeout = EMC_FAILOVER_TIMEOUT; 116 114 rq->cmd_type = REQ_TYPE_BLOCK_PC; 117 115 rq->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE;
-1
drivers/md/dm-mpath-hp-sw.c
··· 137 137 req->sense = h->sense; 138 138 memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); 139 139 140 - memset(&req->cmd, 0, BLK_MAX_CDB); 141 140 req->cmd[0] = START_STOP; 142 141 req->cmd[4] = 1; 143 142 req->cmd_len = COMMAND_SIZE(req->cmd[0]);
-1
drivers/md/dm-mpath-rdac.c
··· 284 284 return NULL; 285 285 } 286 286 287 - memset(&rq->cmd, 0, BLK_MAX_CDB); 288 287 rq->sense = h->sense; 289 288 memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); 290 289 rq->sense_len = 0;