]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: st: Add sysfs file position_lost_in_reset
authorKai Mäkisara <Kai.Makisara@kolumbus.fi>
Sat, 1 Feb 2025 15:11:06 +0000 (17:11 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 3 Feb 2025 22:51:31 +0000 (17:51 -0500)
If the value read from the file is 1, reads and writes from/to the device
are blocked because the tape position may not match user's expectation
(tape rewound after device reset).

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
Link: https://lore.kernel.org/r/20250201151106.25529-1-Kai.Makisara@kolumbus.fi
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Documentation/scsi/st.rst
drivers/scsi/st.c

index d3b28c28d74c24f9f13faacca723e94ce661db6e..b4a092faa9c8204b03e76b6a3c4e5201491b51f0 100644 (file)
@@ -157,6 +157,11 @@ enabled driver and mode options. The value in the file is a bit mask where the
 bit definitions are the same as those used with MTSETDRVBUFFER in setting the
 options.
 
+Each directory contains the entry 'position_lost_in_reset'. If this value is
+one, reading and writing to the device is blocked after device reset. Most
+devices rewind the tape after reset and the writes/read don't access the
+tape position the user expects.
+
 A link named 'tape' is made from the SCSI device directory to the class
 directory corresponding to the mode 0 auto-rewind device (e.g., st0).
 
index 6ec1cfeb92ff13a739e57c970881bd02e0f5455a..85867120c8a9e629a59361fc4b5ff6cd824dc48d 100644 (file)
@@ -4703,6 +4703,24 @@ options_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR_RO(options);
 
+/**
+ * position_lost_in_reset_show - Value 1 indicates that reads, writes, etc.
+ * are blocked because a device reset has occurred and no operation positioning
+ * the tape has been issued.
+ * @dev: struct device
+ * @attr: attribute structure
+ * @buf: buffer to return formatted data in
+ */
+static ssize_t position_lost_in_reset_show(struct device *dev,
+       struct device_attribute *attr, char *buf)
+{
+       struct st_modedef *STm = dev_get_drvdata(dev);
+       struct scsi_tape *STp = STm->tape;
+
+       return sprintf(buf, "%d", STp->pos_unknown);
+}
+static DEVICE_ATTR_RO(position_lost_in_reset);
+
 /* Support for tape stats */
 
 /**
@@ -4887,6 +4905,7 @@ static struct attribute *st_dev_attrs[] = {
        &dev_attr_default_density.attr,
        &dev_attr_default_compression.attr,
        &dev_attr_options.attr,
+       &dev_attr_position_lost_in_reset.attr,
        NULL,
 };