Skip to content

Commit 3868cf8

Browse files
author
Christoph Hellwig
committed
scsi: restructure command initialization for TYPE_FS requests
We should call the device handler prep_fn for all TYPE_FS requests, not just simple read/write calls that are handled by the disk driver. Restructure the common I/O code to call the prep_fn handler and zero out the CDB, and just leave the call to scsi_init_io to the ULDs. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de>
1 parent 635d98b commit 3868cf8

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎drivers/scsi/scsi_lib.c‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,11 +1082,10 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
10821082
EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd);
10831083

10841084
/*
1085-
* Setup a REQ_TYPE_FS command. These are simple read/write request
1086-
* from filesystems that still need to be translated to SCSI CDBs from
1087-
* the ULD.
1085+
* Setup a REQ_TYPE_FS command. These are simple request from filesystems
1086+
* that still need to be translated to SCSI CDBs from the ULD.
10881087
*/
1089-
int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
1088+
static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
10901089
{
10911090
struct scsi_cmnd *cmd = req->special;
10921091

@@ -1098,9 +1097,8 @@ int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
10981097
}
10991098

11001099
memset(cmd->cmnd, 0, BLK_MAX_CDB);
1101-
return scsi_init_io(cmd, GFP_ATOMIC);
1100+
return scsi_cmd_to_driver(cmd)->init_command(cmd);
11021101
}
1103-
EXPORT_SYMBOL(scsi_setup_fs_cmnd);
11041102

11051103
static int
11061104
scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
@@ -1205,12 +1203,16 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
12051203
goto out;
12061204
}
12071205

1208-
if (req->cmd_type == REQ_TYPE_FS)
1209-
ret = scsi_cmd_to_driver(cmd)->init_command(cmd);
1210-
else if (req->cmd_type == REQ_TYPE_BLOCK_PC)
1206+
switch (req->cmd_type) {
1207+
case REQ_TYPE_FS:
1208+
ret = scsi_setup_fs_cmnd(sdev, req);
1209+
break;
1210+
case REQ_TYPE_BLOCK_PC:
12111211
ret = scsi_setup_blk_pc_cmnd(sdev, req);
1212-
else
1212+
break;
1213+
default:
12131214
ret = BLKPREP_KILL;
1215+
}
12141216

12151217
out:
12161218
return scsi_prep_return(q, req, ret);

‎drivers/scsi/sd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ static int sd_init_command(struct scsi_cmnd *SCpnt)
894894
ret = scsi_setup_flush_cmnd(sdp, rq);
895895
goto out;
896896
}
897-
ret = scsi_setup_fs_cmnd(sdp, rq);
897+
ret = scsi_init_io(SCpnt, GFP_ATOMIC);
898898
if (ret != BLKPREP_OK)
899899
goto out;
900900
SCpnt = rq->special;

‎drivers/scsi/sr.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,9 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
385385
int block = 0, this_count, s_size;
386386
struct scsi_cd *cd;
387387
struct request *rq = SCpnt->request;
388-
struct scsi_device *sdp = SCpnt->device;
389388
int ret;
390389

391-
ret = scsi_setup_fs_cmnd(sdp, rq);
390+
ret = scsi_init_io(SCpnt, GFP_ATOMIC);
392391
if (ret != BLKPREP_OK)
393392
goto out;
394393
SCpnt = rq->special;

‎include/scsi/scsi_driver.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ extern int scsi_register_interface(struct class_interface *);
3030
class_interface_unregister(intf)
3131

3232
int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req);
33-
int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req);
3433

3534
#endif /* _SCSI_SCSI_DRIVER_H */

0 commit comments

Comments
 (0)