hreinecke / sg3_utils

Deprecated git-svn mirror for sg3_utils
http://sg.danny.cz/sg/sg3_utils.html
Other
155 stars 91 forks source link

Better handling of the response length exceeding the response buffer #79

Closed brianatpurestorage closed 1 year ago

brianatpurestorage commented 2 years ago

If the response length of an RTPG request exceeds the allocated buffer, the response is truncated to the size of the buffer. This results in ugly output.

Everything past f7 is made up after the truncate because the uutput still wants to display the number of ports returned in the target port count.

In this case the response size is 1072 bytes and the buffer is 1024 bytes.

... target port count : 41 ... 0xf7 0x00 0x00 0x5e44 0x13db 0x00 0x00 0x00 0x00 0x00 0x00 0x4000 0x00 0x627d

Use the same logic as in scsi_dh_alua.c in the kernel if the response length exceeds the buffer length. This will reallocate the buffer length to the response length and re-run the RTPG command. The second time through the response buffer is big enough to handle the full response from the target.

... target port count : 41 ... 0xf7 0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x100 0x101 0x102 0x103 0x104

doug-gilbert commented 2 years ago

I have applied this patch to my upstream repository. It will be a little while before it appears due to some JSON surgery going on at the moment. When it does get committed it will first appear https://github.com/doug-gilbert/sg3_utils .

hreinecke commented 1 year ago

Fixed with git svn id 944.