Skip to content

Commit 59c30cf

Browse files
author
CKI KWF Bot
committed
Merge: SCSI updates for 9.8
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7365 SCSI core updates for RHEL 9.8 to upstream 6.17 +/- JIRA: https://issues.redhat.com/browse/RHEL-116075 Signed-off-by: Ewan D. Milne <emilne@redhat.com> Approved-by: bgurney <bgurney@redhat.com> Approved-by: Ming Lei <ming.lei@redhat.com> Approved-by: John Meneghini <jmeneghi@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents c52c193 + d0bf82c commit 59c30cf

File tree

14 files changed

+401
-280
lines changed

14 files changed

+401
-280
lines changed

drivers/scsi/hosts.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,17 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
473473
else
474474
shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS;
475475

476-
if (sht->max_segment_size)
477-
shost->max_segment_size = sht->max_segment_size;
478-
else
479-
shost->max_segment_size = BLK_MAX_SEGMENT_SIZE;
476+
shost->virt_boundary_mask = sht->virt_boundary_mask;
477+
if (shost->virt_boundary_mask) {
478+
WARN_ON_ONCE(sht->max_segment_size &&
479+
sht->max_segment_size != UINT_MAX);
480+
shost->max_segment_size = UINT_MAX;
481+
} else {
482+
if (sht->max_segment_size)
483+
shost->max_segment_size = sht->max_segment_size;
484+
else
485+
shost->max_segment_size = BLK_MAX_SEGMENT_SIZE;
486+
}
480487

481488
/* 32-byte (dword) is a common minimum for HBAs. */
482489
if (sht->dma_alignment)
@@ -492,9 +499,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
492499
else
493500
shost->dma_boundary = 0xffffffff;
494501

495-
if (sht->virt_boundary_mask)
496-
shost->virt_boundary_mask = sht->virt_boundary_mask;
497-
498502
device_initialize(&shost->shost_gendev);
499503
dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
500504
shost->shost_gendev.bus = &scsi_bus_type;

