Skip to content

Commit 3a53e3f

Browse files
author
CKI KWF Bot
committed
Merge: st tape driver patches in RHEL 9 missing from RHEL 10
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1677 The following patches are present in RHEL 9, but not in RHEL 10: JIRA: https://issues.redhat.com/browse/RHEL-124946 R9 C9 LT LS SF SQ SS 5bb2d61 scsi: st: Don't modify unknown block number in MTIOCGET R8 R9 C9 LT LS SF SQ SS 0b120ed scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset R8 R9 C9 LT LS SF SQ SS a4550b2 scsi: st: New session only when Unit Attention for new tape R8 R9 C9 LT LS SF SQ SS 98b3788 scsi: st: Don't set pos_unknown just after device recognition Signed-off-by: Ewan D. Milne <emilne@redhat.com> Approved-by: Tomas Henzl <thenzl@redhat.com> Approved-by: Chris Leech <cleech@redhat.com> Approved-by: John Meneghini <jmeneghi@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: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents f4bcb3f + c0cca69 commit 3a53e3f

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

drivers/scsi/st.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,10 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
10021002
scode = cmdstatp->sense_hdr.sense_key;
10031003

10041004
if (scode == UNIT_ATTENTION) { /* New media? */
1005-
new_session = 1;
1005+
if (cmdstatp->sense_hdr.asc == 0x28) { /* New media */
1006+
new_session = 1;
1007+
DEBC_printk(STp, "New tape session.");
1008+
}
10061009
if (attentions < MAX_ATTENTIONS) {
10071010
attentions++;
10081011
continue;
@@ -1045,6 +1048,11 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
10451048
retval = new_session ? CHKRES_NEW_SESSION : CHKRES_READY;
10461049
break;
10471050
}
1051+
if (STp->first_tur) {
1052+
/* Don't set pos_unknown right after device recognition */
1053+
STp->pos_unknown = 0;
1054+
STp->first_tur = 0;
1055+
}
10481056

10491057
if (SRpnt != NULL)
10501058
st_release_request(SRpnt);
@@ -3528,6 +3536,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
35283536
int i, cmd_nr, cmd_type, bt;
35293537
int retval = 0;
35303538
unsigned int blk;
3539+
bool cmd_mtiocget;
35313540
struct scsi_tape *STp = file->private_data;
35323541
struct st_modedef *STm;
35333542
struct st_partstat *STps;
@@ -3641,6 +3650,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
36413650
*/
36423651
if (mtc.mt_op != MTREW &&
36433652
mtc.mt_op != MTOFFL &&
3653+
mtc.mt_op != MTLOAD &&
36443654
mtc.mt_op != MTRETEN &&
36453655
mtc.mt_op != MTERASE &&
36463656
mtc.mt_op != MTSEEK &&
@@ -3768,17 +3778,28 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
37683778
goto out;
37693779
}
37703780

3781+
cmd_mtiocget = cmd_type == _IOC_TYPE(MTIOCGET) && cmd_nr == _IOC_NR(MTIOCGET);
3782+
37713783
if ((i = flush_buffer(STp, 0)) < 0) {
3772-
retval = i;
3773-
goto out;
3774-
}
3775-
if (STp->can_partitions &&
3776-
(i = switch_partition(STp)) < 0) {
3777-
retval = i;
3778-
goto out;
3784+
if (cmd_mtiocget && STp->pos_unknown) {
3785+
/* flush fails -> modify status accordingly */
3786+
reset_state(STp);
3787+
STp->pos_unknown = 1;
3788+
} else { /* return error */
3789+
retval = i;
3790+
goto out;
3791+
}
3792+
} else { /* flush_buffer succeeds */
3793+
if (STp->can_partitions) {
3794+
i = switch_partition(STp);
3795+
if (i < 0) {
3796+
retval = i;
3797+
goto out;
3798+
}
3799+
}
37793800
}
37803801

3781-
if (cmd_type == _IOC_TYPE(MTIOCGET) && cmd_nr == _IOC_NR(MTIOCGET)) {
3802+
if (cmd_mtiocget) {
37823803
struct mtget mt_status;
37833804

37843805
if (_IOC_SIZE(cmd_in) != sizeof(struct mtget)) {
@@ -3792,7 +3813,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
37923813
((STp->density << MT_ST_DENSITY_SHIFT) & MT_ST_DENSITY_MASK);
37933814
mt_status.mt_blkno = STps->drv_block;
37943815
mt_status.mt_fileno = STps->drv_file;
3795-
if (STp->block_size != 0) {
3816+
if (STp->block_size != 0 && mt_status.mt_blkno >= 0) {
37963817
if (STps->rw == ST_WRITING)
37973818
mt_status.mt_blkno +=
37983819
(STp->buffer)->buffer_bytes / STp->block_size;
@@ -4348,6 +4369,7 @@ static int st_probe(struct device *dev)
43484369
blk_queue_rq_timeout(tpnt->device->request_queue, ST_TIMEOUT);
43494370
tpnt->long_timeout = ST_LONG_TIMEOUT;
43504371
tpnt->try_dio = try_direct_io;
4372+
tpnt->first_tur = 1;
43514373

43524374
for (i = 0; i < ST_NBR_MODES; i++) {
43534375
STm = &(tpnt->modes[i]);

drivers/scsi/st.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ struct scsi_tape {
171171
unsigned char rew_at_close; /* rewind necessary at close */
172172
unsigned char inited;
173173
unsigned char cleaning_req; /* cleaning requested? */
174+
unsigned char first_tur; /* first TEST UNIT READY */
174175
int block_size;
175176
int changed_blksize;
176177
int min_block;

0 commit comments

Comments
 (0)