http://bugs.gentoo.org/210392 --- lib/qpxtransport/qpx_transport.cpp +++ lib/qpxtransport/qpx_transport.cpp @@ -215,6 +215,21 @@ #define KERNEL_BROKEN 0 if (use_sg_io) { + /* see linux-2.6.23/block/scsi_ioctl.c:36 */ + static const unsigned char scsi_command_size[8] = + { + 6, 10, 10, 12, + 16, 12, 10, 10 + }; + char cmdsize, opcode; + + opcode = cgc.cmd[0]; + /* see linux-2.6.23/include/scsi/scsi.h:25 */ + cmdsize = scsi_command_size[((opcode) >> 5) & 7]; + if ((sg_io.cmd_len > 0) && (sg_io.cmd_len < cmdsize)) { + sg_io.cmd_len = cmdsize; + } + sg_io.dxferp = buf; sg_io.dxfer_len = sz; sg_io.dxfer_direction = use_sg_io[dir];