mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: st: Fix input/output error on empty drive reset
@ 2024-09-05 17:39 Rafael Rocha
  2024-09-06  6:19 ` "Kai Mäkisara (Kolumbus)"
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rafael Rocha @ 2024-09-05 17:39 UTC (permalink / raw)
  To: Kai.Makisara
  Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel, rrochavi

A previous change was introduced to prevent data loss during a power-on reset
when a tape is present inside the drive. This change set the "pos_unknown" flag
to true to avoid operations that could compromise data by performing actions
from an untracked position. The relevant commit is:

Commit: 9604eea5bd3ae1fa3c098294f4fc29ad687141ea
Subject: scsi: st: Add third-party power-on reset handling

As a consequence of this change, a new issue has surfaced: the driver now
returns an "Input/output error" even for empty drives when the drive, host, or
bus is reset. This issue stems from the "flush_buffer" function, which first
checks whether the "pos_unknown" flag is set. If the flag is set, the user will
encounter an "Input/output error" until the tape position is known again. This
behavior differs from the previous implementation, where empty drives were not
affected at system start up time, allowing tape software to send commands to
the driver to retrieve the drive's status and other information.

The current behavior prioritizes the "pos_unknown" flag over the "ST_NO_TAPE"
status, leading to issues for software that detects drives during system
startup. This software will receive an "Input/output error" until a tape is
loaded and its position is known.

To resolve this, the "ST_NO_TAPE" status should take priority when the drive is
empty, allowing communication with the drive following a power-on reset. At the
same time, the change should continue to protect data by maintaining the
"pos_unknown" flag when the drive contains a tape and its position is unknown.

Signed-off-by: Rafael Rocha <rrochavi@fnal.gov>
---
 drivers/scsi/st.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 0d8ce1a92168..be881d5bac05 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -834,6 +834,9 @@ static int flush_buffer(struct scsi_tape *STp, int seek_next)
 	int backspace, result;
 	struct st_partstat *STps;
 
+        if (STp->ready != ST_READY)
+                return 0;
+
 	/*
 	 * If there was a bus reset, block further access
 	 * to this device.
@@ -841,8 +844,6 @@ static int flush_buffer(struct scsi_tape *STp, int seek_next)
 	if (STp->pos_unknown)
 		return (-EIO);
 
-	if (STp->ready != ST_READY)
-		return 0;
 	STps = &(STp->ps[STp->partition]);
 	if (STps->rw == ST_WRITING)	/* Writing */
 		return st_flush_write_buffer(STp);
-- 
2.39.3 (Apple Git-146)


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] scsi: st: Fix input/output error on empty drive reset
@ 2024-08-28  1:11 Rafael Rocha
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael Rocha @ 2024-08-28  1:11 UTC (permalink / raw)
  To: Kai.Makisara; +Cc: linux-scsi, linux-kernel, rrochavi

Tape drives are returning an "Input/output error" when a drive, the host, or
the bus is reset. This behavior is expected when a tape is present to prevent
data loss. However, the driver currently drops these errors even for empty
drives due to the following change:

Commit: 9604eea5bd3ae1fa3c098294f4fc29ad687141ea
Subject: scsi: st: Add third-party power-on reset handling
Link: https://github.com/torvalds/linux/commit/9604eea5bd3ae1fa3c098294f4fc29ad687141ea

This issue is causing several tape software applications to crash on startup or
when performing drive health checks, as noted in the following CERN CTA Tape
software discussion:
https://cta-community.web.cern.ch/t/input-output-error-from-tape-drive-device-dev-nst0/302

To correct this behavior, it is necessary to either check for the presence of a
tape before blocking the device or revise the drive's readiness verification at
the beginning of the flush function.

Signed-off-by: Rafael Rocha <rrochavi@fnal.gov>
---
 drivers/scsi/st.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 0d8ce1a92168..10bda3543e93 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -834,6 +834,9 @@ static int flush_buffer(struct scsi_tape *STp, int seek_next)
 	int backspace, result;
 	struct st_partstat *STps;
 
+	if (STp->ready != ST_READY)
+                return 0;
+
 	/*
 	 * If there was a bus reset, block further access
 	 * to this device.
@@ -841,8 +844,6 @@ static int flush_buffer(struct scsi_tape *STp, int seek_next)
 	if (STp->pos_unknown)
 		return (-EIO);
 
-	if (STp->ready != ST_READY)
-		return 0;
 	STps = &(STp->ps[STp->partition]);
 	if (STps->rw == ST_WRITING)	/* Writing */
 		return st_flush_write_buffer(STp);
-- 
2.39.3 (Apple Git-146)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-19 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-05 17:39 [PATCH] scsi: st: Fix input/output error on empty drive reset Rafael Rocha
2024-09-06  6:19 ` "Kai Mäkisara (Kolumbus)"
2024-09-13  0:08 ` Martin K. Petersen
2024-09-19 15:53 ` Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2024-08-28  1:11 Rafael Rocha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®