doug-gilbert / sdparm

official git-svn mirror for sdparm, access SCSI parameters (mode+VPD pages)

Home Page:https://sg.danny.cz/sg/sdparm.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v1.12 exit code 5 on `--get WCE` command

maxxwizard opened this issue · comments

v1.10 and v1.12 yield the same output on similar hardware but exit code is different.

[root@xyz ~]# sdparm --version
version: 1.10 20160222 [svn: r279]

[root@xyz ~]# sdparm --get WCE /dev/sdy --verbose; echo "exit code" $?
mp_settings: page,subpage=0x8,0x0  num=1
  [0x8,0x0]  pdt=0 start_byte=0x2 start_bit=2 num_bits=1  val=0  acronym: WCE
    /dev/sdy: ATA       WDC  WUH721818AL  W233
WCE           1  [cha: y]
exit code 0
[root@abc ~]# sdparm --version
version: 1.12 20210421 [svn: r347]

[root@abc ~]# sdparm --get WCE /dev/sdy --verbose; echo "exit code" $?
mp_settings: page,subpage=0x8,0x0  num=1
  [0x8,0x0]  pdt=5120 start_byte=0x2 start_bit=2 num_bits=1  val=0  acronym: WCE
    /dev/sdy: ATA       WDC  WUH721818AL  W233
WCE           1  [cha: y]
exit code 5

I did a quick strace diff between the 2 versions and find nothing significant.

Exit code 5 according to man pages:

the DEVICE reports an "illegal request" with an additional sense code other than "invalid operation code". This is often a supported command with a field set requesting an unsupported capability. For commands that require a "service action" field this value can indicate that the command is not supported.

I thought perhaps WCE isn't a supported capability but I can change the bit just fine.

[root@abc ~]# sdparm --set WCE=0 /dev/sdy --verbose; echo "exit code" $?
mp_settings: page,subpage=0x8,0x0  num=1
  pdt=5120 start_byte=0x2 start_bit=2 num_bits=1  val=0  acronym: WCE
    /dev/sdy: ATA       WDC  WUH721818AL  W233
    mode sense(10) cdb: [5a 00 08 00 00 00 00 00 04 00]
    mode sense(10) cdb: [5a 00 08 00 00 00 00 00 24 00]
    mode select(10) cdb: [55 10 00 00 00 00 00 00 24 00]
exit code 0

[root@abc ~]# sdparm --get WCE /dev/sdy --verbose; echo "exit code" $?
mp_settings: page,subpage=0x8,0x0  num=1
  [0x8,0x0]  pdt=5120 start_byte=0x2 start_bit=2 num_bits=1  val=0  acronym: WCE
    /dev/sdy: ATA       WDC  WUH721818AL  W233
WCE           0  [cha: y]
exit code 5

Looks like a bug in sdparm 1.12 release [20210421]. I don't revisit my releases, but downstream distributions might. If there is a serious issue I will hurry out a new release to fix it. Tested your example with my current revision (364) which has just been mirrored here. With both SAS and ATA disks I'm only seeing exit status values of 0 which is as it should be. Thanks for the report. A new release of sdparm (1.13) should be soon, but I'm in the middle of adding JSON support which is time consuming. Adding more --verbose options (say '-vvvv') might show you where the "5" exit status is coming from.

I think v1.12 is working correctly because the sense key is set to Illegal Request, so sdparm should exit with code 5. So this was a bug in v1.10 that got fixed?

Here's output from same machine across the 2 versions:

v1.10

[root@xyz ~]# sdparm --get WCE /dev/sdy -vvvv; echo "exit code" $?
mp_settings: page,subpage=0x8,0x0  num=1
  [0x8,0x0]  pdt=0 start_byte=0x2 start_bit=2 num_bits=1  val=0  acronym: WCE
>>> about to open device name: /dev/sdy
open /dev/sdy with flags=0x800
    inquiry cdb: 12 00 00 00 24 00
      duration=1 ms
    /dev/sdy: ATA       WDC  WUH721818AL  W233
    mode sense (10) cdb: 5a 00 08 00 00 00 00 00 08 00
      duration=0 ms
    mode sense (10): response
00 22 00 10 00 00 00 08
    mode sense (10) cdb: 5a 00 08 00 00 00 00 00 24 00
      duration=0 ms
    mode sense (10): response
00 22 00 10 00 00 00 08  ff ff ff ff 00 00 10 00
08 12 04 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00
    mode sense (10) cdb: 5a 00 48 00 00 00 00 00 24 00
      duration=1 ms
    mode sense (10): response
00 22 00 10 00 00 00 08  ff ff ff ff 00 00 10 00
08 12 04 00 00 00 00 00  00 00 00 00 20 00 00 00
00 00 00 00
    mode sense (10) cdb: 5a 00 88 00 00 00 00 00 24 00
      duration=0 ms
mode sense (10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid field in cdb
 Raw sense data (in hex):
        70 00 05 00 00 00 00 0a  00 00 00 00 24 00 00 00
        00 00
    pass-through requested 36 bytes (data-in) but got 0 bytes
    mode sense (10) cdb: 5a 00 c8 00 00 00 00 00 24 00
      duration=0 ms
mode sense (10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid field in cdb
 Raw sense data (in hex):
        70 00 05 00 00 00 00 0a  00 00 00 00 24 00 00 00
        00 00
    pass-through requested 36 bytes (data-in) but got 0 bytes
WCE           1  [cha: y]
exit code 0

v1.12

[root@xyz ~]# sdparm --get WCE /dev/sdy -vvvv; echo "exit code" $?
mp_settings: page,subpage=0x8,0x0  num=1
  [0x8,0x0]  pdt=5120 start_byte=0x2 start_bit=2 num_bits=1  val=0  acronym: WCE
>>> about to open device name: /dev/sdy
open /dev/sdy with flags=0x800
    inquiry cdb: [12 00 00 00 24 00]
      duration=1 ms
    /dev/sdy: ATA       WDC  WUH721818AL  W233
    mode sense(10) cdb: [5a 00 08 00 00 00 00 00 08 00]
      duration=0 ms
    mode sense(10): response:
00 22 00 10 00 00 00 08
    mode sense(10) cdb: [5a 00 08 00 00 00 00 00 24 00]
      duration=0 ms
    mode sense(10): response:
00 22 00 10 00 00 00 08  ff ff ff ff 00 00 10 00
08 12 04 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00
    mode sense(10) cdb: [5a 00 48 00 00 00 00 00 24 00]
      duration=0 ms
    mode sense(10): response:
00 22 00 10 00 00 00 08  ff ff ff ff 00 00 10 00
08 12 04 00 00 00 00 00  00 00 00 00 20 00 00 00
00 00 00 00
    mode sense(10) cdb: [5a 00 88 00 00 00 00 00 24 00]
      duration=0 ms
mode sense(10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid field in cdb
 Raw sense data (in hex), sb_len=18, embedded_len=18
        70 00 05 00 00 00 00 0a  00 00 00 00 24 00 00 00
        00 00
    mode sense(10): pass-through requested 36 bytes (data-in), got  got 0 bytes
    mode sense(10) cdb: [5a 00 c8 00 00 00 00 00 24 00]
      duration=0 ms
mode sense(10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid field in cdb
 Raw sense data (in hex), sb_len=18, embedded_len=18
        70 00 05 00 00 00 00 0a  00 00 00 00 24 00 00 00
        00 00
    mode sense(10): pass-through requested 36 bytes (data-in), got  got 0 bytes
WCE           1  [cha: y]
exit code 5