mbox series

[RFC,0/6] scsi: scsi_debug: Add more tape support

Message ID 20250128142250.163901-1-Kai.Makisara@kolumbus.fi
Headers show
Series scsi: scsi_debug: Add more tape support | expand

Message

Kai Mäkisara Jan. 28, 2025, 2:22 p.m. UTC
These changes to the scsi_debug driver have been made to support testing
of the st driver. This is a RFC to see if there is interest to add
this to the kernel scsi_debug driver.

Currently, the scsi_debug driver can create tape devices and the st
driver attaches to those. Nothing much can be done with the tape devices
because scsi_debug does not have support for the tape-specific commands
and features. These patches add some more tape support to the scsi_debug
driver. The end result is simulated drives with a tape having two
partitions (i.e., partitioning can't be changed).

The tape partitions are implemented as fixed number of 8-byte
units (partition zero 100 000 units and partition one 1000 units).
The first four bytes of a unit contains the type of the unit (data
block, filemark or end-of-data mark). If the units is a data block,
the first four bytes contain the block length and the remaining
four bytes the first four bytes of written data. This allows the user
to use tags to see that the read block is what it was supposed to be.

The following SCSI operations are added or modified:
LOCATE
- added
MODE SELECT
- modified to allow use without page(s) (just header and block descriptor)
  - store density and block size
MODE SENSE
- modified to allow use without page(s) (just header and block descriptor)
  - set density and block size
- partition page added
READ BLOCK LIMITS
- added
READ POSITION
- added
READ
- added tape support for READ (6)
REWIND
- modified to set the tape position
SPACE
- added
START STOP (LOAD)
- modified to return New Medium Unit Attention if tape loaded (not
  according to the standard, but enables testing this UA)
WRITE
- added tape support for WRITE (6)
WRITE FILEMARKS
- added

Kai Mäkisara (6):
  scsi: scsi_debug: First fixes for tapes
  scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes
  scsi: scsi_debug: Add tape write support with block lengths  and
    4 bytes of data
  scsi: scsi_debug: Add read support and update locate for tapes
  scsi: scsi_debug: Add compression mode page for tapes
  scsi: scsi_debug: Reset tape setting at device reset

 drivers/scsi/scsi_debug.c | 630 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 618 insertions(+), 12 deletions(-)

Comments

Bart Van Assche Jan. 28, 2025, 5:32 p.m. UTC | #1
On 1/28/25 6:22 AM, Kai Mäkisara wrote:
> +#define SDEBUG_READ_BLOCK_LIMITS_ARR_SZ 6

Isn't enum or 'static const' preferred for declaring constants that are 
only used inside a single function?

> +	unsigned char arr[SDEBUG_READ_BLOCK_LIMITS_ARR_SZ];
> +
> +	memset(arr, 0, SDEBUG_READ_BLOCK_LIMITS_ARR_SZ);

The above two statements can be combined in a single statement:

	u8 arr[SDEBUG_READ_BLOCK_LIMITS_ARR_SZ] = { };

Thanks,

Bart.