#876351 mtx: MTX fails with AWS Virtual Tape Storage on kernel 4.12

Package:
mtx
Source:
mtx
Description:
controls autoloaders and tape libraries
Submitter:
Lior Okman
Date:
2017-09-21 09:00:05 UTC
Severity:
important
#876351#5
Date:
2017-09-21 08:56:59 UTC
From:
To:
Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

   * What led up to the situation?
   * What exactly did you do (or not do) that was effective (or
     ineffective)?
   * What was the outcome of this action?
   * What outcome did you expect instead?

*** End of the template - remove these template lines ***

I'm trying to setup a tape changer with mtx and the Amazon Storage Gateway while running on unstable.

The autochanger device is an iscsi device emulating an STK-L700.

# tapeinfo -f /dev/sg3
Product Type: Medium Changer
Vendor ID: 'STK     '
Product ID: 'L700            '
Revision: '0103'
Attached Changer API: No
SerialNumber: 'AMZN_SGW-REDACTED_MC_00001'
SCSI ID: 0
SCSI LUN: 0
Ready: no


Running mtx status works correctly (cut at 40 lines here because there
are 3200 slots):

# mtx -f /dev/sg3 status|head -40
  Storage Changer /dev/sg3:10 Drives, 3200 Slots ( 1600 Import/Export )
Data Transfer Element 0:Empty
Data Transfer Element 1:Empty
Data Transfer Element 2:Empty
Data Transfer Element 3:Empty
Data Transfer Element 4:Empty
Data Transfer Element 5:Empty
Data Transfer Element 6:Empty
Data Transfer Element 7:Empty
Data Transfer Element 8:Empty
Data Transfer Element 9:Empty
      Storage Element 1:Empty:VolumeTag=
      Storage Element 2:Empty:VolumeTag=
      Storage Element 3:Empty:VolumeTag=
      Storage Element 4:Empty:VolumeTag=

Trying to move a tape from a full slot to a Data Transfer Element fail:

# mtx -f /dev/sg3 status|grep Full
      Storage Element 1000:Full :VolumeTag=A504FF5
# mtx -f /dev/sg3 load 1000
Loading media from Storage Element 1000 into drive 0...mtx: Request Sense: Long Report=yes
mtx: Request Sense: Valid Residual=no
mtx: Request Sense: Error Code=0 (Unknown?!)
mtx: Request Sense: Sense Key=No Sense
mtx: Request Sense: FileMark=no
mtx: Request Sense: EOM=no
mtx: Request Sense: ILI=no
mtx: Request Sense: Additional Sense Code = 00
mtx: Request Sense: Additional Sense Qualifier = 00
mtx: Request Sense: BPV=no
mtx: Request Sense: Error in CDB=no
mtx: Request Sense: SKSV=no
MOVE MEDIUM from Element Address 20999 to 10000 Failed

Rebooting the host with the kernel version available in stable works
correctly.

Here are the kernels I have installed on the host:

# dpkg --list  linux-image-4\*
    Name                         Version           Architecture Description
+++-============================-=================-============-=========================
ii  linux-image-4.12.0-1-amd64   4.12.6-1          amd64        Linux 4.12 for 64-bit PCs
ii  linux-image-4.9.0-3-amd64    4.9.30-2+deb9u5   amd64        Linux 4.9 for 64-bit PCs

The difference seems to be in the last ioctl issued by the mtx command.
I ran strace on the mtx command and the problem starts with the last
ioctl call.

This works (using kernel 4.9):

ioctl(3, SG_IO, {'S', SG_DXFER_TO_DEV, cmd[12]=[a5, 00, 00, 00, 27, 10, 52, 07, 00, 00, 00, 00], mx_sb_len=20, iovec_count=0, dxfer_len=0, timeout=300000, flags=0, data[0]=NULL, status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=0, info=0}) = 0

This fails (using kernel 4.12)

ioctl(3, SG_IO, {'S', SG_DXFER_TO_DEV, cmd[12]=[a5, 00, 00, 00, 52, 07, 27, 10, 00, 00, 00, 00], mx_sb_len=20, iovec_count=0, dxfer_len=0, timeout=300000, flags=0, data[0]=NULL}) = -1 EINVAL (Invalid argument)