Commit 5999ccff authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: sd: Use scsi_cmd_to_rq() instead of scsi_cmnd.request

Prepare for removal of the request pointer by using scsi_cmd_to_rq()
instead. This patch does not change any functionality.

Link: https://lore.kernel.org/r/20210809230355.8186-4-bvanassche@acm.org
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Ming Lei <ming.lei@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent aa8e25e5
...@@ -776,8 +776,9 @@ static unsigned int sd_prot_flag_mask(unsigned int prot_op) ...@@ -776,8 +776,9 @@ static unsigned int sd_prot_flag_mask(unsigned int prot_op)
static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd, static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
unsigned int dix, unsigned int dif) unsigned int dix, unsigned int dif)
{ {
struct bio *bio = scmd->request->bio; struct request *rq = scsi_cmd_to_rq(scmd);
unsigned int prot_op = sd_prot_op(rq_data_dir(scmd->request), dix, dif); struct bio *bio = rq->bio;
unsigned int prot_op = sd_prot_op(rq_data_dir(rq), dix, dif);
unsigned int protect = 0; unsigned int protect = 0;
if (dix) { /* DIX Type 0, 1, 2, 3 */ if (dix) { /* DIX Type 0, 1, 2, 3 */
...@@ -868,7 +869,7 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) ...@@ -868,7 +869,7 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd) static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)
{ {
struct scsi_device *sdp = cmd->device; struct scsi_device *sdp = cmd->device;
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq)); u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq));
u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
...@@ -904,7 +905,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, ...@@ -904,7 +905,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,
bool unmap) bool unmap)
{ {
struct scsi_device *sdp = cmd->device; struct scsi_device *sdp = cmd->device;
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq)); u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq));
u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
...@@ -936,7 +937,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, ...@@ -936,7 +937,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
bool unmap) bool unmap)
{ {
struct scsi_device *sdp = cmd->device; struct scsi_device *sdp = cmd->device;
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq)); u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq));
u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq)); u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
...@@ -966,7 +967,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, ...@@ -966,7 +967,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_device *sdp = cmd->device; struct scsi_device *sdp = cmd->device;
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq)); u64 lba = sectors_to_logical(sdp, blk_rq_pos(rq));
...@@ -1063,7 +1064,7 @@ static void sd_config_write_same(struct scsi_disk *sdkp) ...@@ -1063,7 +1064,7 @@ static void sd_config_write_same(struct scsi_disk *sdkp)
**/ **/
static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_device *sdp = cmd->device; struct scsi_device *sdp = cmd->device;
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
struct bio *bio = rq->bio; struct bio *bio = rq->bio;
...@@ -1112,7 +1113,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) ...@@ -1112,7 +1113,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd) static blk_status_t sd_setup_flush_cmnd(struct scsi_cmnd *cmd)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
/* flush requests don't perform I/O, zero the S/G table */ /* flush requests don't perform I/O, zero the S/G table */
...@@ -1210,7 +1211,7 @@ static blk_status_t sd_setup_rw6_cmnd(struct scsi_cmnd *cmd, bool write, ...@@ -1210,7 +1211,7 @@ static blk_status_t sd_setup_rw6_cmnd(struct scsi_cmnd *cmd, bool write,
static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_device *sdp = cmd->device; struct scsi_device *sdp = cmd->device;
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
sector_t lba = sectors_to_logical(sdp, blk_rq_pos(rq)); sector_t lba = sectors_to_logical(sdp, blk_rq_pos(rq));
...@@ -1324,7 +1325,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) ...@@ -1324,7 +1325,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
static blk_status_t sd_init_command(struct scsi_cmnd *cmd) static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
switch (req_op(rq)) { switch (req_op(rq)) {
case REQ_OP_DISCARD: case REQ_OP_DISCARD:
...@@ -1370,7 +1371,7 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd) ...@@ -1370,7 +1371,7 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
static void sd_uninit_command(struct scsi_cmnd *SCpnt) static void sd_uninit_command(struct scsi_cmnd *SCpnt)
{ {
struct request *rq = SCpnt->request; struct request *rq = scsi_cmd_to_rq(SCpnt);
u8 *cmnd; u8 *cmnd;
if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
...@@ -1875,7 +1876,7 @@ static const struct block_device_operations sd_fops = { ...@@ -1875,7 +1876,7 @@ static const struct block_device_operations sd_fops = {
**/ **/
static void sd_eh_reset(struct scsi_cmnd *scmd) static void sd_eh_reset(struct scsi_cmnd *scmd)
{ {
struct scsi_disk *sdkp = scsi_disk(scmd->request->rq_disk); struct scsi_disk *sdkp = scsi_disk(scsi_cmd_to_rq(scmd)->rq_disk);
/* New SCSI EH run, reset gate variable */ /* New SCSI EH run, reset gate variable */
sdkp->ignore_medium_access_errors = false; sdkp->ignore_medium_access_errors = false;
...@@ -1895,7 +1896,7 @@ static void sd_eh_reset(struct scsi_cmnd *scmd) ...@@ -1895,7 +1896,7 @@ static void sd_eh_reset(struct scsi_cmnd *scmd)
**/ **/
static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp) static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp)
{ {
struct scsi_disk *sdkp = scsi_disk(scmd->request->rq_disk); struct scsi_disk *sdkp = scsi_disk(scsi_cmd_to_rq(scmd)->rq_disk);
struct scsi_device *sdev = scmd->device; struct scsi_device *sdev = scmd->device;
if (!scsi_device_online(sdev) || if (!scsi_device_online(sdev) ||
...@@ -1936,7 +1937,7 @@ static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp) ...@@ -1936,7 +1937,7 @@ static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp)
static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
{ {
struct request *req = scmd->request; struct request *req = scsi_cmd_to_rq(scmd);
struct scsi_device *sdev = scmd->device; struct scsi_device *sdev = scmd->device;
unsigned int transferred, good_bytes; unsigned int transferred, good_bytes;
u64 start_lba, end_lba, bad_lba; u64 start_lba, end_lba, bad_lba;
...@@ -1991,8 +1992,8 @@ static int sd_done(struct scsi_cmnd *SCpnt) ...@@ -1991,8 +1992,8 @@ static int sd_done(struct scsi_cmnd *SCpnt)
unsigned int sector_size = SCpnt->device->sector_size; unsigned int sector_size = SCpnt->device->sector_size;
unsigned int resid; unsigned int resid;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); struct request *req = scsi_cmd_to_rq(SCpnt);
struct request *req = SCpnt->request; struct scsi_disk *sdkp = scsi_disk(req->rq_disk);
int sense_valid = 0; int sense_valid = 0;
int sense_deferred = 0; int sense_deferred = 0;
......
...@@ -243,7 +243,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, ...@@ -243,7 +243,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
static blk_status_t sd_zbc_cmnd_checks(struct scsi_cmnd *cmd) static blk_status_t sd_zbc_cmnd_checks(struct scsi_cmnd *cmd)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
sector_t sector = blk_rq_pos(rq); sector_t sector = blk_rq_pos(rq);
...@@ -321,7 +321,7 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) ...@@ -321,7 +321,7 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
unsigned int nr_blocks) unsigned int nr_blocks)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
unsigned int wp_offset, zno = blk_rq_zone_no(rq); unsigned int wp_offset, zno = blk_rq_zone_no(rq);
unsigned long flags; unsigned long flags;
...@@ -386,7 +386,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, ...@@ -386,7 +386,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd, blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
unsigned char op, bool all) unsigned char op, bool all)
{ {
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
sector_t sector = blk_rq_pos(rq); sector_t sector = blk_rq_pos(rq);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
sector_t block = sectors_to_logical(sdkp->device, sector); sector_t block = sectors_to_logical(sdkp->device, sector);
...@@ -442,7 +442,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd, ...@@ -442,7 +442,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
unsigned int good_bytes) unsigned int good_bytes)
{ {
int result = cmd->result; int result = cmd->result;
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
unsigned int zno = blk_rq_zone_no(rq); unsigned int zno = blk_rq_zone_no(rq);
enum req_opf op = req_op(rq); enum req_opf op = req_op(rq);
...@@ -516,7 +516,7 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, ...@@ -516,7 +516,7 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
struct scsi_sense_hdr *sshdr) struct scsi_sense_hdr *sshdr)
{ {
int result = cmd->result; int result = cmd->result;
struct request *rq = cmd->request; struct request *rq = scsi_cmd_to_rq(cmd);
if (op_is_zone_mgmt(req_op(rq)) && if (op_is_zone_mgmt(req_op(rq)) &&
result && result &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment