Skip to content

Commit 7f632dc

Browse files
committed
Merge: SCSI updates for 10.1, part II
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/978 SCSI core updates for 10.1 to upstream 6.15 JIRA: https://issues.redhat.com/browse/RHEL-94045 Signed-off-by: Ewan D. Milne <emilne@redhat.com> Approved-by: Chris Leech <cleech@redhat.com> Approved-by: bgurney <bgurney@redhat.com> Approved-by: Maurizio Lombardi <mlombard@redhat.com> Approved-by: Ming Lei <ming.lei@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 49bb536 + 1c6b0f0 commit 7f632dc

File tree

28 files changed

+1008
-221
lines changed

28 files changed

+1008
-221
lines changed

Documentation/scsi/st.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ enabled driver and mode options. The value in the file is a bit mask where the
157157
bit definitions are the same as those used with MTSETDRVBUFFER in setting the
158158
options.
159159

160+
Each directory contains the entry 'position_lost_in_reset'. If this value is
161+
one, reading and writing to the device is blocked after device reset. Most
162+
devices rewind the tape after reset and the writes/read don't access the
163+
tape position the user expects.
164+
160165
A link named 'tape' is made from the SCSI device directory to the class
161166
directory corresponding to the mode 0 auto-rewind device (e.g., st0).
162167

block/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ struct bio *bio_kmalloc(unsigned short nr_vecs, gfp_t gfp_mask)
611611
{
612612
struct bio *bio;
613613

614-
if (nr_vecs > UIO_MAXIOV)
614+
if (nr_vecs > BIO_MAX_INLINE_VECS)
615615
return NULL;
616616
return kmalloc(struct_size(bio, bi_inline_vecs, nr_vecs), gfp_mask);
617617
}

drivers/message/fusion/mptscsih.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,14 +2915,14 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
29152915
timeout = 10;
29162916
break;
29172917

2918-
case RESERVE:
2918+
case RESERVE_6:
29192919
cmdLen = 6;
29202920
dir = MPI_SCSIIO_CONTROL_READ;
29212921
CDB[0] = cmd;
29222922
timeout = 10;
29232923
break;
29242924

2925-
case RELEASE:
2925+
case RELEASE_6:
29262926
cmdLen = 6;
29272927
dir = MPI_SCSIIO_CONTROL_READ;
29282928
CDB[0] = cmd;

drivers/scsi/aacraid/aachba.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,8 +3221,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
32213221
break;
32223222
}
32233223
fallthrough;
3224-
case RESERVE:
3225-
case RELEASE:
3224+
case RESERVE_6:
3225+
case RELEASE_6:
32263226
case REZERO_UNIT:
32273227
case REASSIGN_BLOCKS:
32283228
case SEEK_10:

drivers/scsi/arm/acornscsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ datadir_t acornscsi_datadirection(int command)
591591
case CHANGE_DEFINITION: case COMPARE: case COPY:
592592
case COPY_VERIFY: case LOG_SELECT: case MODE_SELECT:
593593
case MODE_SELECT_10: case SEND_DIAGNOSTIC: case WRITE_BUFFER:
594-
case FORMAT_UNIT: case REASSIGN_BLOCKS: case RESERVE:
594+
case FORMAT_UNIT: case REASSIGN_BLOCKS: case RESERVE_6:
595595
case SEARCH_EQUAL: case SEARCH_HIGH: case SEARCH_LOW:
596596
case WRITE_6: case WRITE_10: case WRITE_VERIFY:
597597
case UPDATE_BLOCK: case WRITE_LONG: case WRITE_SAME:

drivers/scsi/ips.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,8 +3631,8 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
36313631

36323632
break;
36333633

3634-
case RESERVE:
3635-
case RELEASE:
3634+
case RESERVE_6:
3635+
case RELEASE_6:
36363636
scb->scsi_cmd->result = DID_OK << 16;
36373637
break;
36383638

@@ -3899,8 +3899,8 @@ ips_chkstatus(ips_ha_t * ha, IPS_STATUS * pstatus)
38993899
case WRITE_6:
39003900
case READ_10:
39013901
case WRITE_10:
3902-
case RESERVE:
3903-
case RELEASE:
3902+
case RESERVE_6:
3903+
case RELEASE_6:
39043904
break;
39053905

39063906
case MODE_SENSE:

drivers/scsi/megaraid.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,8 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
855855
return scb;
856856

857857
#if MEGA_HAVE_CLUSTERING
858-
case RESERVE:
859-
case RELEASE:
858+
case RESERVE_6:
859+
case RELEASE_6:
860860

