sg-io-residual-count · shipping · also sg_io_hdr.resid

SG_IO residual count

The SG_IO residual count is a signed byte count reporting the difference between the requested data-transfer length and the length actually transferred through the Linux SCSI generic v3 interface.

The ABI defines resid as dxfer_len minus actual transferred bytes. It is not a command status or the length of sense data; sb_len_wr reports the latter. [1]

Linux v6.12's block-device SG_IO completion copies SCSI and host status into separate fields. Its system-call result can remain successful while those fields report a problem. Inspect the complete response before interpreting transferred data. [2]

A positive residual need not mean failure when the command permits a shorter response. Conversely, the historical SG HOWTO warns that unsupported or inaccurate reporting can yield misleading values, including zero. That warning is not a measurement of current adapters: validate the reporting path and the command's expected length. [3]

Relations

related
SCSI, SCSI CHECK CONDITION, SCSI deferred error

Citations

  1. Linux v6.12: sg_io_hdr fields and SG_INFO status mask (accessed 2026-10-25)
  2. Linux v6.12: scsi_complete_sghdr_rq and sg_io in scsi_ioctl.c (accessed 2026-10-25)
  3. Douglas Gilbert, Linux SCSI Generic HOWTO, section 6.20: resid (historical driver caveat) (accessed 2026-10-25)

Further reading

  1. Hesela: SG_IO completion is not one success bit (accessed 2026-10-25)
Sources & caveats
  • Source review of Linux v6.12 and the historical SG HOWTO. No commands sent to hardware, no driver-validation experiment and no measured failure rate.

JSON: /data/terms/sg-io-residual-count.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. SG_IO residual count. Hesela. 2026-10-25. https://hesela.dev/terms/sg-io-residual-count/