Skip to content

Commit 2c445d5

Browse files
kmakisaramartinkpetersen
authored andcommitted
scsi: st: Add sysfs file position_lost_in_reset
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>
1 parent 341128d commit 2c445d5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
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

drivers/scsi/st.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,24 @@ options_show(struct device *dev, struct device_attribute *attr, char *buf)
47034703
}
47044704
static DEVICE_ATTR_RO(options);
47054705

4706+
/**
4707+
* position_lost_in_reset_show - Value 1 indicates that reads, writes, etc.
4708+
* are blocked because a device reset has occurred and no operation positioning
4709+
* the tape has been issued.
4710+
* @dev: struct device
4711+
* @attr: attribute structure
4712+
* @buf: buffer to return formatted data in
4713+
*/
4714+
static ssize_t position_lost_in_reset_show(struct device *dev,
4715+
struct device_attribute *attr, char *buf)
4716+
{
4717+
struct st_modedef *STm = dev_get_drvdata(dev);
4718+
struct scsi_tape *STp = STm->tape;
4719+
4720+
return sprintf(buf, "%d", STp->pos_unknown);
4721+
}
4722+
static DEVICE_ATTR_RO(position_lost_in_reset);
4723+
47064724
/* Support for tape stats */
47074725

47084726
/**
@@ -4887,6 +4905,7 @@ static struct attribute *st_dev_attrs[] = {
48874905
&dev_attr_default_density.attr,
48884906
&dev_attr_default_compression.attr,
48894907
&dev_attr_options.attr,
4908+
&dev_attr_position_lost_in_reset.attr,
48904909
NULL,
48914910
};
48924911

0 commit comments

Comments
 (0)