]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
scsi: restructure command initialization for TYPE_FS requests
authorChristoph Hellwig <hch@lst.de>
Sat, 28 Jun 2014 09:58:42 +0000 (11:58 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 17 Jul 2014 20:11:27 +0000 (22:11 +0200)
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>
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c
drivers/scsi/sr.c
include/scsi/scsi_driver.h

index 150d7bb675a1ce505e475edcf2cdbb7c721f4d76..2afb96b801cb343b46672733edca7211a5b9d5df 100644 (file)
@@ -1082,11 +1082,10 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
 EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd);
 
 /*
- * Setup a REQ_TYPE_FS command.  These are simple read/write request
- * from filesystems that still need to be translated to SCSI CDBs from
- * the ULD.
+ * Setup a REQ_TYPE_FS command.  These are simple request from filesystems
+ * that still need to be translated to SCSI CDBs from the ULD.
  */
-int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
+static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
 {
        struct scsi_cmnd *cmd = req->special;
 
@@ -1098,9 +1097,8 @@ int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
        }
 
        memset(cmd->cmnd, 0, BLK_MAX_CDB);
-       return scsi_init_io(cmd, GFP_ATOMIC);
+       return scsi_cmd_to_driver(cmd)->init_command(cmd);
 }
-EXPORT_SYMBOL(scsi_setup_fs_cmnd);
 
 static int
 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)
                goto out;
        }
 
-       if (req->cmd_type == REQ_TYPE_FS)
-               ret = scsi_cmd_to_driver(cmd)->init_command(cmd);
-       else if (req->cmd_type == REQ_TYPE_BLOCK_PC)
+       switch (req->cmd_type) {
+       case REQ_TYPE_FS:
+               ret = scsi_setup_fs_cmnd(sdev, req);
+               break;
+       case REQ_TYPE_BLOCK_PC:
                ret = scsi_setup_blk_pc_cmnd(sdev, req);
-       else
+               break;
+       default:
                ret = BLKPREP_KILL;
+       }
 
 out:
        return scsi_prep_return(q, req, ret);
index 87566b51fcf7bdd269b7dbf626cda570599b0ca1..1b166c7ea891dbed292b584378974ec72bd3684a 100644 (file)
@@ -894,7 +894,7 @@ static int sd_init_command(struct scsi_cmnd *SCpnt)
                ret = scsi_setup_flush_cmnd(sdp, rq);
                goto out;
        }
-       ret = scsi_setup_fs_cmnd(sdp, rq);
+       ret = scsi_init_io(SCpnt, GFP_ATOMIC);
        if (ret != BLKPREP_OK)
                goto out;
        SCpnt = rq->special;
index a7ea27c012869bbbc8b04290b9b62d94d081b3fd..9feeb3766d7dc2fe24906005e746e4dc5f12bbe7 100644 (file)
@@ -385,10 +385,9 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
        int block = 0, this_count, s_size;
        struct scsi_cd *cd;
        struct request *rq = SCpnt->request;
-       struct scsi_device *sdp = SCpnt->device;
        int ret;
 
-       ret = scsi_setup_fs_cmnd(sdp, rq);
+       ret = scsi_init_io(SCpnt, GFP_ATOMIC);
        if (ret != BLKPREP_OK)
                goto out;
        SCpnt = rq->special;
index 36c4114ed9bc2ce47dfab7b5beb79e2a64a68aa5..009d2ae91a522ad123955930e4e0483e4c32453e 100644 (file)
@@ -30,6 +30,5 @@ extern int scsi_register_interface(struct class_interface *);
        class_interface_unregister(intf)
 
 int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req);
-int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req);
 
 #endif /* _SCSI_SCSI_DRIVER_H */