drivers/scsi/scsi.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,11 @@ EXPORT_SYMBOL(scsi_change_queue_depth);
242242
* specific SCSI device to determine if and when there is a
243243
* need to adjust the queue depth on the device.
244244
*
245-
* Returns: 0 - No change needed, >0 - Adjust queue depth to this new depth,
246-
* -1 - Drop back to untagged operation using host->cmd_per_lun
247-
* as the untagged command depth
245+
* Returns:
246+
* * 0 - No change needed
247+
* * >0 - Adjust queue depth to this new depth,
248+
* * -1 - Drop back to untagged operation using host->cmd_per_lun as the
249+
* untagged command depth
248250
*
249251
* Lock Status: None held on entry
250252
*
@@ -708,20 +710,15 @@ void scsi_cdl_check(struct scsi_device *sdev)
708710
int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
709711
{
710712
char buf[64];
711-
bool is_ata;
712713
int ret;
713714

714715
if (!sdev->cdl_supported)
715716
return -EOPNOTSUPP;
716717

717-
rcu_read_lock();
718-
is_ata = rcu_dereference(sdev->vpd_pg89);
719-
rcu_read_unlock();
720-
721718
/*
722719
* For ATA devices, CDL needs to be enabled with a SET FEATURES command.
723720
*/
724-
if (is_ata) {
721+
if (sdev->is_ata) {
725722
struct scsi_mode_data data;
726723
struct scsi_sense_hdr sshdr;
727724
char *buf_data;

drivers/scsi/scsi_debug.c

Lines changed: 263 additions & 189 deletions
Large diffs are not rendered by default.

drivers/scsi/scsi_devinfo.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,12 @@ static struct {
269269
static struct scsi_dev_info_list_table *scsi_devinfo_lookup_by_key(int key)
270270
{
271271
struct scsi_dev_info_list_table *devinfo_table;
272-
int found = 0;
273272

274273
list_for_each_entry(devinfo_table, &scsi_dev_info_list, node)
275-
if (devinfo_table->key == key) {
276-
found = 1;
277-
break;
278-
}
279-
if (!found)
280-
return ERR_PTR(-EINVAL);
274+
if (devinfo_table->key == key)
275+
return devinfo_table;
281276

282-
return devinfo_table;
277+
return ERR_PTR(-EINVAL);
283278
}
284279

285280
/*
@@ -863,7 +858,7 @@ int __init scsi_init_devinfo(void)
863858
goto out;
864859

865860
for (i = 0; scsi_static_device_list[i].vendor; i++) {
866-
error = scsi_dev_info_list_add(1 /* compatibile */,
861+
error = scsi_dev_info_list_add(1 /* compatible */,
867862
scsi_static_device_list[i].vendor,
868863
scsi_static_device_list[i].model,
869864
NULL,

drivers/scsi/scsi_error.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,8 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
665665
* if the device is in the process of becoming ready, we
666666
* should retry.
667667
*/
668-
if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))
668+
if ((sshdr.asc == 0x04) &&
669+
(sshdr.ascq == 0x01 || sshdr.ascq == 0x0a))
669670
return NEEDS_RETRY;
670671
/*
671672
* if the device is not started, we need to wake

drivers/scsi/scsi_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
18711871
* a function to initialize that data.
18721872
*/
18731873
if (shost->hostt->cmd_size && !shost->hostt->init_cmd_priv)
1874-
memset(cmd + 1, 0, shost->hostt->cmd_size);
1874+
memset(scsi_cmd_priv(cmd), 0, shost->hostt->cmd_size);
18751875

18761876
if (!(req->rq_flags & RQF_DONTPREP)) {
18771877
ret = scsi_prepare_cmd(req);

drivers/scsi/scsi_scan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,8 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
909909
sdev->model = (char *) (sdev->inquiry + 16);
910910
sdev->rev = (char *) (sdev->inquiry + 32);
911911

912-
if (strncmp(sdev->vendor, "ATA ", 8) == 0) {
912+
sdev->is_ata = strncmp(sdev->vendor, "ATA ", 8) == 0;
913+
if (sdev->is_ata) {
913914
/*
914915
* sata emulation layer device. This is a hack to work around
915916
* the SATL power management specifications which state that
@@ -1873,7 +1874,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
18731874

18741875
return 0;
18751876
}
1876-
1877+
EXPORT_SYMBOL(scsi_scan_host_selected);
18771878
static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
18781879
{
18791880
struct scsi_device *sdev;

drivers/scsi/scsi_sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ show_shost_supported_mode(struct device *dev, struct device_attribute *attr,
265265
return show_shost_mode(supported_mode, buf);
266266
}
267267

268-
static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
268+
static DEVICE_ATTR(supported_mode, S_IRUGO, show_shost_supported_mode, NULL);
269269

270270
static ssize_t
271271
show_shost_active_mode(struct device *dev,
@@ -279,7 +279,7 @@ show_shost_active_mode(struct device *dev,
279279
return show_shost_mode(shost->active_mode, buf);
280280
}
281281

282-
static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
282+
static DEVICE_ATTR(active_mode, S_IRUGO, show_shost_active_mode, NULL);
283283

284284
static int check_reset_type(const char *str)
285285
{

drivers/scsi/scsi_transport_fc.c

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,6 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
446446
return -ENOMEM;
447447

448448
fc_host->dev_loss_tmo = fc_dev_loss_tmo;
449-
fc_host->devloss_work_q = alloc_workqueue("fc_dl_%d", 0, 0,
450-
shost->host_no);
451-
if (!fc_host->devloss_work_q) {
452-
destroy_workqueue(fc_host->work_q);
453-
fc_host->work_q = NULL;
454-
return -ENOMEM;
455-
}
456449

457450
fc_bsg_hostadd(shost, fc_host);
458451
/* ignore any bsg add error - we just can't do sgio */
@@ -2814,17 +2807,18 @@ fc_flush_work(struct Scsi_Host *shost)
28142807
/**
28152808
* fc_queue_devloss_work - Schedule work for the fc_host devloss workqueue.
28162809
* @shost: Pointer to Scsi_Host bound to fc_host.
2810+
* @rport: rport associated with the devloss work
28172811
* @work: Work to queue for execution.
28182812
* @delay: jiffies to delay the work queuing
28192813
*
28202814
* Return value:
28212815
* 1 on success / 0 already queued / < 0 for error
28222816
*/
28232817
static int
2824-
fc_queue_devloss_work(struct Scsi_Host *shost, struct delayed_work *work,
2825-
unsigned long delay)
2818+
fc_queue_devloss_work(struct Scsi_Host *shost, struct fc_rport *rport,
2819+
struct delayed_work *work, unsigned long delay)
28262820
{
2827-
if (unlikely(!fc_host_devloss_work_q(shost))) {
2821+
if (unlikely(!rport->devloss_work_q)) {
28282822
printk(KERN_ERR
28292823
"ERROR: FC host '%s' attempted to queue work, "
28302824
"when no workqueue created.\n", shost->hostt->name);
@@ -2833,25 +2827,26 @@ fc_queue_devloss_work(struct Scsi_Host *shost, struct delayed_work *work,
28332827
return -EINVAL;
28342828
}
28352829

2836-
return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay);
2830+
return queue_delayed_work(rport->devloss_work_q, work, delay);
28372831
}
28382832

28392833
/**
28402834
* fc_flush_devloss - Flush a fc_host's devloss workqueue.
28412835
* @shost: Pointer to Scsi_Host bound to fc_host.
2836+
* @rport: rport associated with the devloss work
28422837
*/
28432838
static void
2844-
fc_flush_devloss(struct Scsi_Host *shost)
2839+
fc_flush_devloss(struct Scsi_Host *shost, struct fc_rport *rport)
28452840
{
2846-
if (!fc_host_devloss_work_q(shost)) {
2841+
if (unlikely(!rport->devloss_work_q)) {
28472842
printk(KERN_ERR
28482843
"ERROR: FC host '%s' attempted to flush work, "
28492844
"when no workqueue created.\n", shost->hostt->name);
28502845
dump_stack();
28512846
return;
28522847
}
28532848

2854-
flush_workqueue(fc_host_devloss_work_q(shost));
2849+
flush_workqueue(rport->devloss_work_q);
28552850
}
28562851

28572852

@@ -2913,13 +2908,6 @@ fc_remove_host(struct Scsi_Host *shost)
29132908
fc_host->work_q = NULL;
29142909
destroy_workqueue(work_q);
29152910
}
2916-
2917-
/* flush all devloss work items, then kill it */
2918-
if (fc_host->devloss_work_q) {
2919-
work_q = fc_host->devloss_work_q;
2920-
fc_host->devloss_work_q = NULL;
2921-
destroy_workqueue(work_q);
2922-
}
29232911
}
29242912
EXPORT_SYMBOL(fc_remove_host);
29252913

@@ -2967,6 +2955,7 @@ fc_rport_final_delete(struct work_struct *work)
29672955
struct device *dev = &rport->dev;
29682956
struct Scsi_Host *shost = rport_to_shost(rport);
29692957
struct fc_internal *i = to_fc_internal(shost->transportt);
2958+
struct workqueue_struct *work_q;
29702959
unsigned long flags;
29712960
int do_callback = 0;
29722961

@@ -2988,9 +2977,9 @@ fc_rport_final_delete(struct work_struct *work)
29882977
if (rport->flags & FC_RPORT_DEVLOSS_PENDING) {
29892978
spin_unlock_irqrestore(shost->host_lock, flags);
29902979
if (!cancel_delayed_work(&rport->fail_io_work))
2991-
fc_flush_devloss(shost);
2980+
fc_flush_devloss(shost, rport);
29922981
if (!cancel_delayed_work(&rport->dev_loss_work))
2993-
fc_flush_devloss(shost);
2982+
fc_flush_devloss(shost, rport);
29942983
cancel_work_sync(&rport->scan_work);
29952984
spin_lock_irqsave(shost->host_lock, flags);
29962985
rport->flags &= ~FC_RPORT_DEVLOSS_PENDING;
@@ -3021,6 +3010,12 @@ fc_rport_final_delete(struct work_struct *work)
30213010

30223011
fc_bsg_remove(rport->rqst_q);
30233012

3013+
if (rport->devloss_work_q) {
3014+
work_q = rport->devloss_work_q;
3015+
rport->devloss_work_q = NULL;
3016+
destroy_workqueue(work_q);
3017+
}
3018+
30243019
transport_remove_device(dev);
30253020
device_del(dev);
30263021
transport_destroy_device(dev);
@@ -3093,6 +3088,22 @@ fc_remote_port_create(struct Scsi_Host *shost, int channel,
30933088

30943089
spin_unlock_irqrestore(shost->host_lock, flags);
30953090

3091+
rport->devloss_work_q = alloc_workqueue("fc_dl_%d_%d", 0, 0,
3092+
shost->host_no, rport->number);
3093+
if (!rport->devloss_work_q) {
3094+
printk(KERN_ERR "FC Remote Port alloc_workqueue failed\n");
3095+
/*
3096+
* Note that we have not yet called device_initialize() / get_device()
3097+
* Cannot reclaim incremented rport->number because we released host_lock
3098+
*/
3099+
spin_lock_irqsave(shost->host_lock, flags);
3100+
list_del(&rport->peers);
3101+
scsi_host_put(shost); /* for fc_host->rport list */
3102+
spin_unlock_irqrestore(shost->host_lock, flags);
3103+
kfree(rport);
3104+
return NULL;
3105+
}
3106+
30963107
dev = &rport->dev;
30973108
device_initialize(dev); /* takes self reference */
30983109
dev->parent = get_device(&shost->shost_gendev); /* parent reference */
@@ -3255,9 +3266,9 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
32553266
* be checked and will NOOP the function.
32563267
*/
32573268
if (!cancel_delayed_work(&rport->fail_io_work))
3258-
fc_flush_devloss(shost);
3269+
fc_flush_devloss(shost, rport);
32593270
if (!cancel_delayed_work(&rport->dev_loss_work))
3260-
fc_flush_devloss(shost);
3271+
fc_flush_devloss(shost, rport);
32613272

32623273
spin_lock_irqsave(shost->host_lock, flags);
32633274

@@ -3451,11 +3462,12 @@ fc_remote_port_delete(struct fc_rport *rport)
34513462
/* see if we need to kill io faster than waiting for device loss */
34523463
if ((rport->fast_io_fail_tmo != -1) &&
34533464
(rport->fast_io_fail_tmo < timeout))
3454-
fc_queue_devloss_work(shost, &rport->fail_io_work,
3455-
rport->fast_io_fail_tmo * HZ);
3465+
fc_queue_devloss_work(shost, rport, &rport->fail_io_work,
3466+
rport->fast_io_fail_tmo * HZ);
34563467

34573468
/* cap the length the devices can be blocked until they are deleted */
3458-
fc_queue_devloss_work(shost, &rport->dev_loss_work, timeout * HZ);
3469+
fc_queue_devloss_work(shost, rport, &rport->dev_loss_work,
3470+
timeout * HZ);
34593471
}
34603472
EXPORT_SYMBOL(fc_remote_port_delete);
34613473

@@ -3509,14 +3521,14 @@ fc_remote_port_rolechg(struct fc_rport *rport, u32 roles)
35093521
* state as the LLDD would not have had an rport
35103522
* reference to pass us.
35113523
*
3512-
* Take no action on the del_timer failure as the state
3524+
* Take no action on the timer_delete() failure as the state
35133525
* machine state change will validate the
35143526
* transaction.
35153527
*/
35163528
if (!cancel_delayed_work(&rport->fail_io_work))
3517-
fc_flush_devloss(shost);
3529+
fc_flush_devloss(shost, rport);
35183530
if (!cancel_delayed_work(&rport->dev_loss_work))
3519-
fc_flush_devloss(shost);
3531+
fc_flush_devloss(shost, rport);
35203532

35213533
spin_lock_irqsave(shost->host_lock, flags);
35223534
rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |

0 commit comments

Comments
 (0)