SCSI patches for kernel v4.13.
Subsystems (17)
cover SCSI patches for kernel v4.13.
Hello Martin,
This patch series consists of the bug fixes I came up with during the past two months. Please consider these patches for kernel v4.13.
Thanks,
Bart.
Bart Van Assche (31):
Split scsi_internal_device_block()
Create two versions of scsi_internal_device_unblock() Protect SCSI device state changes with a mutex
Introduce scsi_start_queue()
Make __scsi_remove_device go straight from BLOCKED to DEL scmd_eh_abort_handler(): Add a comment
scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command
pointer
sd, sr: Convert two assignments into warning statements
block: Avoid that blk_exit_rl() triggers a use-after-free Avoid that scsi_exit_rq() triggers a use-after-free
block: Introduce queue flag QUEUE_FLAG_SCSI_SUP
bsg: Check queue type before attaching to a queue
pktcdvd: Check queue type before attaching to a queue
cdrom: Check private request size before attaching to a queue
nfsd: Check private request size before submitting a SCSI request
scsi: Make scsi_ioctl_reset() pass the request queue pointer to
blk_rq_init()
block: Introduce request_queue.initialize_rq_fn()
block: Make scsi_req_init() calls implicit
scsi: Change argument type of scsi_req_init()
scsi: Only add commands to the device command list if required by the
LLD
scsi: Move most of scsi_init_command() into scsi_initialize_rq()
scsi: Inline scsi_init_command()
scsi: Move sense buffer pointer initialization into
scsi_initialize_rq()
scsi: Make scsi_initialize_rq() zero the entire struct scsi_cmnd
scsi-mq: Make behavior scsi_mq_prep_fn() closer to that of
scsi_prep_fn() scsi: Move the code for clearing private command data into
scsi_dispatch_cmd()
scsi: Consolidate more initialization code scsi_setup_fs_cmnd(): Call scsi_req_init() instead of open-coding it
scsi: snic: Remove code that zeroes driver-private command data
scsi: virtio: Remove code that zeroes driver-private command data xen/scsifront: Remove code that zeroes driver-private command data
block/blk-cgroup.c | 2 +- block/blk-core.c | 13 +- block/blk-mq.c | 3 + block/blk-sysfs.c | 2 +- block/blk.h | 2 +- block/bsg-lib.c | 1 + block/bsg.c | 7 +- block/scsi_ioctl.c | 13 +- drivers/block/cciss.c | 1 + drivers/block/pktcdvd.c | 6 +- drivers/cdrom/cdrom.c | 5 +- drivers/ide/ide-atapi.c | 2 - drivers/ide/ide-cd.c | 1 - drivers/ide/ide-cd_ioctl.c | 1 - drivers/ide/ide-devsets.c | 1 - drivers/ide/ide-disk.c | 1 - drivers/ide/ide-ioctls.c | 2 - drivers/ide/ide-park.c | 2 - drivers/ide/ide-pm.c | 2 - drivers/ide/ide-probe.c | 7 +- drivers/ide/ide-tape.c | 1 - drivers/ide/ide-taskfile.c | 1 - drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 +- drivers/scsi/osd/osd_initiator.c | 2 - drivers/scsi/osst.c | 1 - drivers/scsi/scsi.c | 9 +- drivers/scsi/scsi_error.c | 26 ++- drivers/scsi/scsi_lib.c | 327 +++++++++++++++++++++-------------- drivers/scsi/scsi_priv.h | 4 +- drivers/scsi/scsi_scan.c | 16 +- drivers/scsi/scsi_sysfs.c | 37 +++- drivers/scsi/scsi_transport_sas.c | 7 + drivers/scsi/scsi_transport_srp.c | 7 +- drivers/scsi/sd.c | 9 +- drivers/scsi/sg.c | 2 - drivers/scsi/snic/snic_scsi.c | 2 - drivers/scsi/sr.c | 2 +- drivers/scsi/st.c | 1 - drivers/scsi/virtio_scsi.c | 1 - drivers/scsi/xen-scsifront.c | 1 - drivers/target/target_core_pscsi.c | 2 - fs/nfsd/blocklayout.c | 4 +- include/linux/blkdev.h | 6 + include/scsi/scsi_cmnd.h | 1 + include/scsi/scsi_device.h | 7 +- include/scsi/scsi_request.h | 2 +- include/scsi/scsi_tcq.h | 2 +- 47 files changed, 345 insertions(+), 217 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/31 Split scsi_internal_device_block()
Instead of passing a "wait" argument to scsi_internal_device_block(), split this function into a function that waits and a function that doesn't wait. This will make it easier to serialize SCSI device state changes through a mutex.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +- drivers/scsi/scsi_lib.c | 73 +++++++++++++++++++++++------------- include/scsi/scsi_device.h | 2 +- 3 files changed, 50 insertions(+), 29 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +2 -2
@@ -2859,7 +2859,7 @@ _scsih_internal_device_block(struct scsi_device *sdev, sas_device_priv_data->sas_target->handle); sas_device_priv_data->block =1 ; - r =scsi_internal_device_block (sdev, false); + r =scsi_internal_device_block_nowait (sdev);if (r == -EINVAL ) sdev_printk(KERN_WARNING, sdev, "device_block failed with return(%d) for handle(0x%04x)\n",
@@ -2895,7 +2895,7 @@ _scsih_internal_device_unblock(struct scsi_device *sdev,"performing a block followed by an unblock\n" , r, sas_device_priv_data->sas_target->handle); sas_device_priv_data->block =1 ; - r =scsi_internal_device_block (sdev, false); + r =scsi_internal_device_block_nowait (sdev);if (r) sdev_printk(KERN_WARNING, sdev, "retried device_block " "failed with return(%d) for handle(0x%04x)\n",
drivers/scsi/scsi_lib.c +47 -26
103 lines not on this page · raw message
include/scsi/scsi_device.h +1 -1
@@ -472,7 +472,7 @@ static inline int scsi_device_created(struct scsi_device *sdev) sdev->sdev_state ==SDEV_CREATED_BLOCK ; } -int scsi_internal_device_block (struct scsi_device *sdev,bool wait); +int scsi_internal_device_block_nowait (struct scsi_device *sdev);int scsi_internal_device_unblock (struct scsi_device *sdev,enum scsi_device_state new_state);
Signature · 1 line
2.12.2
Re: [PATCH 01/31] Split scsi_internal_device_block()
Quoted 10 lines · Bart Van Assche
Instead of passing a "wait" argument to
scsi_internal_device_block(), split this function into a function that waits and a function that doesn't wait. This will make it easier to serialize SCSI device state changes through a mutex.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Sreekanth Reddy <[email protected]>
Quoted 6 lines
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +- drivers/scsi/scsi_lib.c | 73 +++++++++++++++++++++++------------- include/scsi/scsi_device.h | 2 +- 3 files changed, 50 insertions(+), 29 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 01/31] Split scsi_internal_device_block()
In reply to Bart Van AsscheQuoted 11 lines · Bart Van Assche
Instead of passing a "wait" argument to
scsi_internal_device_block(), split this function into a function that waits and a function that doesn't wait. This will make it easier to serialize SCSI device state changes through a mutex.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Sreekanth Reddy <[email protected]>---
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 2/31 Create two versions of scsi_internal_device_unblock()
In reply to Bart Van AsscheThis will make it easier to serialize SCSI device state changes through a mutex.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- drivers/scsi/scsi_lib.c | 46 +++++++++++++++++++++++++----------- include/scsi/scsi_device.h | 4 ++-- 3 files changed, 36 insertions(+), 18 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +2 -2
@@ -2883,7 +2883,7 @@ _scsih_internal_device_unblock(struct scsi_device *sdev,sdev_printk (KERN_WARNING , sdev,"device_unblock and setting to running, " "handle(0x%04x)\n" , sas_device_priv_data->sas_target->handle); sas_device_priv_data->block =0 ; - r =scsi_internal_device_unblock (sdev,SDEV_RUNNING ); + r =scsi_internal_device_unblock_nowait (sdev,SDEV_RUNNING );if (r == -EINVAL ) {/* The device has been set to SDEV_RUNNING by SD layer during * device addition but the request queue is still stopped by
@@ -2902,7 +2902,7 @@ _scsih_internal_device_unblock(struct scsi_device *sdev, r, sas_device_priv_data->sas_target->handle); sas_device_priv_data->block =0 ; - r =scsi_internal_device_unblock (sdev,SDEV_RUNNING ); + r =scsi_internal_device_unblock_nowait (sdev,SDEV_RUNNING );if (r) sdev_printk(KERN_WARNING, sdev, "retried device_unblock" " failed with return(%d) for handle(0x%04x)\n",
drivers/scsi/scsi_lib.c +32 -14
63 lines not on this page · raw message
include/scsi/scsi_device.h +2 -2
@@ -473,8 +473,8 @@ static inline int scsi_device_created(struct scsi_device *sdev) }int scsi_internal_device_block_nowait (struct scsi_device *sdev); -int scsi_internal_device_unblock (struct scsi_device *sdev, -enum scsi_device_state new_state); +int scsi_internal_device_unblock_nowait (struct scsi_device *sdev, +enum scsi_device_state new_state);/* accessor functions for the SCSI parameters */ static inline int scsi_device_sync (struct scsi_device *sdev)
Signature · 1 line
2.12.2
Re: [PATCH 02/31] Create two versions of scsi_internal_device_unblock()
Quoted 8 lines · Bart Van Assche
This will make it easier to serialize SCSI device state changes through a mutex.
Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Sreekanth Reddy <[email protected]>
Quoted 6 lines
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- drivers/scsi/scsi_lib.c | 46 +++++++++++++++++++++++++----------- include/scsi/scsi_device.h | 4 ++-- 3 files changed, 36 insertions(+), 18 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 02/31] Create two versions of scsi_internal_device_unblock()
In reply to Bart Van AsscheQuoted 9 lines · Bart Van Assche
This will make it easier to serialize SCSI device state changes through a mutex.
Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>Cc Sreekanth Reddy <[email protected]>---
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 3/31 Protect SCSI device state changes with a mutex
In reply to Bart Van AsscheEnable this mechanism for all scsi_target_*block() callers but not for the scsi_internal_device_unblock() calls from the mpt3sas driver because that driver can call scsi_internal_device_unblock() from atomic context.
--- drivers/scsi/scsi_error.c | 8 +++++++- drivers/scsi/scsi_lib.c | 27 +++++++++++++++++++++------ drivers/scsi/scsi_scan.c | 16 +++++++++------- drivers/scsi/scsi_sysfs.c | 24 +++++++++++++++++++----- drivers/scsi/scsi_transport_srp.c | 7 ++++--- drivers/scsi/sd.c | 7 +++++-- include/scsi/scsi_device.h | 1 + 7 files changed, 66 insertions(+), 24 deletions(-)
drivers/scsi/scsi_error.c +7 -1
@@ -1628,11 +1628,17 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q, struct list_head *done_q) {struct scsi_cmnd *scmd, *next; +struct scsi_device *sdev;list_for_each_entry_safe (scmd, next, work_q, eh_entry) {sdev_printk (KERN_INFO , scmd->device,"Device offlined - " "not ready after error recovery\n" ); -scsi_device_set_state (scmd->device,SDEV_OFFLINE ); + sdev = scmd->device; + +mutex_lock (&sdev->state_mutex); +scsi_device_set_state (sdev,SDEV_OFFLINE ); +mutex_unlock (&sdev->state_mutex); +scsi_eh_finish_cmd (scmd, done_q); }return ;
drivers/scsi/scsi_lib.c +21 -6
@@ -2870,7 +2870,12 @@ static void scsi_wait_for_queuecommand(struct scsi_device *sdev)int scsi_device_quiesce (struct scsi_device *sdev) { -int err =scsi_device_set_state (sdev,SDEV_QUIESCE ); +int err; + +mutex_lock (&sdev->state_mutex); + err =scsi_device_set_state (sdev,SDEV_QUIESCE ); +mutex_unlock (&sdev->state_mutex); +if (err)return err;
@@ -2898,10 +2903,11 @@ void scsi_device_resume(struct scsi_device *sdev)* so assume the state is being managed elsewhere (for example * device deleted during suspend) */ -if (sdev->sdev_state !=SDEV_QUIESCE || -scsi_device_set_state (sdev,SDEV_RUNNING )) -return ; -scsi_run_queue (sdev->request_queue); +mutex_lock (&sdev->state_mutex); +if (sdev->sdev_state ==SDEV_QUIESCE && +scsi_device_set_state (sdev,SDEV_RUNNING ) ==0 ) +scsi_run_queue (sdev->request_queue); +mutex_unlock (&sdev->state_mutex); }EXPORT_SYMBOL (scsi_device_resume);
@@ -3000,6 +3006,7 @@ static int scsi_internal_device_block(struct scsi_device *sdev)struct request_queue *q = sdev->request_queue;int err; +mutex_lock (&sdev->state_mutex); err =scsi_internal_device_block_nowait (sdev);if (err ==0 ) {if (q->mq_ops)
@@ -3007,6 +3014,8 @@ static int scsi_internal_device_block(struct scsi_device *sdev)else scsi_wait_for_queuecommand (sdev); } +mutex_unlock (&sdev->state_mutex); +return err; }
@@ -3077,7 +3086,13 @@ EXPORT_SYMBOL_GPL(scsi_internal_device_unblock_nowait);static int scsi_internal_device_unblock (struct scsi_device *sdev,enum scsi_device_state new_state) { -return scsi_internal_device_unblock_nowait (sdev, new_state); +int ret; + +mutex_lock (&sdev->state_mutex); + ret =scsi_internal_device_unblock_nowait (sdev, new_state); +mutex_unlock (&sdev->state_mutex); + +return ret; } static void
drivers/scsi/scsi_scan.c +9 -7
@@ -231,6 +231,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, sdev->id = starget->id; sdev->lun = lun; sdev->channel = starget->channel; +mutex_init (&sdev->state_mutex); sdev->sdev_state =SDEV_CREATED ;INIT_LIST_HEAD (&sdev->siblings);INIT_LIST_HEAD (&sdev->same_target_siblings);
@@ -943,16 +944,17 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,/* set the device running here so that slave configure * may do I/O */ +mutex_lock (&sdev->state_mutex); ret =scsi_device_set_state (sdev,SDEV_RUNNING ); -if (ret) { +if (ret) ret =scsi_device_set_state (sdev,SDEV_BLOCK ); +mutex_unlock (&sdev->state_mutex); -if (ret) { -sdev_printk (KERN_ERR , sdev, -"in wrong state %s to complete scan\n" , -scsi_device_state_name (sdev->sdev_state)); -return SCSI_SCAN_NO_RESPONSE ; - } +if (ret) { +sdev_printk (KERN_ERR , sdev, +"in wrong state %s to complete scan\n" , +scsi_device_state_name (sdev->sdev_state)); +return SCSI_SCAN_NO_RESPONSE ; }if (*bflags &BLIST_MS_192_BYTES_FOR_3F )
drivers/scsi/scsi_sysfs.c +19 -5
@@ -719,7 +719,7 @@ static ssize_t store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int i; + int i, ret;struct scsi_device *sdev =to_scsi_device (dev);enum scsi_device_state state =0 ;
@@ -734,9 +734,11 @@ store_state_field(struct device *dev, struct device_attribute *attr,if (!state)return -EINVAL ; -if (scsi_device_set_state (sdev, state)) -return -EINVAL ; -return count; +mutex_lock (&sdev->state_mutex); + ret =scsi_device_set_state (sdev, state); +mutex_unlock (&sdev->state_mutex); + +return ret ==0 ? count : -EINVAL ; } static ssize_t
@@ -1272,6 +1274,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)void __scsi_remove_device (struct scsi_device *sdev) {struct device *dev = &sdev->sdev_gendev; +int res;/* * This cleanup path is not reentrant and while it is impossible
@@ -1282,7 +1285,15 @@ void __scsi_remove_device(struct scsi_device *sdev)return ;if (sdev->is_visible) { -if (scsi_device_set_state (sdev,SDEV_CANCEL ) !=0 ) +/* +* If scsi_internal_target_block() is running concurrently, +* wait until it has finished before changing the device state. +*/ +mutex_lock (&sdev->state_mutex); + res =scsi_device_set_state (sdev,SDEV_CANCEL ); +mutex_unlock (&sdev->state_mutex); + +if (res !=0 )return ;bsg_unregister_queue (sdev->request_queue);
@@ -1298,7 +1309,10 @@ void __scsi_remove_device(struct scsi_device *sdev)* scsi_run_queue() invocations have finished before tearing down the * device. */ +mutex_lock (&sdev->state_mutex);scsi_device_set_state (sdev,SDEV_DEL ); +mutex_unlock (&sdev->state_mutex); +blk_cleanup_queue (sdev->request_queue);cancel_work_sync (&sdev->requeue_work);
drivers/scsi/scsi_transport_srp.c +4 -3
@@ -554,11 +554,12 @@ int srp_reconnect_rport(struct srp_rport *rport)* invoking scsi_target_unblock() won't change the state of * these devices into running so do that explicitly. */ -spin_lock_irq (shost->host_lock); -__shost_for_each_device (sdev, shost) +shost_for_each_device (sdev, shost) { +mutex_lock (&sdev->state_mutex);if (sdev->sdev_state ==SDEV_OFFLINE ) sdev->sdev_state =SDEV_RUNNING ; -spin_unlock_irq (shost->host_lock); +mutex_unlock (&sdev->state_mutex); + } }else if (rport->state ==SRP_RPORT_RUNNING ) {/* * srp_reconnect_rport() has been invoked with fast_io_fail
drivers/scsi/sd.c +5 -2
@@ -1798,8 +1798,9 @@ static void sd_eh_reset(struct scsi_cmnd *scmd)static int sd_eh_action (struct scsi_cmnd *scmd,int eh_disp) {struct scsi_disk *sdkp =scsi_disk (scmd->request->rq_disk); +struct scsi_device *sdev = scmd->device; -if (!scsi_device_online (scmd->device) || +if (!scsi_device_online (sdev) || !scsi_medium_access_command (scmd) ||host_byte (scmd->result) !=DID_TIME_OUT || eh_disp !=SUCCESS )
@@ -1825,7 +1826,9 @@ static int sd_eh_action(struct scsi_cmnd *scmd, int eh_disp)if (sdkp->medium_access_timed_out >= sdkp->max_medium_access_timeouts) {scmd_printk (KERN_ERR , scmd,"Medium access timeout failure. Offlining disk!\n" ); -scsi_device_set_state (scmd->device,SDEV_OFFLINE ); +mutex_lock (&sdev->state_mutex); +scsi_device_set_state (sdev,SDEV_OFFLINE ); +mutex_unlock (&sdev->state_mutex);return SUCCESS ; }
include/scsi/scsi_device.h +1 -0
@@ -207,6 +207,7 @@ struct scsi_device {void *handler_data;unsigned char access_state; +struct mutex state_mutex;enum scsi_device_state sdev_state;unsigned long sdev_data[0 ]; } __attribute__((aligned(sizeof(unsigned long))));
Signature · 1 line
2.12.2
Re: [PATCH 03/31] Protect SCSI device state changes with a mutex
Quoted 19 lines · Bart Van Assche
Enable this mechanism for all scsi_target_*block() callers but not for the
scsi_internal_device_unblock()calls from the mpt3sas driver because that driver can callscsi_internal_device_unblock()from atomic context.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>--- drivers/scsi/scsi_error.c | 8 +++++++- drivers/scsi/scsi_lib.c | 27 +++++++++++++++++++++------ drivers/scsi/scsi_scan.c | 16 +++++++++------- drivers/scsi/scsi_sysfs.c | 24 +++++++++++++++++++----- drivers/scsi/scsi_transport_srp.c | 7 ++++--- drivers/scsi/sd.c | 7 +++++-- include/scsi/scsi_device.h | 1 + 7 files changed, 66 insertions(+), 24 deletions(-)
[ .. ]
Quoted 10 lines
drivers/scsi/scsi_transport_srp.c +0
-2@@ -554,11 +554,12 @@ int srp_reconnect_rport(struct srp_rport *rport)* invoking scsi_target_unblock() won't change the state of * these devices into running so do that explicitly. */ -spin_lock_irq (shost->host_lock); -__shost_for_each_device (sdev, shost)
drivers/scsi/scsi_transport_srp.c int srp_reconnect_rport(struct srp_rport *rport) · line 565
Quoted 10 lines
drivers/scsi/scsi_transport_srp.c +4
-1+shost_for_each_device (sdev, shost) { +mutex_lock (&sdev->state_mutex);if (sdev->sdev_state ==SDEV_OFFLINE ) sdev->sdev_state =SDEV_RUNNING ; -spin_unlock_irq (shost->host_lock); +mutex_unlock (&sdev->state_mutex); + } }else if (rport->state ==SRP_RPORT_RUNNING ) {/* * srp_reconnect_rport() has been invoked with fast_io_fail
Why do you drop the host lock here? I thought that the host lock is needed to protect shost_for_each_device()?
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 03/31] Protect SCSI device state changes with a mutex
Quoted 37 lines · Hannes Reinecke
Quoted 19 lines · Bart Van Assche
Enable this mechanism for all scsi_target_*block() callers but not for the
scsi_internal_device_unblock()calls from the mpt3sas driver because that driver can callscsi_internal_device_unblock()from atomic context.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>--- drivers/scsi/scsi_error.c | 8 +++++++- drivers/scsi/scsi_lib.c | 27 +++++++++++++++++++++------ drivers/scsi/scsi_scan.c | 16 +++++++++------- drivers/scsi/scsi_sysfs.c | 24 +++++++++++++++++++----- drivers/scsi/scsi_transport_srp.c | 7 ++++--- drivers/scsi/sd.c | 7 +++++-- include/scsi/scsi_device.h | 1 + 7 files changed, 66 insertions(+), 24 deletions(-)[ .. ]
Quoted 15 lines
drivers/scsi/scsi_transport_srp.c +2
-3@@ -554,11 +554,12 @@ int srp_reconnect_rport(struct srp_rport *rport)* invoking scsi_target_unblock() won't change the state of * these devices into running so do that explicitly. */ -spin_lock_irq (shost->host_lock); -__shost_for_each_device (sdev, shost) +shost_for_each_device (sdev, shost) { +mutex_lock (&sdev->state_mutex);if (sdev->sdev_state ==SDEV_OFFLINE ) sdev->sdev_state =SDEV_RUNNING ; -spin_unlock_irq (shost->host_lock);
Quoted 8 lines
drivers/scsi/scsi_transport_srp.c int srp_reconnect_rport(struct srp_rport *rport) · line 565
Quoted 5 lines
drivers/scsi/scsi_transport_srp.c +2
-0+mutex_unlock (&sdev->state_mutex); + } }else if (rport->state ==SRP_RPORT_RUNNING ) {/* * srp_reconnect_rport() has been invoked with fast_io_fail Why do you drop the host lock here? I thought that the host lock is needed to protect
shost_for_each_device()?
Hello Hannes,
The only purpose of holding the host lock was to protect the SCSI device list iteration by __shost_for_each_device(). shost_for_each_device() obtains that lock itself. From <scsi/scsi_device.h>:
#define shost_for_each_device(sdev, shost) \ for ((sdev) = __scsi_iterate_devices((shost), NULL); \ (sdev); \ (sdev) = __scsi_iterate_devices((shost), (sdev)))
Quoted 1 line
From
drivers/scsi/scsi.c:
struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *shost,
struct scsi_device *prev)
{
struct list_head *list = (prev ? &prev->siblings : &shost->__devices);
struct scsi_device *next = NULL;
unsigned long flags;
spin_lock_irqsave(shost->host_lock, flags);
while (list->next != &shost->__devices) {
next = list_entry(list->next, struct scsi_device, siblings);
/* skip devices that we can't get a reference to */
if (!scsi_device_get(next))
break;
next = NULL;
list = list->next;
}
spin_unlock_irqrestore(shost->host_lock, flags);
if (prev)
scsi_device_put(prev);
return next;
}Bart.
PATCH 4/31 Introduce scsi_start_queue()
In reply to Bart Van AsscheThis patch does not change any functionality.
--- drivers/scsi/scsi_lib.c | 25 +++++++++++++++---------- drivers/scsi/scsi_priv.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-)
drivers/scsi/scsi_lib.c +15 -10
@@ -3019,6 +3019,20 @@ static int scsi_internal_device_block(struct scsi_device *sdev)return err; } +void scsi_start_queue (struct scsi_device *sdev) +{ +struct request_queue *q = sdev->request_queue; +unsigned long flags; + +if (q->mq_ops) { +blk_mq_start_stopped_hw_queues (q, false); + }else { +spin_lock_irqsave (q->queue_lock, flags); +blk_start_queue (q); +spin_unlock_irqrestore (q->queue_lock, flags); + } +} +/** * scsi_internal_device_unblock_nowait - resume a device after a block request * @sdev: device to resume
@@ -3037,9 +3051,6 @@ static int scsi_internal_device_block(struct scsi_device *sdev)int scsi_internal_device_unblock_nowait (struct scsi_device *sdev,enum scsi_device_state new_state) { -struct request_queue *q = sdev->request_queue; -unsigned long flags; -/* * Try to transition the scsi device to SDEV_RUNNING or one of the * offlined states and goose the device queue if successful.
@@ -3057,13 +3068,7 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev, sdev->sdev_state != SDEV_OFFLINE)return -EINVAL ; -if (q->mq_ops) { -blk_mq_start_stopped_hw_queues (q, false); - }else { -spin_lock_irqsave (q->queue_lock, flags); -blk_start_queue (q); -spin_unlock_irqrestore (q->queue_lock, flags); - } +scsi_start_queue (sdev);return 0 ; }
drivers/scsi/scsi_priv.h +1 -0
@@ -88,6 +88,7 @@ extern void scsi_run_host_queues(struct Scsi_Host *shost);extern void scsi_requeue_run_queue (struct work_struct *work);extern struct request_queue *scsi_alloc_queue (struct scsi_device *sdev);extern struct request_queue *scsi_mq_alloc_queue (struct scsi_device *sdev); +extern void scsi_start_queue (struct scsi_device *sdev);extern int scsi_mq_setup_tags (struct Scsi_Host *shost);extern void scsi_mq_destroy_tags (struct Scsi_Host *shost);extern int scsi_init_queue (void );
Signature · 1 line
2.12.2
Re: [PATCH 04/31] Introduce scsi_start_queue()
Quoted 7 lines · Bart Van Assche
This patch does not change any functionality.
Signed-off-by Bart Van Assche <[email protected]>Cc Israel Rukshin <[email protected]>Cc Max Gurtovoy <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Benjamin Block <[email protected]>
Quoted 5 lines
--- drivers/scsi/scsi_lib.c | 25 +++++++++++++++---------- drivers/scsi/scsi_priv.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 5/31 Make __scsi_remove_device go straight from BLOCKED to DEL
In reply to Bart Van AsscheIf a device is blocked, make __scsi_remove_device() cause it to transition to the DEL state. This means that all the commands issued in .shutdown() will error in the mid-layer, thus making the removal proceed without being stopped.
This patch is a slightly modified version of a patch from James Bottomley. This patch avoids that the following lockup occurs:
Call Trace: schedule+0x35/0x80 schedule_timeout+0x237/0x2d0 io_schedule_timeout+0xa6/0x110 wait_for_completion_io+0xa3/0x110 blk_execute_rq+0xdf/0x120 scsi_execute+0xce/0x150 [scsi_mod] scsi_execute_req_flags+0x8f/0xf0 [scsi_mod] sd_sync_cache+0xa9/0x190 [sd_mod] sd_shutdown+0x6a/0x100 [sd_mod] sd_remove+0x64/0xc0 [sd_mod] __device_release_driver+0x8d/0x120 device_release_driver+0x1e/0x30 bus_remove_device+0xf9/0x170 device_del+0x127/0x240 __scsi_remove_device+0xc1/0xd0 [scsi_mod] scsi_forget_host+0x57/0x60 [scsi_mod] scsi_remove_host+0x72/0x110 [scsi_mod] srp_remove_work+0x8b/0x200 [ib_srp]
--- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/scsi_sysfs.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
@@ -2613,7 +2613,6 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)case SDEV_QUIESCE :case SDEV_OFFLINE :case SDEV_TRANSPORT_OFFLINE : -case SDEV_BLOCK :break ;default : goto illegal;
@@ -2627,6 +2626,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)case SDEV_OFFLINE :case SDEV_TRANSPORT_OFFLINE :case SDEV_CANCEL : +case SDEV_BLOCK :case SDEV_CREATED_BLOCK :break ;default :
drivers/scsi/scsi_sysfs.c +13 -0
@@ -1290,7 +1290,20 @@ void __scsi_remove_device(struct scsi_device *sdev)* wait until it has finished before changing the device state. */ mutex_lock (&sdev->state_mutex); +/* +* If blocked, we go straight to DEL and restart the queue so +* any commands issued during driver shutdown (like sync +* cache) are errored immediately. +*/ res =scsi_device_set_state (sdev,SDEV_CANCEL ); +if (res !=0 ) { + res =scsi_device_set_state (sdev,SDEV_DEL ); +if (res ==0 ) { +scsi_start_queue (sdev); +sdev_printk (KERN_DEBUG , sdev, +"Changed state from BLOCKED to DEL\n" ); + } + }mutex_unlock (&sdev->state_mutex);if (res !=0 )
Signature · 1 line
2.12.2
Re: [PATCH 05/31] Make __scsi_remove_device go straight from BLOCKED to DEL
Quoted 35 lines · Bart Van Assche
If a device is blocked, make
__scsi_remove_device()cause it to transition to the DEL state. This means that all the commands issued in .shutdown() will error in the mid-layer, thus making the removal proceed without being stopped.This patch is a slightly modified version of a patch from James Bottomley. This patch avoids that the following lockup occurs:
Call Trace: schedule+0x35/0x80 schedule_timeout+0x237/0x2d0 io_schedule_timeout+0xa6/0x110 wait_for_completion_io+0xa3/0x110 blk_execute_rq+0xdf/0x120 scsi_execute+0xce/0x150 [scsi_mod] scsi_execute_req_flags+0x8f/0xf0 [scsi_mod] sd_sync_cache+0xa9/0x190 [sd_mod] sd_shutdown+0x6a/0x100 [sd_mod] sd_remove+0x64/0xc0 [sd_mod] __device_release_driver+0x8d/0x120 device_release_driver+0x1e/0x30 bus_remove_device+0xf9/0x170 device_del+0x127/0x240 __scsi_remove_device+0xc1/0xd0 [scsi_mod] scsi_forget_host+0x57/0x60 [scsi_mod] scsi_remove_host+0x72/0x110 [scsi_mod] srp_remove_work+0x8b/0x200 [ib_srp]Reported-by Israel Rukshin <[email protected]>Signed-off-by Bart Van Assche <[email protected]>Cc James Bottomley <[email protected]>Cc Israel Rukshin <[email protected]>Cc Max Gurtovoy <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Benjamin Block <[email protected]>
Quoted 5 lines
--- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/scsi_sysfs.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 6/31 scmd_eh_abort_handler(): Add a comment
In reply to Bart Van AsscheAfter the patch that introduced this function was posted on the linux-scsi mailing list an explanation was posted why this patch is correct. Since that explanation contains important information, add a summary of it above the code that explanation applies to. See also http://www.spinics.net/lists/linux-scsi/msg106326.html.
References: e494f6a72839 ("[SCSI] improve eh timeout handler")
--- drivers/scsi/scsi_error.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/scsi_error.c +6 -0
@@ -116,6 +116,12 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)/** * scmd_eh_abort_handler - Handle command aborts * @work: command to be aborted. +* +* Note: this function must be called only for a command that has timed out. +* Because the block layer sets REQ_ATOM_COMPLETE before it calls +* scsi_times_out(), any .scsi_done() calls from the LLD for commands that +* have timed out do not have any effect. Hence it is safe to call +* scsi_finish_command() from this function. */ void scmd_eh_abort_handler (struct work_struct *work)
Signature · 1 line
2.12.2
Re: [PATCH 06/31] scmd_eh_abort_handler(): Add a comment
Quoted 21 lines · Bart Van Assche
After the patch that introduced this function was posted on the linux-scsi mailing list an explanation was posted why this patch is correct. Since that explanation contains important information, add a summary of it above the code that explanation applies to. See also http://www.spinics.net/lists/linux-scsi/msg106326.html.
References:
e494f6a72839("[SCSI] improve eh timeout handler")Signed-off-by Bart Van Assche <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_error.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/scsi/scsi_error.c +0
-0@@ -116,6 +116,12 @@ static int scsi_host_eh_past_deadline(struct Scsi_Host *shost)/** * scmd_eh_abort_handler - Handle command aborts
drivers/scsi/scsi_error.c static int scsi_host_eh_past_deadline(struct Scsi_Host *shost) · line 127
Quoted 10 lines
drivers/scsi/scsi_error.c +6
-0* @work: command to be aborted. +* +* Note: this function must be called only for a command that has timed out. +* Because the block layer sets REQ_ATOM_COMPLETE before it calls +* scsi_times_out(), any .scsi_done() calls from the LLD for commands that +* have timed out do not have any effect. Hence it is safe to call +* scsi_finish_command() from this function. */ void scmd_eh_abort_handler (struct work_struct *work)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 7/31 scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
In reply to Bart Van AsscheSince commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request") struct request and struct scsi_cmnd are adjacent. This means that there is now an alternative to reading req->special to convert a pointer to a prepared request into a SCSI command pointer, namely by using blk_mq_rq_to_pdu(). Make this change where appropriate. Although this patch does not change any functionality, it slightly improves performance and slightly improves readability.
--- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/scsi_lib.c | 18 +++++++++--------- include/scsi/scsi_tcq.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/scsi/scsi_error.c +1 -1
@@ -265,7 +265,7 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd)*/ enum blk_eh_timer_return scsi_times_out (struct request *req) { -struct scsi_cmnd *scmd = req->special; +struct scsi_cmnd *scmd =blk_mq_rq_to_pdu (req);enum blk_eh_timer_return rtn =BLK_EH_NOT_HANDLED ;struct Scsi_Host *host = scmd->device->host;
drivers/scsi/scsi_lib.c +9 -9
@@ -637,7 +637,7 @@ static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd)static bool scsi_end_request (struct request *req,int error,unsigned int bytes,unsigned int bidi_bytes) { -struct scsi_cmnd *cmd = req->special; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);struct scsi_device *sdev = cmd->device;struct request_queue *q = sdev->request_queue;
@@ -1156,7 +1156,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)static int scsi_setup_scsi_cmnd (struct scsi_device *sdev,struct request *req) { -struct scsi_cmnd *cmd = req->special; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);/* * Passthrough requests may transfer data, in which case they must
@@ -1187,7 +1187,7 @@ static int scsi_setup_scsi_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; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);if (unlikely (sdev->handler && sdev->handler->prep_fn)) {int ret = sdev->handler->prep_fn (sdev, req);
@@ -1202,7 +1202,7 @@ static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)static int scsi_setup_cmnd (struct scsi_device *sdev,struct request *req) { -struct scsi_cmnd *cmd = req->special; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);if (!blk_rq_bytes (req)) cmd->sc_data_direction =DMA_NONE ;
@@ -1339,7 +1339,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)static void scsi_unprep_fn (struct request_queue *q,struct request *req) { -scsi_uninit_cmd (req->special); +scsi_uninit_cmd (blk_mq_rq_to_pdu (req)); }/*
@@ -1530,7 +1530,7 @@ static int scsi_lld_busy(struct request_queue *q)*/ static void scsi_kill_request (struct request *req,struct request_queue *q) { -struct scsi_cmnd *cmd = req->special; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);struct scsi_device *sdev;struct scsi_target *starget;struct Scsi_Host *shost;
@@ -1561,7 +1561,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)static void scsi_softirq_done (struct request *rq) { -struct scsi_cmnd *cmd = rq->special; +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq);unsigned long wait_for = (cmd->allowed +1 ) * rq->timeout;int disposition;
@@ -1749,8 +1749,8 @@ static void scsi_request_fn(struct request_queue *q)blk_start_request (req);spin_unlock_irq (q->queue_lock); - cmd = req->special; -if (unlikely (cmd ==NULL )) { + cmd =blk_mq_rq_to_pdu (req); +if (cmd != req->special) { printk(KERN_CRIT "impossible request in %s.\n" "please mail a stack trace to " "[email protected]\n",
include/scsi/scsi_tcq.h +1 -1
@@ -39,7 +39,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,if (!req)return NULL ; - return req->special; + return blk_mq_rq_to_pdu(req); }#endif /* CONFIG_BLOCK */
Signature · 1 line
2.12.2
Re: [PATCH 07/31] scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
Quoted 13 lines · Bart Van Assche
Since commit
e9c787e65c0c("scsi: allocatescsi_cmndstructures as part of struct request") struct request and structscsi_cmndare adjacent. This means that there is now an alternative to readingreq->specialto convert a pointer to a prepared request into a SCSI command pointer, namely by usingblk_mq_rq_to_pdu(). Make this change where appropriate. Although this patch does not change any functionality, it slightly improves performance and slightly improves readability.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>
Quoted 6 lines
--- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/scsi_lib.c | 18 +++++++++--------- include/scsi/scsi_tcq.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 07/31] scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
In reply to Bart Van AsscheQuoted 9 lines · Bart Van Assche
Since commit
e9c787e65c0c("scsi: allocatescsi_cmndstructures as part of struct request") struct request and structscsi_cmndare adjacent. This means that there is now an alternative to readingreq->specialto convert a pointer to a prepared request into a SCSI command pointer, namely by usingblk_mq_rq_to_pdu(). Make this change where appropriate. Although this patch does not change any functionality, it slightly improves performance and slightly improves readability.
Quoted 5 lines
Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>---
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 8/31 sd, sr: Convert two assignments into warning statements
In reply to Bart Van AsscheBefore scsi_prep_fn() calls the ULP .init_command() callback function it stores the SCSI command pointer in request.special. This means that the SCpnt = rq->special assignments in the sd and sr drivers assign a pointer to itself. Hence convert these two assignment statements into warning statements.
--- drivers/scsi/sd.c | 2 +- drivers/scsi/sr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +1 -1
@@ -990,7 +990,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) ret =scsi_init_io (SCpnt);if (ret !=BLKPREP_OK ) goto out; - SCpnt = rq->special; +WARN_ON_ONCE (SCpnt != rq->special);/* from here on until we're complete, any goto out * is used for a killable error condition */
drivers/scsi/sr.c +1 -1
@@ -393,7 +393,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt) ret =scsi_init_io (SCpnt);if (ret !=BLKPREP_OK ) goto out; - SCpnt = rq->special; +WARN_ON_ONCE (SCpnt != rq->special); cd =scsi_cd (rq->rq_disk);/* from here on until we're complete, any goto out
Signature · 1 line
2.12.2
Re: [PATCH 08/31] sd, sr: Convert two assignments into warning statements
Quoted 6 lines · Bart Van Assche
Before
scsi_prep_fn()calls the ULP .init_command() callback function it stores the SCSI command pointer in request.special. This means that the SCpnt =rq->specialassignments in the sd and sr drivers assign a pointer to itself. Hence convert these two assignment statements into warning statements.
Quoted 9 lines
Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>--- drivers/scsi/sd.c | 2 +- drivers/scsi/sr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 08/31] sd, sr: Convert two assignments into warning statements
In reply to Bart Van AsscheQuoted 11 lines · Bart Van Assche
Before
scsi_prep_fn()calls the ULP .init_command() callback function it stores the SCSI command pointer in request.special. This means that the SCpnt =rq->specialassignments in the sd and sr drivers assign a pointer to itself. Hence convert these two assignment statements into warning statements.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Johannes Thumshirn <[email protected]>---
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 9/31 block: Avoid that blk_exit_rl() triggers a use-after-free
In reply to Bart Van AsscheSince the introduction of the .init_rq_fn() and .exit_rq_fn() it is essential that the memory allocated for struct request_queue stays around until all blk_exit_rl() calls have finished. Hence make blk_init_rl() take a reference on struct request_queue.
This patch fixes the following crash:
general protection fault: 0000 [#2] SMP CPU: 3 PID: 28 Comm: ksoftirqd/3 Tainted: G D 4.12.0-rc2-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 task: ffff88013a108040 task.stack: ffffc9000071c000 RIP: 0010:free_request_size+0x1a/0x30 RSP: 0018:ffffc9000071fd38 EFLAGS: 00010202 RAX: 6b6b6b6b6b6b6b6b RBX: ffff880067362a88 RCX: 0000000000000003 RDX: ffff880067464178 RSI: ffff880067362a88 RDI: ffff880135ea4418 RBP: ffffc9000071fd40 R08: 0000000000000000 R09: 0000000100180009 R10: ffffc9000071fd38 R11: ffffffff81110800 R12: ffff88006752d3d8 R13: ffff88006752d3d8 R14: ffff88013a108040 R15: 000000000000000a FS: 0000000000000000(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa8ec1edb00 CR3: 0000000138ee8000 CR4: 00000000001406e0 Call Trace: mempool_destroy.part.10+0x21/0x40 mempool_destroy+0xe/0x10 blk_exit_rl+0x12/0x20 blkg_free+0x4d/0xa0 __blkg_release_rcu+0x59/0x170 rcu_process_callbacks+0x260/0x4e0 __do_softirq+0x116/0x250 smpboot_thread_fn+0x123/0x1e0 kthread+0x109/0x140 ret_from_fork+0x31/0x40
--- block/blk-cgroup.c | 2 +- block/blk-core.c | 10 ++++++++-- block/blk-sysfs.c | 2 +- block/blk.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-)
block/blk-cgroup.c +1 -1
@@ -74,7 +74,7 @@ static void blkg_free(struct blkcg_gq *blkg) blkcg_policy[i]->pd_free_fn (blkg->pd[i]);if (blkg->blkcg != &blkcg_root) -blk_exit_rl (&blkg->rl); +blk_exit_rl (blkg->q, &blkg->rl);blkg_rwstat_exit (&blkg->stat_ios);blkg_rwstat_exit (&blkg->stat_bytes);
block/blk-core.c +8 -2
@@ -648,13 +648,19 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q,if (!rl->rq_pool)return -ENOMEM ; +if (rl != &q->root_rl) +blk_get_queue (q); +return 0 ; } -void blk_exit_rl (struct request_list *rl) +void blk_exit_rl (struct request_queue *q,struct request_list *rl) { -if (rl->rq_pool) +if (rl->rq_pool) {mempool_destroy (rl->rq_pool); +if (rl != &q->root_rl) +blk_put_queue (q); + } }struct request_queue *blk_alloc_queue (gfp_t gfp_mask)
block/blk-sysfs.c +1 -1
@@ -809,7 +809,7 @@ static void blk_release_queue(struct kobject *kobj)blk_free_queue_stats (q->stats); -blk_exit_rl (&q->root_rl); +blk_exit_rl (q, &q->root_rl);if (q->queue_tags)__blk_queue_free_tags (q);
block/blk.h +1 -1
@@ -59,7 +59,7 @@ void blk_free_flush_queue(struct blk_flush_queue *q);int blk_init_rl (struct request_list *rl,struct request_queue *q,gfp_t gfp_mask); -void blk_exit_rl (struct request_list *rl); +void blk_exit_rl (struct request_queue *q,struct request_list *rl);void blk_rq_bio_prep (struct request_queue *q,struct request *rq,struct bio *bio);void blk_queue_bypass_start (struct request_queue *q);
Signature · 1 line
2.12.2
Re: [PATCH 09/31] block: Avoid that blk_exit_rl() triggers a use-after-free
Quoted 41 lines · Bart Van Assche
Since the introduction of the .init_rq_fn() and .exit_rq_fn() it is essential that the memory allocated for struct
request_queuestays around until allblk_exit_rl()calls have finished. Hence makeblk_init_rl()take a reference on structrequest_queue.This patch fixes the following crash:
general protection fault: 0000 [#2] SMP CPU: 3 PID: 28 Comm: ksoftirqd/3 Tainted: G D 4.12.0-rc2-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 task: ffff88013a108040 task.stack: ffffc9000071c000 RIP: 0010:free_request_size+0x1a/0x30 RSP: 0018:ffffc9000071fd38 EFLAGS: 00010202 RAX: 6b6b6b6b6b6b6b6b RBX: ffff880067362a88 RCX: 0000000000000003 RDX: ffff880067464178 RSI: ffff880067362a88 RDI: ffff880135ea4418 RBP: ffffc9000071fd40 R08: 0000000000000000 R09: 0000000100180009 R10: ffffc9000071fd38 R11: ffffffff81110800 R12: ffff88006752d3d8 R13: ffff88006752d3d8 R14: ffff88013a108040 R15: 000000000000000a FS: 0000000000000000(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa8ec1edb00 CR3: 0000000138ee8000 CR4: 00000000001406e0 Call Trace: mempool_destroy.part.10+0x21/0x40 mempool_destroy+0xe/0x10 blk_exit_rl+0x12/0x20 blkg_free+0x4d/0xa0 __blkg_release_rcu+0x59/0x170 rcu_process_callbacks+0x260/0x4e0 __do_softirq+0x116/0x250 smpboot_thread_fn+0x123/0x1e0 kthread+0x109/0x140 ret_from_fork+0x31/0x40Fixes commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Tejun Heo <[email protected]>Cc Jan Kara <[email protected]>Cc Hannes Reinecke <[email protected]>Cc <[email protected]> # v4.11+
Quoted 7 lines
--- block/blk-cgroup.c | 2 +- block/blk-core.c | 10 ++++++++-- block/blk-sysfs.c | 2 +- block/blk.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 09/31] block: Avoid that blk_exit_rl() triggers a use-after-free
In reply to Bart Van AsscheQuoted 33 lines · Bart Van Assche
Since the introduction of the .init_rq_fn() and .exit_rq_fn() it is essential that the memory allocated for struct
request_queuestays around until allblk_exit_rl()calls have finished. Hence makeblk_init_rl()take a reference on structrequest_queue.This patch fixes the following crash:
general protection fault: 0000 [#2] SMP CPU: 3 PID: 28 Comm: ksoftirqd/3 Tainted: G D 4.12.0-rc2-dbg+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 task: ffff88013a108040 task.stack: ffffc9000071c000 RIP: 0010:free_request_size+0x1a/0x30 RSP: 0018:ffffc9000071fd38 EFLAGS: 00010202 RAX: 6b6b6b6b6b6b6b6b RBX: ffff880067362a88 RCX: 0000000000000003 RDX: ffff880067464178 RSI: ffff880067362a88 RDI: ffff880135ea4418 RBP: ffffc9000071fd40 R08: 0000000000000000 R09: 0000000100180009 R10: ffffc9000071fd38 R11: ffffffff81110800 R12: ffff88006752d3d8 R13: ffff88006752d3d8 R14: ffff88013a108040 R15: 000000000000000a FS: 0000000000000000(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa8ec1edb00 CR3: 0000000138ee8000 CR4: 00000000001406e0 Call Trace: mempool_destroy.part.10+0x21/0x40 mempool_destroy+0xe/0x10 blk_exit_rl+0x12/0x20 blkg_free+0x4d/0xa0 __blkg_release_rcu+0x59/0x170 rcu_process_callbacks+0x260/0x4e0 __do_softirq+0x116/0x250 smpboot_thread_fn+0x123/0x1e0 kthread+0x109/0x140 ret_from_fork+0x31/0x40
Quoted 8 lines
Fixes commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Tejun Heo <[email protected]>Cc Jan Kara <[email protected]>Cc Hannes Reinecke <[email protected]>Cc <[email protected]> # v4.11+
Thanks.
Signature · 1 line
tejun
PATCH 10/31 Avoid that scsi_exit_rq() triggers a use-after-free
In reply to Bart Van AsscheDereferencing shost from scsi_exit_rq() is not safe because the SCSI host may already have been freed when scsi_exit_rq() is called. Increasing the shost reference count in scsi_init_rq() and dropping that reference in scsi_exit_rq() is nontrivial since scsi_host_dev_release() may sleep and since scsi_exit_rq() may be called from interrupt context. Since scsi_exit_rq() only needs a single bit from shost, copy that bit into struct scsi_cmnd.
--- drivers/scsi/scsi_lib.c | 43 +++++++++++++++++++++++++------------------ include/scsi/scsi_cmnd.h | 1 + 2 files changed, 26 insertions(+), 18 deletions(-)
drivers/scsi/scsi_lib.c +25 -18
@@ -44,23 +44,23 @@ static struct kmem_cache *scsi_sense_isadma_cache;static DEFINE_MUTEX (scsi_sense_cache_mutex);static inline struct kmem_cache * -scsi_select_sense_cache (struct Scsi_Host *shost) +scsi_select_sense_cache (bool unchecked_isa_dma) { -return shost->unchecked_isa_dma ? - scsi_sense_isadma_cache : scsi_sense_cache; +return unchecked_isa_dma ? scsi_sense_isadma_cache : scsi_sense_cache; } -static void scsi_free_sense_buffer (struct Scsi_Host *shost, -unsigned char *sense_buffer) +static void scsi_free_sense_buffer (bool unchecked_isa_dma, +unsigned char *sense_buffer) { -kmem_cache_free (scsi_select_sense_cache (shost), sense_buffer); +kmem_cache_free (scsi_select_sense_cache (unchecked_isa_dma), + sense_buffer); } -static unsigned char *scsi_alloc_sense_buffer (struct Scsi_Host *shost, +static unsigned char *scsi_alloc_sense_buffer (bool unchecked_isa_dma,gfp_t gfp_mask,int numa_node) { -return kmem_cache_alloc_node (scsi_select_sense_cache (shost), gfp_mask, - numa_node); +return kmem_cache_alloc_node (scsi_select_sense_cache (unchecked_isa_dma), + gfp_mask, numa_node); }int scsi_init_sense_cache (struct Scsi_Host *shost)
@@ -68,7 +68,7 @@ int scsi_init_sense_cache(struct Scsi_Host *shost)struct kmem_cache *cache;int ret =0 ; - cache =scsi_select_sense_cache (shost); + cache =scsi_select_sense_cache (shost->unchecked_isa_dma);if (cache)return 0 ;
@@ -2003,10 +2003,13 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx, unsigned int numa_node) { struct Scsi_Host *shost = set->driver_data; +const bool unchecked_isa_dma = shost->unchecked_isa_dma;struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); - cmd->sense_buffer = -scsi_alloc_sense_buffer (shost,GFP_KERNEL , numa_node); +if (unchecked_isa_dma) + cmd->flags |=SCMD_UNCHECKED_ISA_DMA ; + cmd->sense_buffer =scsi_alloc_sense_buffer (unchecked_isa_dma, +GFP_KERNEL , numa_node);if (!cmd->sense_buffer)return -ENOMEM ; cmd->req.sense = cmd->sense_buffer;
@@ -2016,10 +2019,10 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq,static void scsi_exit_request (struct blk_mq_tag_set *set,struct request *rq,unsigned int hctx_idx) { -struct Scsi_Host *shost = set->driver_data;struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); -scsi_free_sense_buffer (shost, cmd->sense_buffer); +scsi_free_sense_buffer (cmd->flags &SCMD_UNCHECKED_ISA_DMA , + cmd->sense_buffer); }static int scsi_map_queues (struct blk_mq_tag_set *set)
@@ -2092,11 +2095,15 @@ EXPORT_SYMBOL_GPL(__scsi_init_queue);static int scsi_init_rq (struct request_queue *q,struct request *rq,gfp_t gfp) {struct Scsi_Host *shost = q->rq_alloc_data; +const bool unchecked_isa_dma = shost->unchecked_isa_dma;struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq);memset (cmd,0 ,sizeof (*cmd)); - cmd->sense_buffer =scsi_alloc_sense_buffer (shost, gfp,NUMA_NO_NODE ); +if (unchecked_isa_dma) + cmd->flags |=SCMD_UNCHECKED_ISA_DMA ; + cmd->sense_buffer =scsi_alloc_sense_buffer (unchecked_isa_dma, gfp, +NUMA_NO_NODE );if (!cmd->sense_buffer) goto fail; cmd->req.sense = cmd->sense_buffer;
@@ -2110,19 +2117,19 @@ static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp)return 0 ; fail_free_sense: -scsi_free_sense_buffer (shost, cmd->sense_buffer); +scsi_free_sense_buffer (unchecked_isa_dma, cmd->sense_buffer); fail:return -ENOMEM ; }static void scsi_exit_rq (struct request_queue *q,struct request *rq) { -struct Scsi_Host *shost = q->rq_alloc_data;struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq);if (cmd->prot_sdb)kmem_cache_free (scsi_sdb_cache, cmd->prot_sdb); -scsi_free_sense_buffer (shost, cmd->sense_buffer); +scsi_free_sense_buffer (cmd->flags &SCMD_UNCHECKED_ISA_DMA , + cmd->sense_buffer); }struct request_queue *scsi_alloc_queue (struct scsi_device *sdev)
include/scsi/scsi_cmnd.h +1 -0
@@ -56,6 +56,7 @@ struct scsi_pointer {/* for scmd->flags */ #define SCMD_TAGGED (1 << 0) +#define SCMD_UNCHECKED_ISA_DMA (1 << 1)struct scsi_cmnd {struct scsi_request req;
Signature · 1 line
2.12.2
Re: [PATCH 10/31] Avoid that scsi_exit_rq() triggers a use-after-free
Quoted 16 lines · Bart Van Assche
Dereferencing shost from
scsi_exit_rq()is not safe because the SCSI host may already have been freed whenscsi_exit_rq()is called. Increasing the shost reference count inscsi_init_rq()and dropping that reference inscsi_exit_rq()is nontrivial sincescsi_host_dev_release()may sleep and sincescsi_exit_rq()may be called from interrupt context. Sincescsi_exit_rq()only needs a single bit from shost, copy that bit into structscsi_cmnd.Reported-by Scott Bauer <[email protected]>Fixes e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Scott Bauer <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Jan Kara <[email protected]>Cc Hannes Reinecke <[email protected]>Cc <[email protected]>
Quoted 5 lines
--- drivers/scsi/scsi_lib.c | 43 +++++++++++++++++++++++++------------------ include/scsi/scsi_cmnd.h | 1 + 2 files changed, 26 insertions(+), 18 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 11/31 block: Introduce queue flag QUEUE_FLAG_SCSI_SUP
In reply to Bart Van AsscheQuoted 1 line
From the context where a SCSI command is submitted it is not always
possible to figure out whether or not the queue the command is submitted to has struct scsi_request as the first member of its private data. Hence introduce the flag QUEUE_FLAG_SCSI_SUP.
--- block/bsg-lib.c | 1 + drivers/block/cciss.c | 1 + drivers/ide/ide-probe.c | 1 + drivers/scsi/scsi_lib.c | 2 ++ drivers/scsi/scsi_transport_sas.c | 1 + include/linux/blkdev.h | 2 ++ 6 files changed, 8 insertions(+)
block/bsg-lib.c +1 -0
@@ -246,6 +246,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, char *name, q->bsg_job_size = dd_job_size; q->bsg_job_fn = job_fn;queue_flag_set_unlocked (QUEUE_FLAG_BIDI , q); +queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , q);blk_queue_softirq_done (q, bsg_softirq_done);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT );
drivers/block/cciss.c +1 -0
@@ -1956,6 +1956,7 @@ static int cciss_add_disk(ctlr_info_t *h, struct gendisk *disk, disk->queue->cmd_size =sizeof (struct scsi_request ); disk->queue->request_fn = do_cciss_request; disk->queue->queue_lock = &h->lock; +queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , disk->queue);if (blk_init_allocated_queue (disk->queue) <0 ) goto cleanup_queue;
drivers/ide/ide-probe.c +1 -0
@@ -773,6 +773,7 @@ static int ide_init_queue(ide_drive_t *drive) q->request_fn = do_ide_request; q->init_rq_fn = ide_init_rq; q->cmd_size =sizeof (struct ide_request ); +queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , q);if (blk_init_allocated_queue (q) <0 ) {blk_cleanup_queue (q);return 1 ;
drivers/scsi/scsi_lib.c +2 -0
@@ -2059,6 +2059,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q) {struct device *dev = shost->dma_dev; +queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , q); +/* * this limit is imposed by hardware restrictions */
drivers/scsi/scsi_transport_sas.c +1 -0
@@ -264,6 +264,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy) q->queuedata = shost;queue_flag_set_unlocked (QUEUE_FLAG_BIDI , q); +queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , q);return 0 ; out_cleanup_queue:
include/linux/blkdev.h +2 -0
@@ -618,6 +618,7 @@ struct request_queue {#define QUEUE_FLAG_STATS 27/* track rq completion times */ #define QUEUE_FLAG_POLL_STATS 28/* collecting stats for hybrid polling */ #define QUEUE_FLAG_REGISTERED 29/* queue has been registered to a disk */ +#define QUEUE_FLAG_SCSI_SUP 30/* queue supports SCSI commands */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_STACKABLE) | \
@@ -708,6 +709,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)#define blk_queue_secure_erase (q) \ (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags))#define blk_queue_dax (q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags) +#define blk_queue_scsi_sup (q) test_bit(QUEUE_FLAG_SCSI_SUP, &(q)->queue_flags)#define blk_noretry_request (rq) \ ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
Signature · 1 line
2.12.2
Re: [PATCH 11/31] block: Introduce queue flag QUEUE_FLAG_SCSI_SUP
Quoted 10 lines · Bart Van Assche
From the context where a SCSI command is submitted it is not always possible to figure out whether or not the queue the command is submitted to has struct
scsi_requestas the first member of its private data. Hence introduce the flagQUEUE_FLAG_SCSI_SUP.Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>
Quoted 9 lines
--- block/bsg-lib.c | 1 + drivers/block/cciss.c | 1 + drivers/ide/ide-probe.c | 1 + drivers/scsi/scsi_lib.c | 2 ++ drivers/scsi/scsi_transport_sas.c | 1 + include/linux/blkdev.h | 2 ++ 6 files changed, 8 insertions(+)
Bit of an odd name; what about QUEUE_FLAG_SCSI_PDU?
Otherwise:
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 11/31] block: Introduce queue flag QUEUE_FLAG_SCSI_SUP
Quoted 20 lines · Hannes Reinecke
Quoted 18 lines · Bart Van Assche
From the context where a SCSI command is submitted it is not always possible to figure out whether or not the queue the command is submitted to has struct
scsi_requestas the first member of its private data. Hence introduce the flagQUEUE_FLAG_SCSI_SUP. =20Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>--- block/bsg-lib.c | 1 + drivers/block/cciss.c | 1 + drivers/ide/ide-probe.c | 1 + drivers/scsi/scsi_lib.c | 2 ++ drivers/scsi/scsi_transport_sas.c | 1 + include/linux/blkdev.h | 2 ++ 6 files changed, 8 insertions(+)Quoted 1 line
=20
Quoted 2 lines
=20
Bit of an odd name; what aboutQUEUE_FLAG_SCSI_PDU?
Hello Hannes,
That sounds like a good idea to me. I will rename the flag when I repost th= is
series.
Bart.=
PATCH 12/31 bsg: Check queue type before attaching to a queue
In reply to Bart Van AsscheSince BSG only supports request queues for which struct scsi_request is the first member of their private request data, refuse to register block layer queues for which struct scsi_request is not the first member of their private data.
References: commit bd1599d931ca ("scsi_transport_sas: fix BSG ioctl memory corruption")
References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
--- block/bsg.c | 6 ++++++ 1 file changed, 6 insertions(+)
block/bsg.c +6 -0
@@ -750,6 +750,12 @@ static struct bsg_device *bsg_add_device(struct inode *inode,#ifdef BSG_DEBUG unsigned char buf[32 ];#endif + +if (!blk_queue_scsi_sup (rq)) { +WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +return ERR_PTR (-EINVAL ); + } +if (!blk_get_queue (rq))return ERR_PTR (-ENXIO );
Signature · 1 line
2.12.2
Re: [PATCH 12/31] bsg: Check queue type before attaching to a queue
Quoted 24 lines · Bart Van Assche
Since BSG only supports request queues for which struct
scsi_requestis the first member of their private request data, refuse to register block layer queues for which structscsi_requestis not the first member of their private data.References: commit
bd1599d931ca("scsi_transport_sas: fix BSG ioctl memory corruption")
References: commit82ed4db499b8("block: splitscsi_requestout of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>--- block/bsg.c | 6 ++++++ 1 file changed, 6 insertions(+)block/bsg.c +0
-0@@ -750,6 +750,12 @@ static struct bsg_device *bsg_add_device(struct inode *inode,#ifdef BSG_DEBUG unsigned char buf[32 ];
block/bsg.c static struct bsg_device *bsg_add_device(struct inode *inode, · line 761
Quoted 10 lines
block/bsg.c +6
-0#endif + +if (!blk_queue_scsi_sup (rq)) { +WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +return ERR_PTR (-EINVAL ); + } +if (!blk_get_queue (rq))return ERR_PTR (-ENXIO );
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 12/31] bsg: Check queue type before attaching to a queue
In reply to Bart Van AsscheBart,
block/bsg.c static struct bsg_device *bsg_add_device(struct inode *inode, · line 754
Quoted 7 lines
Since BSG only supports request queues for which struct
scsi_requestis the first member of their private request data, refuse to register block layer queues for which structscsi_requestis not the first member of their private data.block/bsg.c +2
-0+ +if (!blk_queue_scsi_sup (rq)) {
If you are renaming the flag, how about blk_queue_scsi_pdu()?
Quoted 6 lines
block/bsg.c +4
-0+WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +return ERR_PTR (-EINVAL ); + } +if (!blk_get_queue (rq))return ERR_PTR (-ENXIO );
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
PATCH 13/31 pktcdvd: Check queue type before attaching to a queue
In reply to Bart Van AsscheSince the pktcdvd driver only supports request queues for which struct scsi_request is the first member of their private request data, refuse to register block layer queues for which struct scsi_request is not the first member of the private data.
References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
--- drivers/block/pktcdvd.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/block/pktcdvd.c +5 -0
@@ -2583,6 +2583,11 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) bdev =bdget (dev);if (!bdev)return -ENOMEM ; +if (!blk_queue_scsi_sup (bdev_get_queue (bdev))) { +WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +bdput (bdev); +return -EINVAL ; + } ret =blkdev_get (bdev,FMODE_READ |FMODE_NDELAY ,NULL );if (ret)return ret;
Signature · 1 line
2.12.2
Re: [PATCH 13/31] pktcdvd: Check queue type before attaching to a queue
Quoted 23 lines · Bart Van Assche
Since the pktcdvd driver only supports request queues for which struct
scsi_requestis the first member of their private request data, refuse to register block layer queues for which structscsi_requestis not the first member of the private data.References: commit
82ed4db499b8("block: splitscsi_requestout of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/block/pktcdvd.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/block/pktcdvd.c +0
-0@@ -2583,6 +2583,11 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) bdev =bdget (dev);
drivers/block/pktcdvd.c static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) · line 2593
Quoted 10 lines
drivers/block/pktcdvd.c +5
-0if (!bdev)return -ENOMEM ; +if (!blk_queue_scsi_sup (bdev_get_queue (bdev))) { +WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +bdput (bdev); +return -EINVAL ; + } ret =blkdev_get (bdev,FMODE_READ |FMODE_NDELAY ,NULL );if (ret)return ret;
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 14/31 cdrom: Check private request size before attaching to a queue
In reply to Bart Van AsscheSince the cdrom driver only supports request queues for which struct scsi_request is the first member of their private request data, refuse to register block layer queues for which this is not the case.
References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
--- drivers/cdrom/cdrom.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/cdrom/cdrom.c +4 -0
@@ -594,6 +594,10 @@ int register_cdrom(struct cdrom_device_info *cdi)if (cdo->open ==NULL || cdo->release ==NULL )return -EINVAL ; +if (!blk_queue_scsi_sup (cdi->disk->queue)) { +WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +return -EINVAL ; + }if (!banner_printed) {pr_info ("Uniform CD-ROM driver " REVISION "\n" ); banner_printed =1 ;
Signature · 1 line
2.12.2
Re: [PATCH 14/31] cdrom: Check private request size before attaching to a queue
Quoted 22 lines · Bart Van Assche
Since the cdrom driver only supports request queues for which struct
scsi_requestis the first member of their private request data, refuse to register block layer queues for which this is not the case.References: commit
82ed4db499b8("block: splitscsi_requestout of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/cdrom/cdrom.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/cdrom/cdrom.c +0
-0
drivers/cdrom/cdrom.c int register_cdrom(struct cdrom_device_info *cdi) · line 603
Quoted 10 lines
drivers/cdrom/cdrom.c +4
-0@@ -594,6 +594,10 @@ int register_cdrom(struct cdrom_device_info *cdi)if (cdo->open ==NULL || cdo->release ==NULL )return -EINVAL ; +if (!blk_queue_scsi_sup (cdi->disk->queue)) { +WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" ); +return -EINVAL ; + }if (!banner_printed) {pr_info ("Uniform CD-ROM driver " REVISION "\n" ); banner_printed =1 ;
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 15/31 nfsd: Check private request size before submitting a SCSI request
In reply to Bart Van AsscheSince using scsi_req() is only allowed against request queues for which struct scsi_request is the first member of their private request data, refuse to submit SCSI commands against a queue for which this is not the case.
References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
--- fs/nfsd/blocklayout.c | 3 +++ 1 file changed, 3 insertions(+)
fs/nfsd/blocklayout.c +3 -0
@@ -219,6 +219,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,u8 *buf, *d, type, assoc;int error; +if (WARN_ON_ONCE (!blk_queue_scsi_sup (q))) +return -EINVAL ; + buf =kzalloc (bufflen,GFP_KERNEL );if (!buf)return -ENOMEM ;
Signature · 6 lines
2.12.2 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 15/31] nfsd: Check private request size before submitting a SCSI request
Quoted 25 lines · Bart Van Assche
Since using
scsi_req()is only allowed against request queues for which structscsi_requestis the first member of their private request data, refuse to submit SCSI commands against a queue for which this is not the case.References: commit
82ed4db499b8("block: splitscsi_requestout of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc J. Bruce Fields <[email protected]>Cc Jeff Layton <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <hare-IBi9RG/[email protected]>--- fs/nfsd/blocklayout.c | 3 +++ 1 file changed, 3 insertions(+)fs/nfsd/blocklayout.c +0
-0
fs/nfsd/blocklayout.c static int nfsd4_scsi_identify_device(struct block_device *bdev, · line 227
Quoted 9 lines
fs/nfsd/blocklayout.c +3
-0@@ -219,6 +219,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,u8 *buf, *d, type, assoc;int error; +if (WARN_ON_ONCE (!blk_queue_scsi_sup (q))) +return -EINVAL ; + buf =kzalloc (bufflen,GFP_KERNEL );if (!buf)return -ENOMEM ;
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 16/31 scsi: Make scsi_ioctl_reset() pass the request queue pointer to blk_rq_init()
In reply to Bart Van AsscheA later patch will add a call to a request initialization function into blk_rq_init(). Hence make sure that all blk_rq_init() calls specify the request queue pointer. Since TMF callback functions in SCSI LLD drivers do not use request.q, this patch does not change the behavior of any SCSI driver.
--- drivers/scsi/scsi_error.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/scsi_error.c +6 -1
@@ -2286,7 +2286,12 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg) shost->hostt->cmd_size, GFP_KERNEL);if (!rq) goto out_put_autopm_host; -blk_rq_init (NULL , rq); +/* +* Although blk_rq_init() is intended for single queue block +* drivers, this code path even uses blk_rq_init() when @dev is +* a scsi-mq device. +*/ +blk_rq_init (dev->request_queue, rq); scmd = (struct scsi_cmnd *)(rq +1 );scsi_init_command (dev, scmd);
Signature · 1 line
2.12.2
Re: [PATCH 16/31] scsi: Make scsi_ioctl_reset() pass the request queue pointer to blk_rq_init()
Quoted 6 lines · Bart Van Assche
A later patch will add a call to a request initialization function into
blk_rq_init(). Hence make sure that allblk_rq_init()calls specify the request queue pointer. Since TMF callback functions in SCSI LLD drivers do not use request.q, this patch does not change the behavior of any SCSI driver.
Quoted 7 lines
Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_error.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 17/31 block: Introduce request_queue.initialize_rq_fn()
In reply to Bart Van AsscheSeveral block drivers need to initialize the driver-private data after having called blk_get_request() and before .prep_rq_fn() is called, e.g. when submitting a REQ_OP_SCSI_* request. Avoid that that initialization code has to be repeated after every blk_get_request() call by adding a new callback function to struct request_queue.
--- block/blk-core.c | 3 +++ block/blk-mq.c | 3 +++ include/linux/blkdev.h | 4 ++++ 3 files changed, 10 insertions(+)
block/blk-core.c +3 -0
@@ -126,6 +126,9 @@ void blk_rq_init(struct request_queue *q, struct request *rq) rq->start_time = jiffies;set_start_time_ns (rq); rq->part =NULL ; + +if (q->initialize_rq_fn) + q->initialize_rq_fn (rq); }EXPORT_SYMBOL (blk_rq_init);
block/blk-mq.c +3 -0
@@ -241,6 +241,9 @@ void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx, rq->end_io_data =NULL ; rq->next_rq =NULL ; +if (q->initialize_rq_fn) + q->initialize_rq_fn (rq); + ctx->rq_dispatched[op_is_sync (op)]++; }EXPORT_SYMBOL_GPL (blk_mq_rq_ctx_init);
include/linux/blkdev.h +4 -0
@@ -410,8 +410,12 @@ struct request_queue {rq_timed_out_fn *rq_timed_out_fn;dma_drain_needed_fn *dma_drain_needed;lld_busy_fn *lld_busy_fn; +/* Called just after a request is allocated */ init_rq_fn *init_rq_fn; +/* Called just before a request is freed */ exit_rq_fn *exit_rq_fn; +/* Called from inside blk_get_request() */ +void (*initialize_rq_fn)(struct request *rq);const struct blk_mq_ops *mq_ops;
Signature · 1 line
2.12.2
Re: [PATCH 17/31] block: Introduce request_queue.initialize_rq_fn()
Quoted 13 lines · Bart Van Assche
Several block drivers need to initialize the driver-private data after having called
blk_get_request()and before .prep_rq_fn() is called, e.g. when submitting a REQ_OP_SCSI_* request. Avoid that that initialization code has to be repeated after everyblk_get_request()call by adding a new callback function to structrequest_queue.Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>
Quoted 6 lines
--- block/blk-core.c | 3 +++ block/blk-mq.c | 3 +++ include/linux/blkdev.h | 4 ++++ 3 files changed, 10 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 18/31 block: Make scsi_req_init() calls implicit
In reply to Bart Van AsscheInstead of explicitly calling scsi_req_init(), let blk_get_request() call that function from inside blk_rq_init(). Add an .initialize_rq_fn() callback function to the block drivers that need it. Merge the IDE .init_rq_fn() function into .initialize_rq_fn() because it is too small to keep it as a separate function.
References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
--- block/bsg.c | 1 - block/scsi_ioctl.c | 3 --- drivers/block/pktcdvd.c | 1 - drivers/cdrom/cdrom.c | 1 - drivers/ide/ide-atapi.c | 2 -- drivers/ide/ide-cd.c | 1 - drivers/ide/ide-cd_ioctl.c | 1 - drivers/ide/ide-devsets.c | 1 - drivers/ide/ide-disk.c | 1 - drivers/ide/ide-ioctls.c | 2 -- drivers/ide/ide-park.c | 2 -- drivers/ide/ide-pm.c | 2 -- drivers/ide/ide-probe.c | 6 +++--- drivers/ide/ide-tape.c | 1 - drivers/ide/ide-taskfile.c | 1 - drivers/scsi/osd/osd_initiator.c | 2 -- drivers/scsi/osst.c | 1 - drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 10 +++++++++- drivers/scsi/scsi_transport_sas.c | 6 ++++++ drivers/scsi/sg.c | 2 -- drivers/scsi/st.c | 1 - drivers/target/target_core_pscsi.c | 2 -- fs/nfsd/blocklayout.c | 1 - 24 files changed, 18 insertions(+), 34 deletions(-)
block/bsg.c +0 -1
@@ -236,7 +236,6 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm) rq =blk_get_request (q, op,GFP_KERNEL );if (IS_ERR (rq))return rq; -scsi_req_init (rq); ret =blk_fill_sgv4_hdr_rq (q, rq, hdr, bd, has_write_perm);if (ret)
block/scsi_ioctl.c +0 -3
@@ -326,7 +326,6 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,if (IS_ERR (rq))return PTR_ERR (rq); req =scsi_req (rq); -scsi_req_init (rq);if (hdr->cmd_len >BLK_MAX_CDB ) { req->cmd =kzalloc (hdr->cmd_len,GFP_KERNEL );
@@ -456,7 +455,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, goto error_free_buffer; } req =scsi_req (rq); -scsi_req_init (rq); cmdlen =COMMAND_SIZE (opcode);
@@ -542,7 +540,6 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, rq =blk_get_request (q,REQ_OP_SCSI_OUT , __GFP_RECLAIM);if (IS_ERR (rq))return PTR_ERR (rq); -scsi_req_init (rq); rq->timeout =BLK_DEFAULT_SG_TIMEOUT ;scsi_req (rq)->cmd[0 ] = cmd;scsi_req (rq)->cmd[4 ] = data;
drivers/block/pktcdvd.c +0 -1
@@ -707,7 +707,6 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, __GFP_RECLAIM);if (IS_ERR (rq))return PTR_ERR (rq); -scsi_req_init (rq);if (cgc->buflen) { ret = blk_rq_map_kern(q, rq, cgc->buffer, cgc->buflen,
drivers/cdrom/cdrom.c +0 -1
@@ -2199,7 +2199,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,break ; } req =scsi_req (rq); -scsi_req_init (rq); ret =blk_rq_map_user (q, rq,NULL , ubuf, len,GFP_KERNEL );if (ret) {
drivers/ide/ide-atapi.c +0 -2
@@ -93,7 +93,6 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,int error; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ; rq->special = (char *)pc;
@@ -200,7 +199,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)memset (sense,0 ,sizeof (*sense));blk_rq_init (rq->q, sense_rq); -scsi_req_init (sense_rq); err =blk_rq_map_kern (drive->queue, sense_rq, sense, sense_len,GFP_NOIO );
drivers/ide/ide-cd.c +0 -1
@@ -438,7 +438,6 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, rq =blk_get_request (drive->queue, write ?REQ_OP_DRV_OUT :REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);memcpy (scsi_req (rq)->cmd, cmd,BLK_MAX_CDB );ide_req (rq)->type =ATA_PRIV_PC ; rq->rq_flags |= rq_flags;
drivers/ide/ide-cd_ioctl.c +0 -1
@@ -304,7 +304,6 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)int ret; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ; rq->rq_flags =RQF_QUIET ;blk_execute_rq (drive->queue, cd->disk, rq,0 );
drivers/ide/ide-devsets.c +0 -1
@@ -166,7 +166,6 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,return setting->set (drive, arg); rq =blk_get_request (q,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd_len =5 ;scsi_req (rq)->cmd[0 ] =REQ_DEVSET_EXEC ;
drivers/ide/ide-disk.c +0 -1
@@ -478,7 +478,6 @@ static int set_multcount(ide_drive_t *drive, int arg)return -EBUSY ; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ; drive->mult_req = arg;
drivers/ide/ide-ioctls.c +0 -2
@@ -126,7 +126,6 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)struct request *rq; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ;blk_execute_rq (drive->queue,NULL , rq,0 ); err =scsi_req (rq)->result ? -EIO :0 ;
@@ -224,7 +223,6 @@ static int generic_drive_reset(ide_drive_t *drive)int ret =0 ; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd_len =1 ;scsi_req (rq)->cmd[0 ] =REQ_DRIVE_RESET ;
drivers/ide/ide-park.c +0 -2
@@ -32,7 +32,6 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)spin_unlock_irq (&hwif->lock); rq =blk_get_request (q,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);scsi_req (rq)->cmd[0 ] =REQ_PARK_HEADS ;scsi_req (rq)->cmd_len =1 ;ide_req (rq)->type =ATA_PRIV_MISC ;
@@ -48,7 +47,6 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)* timeout has expired, so power management will be reenabled. */ rq =blk_get_request (q,REQ_OP_DRV_IN ,GFP_NOWAIT ); -scsi_req_init (rq);if (IS_ERR (rq)) goto out;
drivers/ide/ide-pm.c +0 -2
@@ -19,7 +19,6 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)memset (&rqpm,0 ,sizeof (rqpm)); rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_PM_SUSPEND ; rq->special = &rqpm; rqpm.pm_step =IDE_PM_START_SUSPEND ;
@@ -91,7 +90,6 @@ int generic_ide_resume(struct device *dev)memset (&rqpm,0 ,sizeof (rqpm)); rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_PM_RESUME ; rq->rq_flags |=RQF_PREEMPT ; rq->special = &rqpm;
drivers/ide/ide-probe.c +3 -3
@@ -741,12 +741,12 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) } } -static int ide_init_rq (struct request_queue *q,struct request *rq,gfp_t gfp) +static void ide_initialize_rq (struct request *rq) {struct ide_request *req =blk_mq_rq_to_pdu (rq); +scsi_req_init (rq); req->sreq.sense = req->sense; -return 0 ; }/*
@@ -771,7 +771,7 @@ static int ide_init_queue(ide_drive_t *drive)return 1 ; q->request_fn = do_ide_request; - q->init_rq_fn = ide_init_rq; + q->initialize_rq_fn = ide_initialize_rq; q->cmd_size =sizeof (struct ide_request );queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , q);if (blk_init_allocated_queue (q) <0 ) {
drivers/ide/ide-tape.c +0 -1
@@ -855,7 +855,6 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)BUG_ON (size <0 || size % tape->blk_size); rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd[13 ] = cmd; rq->rq_disk = tape->disk;
drivers/ide/ide-taskfile.c +0 -1
@@ -433,7 +433,6 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, rq =blk_get_request (drive->queue, (cmd->tf_flags &IDE_TFLAG_WRITE ) ?REQ_OP_DRV_OUT :REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ;/*
drivers/scsi/osd/osd_initiator.c +0 -2
@@ -1572,7 +1572,6 @@ static struct request *_make_request(struct request_queue *q, bool has_write, flags);if (IS_ERR (req))return req; -scsi_req_init (req);for_each_bio (bio) {struct bio *bounce_bio = bio;
@@ -1617,7 +1616,6 @@ static int _init_blk_request(struct osd_request *or, ret =PTR_ERR (req); goto out; } -scsi_req_init (req); or->in.req = or->request->next_rq = req; } }else if (has_in)
drivers/scsi/osst.c +0 -1
@@ -373,7 +373,6 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,return DRIVER_ERROR <<24 ; rq =scsi_req (req); -scsi_req_init (req); req->rq_flags |=RQF_QUIET ; SRpnt->bio =NULL ;
drivers/scsi/scsi_error.c +0 -1
@@ -1915,7 +1915,6 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)if (IS_ERR (req))return ; rq =scsi_req (req); -scsi_req_init (req); rq->cmd[0 ] =ALLOW_MEDIUM_REMOVAL ; rq->cmd[1 ] =0 ;
drivers/scsi/scsi_lib.c +9 -1
@@ -249,7 +249,6 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,if (IS_ERR (req))return ret; rq =scsi_req (req); -scsi_req_init (req);if (bufflen &&blk_rq_map_kern (sdev->request_queue, req, buffer, bufflen, __GFP_RECLAIM))
@@ -1133,6 +1132,13 @@ int scsi_init_io(struct scsi_cmnd *cmd) }EXPORT_SYMBOL (scsi_init_io); +/* Called from inside blk_get_request() */ +static void scsi_initialize_rq (struct request *rq) +{ +scsi_req_init (rq); +} + +/* Called after a request has been started. */ void scsi_init_command (struct scsi_device *dev,struct scsi_cmnd *cmd) {void *buf = cmd->sense_buffer;
@@ -2091,6 +2097,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)* blk_queue_update_dma_alignment() later. */ blk_queue_dma_alignment (q,0x03 ); + + q->initialize_rq_fn = scsi_initialize_rq; }EXPORT_SYMBOL_GPL (__scsi_init_queue);
drivers/scsi/scsi_transport_sas.c +6 -0
@@ -213,6 +213,11 @@ static void sas_host_release(struct device *dev)blk_cleanup_queue (q); } +static void sas_initialize_rq (struct request *rq) +{ +scsi_req_init (rq); +} +static int sas_bsg_initialize (struct Scsi_Host *shost,struct sas_rphy *rphy) {struct request_queue *q;
@@ -230,6 +235,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy) q =blk_alloc_queue (GFP_KERNEL );if (!q)return -ENOMEM ; + q->initialize_rq_fn = sas_initialize_rq; q->cmd_size =sizeof (struct scsi_request );if (rphy) {
drivers/scsi/sg.c +0 -2
@@ -1732,8 +1732,6 @@ sg_start_req(Sg_request *srp, unsigned char *cmd) } req =scsi_req (rq); -scsi_req_init (rq); -if (hp->cmd_len >BLK_MAX_CDB ) req->cmd = long_cmdp;memcpy (req->cmd, cmd, hp->cmd_len);
drivers/scsi/st.c +0 -1
@@ -549,7 +549,6 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,if (IS_ERR (req))return DRIVER_ERROR <<24 ; rq =scsi_req (req); -scsi_req_init (req); req->rq_flags |=RQF_QUIET ; mdata->null_mapped =1 ;
drivers/target/target_core_pscsi.c +0 -2
@@ -992,8 +992,6 @@ pscsi_execute_cmd(struct se_cmd *cmd) goto fail; } -scsi_req_init (req); -if (sgl) { ret =pscsi_map_sg (cmd, sgl, sgl_nents, req);if (ret)
fs/nfsd/blocklayout.c +0 -1
@@ -232,7 +232,6 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev, goto out_free_buf; } req =scsi_req (rq); -scsi_req_init (rq); error =blk_rq_map_kern (q, rq, buf, bufflen,GFP_KERNEL );if (error)
Signature · 1 line
2.12.2
Re: [PATCH 18/31] block: Make scsi_req_init() calls implicit
Quoted 381 lines · Bart Van Assche
Instead of explicitly calling
scsi_req_init(), letblk_get_request()call that function from insideblk_rq_init(). Add an .initialize_rq_fn() callback function to the block drivers that need it. Merge the IDE .init_rq_fn() function into .initialize_rq_fn() because it is too small to keep it as a separate function.References: commit
82ed4db499b8("block: splitscsi_requestout of struct request")Signed-off-by Bart Van Assche <[email protected]>Cc Jens Axboe <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Omar Sandoval <[email protected]>Cc Hannes Reinecke <[email protected]>--- block/bsg.c | 1 - block/scsi_ioctl.c | 3 --- drivers/block/pktcdvd.c | 1 - drivers/cdrom/cdrom.c | 1 - drivers/ide/ide-atapi.c | 2 -- drivers/ide/ide-cd.c | 1 - drivers/ide/ide-cd_ioctl.c | 1 - drivers/ide/ide-devsets.c | 1 - drivers/ide/ide-disk.c | 1 - drivers/ide/ide-ioctls.c | 2 -- drivers/ide/ide-park.c | 2 -- drivers/ide/ide-pm.c | 2 -- drivers/ide/ide-probe.c | 6 +++--- drivers/ide/ide-tape.c | 1 - drivers/ide/ide-taskfile.c | 1 - drivers/scsi/osd/osd_initiator.c | 2 -- drivers/scsi/osst.c | 1 - drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 10 +++++++++- drivers/scsi/scsi_transport_sas.c | 6 ++++++ drivers/scsi/sg.c | 2 -- drivers/scsi/st.c | 1 - drivers/target/target_core_pscsi.c | 2 -- fs/nfsd/blocklayout.c | 1 - 24 files changed, 18 insertions(+), 34 deletions(-)block/bsg.c +0
-1@@ -236,7 +236,6 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm) rq =blk_get_request (q, op,GFP_KERNEL );if (IS_ERR (rq))return rq; -scsi_req_init (rq); ret =blk_fill_sgv4_hdr_rq (q, rq, hdr, bd, has_write_perm);if (ret)block/scsi_ioctl.c +0
-3@@ -326,7 +326,6 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,if (IS_ERR (rq))return PTR_ERR (rq); req =scsi_req (rq); -scsi_req_init (rq);if (hdr->cmd_len >BLK_MAX_CDB ) { req->cmd =kzalloc (hdr->cmd_len,GFP_KERNEL );@@ -456,7 +455,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, goto error_free_buffer; } req =scsi_req (rq); -scsi_req_init (rq); cmdlen =COMMAND_SIZE (opcode);@@ -542,7 +540,6 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, rq =blk_get_request (q,REQ_OP_SCSI_OUT , __GFP_RECLAIM);if (IS_ERR (rq))return PTR_ERR (rq); -scsi_req_init (rq); rq->timeout =BLK_DEFAULT_SG_TIMEOUT ;scsi_req (rq)->cmd[0 ] = cmd;scsi_req (rq)->cmd[4 ] = data;drivers/block/pktcdvd.c +0
-1@@ -707,7 +707,6 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, __GFP_RECLAIM);if (IS_ERR (rq))return PTR_ERR (rq); -scsi_req_init (rq);if (cgc->buflen) { ret = blk_rq_map_kern(q, rq, cgc->buffer, cgc->buflen,drivers/cdrom/cdrom.c +0
-1@@ -2199,7 +2199,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,break ; } req =scsi_req (rq); -scsi_req_init (rq); ret =blk_rq_map_user (q, rq,NULL , ubuf, len,GFP_KERNEL );if (ret) {drivers/ide/ide-atapi.c +0
-2@@ -93,7 +93,6 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,int error; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ; rq->special = (char *)pc;@@ -200,7 +199,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)memset (sense,0 ,sizeof (*sense));blk_rq_init (rq->q, sense_rq); -scsi_req_init (sense_rq); err =blk_rq_map_kern (drive->queue, sense_rq, sense, sense_len,GFP_NOIO );drivers/ide/ide-cd.c +0
-1@@ -438,7 +438,6 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, rq =blk_get_request (drive->queue, write ?REQ_OP_DRV_OUT :REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);memcpy (scsi_req (rq)->cmd, cmd,BLK_MAX_CDB );ide_req (rq)->type =ATA_PRIV_PC ; rq->rq_flags |= rq_flags;drivers/ide/ide-cd_ioctl.c +0
-1@@ -304,7 +304,6 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)int ret; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ; rq->rq_flags =RQF_QUIET ;blk_execute_rq (drive->queue, cd->disk, rq,0 );drivers/ide/ide-devsets.c +0
-1@@ -166,7 +166,6 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,return setting->set (drive, arg); rq =blk_get_request (q,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd_len =5 ;scsi_req (rq)->cmd[0 ] =REQ_DEVSET_EXEC ;drivers/ide/ide-disk.c +0
-1@@ -478,7 +478,6 @@ static int set_multcount(ide_drive_t *drive, int arg)return -EBUSY ; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ; drive->mult_req = arg;drivers/ide/ide-ioctls.c +0
-2@@ -126,7 +126,6 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)struct request *rq; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ;blk_execute_rq (drive->queue,NULL , rq,0 ); err =scsi_req (rq)->result ? -EIO :0 ;@@ -224,7 +223,6 @@ static int generic_drive_reset(ide_drive_t *drive)int ret =0 ; rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd_len =1 ;scsi_req (rq)->cmd[0 ] =REQ_DRIVE_RESET ;drivers/ide/ide-park.c +0
-2@@ -32,7 +32,6 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)spin_unlock_irq (&hwif->lock); rq =blk_get_request (q,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);scsi_req (rq)->cmd[0 ] =REQ_PARK_HEADS ;scsi_req (rq)->cmd_len =1 ;ide_req (rq)->type =ATA_PRIV_MISC ;@@ -48,7 +47,6 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)* timeout has expired, so power management will be reenabled. */ rq =blk_get_request (q,REQ_OP_DRV_IN ,GFP_NOWAIT ); -scsi_req_init (rq);if (IS_ERR (rq)) goto out;drivers/ide/ide-pm.c +0
-2@@ -19,7 +19,6 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)memset (&rqpm,0 ,sizeof (rqpm)); rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_PM_SUSPEND ; rq->special = &rqpm; rqpm.pm_step =IDE_PM_START_SUSPEND ;@@ -91,7 +90,6 @@ int generic_ide_resume(struct device *dev)memset (&rqpm,0 ,sizeof (rqpm)); rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_PM_RESUME ; rq->rq_flags |=RQF_PREEMPT ; rq->special = &rqpm;drivers/ide/ide-probe.c +3
-3@@ -741,12 +741,12 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) } } -static int ide_init_rq (struct request_queue *q,struct request *rq,gfp_t gfp) +static void ide_initialize_rq (struct request *rq) {struct ide_request *req =blk_mq_rq_to_pdu (rq); +scsi_req_init (rq); req->sreq.sense = req->sense; -return 0 ; }/* @@ -771,7 +771,7 @@ static int ide_init_queue(ide_drive_t *drive)return 1 ; q->request_fn = do_ide_request; - q->init_rq_fn = ide_init_rq; + q->initialize_rq_fn = ide_initialize_rq; q->cmd_size =sizeof (struct ide_request );queue_flag_set_unlocked (QUEUE_FLAG_SCSI_SUP , q);if (blk_init_allocated_queue (q) <0 ) {drivers/ide/ide-tape.c +0
-1@@ -855,7 +855,6 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)BUG_ON (size <0 || size % tape->blk_size); rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd[13 ] = cmd; rq->rq_disk = tape->disk;drivers/ide/ide-taskfile.c +0
-1@@ -433,7 +433,6 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, rq =blk_get_request (drive->queue, (cmd->tf_flags &IDE_TFLAG_WRITE ) ?REQ_OP_DRV_OUT :REQ_OP_DRV_IN , __GFP_RECLAIM); -scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ;/* drivers/scsi/osd/osd_initiator.c +0
-2@@ -1572,7 +1572,6 @@ static struct request *_make_request(struct request_queue *q, bool has_write, flags);if (IS_ERR (req))return req; -scsi_req_init (req);for_each_bio (bio) {struct bio *bounce_bio = bio;@@ -1617,7 +1616,6 @@ static int _init_blk_request(struct osd_request *or, ret =PTR_ERR (req); goto out; } -scsi_req_init (req); or->in.req = or->request->next_rq = req; } }else if (has_in)drivers/scsi/osst.c +0
-1@@ -373,7 +373,6 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,return DRIVER_ERROR <<24 ; rq =scsi_req (req); -scsi_req_init (req); req->rq_flags |=RQF_QUIET ; SRpnt->bio =NULL ;drivers/scsi/scsi_error.c +0
-1@@ -1915,7 +1915,6 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)if (IS_ERR (req))return ; rq =scsi_req (req); -scsi_req_init (req); rq->cmd[0 ] =ALLOW_MEDIUM_REMOVAL ; rq->cmd[1 ] =0 ;drivers/scsi/scsi_lib.c +9
-1@@ -249,7 +249,6 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,if (IS_ERR (req))return ret; rq =scsi_req (req); -scsi_req_init (req);if (bufflen &&blk_rq_map_kern (sdev->request_queue, req, buffer, bufflen, __GFP_RECLAIM))@@ -1133,6 +1132,13 @@ int scsi_init_io(struct scsi_cmnd *cmd) }EXPORT_SYMBOL (scsi_init_io); +/* Called from inside blk_get_request() */ +static void scsi_initialize_rq (struct request *rq) +{ +scsi_req_init (rq); +} + +/* Called after a request has been started. */ void scsi_init_command (struct scsi_device *dev,struct scsi_cmnd *cmd) {void *buf = cmd->sense_buffer;@@ -2091,6 +2097,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)* blk_queue_update_dma_alignment() later. */ blk_queue_dma_alignment (q,0x03 ); + + q->initialize_rq_fn = scsi_initialize_rq; }EXPORT_SYMBOL_GPL (__scsi_init_queue);drivers/scsi/scsi_transport_sas.c +5
-0@@ -213,6 +213,11 @@ static void sas_host_release(struct device *dev)blk_cleanup_queue (q); } +static void sas_initialize_rq (struct request *rq) +{ +scsi_req_init (rq); +} +static int sas_bsg_initialize (struct Scsi_Host *shost,struct sas_rphy *rphy) {struct request_queue *q;
drivers/scsi/scsi_transport_sas.c static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy) · line 241
Quoted 7 lines
drivers/scsi/scsi_transport_sas.c +1
-0@@ -230,6 +235,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy) q =blk_alloc_queue (GFP_KERNEL );if (!q)return -ENOMEM ; + q->initialize_rq_fn = sas_initialize_rq; q->cmd_size =sizeof (struct scsi_request );if (rphy) {
Why not using scsi_req_init() directly?
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 19/31 scsi: Change argument type of scsi_req_init()
In reply to Bart Van AsscheSince scsi_req_init() works on a struct scsi_request, change the argument type into struct scsi_request *.
--- block/scsi_ioctl.c | 10 +++++++--- drivers/ide/ide-probe.c | 2 +- drivers/scsi/scsi_lib.c | 4 +++- drivers/scsi/scsi_transport_sas.c | 2 +- include/scsi/scsi_request.h | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-)
block/scsi_ioctl.c +7 -3
@@ -741,10 +741,14 @@ int scsi_cmd_blk_ioctl(struct block_device *bd, fmode_t mode, }EXPORT_SYMBOL (scsi_cmd_blk_ioctl); -void scsi_req_init (struct request *rq) +/** +* scsi_req_init - initialize certain fields of a scsi_request structure +* @req: Pointer to a scsi_request structure. +* Initializes .__cmd[], .cmd, .cmd_len and .sense_len but no other members +* of struct scsi_request. +*/ +void scsi_req_init (struct scsi_request *req) { -struct scsi_request *req =scsi_req (rq); -memset (req->__cmd,0 ,sizeof (req->__cmd)); req->cmd = req->__cmd; req->cmd_len =BLK_MAX_CDB ;
drivers/ide/ide-probe.c +1 -1
@@ -745,7 +745,7 @@ static void ide_initialize_rq(struct request *rq) {struct ide_request *req =blk_mq_rq_to_pdu (rq); -scsi_req_init (rq); +scsi_req_init (&req->sreq); req->sreq.sense = req->sense; }
drivers/scsi/scsi_lib.c +3 -1
@@ -1135,7 +1135,9 @@ EXPORT_SYMBOL(scsi_init_io);/* Called from inside blk_get_request() */ static void scsi_initialize_rq (struct request *rq) { -scsi_req_init (rq); +struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); + +scsi_req_init (&cmd->req); }/* Called after a request has been started. */
drivers/scsi/scsi_transport_sas.c +1 -1
@@ -215,7 +215,7 @@ static void sas_host_release(struct device *dev)static void sas_initialize_rq (struct request *rq) { -scsi_req_init (rq); +scsi_req_init (scsi_req (rq)); }static int sas_bsg_initialize (struct Scsi_Host *shost,struct sas_rphy *rphy)
include/scsi/scsi_request.h +1 -1
@@ -27,6 +27,6 @@ static inline void scsi_req_free_cmd(struct scsi_request *req) kfree(req->cmd); } -void scsi_req_init (struct request *); +void scsi_req_init (struct scsi_request *req);#endif /* _SCSI_SCSI_REQUEST_H */
Signature · 1 line
2.12.2
Re: [PATCH 19/31] scsi: Change argument type of scsi_req_init()
Quoted 6 lines · Bart Van Assche
Since
scsi_req_init()works on a structscsi_request, change the argument type into structscsi_request*.Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>
Quoted 8 lines
--- block/scsi_ioctl.c | 10 +++++++--- drivers/ide/ide-probe.c | 2 +- drivers/scsi/scsi_lib.c | 4 +++- drivers/scsi/scsi_transport_sas.c | 2 +- include/scsi/scsi_request.h | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-)
Ah, right. Now it's clear.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 20/31 scsi: Only add commands to the device command list if required by the LLD
In reply to Bart Van AsscheJust like for the scsi-mq code path, in the single queue SCSI code path only add commands to the per-device command list if required by the SCSI LLD. This patch will make it easier to merge the single-queue and multiqueue command initialization code.
--- drivers/scsi/scsi.c | 9 +-------- drivers/scsi/scsi_lib.c | 52 +++++++++++++++++++++++++++++------------------- drivers/scsi/scsi_priv.h | 2 ++ 3 files changed, 35 insertions(+), 28 deletions(-)
drivers/scsi/scsi.c +1 -8
@@ -108,14 +108,7 @@ EXPORT_SYMBOL(scsi_sd_pm_domain);*/ void scsi_put_command (struct scsi_cmnd *cmd) { -unsigned long flags; - -/* serious error if the command hasn't come from a device list */ -spin_lock_irqsave (&cmd->device->list_lock, flags); -BUG_ON (list_empty (&cmd->list)); -list_del_init (&cmd->list); -spin_unlock_irqrestore (&cmd->device->list_lock, flags); - +scsi_del_cmd_from_list (cmd);BUG_ON (delayed_work_pending (&cmd->abort_work)); }
drivers/scsi/scsi_lib.c +32 -20
84 lines not on this page · raw message
drivers/scsi/scsi_priv.h +2 -0
@@ -80,6 +80,8 @@ int scsi_eh_get_sense(struct list_head *work_q,int scsi_noretry_cmd (struct scsi_cmnd *scmd);/* scsi_lib.c */ +extern void scsi_add_cmd_to_list (struct scsi_cmnd *cmd); +extern void scsi_del_cmd_from_list (struct scsi_cmnd *cmd);extern int scsi_maybe_unblock_host (struct scsi_device *sdev);extern void scsi_device_unbusy (struct scsi_device *sdev);extern void scsi_queue_insert (struct scsi_cmnd *cmd,int reason);
Signature · 1 line
2.12.2
Re: [PATCH 20/31] scsi: Only add commands to the device command list if required by the LLD
Quoted 5 lines · Bart Van Assche
Just like for the scsi-mq code path, in the single queue SCSI code path only add commands to the per-device command list if required by the SCSI LLD. This patch will make it easier to merge the single-queue and multiqueue command initialization code.
Quoted 9 lines
Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi.c | 9 +-------- drivers/scsi/scsi_lib.c | 52 +++++++++++++++++++++++++++++------------------- drivers/scsi/scsi_priv.h | 2 ++ 3 files changed, 35 insertions(+), 28 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 21/31 scsi: Move most of scsi_init_command() into scsi_initialize_rq()
In reply to Bart Van AsscheMove the initializations that only have to be performed once and not every time a request is prepared from scsi_init_command() into scsi_initialize_rq(). This patch also moves the jiffies_at_alloc assignment such that it gets back the meaning it had before commit e9c787e65c0c, namely the value of the jiffies counter at request allocation time.
--- drivers/scsi/scsi_lib.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/scsi/scsi_lib.c +8 -9
@@ -1155,26 +1155,25 @@ void scsi_del_cmd_from_list(struct scsi_cmnd *cmd)static void scsi_initialize_rq (struct request *rq) {struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (rq); - -scsi_req_init (&cmd->req); -} - -/* Called after a request has been started. */ -void scsi_init_command (struct scsi_device *dev,struct scsi_cmnd *cmd) -{ +struct scsi_device *dev = rq->q->queuedata;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); - +sizeof (*cmd) -sizeof (cmd->req)); +scsi_req_init (&cmd->req); cmd->device = dev; cmd->sense_buffer = buf; cmd->prot_sdb = prot;INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler); cmd->jiffies_at_alloc = jiffies; +} +/* Called after a request has been started. */ +void scsi_init_command (struct scsi_device *dev,struct scsi_cmnd *cmd) +{ +memset (scsi_cmd_priv (cmd),0 , dev->host->hostt->cmd_size);scsi_add_cmd_to_list (cmd); }
Signature · 1 line
2.12.2
Re: [PATCH 21/31] scsi: Move most of scsi_init_command() into scsi_initialize_rq()
Quoted 7 lines · Bart Van Assche
Move the initializations that only have to be performed once and not every time a request is prepared from
scsi_init_command()intoscsi_initialize_rq(). This patch also moves thejiffies_at_allocassignment such that it gets back the meaning it had before commite9c787e65c0c, namely the value of the jiffies counter at request allocation time.
Quoted 8 lines
Fixes commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request")Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_lib.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 22/31 scsi: Inline scsi_init_command()
In reply to Bart Van AsscheThe two drivers that use the per-device command list, namely aacraid and dpt_i2o, expect that that list contains only SCSI commands and no task management functions. Hence only call scsi_add_cmd_to_list() from the block layer prep callback functions and not from scsi_ioctl_reset().
--- drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 10 ++-------- drivers/scsi/scsi_priv.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-)
drivers/scsi/scsi_error.c +0 -1
@@ -2293,7 +2293,6 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)blk_rq_init (dev->request_queue, rq); scmd = (struct scsi_cmnd *)(rq +1 ); -scsi_init_command (dev, scmd); scmd->request = rq; scmd->cmnd =scsi_req (rq)->cmd;
drivers/scsi/scsi_lib.c +2 -8
@@ -1170,13 +1170,6 @@ static void scsi_initialize_rq(struct request *rq) cmd->jiffies_at_alloc = jiffies; } -/* Called after a request has been started. */ -void scsi_init_command (struct scsi_device *dev,struct scsi_cmnd *cmd) -{ -memset (scsi_cmd_priv (cmd),0 , dev->host->hostt->cmd_size); -scsi_add_cmd_to_list (cmd); -} -static int scsi_setup_scsi_cmnd (struct scsi_device *sdev,struct request *req) {struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);
@@ -1347,7 +1340,8 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) goto out; } -scsi_init_command (sdev, cmd); +memset (scsi_cmd_priv (cmd),0 , dev->host->hostt->cmd_size); +scsi_add_cmd_to_list (cmd); req->special = cmd; }
drivers/scsi/scsi_priv.h +0 -1
@@ -30,7 +30,6 @@ extern void scsi_exit_hosts(void);/* scsi.c */ extern bool scsi_use_blk_mq;int scsi_init_sense_cache (struct Scsi_Host *shost); -void scsi_init_command (struct scsi_device *dev,struct scsi_cmnd *cmd);#ifdef CONFIG_SCSI_LOGGING void scsi_log_send (struct scsi_cmnd *cmd);void scsi_log_completion (struct scsi_cmnd *cmd,int disposition);
Signature · 1 line
2.12.2
Re: [PATCH 22/31] scsi: Inline scsi_init_command()
Quoted 6 lines · Bart Van Assche
The two drivers that use the per-device command list, namely aacraid and
dpt_i2o, expect that that list contains only SCSI commands and no task management functions. Hence only callscsi_add_cmd_to_list()from the block layer prep callback functions and not fromscsi_ioctl_reset().
Quoted 9 lines
Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 10 ++-------- drivers/scsi/scsi_priv.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 23/31 scsi: Move sense buffer pointer initialization into scsi_initialize_rq()
In reply to Bart Van AsscheThis patch is a preparation for the next patch that will zero the struct scsi_request embedded in struct scsi_cmnd before calling scsi_req_init().
--- drivers/scsi/scsi_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +1 -2
@@ -1164,6 +1164,7 @@ static void scsi_initialize_rq(struct request *rq) sizeof(*cmd) - sizeof(cmd->req));scsi_req_init (&cmd->req); cmd->device = dev; + cmd->req.sense = cmd->sense_buffer; cmd->sense_buffer = buf; cmd->prot_sdb = prot;INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler);
@@ -2025,7 +2026,6 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq, GFP_KERNEL, numa_node);if (!cmd->sense_buffer)return -ENOMEM ; - cmd->req.sense = cmd->sense_buffer;return 0 ; }
@@ -2123,7 +2123,6 @@ static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp) NUMA_NO_NODE);if (!cmd->sense_buffer) goto fail; - cmd->req.sense = cmd->sense_buffer;if (scsi_host_get_prot (shost) >=SHOST_DIX_TYPE0_PROTECTION ) { cmd->prot_sdb =kmem_cache_zalloc (scsi_sdb_cache, gfp);
Signature · 1 line
2.12.2
Re: [PATCH 23/31] scsi: Move sense buffer pointer initialization into scsi_initialize_rq()
Quoted 11 lines · Bart Van Assche
This patch is a preparation for the next patch that will zero the struct
scsi_requestembedded in structscsi_cmndbefore callingscsi_req_init().Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 24/31 scsi: Make scsi_initialize_rq() zero the entire struct scsi_cmnd
In reply to Bart Van AsscheThis simplifies the memset() call in scsi_initialize_rq() and avoids that any stale data is left behind in struct scsi_request.
--- drivers/scsi/scsi_lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/scsi_lib.c +2 -4
@@ -1159,12 +1159,10 @@ 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)); +memset (cmd,0 ,sizeof (*cmd));scsi_req_init (&cmd->req); cmd->device = dev; - cmd->req.sense = cmd->sense_buffer; + cmd->req.sense = buf; cmd->sense_buffer = buf; cmd->prot_sdb = prot;INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler);
Signature · 1 line
2.12.2
Re: [PATCH 24/31] scsi: Make scsi_initialize_rq() zero the entire struct scsi_cmnd
Quoted 20 lines · Bart Van Assche
This simplifies the
memset()call inscsi_initialize_rq()and avoids that any stale data is left behind in structscsi_request.Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_lib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/scsi/scsi_lib.c +0
-1@@ -1159,12 +1159,10 @@ 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 */
drivers/scsi/scsi_lib.c static void scsi_initialize_rq(struct request *rq) · line 1168
Quoted 10 lines
drivers/scsi/scsi_lib.c +2
-3-memset ((char *)cmd +sizeof (cmd->req),0 , -sizeof (*cmd) -sizeof (cmd->req)); +memset (cmd,0 ,sizeof (*cmd));scsi_req_init (&cmd->req); cmd->device = dev; - cmd->req.sense = cmd->sense_buffer; + cmd->req.sense = buf; cmd->sense_buffer = buf; cmd->prot_sdb = prot;INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler);
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 25/31 scsi-mq: Make behavior scsi_mq_prep_fn() closer to that of scsi_prep_fn()
In reply to Bart Van AsscheInstead of clearing most of struct scsi_cmnd and reinitializing it, rely on scsi_initialize_rq() for initialization of struct scsi_cmnd. This patch fixes a bug, namely that it avoids that jiffies_at_alloc gets overwritten if a request is requeued.
--- drivers/scsi/scsi_lib.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/scsi/scsi_lib.c +1 -11
@@ -1861,27 +1861,17 @@ static int scsi_mq_prep_fn(struct request *req)struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);struct scsi_device *sdev = req->q->queuedata;struct Scsi_Host *shost = sdev->host; -unsigned char *sense_buf = cmd->sense_buffer;struct scatterlist *sg; -/* zero out the cmd, except for the embedded scsi_request */ -memset ((char *)cmd +sizeof (cmd->req),0 , -sizeof (*cmd) -sizeof (cmd->req) + shost->hostt->cmd_size); +memset (scsi_cmd_priv (cmd),0 , shost->hostt->cmd_size); req->special = cmd; cmd->request = req; - cmd->device = sdev; - cmd->sense_buffer = sense_buf; cmd->tag = req->tag; - cmd->prot_op =SCSI_PROT_NORMAL ; -INIT_LIST_HEAD (&cmd->list); -INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler); - cmd->jiffies_at_alloc = jiffies; -scsi_add_cmd_to_list (cmd); sg = (void *)cmd +sizeof (struct scsi_cmnd ) + shost->hostt->cmd_size;
Signature · 1 line
2.12.2
Re: [PATCH 25/31] scsi-mq: Make behavior scsi_mq_prep_fn() closer to that of scsi_prep_fn()
Quoted 36 lines · Bart Van Assche
Instead of clearing most of struct
scsi_cmndand reinitializing it, rely onscsi_initialize_rq()for initialization of structscsi_cmnd. This patch fixes a bug, namely that it avoids thatjiffies_at_allocgets overwritten if a request is requeued.Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_lib.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/scsi/scsi_lib.c +1
-6@@ -1861,27 +1861,17 @@ static int scsi_mq_prep_fn(struct request *req)struct scsi_cmnd *cmd =blk_mq_rq_to_pdu (req);struct scsi_device *sdev = req->q->queuedata;struct Scsi_Host *shost = sdev->host; -unsigned char *sense_buf = cmd->sense_buffer;struct scatterlist *sg; -/* zero out the cmd, except for the embedded scsi_request */ -memset ((char *)cmd +sizeof (cmd->req),0 , -sizeof (*cmd) -sizeof (cmd->req) + shost->hostt->cmd_size); +memset (scsi_cmd_priv (cmd),0 , shost->hostt->cmd_size); req->special = cmd; cmd->request = req; - cmd->device = sdev; - cmd->sense_buffer = sense_buf; cmd->tag = req->tag;
drivers/scsi/scsi_lib.c static int scsi_mq_prep_fn(struct request *req) · line 1877
Quoted 10 lines
drivers/scsi/scsi_lib.c +0
-5- cmd->prot_op =SCSI_PROT_NORMAL ; -INIT_LIST_HEAD (&cmd->list); -INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler); - cmd->jiffies_at_alloc = jiffies; -scsi_add_cmd_to_list (cmd); sg = (void *)cmd +sizeof (struct scsi_cmnd ) + shost->hostt->cmd_size;
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 26/31 scsi: Move the code for clearing private command data into scsi_dispatch_cmd()
In reply to Bart Van AsscheThis patch does not change any functionality but avoids duplication of the code for clearing driver-private command data.
--- drivers/scsi/scsi_lib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/scsi_lib.c +2 -3
@@ -1339,7 +1339,6 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) goto out; } -memset (scsi_cmd_priv (cmd),0 , dev->host->hostt->cmd_size);scsi_add_cmd_to_list (cmd); req->special = cmd; }
@@ -1677,6 +1676,8 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) } +memset (scsi_cmd_priv (cmd),0 , host->hostt->cmd_size); +trace_scsi_dispatch_cmd_start (cmd); rtn = host->hostt->queuecommand (host, cmd);if (rtn) {
@@ -1863,8 +1864,6 @@ static int scsi_mq_prep_fn(struct request *req)struct Scsi_Host *shost = sdev->host;struct scatterlist *sg; -memset (scsi_cmd_priv (cmd),0 , shost->hostt->cmd_size); - req->special = cmd; cmd->request = req;
Signature · 1 line
2.12.2
Re: [PATCH 26/31] scsi: Move the code for clearing private command data into scsi_dispatch_cmd()
Quoted 10 lines · Bart Van Assche
This patch does not change any functionality but avoids duplication of the code for clearing driver-private command data.
Signed-off-by Bart Van Assche <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_lib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 27/31 scsi: Consolidate more initialization code
In reply to Bart Van AsscheInitialize struct scsi_cmnd.request from inside scsi_initialize_rq() instead of every time a request is prepared. Note: moving the tag initialization into scsi_initialize_rq() is not possible because the single-queue block layer only assigns a tag to a request after a request has been started.
--- drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/scsi_error.c +0 -1
@@ -2293,7 +2293,6 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)blk_rq_init (dev->request_queue, rq); scmd = (struct scsi_cmnd *)(rq +1 ); - scmd->request = rq; scmd->cmnd =scsi_req (rq)->cmd; scmd->scsi_done = scsi_reset_provider_done_command;
drivers/scsi/scsi_lib.c +1 -3
@@ -1165,6 +1165,7 @@ static void scsi_initialize_rq(struct request *rq) cmd->req.sense = buf; cmd->sense_buffer = buf; cmd->prot_sdb = prot; + cmd->request = rq;INIT_DELAYED_WORK (&cmd->abort_work, scmd_eh_abort_handler); cmd->jiffies_at_alloc = jiffies; }
@@ -1344,7 +1345,6 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) } cmd->tag = req->tag; - cmd->request = req; cmd->prot_op =SCSI_PROT_NORMAL ; ret =scsi_setup_cmnd (sdev, req);
@@ -1866,8 +1866,6 @@ static int scsi_mq_prep_fn(struct request *req) req->special = cmd; - cmd->request = req; - cmd->tag = req->tag; cmd->prot_op =SCSI_PROT_NORMAL ;
Signature · 1 line
2.12.2
Re: [PATCH 27/31] scsi: Consolidate more initialization code
Quoted 6 lines · Bart Van Assche
Initialize struct scsi_cmnd.request from inside
scsi_initialize_rq()instead of every time a request is prepared. Note: moving the tag initialization intoscsi_initialize_rq()is not possible because the single-queue block layer only assigns a tag to a request after a request has been started.
Quoted 8 lines
Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_error.c | 1 - drivers/scsi/scsi_lib.c | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 28/31 scsi_setup_fs_cmnd(): Call scsi_req_init() instead of open-coding it
In reply to Bart Van AsscheThe only functional change is that this patch causes scsi_setup_fs_cmnd() to clear scsi_request.sense_len.
--- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_lib.c +2 -2
@@ -1211,8 +1211,8 @@ static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)return ret; } - cmd->cmnd =scsi_req (req)->cmd =scsi_req (req)->__cmd; -memset (cmd->cmnd,0 ,BLK_MAX_CDB ); +scsi_req_init (&cmd->req); + cmd->cmnd =scsi_req (req)->cmd;return scsi_cmd_to_driver (cmd)->init_command (cmd); }
Signature · 1 line
2.12.2
Re: [PATCH 28/31] scsi_setup_fs_cmnd(): Call scsi_req_init() instead of open-coding it
Quoted 10 lines · Bart Van Assche
The only functional change is that this patch causes
scsi_setup_fs_cmnd()to clear scsi_request.sense_len.Signed-off-by Bart Van Assche <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 29/31 scsi: snic: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheSince the SCSI core zeroes driver-private command data, remove that code from the snic driver.
--- drivers/scsi/snic/snic_scsi.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/snic/snic_scsi.c +0 -2
@@ -359,8 +359,6 @@ snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)SNIC_SCSI_DBG (shost,"sc %p Tag %d (sc %0x) lun %lld in snic_qcmd\n" , sc,snic_cmd_tag (sc), sc->cmnd[0 ], sc->device->lun); -memset (scsi_cmd_priv (sc),0 ,sizeof (struct snic_internal_io_state )); - ret =snic_issue_scsi_req (snic, tgt, sc);if (ret) {SNIC_HOST_ERR (shost,"Failed to Q, Scsi Req w/ err %d.\n" , ret);
Signature · 1 line
2.12.2
Re: [PATCH 29/31] scsi: snic: Remove code that zeroes driver-private command data
Quoted 18 lines · Bart Van Assche
Since the SCSI core zeroes driver-private command data, remove that code from the snic driver.
Signed-off-by Bart Van Assche <[email protected]>Cc Narsimhulu Musini <[email protected]>Cc Sesidhar Baddela <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/snic/snic_scsi.c | 2 -- 1 file changed, 2 deletions(-)drivers/scsi/snic/snic_scsi.c +0
-0
drivers/scsi/snic/snic_scsi.c snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) · line 364
Quoted 8 lines
drivers/scsi/snic/snic_scsi.c +0
-2@@ -359,8 +359,6 @@ snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)SNIC_SCSI_DBG (shost,"sc %p Tag %d (sc %0x) lun %lld in snic_qcmd\n" , sc,snic_cmd_tag (sc), sc->cmnd[0 ], sc->device->lun); -memset (scsi_cmd_priv (sc),0 ,sizeof (struct snic_internal_io_state )); - ret =snic_issue_scsi_req (snic, tgt, sc);if (ret) {SNIC_HOST_ERR (shost,"Failed to Q, Scsi Req w/ err %d.\n" , ret);
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 30/31 scsi: virtio: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheSince the SCSI core zeroes driver-private command data, remove that code from the virtio driver.
--- drivers/scsi/virtio_scsi.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/virtio_scsi.c +0 -1
@@ -547,7 +547,6 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,dev_dbg (&sc->device->sdev_gendev,"cmd %p CDB: %#02x\n" , sc, sc->cmnd[0 ]); -memset (cmd,0 ,sizeof (*cmd)); cmd->sc = sc;BUG_ON (sc->cmd_len >VIRTIO_SCSI_CDB_SIZE );
Signature · 1 line
2.12.2
Re: [PATCH 30/31] scsi: virtio: Remove code that zeroes driver-private command data
Quoted 17 lines · Bart Van Assche
Since the SCSI core zeroes driver-private command data, remove that code from the virtio driver.
Signed-off-by Bart Van Assche <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>--- drivers/scsi/virtio_scsi.c | 1 - 1 file changed, 1 deletion(-)drivers/scsi/virtio_scsi.c +0
-0
drivers/scsi/virtio_scsi.c static int virtscsi_queuecommand(struct virtio_scsi *vscsi, · line 552
Quoted 7 lines
drivers/scsi/virtio_scsi.c +0
-1@@ -547,7 +547,6 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,dev_dbg (&sc->device->sdev_gendev,"cmd %p CDB: %#02x\n" , sc, sc->cmnd[0 ]); -memset (cmd,0 ,sizeof (*cmd)); cmd->sc = sc;BUG_ON (sc->cmd_len >VIRTIO_SCSI_CDB_SIZE );
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
PATCH 31/31 xen/scsifront: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheSince the SCSI core zeroes driver-private command data, remove that code from the xen-scsifront driver.
--- drivers/scsi/xen-scsifront.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/xen-scsifront.c +0 -1
@@ -534,7 +534,6 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,int err; sc->result =0 ; -memset (shadow,0 ,sizeof (*shadow)); shadow->sc = sc; shadow->act =VSCSIIF_ACT_SCSI_CDB ;
Signature · 1 line
2.12.2
Re: [PATCH 31/31] xen/scsifront: Remove code that zeroes driver-private command data
Quoted 16 lines · Bart Van Assche
Since the SCSI core zeroes driver-private command data, remove that code from the xen-scsifront driver.
Signed-off-by Bart Van Assche <[email protected]>Cc Juergen Gross <[email protected]>--- drivers/scsi/xen-scsifront.c | 1 - 1 file changed, 1 deletion(-)drivers/scsi/xen-scsifront.c +0
-0
drivers/scsi/xen-scsifront.c static int scsifront_queuecommand(struct Scsi_Host *shost, · line 539
Quoted 7 lines
drivers/scsi/xen-scsifront.c +0
-1@@ -534,7 +534,6 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,int err; sc->result =0 ; -memset (shadow,0 ,sizeof (*shadow)); shadow->sc = sc; shadow->act =VSCSIIF_ACT_SCSI_CDB ;
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 31/31] xen/scsifront: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheQuoted 16 lines · Bart Van Assche
Since the SCSI core zeroes driver-private command data, remove that code from the xen-scsifront driver.
Signed-off-by Bart Van Assche <[email protected]>Cc Juergen Gross <[email protected]>--- drivers/scsi/xen-scsifront.c | 1 - 1 file changed, 1 deletion(-)drivers/scsi/xen-scsifront.c +0
-0
drivers/scsi/xen-scsifront.c static int scsifront_queuecommand(struct Scsi_Host *shost, · line 539
Quoted 7 lines
drivers/scsi/xen-scsifront.c +0
-1@@ -534,7 +534,6 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,int err; sc->result =0 ; -memset (shadow,0 ,sizeof (*shadow)); shadow->sc = sc; shadow->act =VSCSIIF_ACT_SCSI_CDB ;
Cheers,
Hannes
Signature · 10 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 31/31] xen/scsifront: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheQuoted 6 lines · Bart Van Assche
Since the SCSI core zeroes driver-private command data, remove that code from the xen-scsifront driver.
Signed-off-by Bart Van Assche <[email protected]>Cc Juergen Gross <[email protected]>
Thanks,
Juergen
Re: [PATCH 31/31] xen/scsifront: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheQuoted 6 lines · Bart Van Assche
Since the SCSI core zeroes driver-private command data, remove that code from the xen-scsifront driver.
Signed-off-by Bart Van Assche <[email protected]>Cc Juergen Gross <[email protected]>
Thanks,
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 31/31 xen/scsifront: Remove code that zeroes driver-private command data
In reply to Bart Van AsscheSince the SCSI core zeroes driver-private command data, remove that code from the xen-scsifront driver.
--- drivers/scsi/xen-scsifront.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/xen-scsifront.c +0 -1
@@ -534,7 +534,6 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,int err; sc->result =0 ; -memset (shadow,0 ,sizeof (*shadow)); shadow->sc = sc; shadow->act =VSCSIIF_ACT_SCSI_CDB ;
Signature · 7 lines
2.12.2 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Bart,
Quoted 2 lines
This patch series consists of the bug fixes I came up with during the past two months. Please consider these patches for kernel v4.13.
I'll have some time tomorrow to go through these.
It would be nice is somebody else would step up to review as well.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Jens Axboe
maintainerQuoted 4 lines · Bart Van Assche
Hello Martin,
This patch series consists of the bug fixes I came up with during the past two months. Please consider these patches for kernel v4.13.
Ehm, last I checked the block patches hadn't been reviewed/signed-off by anyone else. We still have that init addition in the hot path for request initialization, as Christoph pointed out.
So let's hold off on this a bit, at least on the block parts, until we have things properly signed off.
Signature · 1 line
Jens Axboe
T24gVHVlLCAyMDE3LTA1LTIzIGF0IDIxOjU1IC0wNjAwLCBKZW5zIEF4Ym9lIHdyb3RlOg0KPiBP biAwNS8yMy8yMDE3IDA2OjMzIFBNLCBCYXJ0IFZhbiBBc3NjaGUgd3JvdGU6DQo+ID4gSGVsbG8g TWFydGluLA0KPiA+IA0KPiA+IFRoaXMgcGF0Y2ggc2VyaWVzIGNvbnNpc3RzIG9mIHRoZSBidWcg Zml4ZXMgSSBjYW1lIHVwIHdpdGggZHVyaW5nDQo+ID4gdGhlIHBhc3QgdHdvIG1vbnRocy4gUGxl YXNlIGNvbnNpZGVyIHRoZXNlIHBhdGNoZXMgZm9yIGtlcm5lbCB2NC4xMy4NCj4gDQo+IEVobSwg bGFzdCBJIGNoZWNrZWQgdGhlIGJsb2NrIHBhdGNoZXMgaGFkbid0IGJlZW4gcmV2aWV3ZWQvc2ln bmVkLW9mZg0KPiBieSBhbnlvbmUgZWxzZS4gV2Ugc3RpbGwgaGF2ZSB0aGF0IGluaXQgYWRkaXRp b24gaW4gdGhlIGhvdCBwYXRoIGZvcg0KPiByZXF1ZXN0IGluaXRpYWxpemF0aW9uLCBhcyBDaHJp c3RvcGggcG9pbnRlZCBvdXQuDQo+IA0KPiBTbyBsZXQncyBob2xkIG9mZiBvbiB0aGlzIGEgYml0 LCBhdCBsZWFzdCBvbiB0aGUgYmxvY2sgcGFydHMsIHVudGlsDQo+IHdlIGhhdmUgdGhpbmdzIHBy b3Blcmx5IHNpZ25lZCBvZmYuDQoNCkhpIEplbnMsDQoNCkluIGNhc2UgdGhpcyB3b3VsZG4ndCBi ZSBjbGVhciwgSSBmdWxseSBhZ3JlZSB3aXRoIHlvdSB0aGF0IHlvdXIgYXBwcm92YWwNCmlzIHJl cXVpcmVkIGZvciB0aGUgYmxvY2sgbGF5ZXIgcGF0Y2hlcy4gSXQncyBiZWNhdXNlIHRoZXJlIGFy ZSBzZXZlcmFsDQpibG9jayBsYXllciBwYXRjaGVzIGluIHRoaXMgc2VyaWVzIHRoYXQgSSBoYXZl IENjLWVkIHRoZSBibG9jayBsYXllcg0KbWFpbGluZyBsaXN0IGZvciB0aGUgd2hvbGUgc2VyaWVz Lg0KDQpCYXJ0Lg==
Bart,
Quoted 2 lines
This patch series consists of the bug fixes I came up with during the past two months. Please consider these patches for kernel v4.13.
No major objections from me. Although you may have to slice and dice the series differently so we can get the block bits queued through Jens and then do the rest as a stage 2 merge.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 6 lines · Martin K. Petersen
Quoted 2 lines
This patch series consists of the bug fixes I came up with during the past two months. Please consider these patches for kernel v4.13.
=20
No major objections from me. Although you may have to slice and dice the series differently so we can get the block bits queued through Jens and then do the rest as a stage 2 merge.
Hello Martin,
The first eight patches in this series do not depend on any block layer cha= nges.
Do you want me to repost this patches or can you perhaps queue these withou= t a
repost?
Thanks,
Bart.=
Quoted 3 lines · Bart Van Assche
The first eight patches in this series do not depend on any block layer changes. Do you want me to repost this patches or can you perhaps queue these without a repost?
It would be great if you could repost them, also for the reviewers.