861861
/*
862862
* Do we support clustering and is the support enabled
@@ -875,7 +875,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
875875
}
876876

877877
scb->raw_mbox[0] = MEGA_CLUSTER_CMD;
878-
scb->raw_mbox[2] = ( *cmd->cmnd == RESERVE ) ?
878+
scb->raw_mbox[2] = *cmd->cmnd == RESERVE_6 ?
879879
MEGA_RESERVE_LD : MEGA_RELEASE_LD;
880880

881881
scb->raw_mbox[3] = ldrv_num;
@@ -1618,8 +1618,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
16181618
* failed or the input parameter is invalid
16191619
*/
16201620
if( status == 1 &&
1621-
(cmd->cmnd[0] == RESERVE ||
1622-
cmd->cmnd[0] == RELEASE) ) {
1621+
(cmd->cmnd[0] == RESERVE_6 ||
1622+
cmd->cmnd[0] == RELEASE_6) ) {
16231623

16241624
cmd->result |= (DID_ERROR << 16) |
16251625
SAM_STAT_RESERVATION_CONFLICT;

drivers/scsi/megaraid/megaraid_mbox.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
17251725

17261726
return scb;
17271727

1728-
case RESERVE:
1729-
case RELEASE:
1728+
case RESERVE_6:
1729+
case RELEASE_6:
17301730
/*
17311731
* Do we support clustering and is the support enabled
17321732
*/
@@ -1748,7 +1748,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
17481748
scb->dev_channel = 0xFF;
17491749
scb->dev_target = target;
17501750
ccb->raw_mbox[0] = CLUSTER_CMD;
1751-
ccb->raw_mbox[2] = (scp->cmnd[0] == RESERVE) ?
1751+
ccb->raw_mbox[2] = scp->cmnd[0] == RESERVE_6 ?
17521752
RESERVE_LD : RELEASE_LD;
17531753

17541754
ccb->raw_mbox[3] = target;
@@ -2334,8 +2334,8 @@ megaraid_mbox_dpc(unsigned long devp)
23342334
* Error code returned is 1 if Reserve or Release
23352335
* failed or the input parameter is invalid
23362336
*/
2337-
if (status == 1 && (scp->cmnd[0] == RESERVE ||
2338-
scp->cmnd[0] == RELEASE)) {
2337+
if (status == 1 && (scp->cmnd[0] == RESERVE_6 ||
2338+
scp->cmnd[0] == RELEASE_6)) {
23392339

23402340
scp->result = DID_ERROR << 16 |
23412341
SAM_STAT_RESERVATION_CONFLICT;

drivers/scsi/scsi.c

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -510,22 +510,34 @@ void scsi_attach_vpd(struct scsi_device *sdev)
510510
return;
511511

512512
for (i = 4; i < vpd_buf->len; i++) {
513-
if (vpd_buf->data[i] == 0x0)
513+
switch (vpd_buf->data[i]) {
514+
case 0x0:
514515
scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0);
515-
if (vpd_buf->data[i] == 0x80)
516+
break;
517+
case 0x80:
516518
scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80);
517-
if (vpd_buf->data[i] == 0x83)
519+
break;
520+
case 0x83:
518521
scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
519-
if (vpd_buf->data[i] == 0x89)
522+
break;
523+
case 0x89:
520524
scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
521-
if (vpd_buf->data[i] == 0xb0)
525+
break;
526+
case 0xb0:
522527
scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0);
523-
if (vpd_buf->data[i] == 0xb1)
528+
break;
529+
case 0xb1:
524530
scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1);
525-
if (vpd_buf->data[i] == 0xb2)
531+
break;
532+
case 0xb2:
526533
scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2);
527-
if (vpd_buf->data[i] == 0xb7)
534+
break;
535+
case 0xb7:
528536
scsi_update_vpd_page(sdev, 0xb7, &sdev->vpd_pgb7);
537+
break;
538+
default:
539+
break;
540+
}
529541
}
530542
kfree(vpd_buf);
531543
}
@@ -695,26 +707,23 @@ void scsi_cdl_check(struct scsi_device *sdev)
695707
*/
696708
int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
697709
{
698-
struct scsi_mode_data data;
699-
struct scsi_sense_hdr sshdr;
700-
struct scsi_vpd *vpd;
701-
bool is_ata = false;
702710
char buf[64];
711+
bool is_ata;
703712
int ret;
704713

705714
if (!sdev->cdl_supported)
706715
return -EOPNOTSUPP;
707716

708717
rcu_read_lock();
709-
vpd = rcu_dereference(sdev->vpd_pg89);
710-
if (vpd)
711-
is_ata = true;
718+
is_ata = rcu_dereference(sdev->vpd_pg89);
712719
rcu_read_unlock();
713720

714721
/*
715722
* For ATA devices, CDL needs to be enabled with a SET FEATURES command.
716723
*/
717724
if (is_ata) {
725+
struct scsi_mode_data data;
726+
struct scsi_sense_hdr sshdr;
718727
char *buf_data;
719728
int len;
720729

@@ -723,16 +732,30 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
723732
if (ret)
724733
return -EINVAL;
725734

726-
/* Enable CDL using the ATA feature page */
735+
/* Enable or disable CDL using the ATA feature page */
727736
len = min_t(size_t, sizeof(buf),
728737
data.length - data.header_length -
729738
data.block_descriptor_length);
730739
buf_data = buf + data.header_length +
731740
data.block_descriptor_length;
732-
if (enable)
733-
buf_data[4] = 0x02;
734-
else
735-
buf_data[4] = 0;
741+
742+
/*
743+
* If we want to enable CDL and CDL is already enabled on the
744+
* device, do nothing. This avoids needlessly resetting the CDL
745+
* statistics on the device as that is implied by the CDL enable
746+
* action. Similar to this, there is no need to do anything if
747+
* we want to disable CDL and CDL is already disabled.
748+
*/
749+
if (enable) {
750+
if ((buf_data[4] & 0x03) == 0x02)
751+
goto out;
752+
buf_data[4] &= ~0x03;
753+
buf_data[4] |= 0x02;
754+
} else {
755+
if ((buf_data[4] & 0x03) == 0x00)
756+
goto out;
757+
buf_data[4] &= ~0x03;
758+
}
736759

737760
ret = scsi_mode_select(sdev, 1, 0, buf_data, len, 5 * HZ, 3,
738761
&data, &sshdr);
@@ -744,6 +767,7 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
744767
}
745768
}
746769

770+
out:
747771
sdev->cdl_enable = enable;
748772

749773
return 0;

0 commit comments

Comments
 (0)