| 1 | Index: ChangeLog
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- ChangeLog (revision 5456)
|
|---|
| 4 | +++ ChangeLog (working copy)
|
|---|
| 5 | @@ -1,5 +1,10 @@
|
|---|
| 6 | $Id$
|
|---|
| 7 |
|
|---|
| 8 | +2023-02-17 Steven Song <steven.song@3snic.com>
|
|---|
| 9 | +
|
|---|
| 10 | + os_linux.cpp: Fix CK_COND issue for SATA disk and use C++11 or
|
|---|
| 11 | + later structure initialization.
|
|---|
| 12 | +
|
|---|
| 13 | 2023-02-14 WHR <whr@rivoreo.one>
|
|---|
| 14 |
|
|---|
| 15 | atacmds.cpp: fix a logical error in function ataReadExtSelfTestLog
|
|---|
| 16 | Index: os_linux.cpp
|
|---|
| 17 | ===================================================================
|
|---|
| 18 | --- os_linux.cpp (revision 5456)
|
|---|
| 19 | +++ os_linux.cpp (working copy)
|
|---|
| 20 | @@ -1399,7 +1399,7 @@
|
|---|
| 21 | unsigned int m_eid;
|
|---|
| 22 | unsigned int m_sid;
|
|---|
| 23 |
|
|---|
| 24 | - bool scsi_cmd(int cdbLen, void *cdb, int dataLen, void *data, int direction);
|
|---|
| 25 | + bool scsi_cmd(scsi_cmnd_io *iop);
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | linux_sssraid_device::linux_sssraid_device(smart_interface *intf,
|
|---|
| 29 | @@ -1439,26 +1439,21 @@
|
|---|
| 30 | pout("%s", buff);
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | - bool r = scsi_cmd(iop->cmnd_len, iop->cmnd,
|
|---|
| 34 | - iop->dxfer_len, iop->dxferp, iop->dxfer_dir);
|
|---|
| 35 | + bool r = scsi_cmd(iop);
|
|---|
| 36 | return r;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | /* Issue passthrough scsi commands to sssraid controllers */
|
|---|
| 40 | -bool linux_sssraid_device::scsi_cmd(int cdbLen, void *cdb,
|
|---|
| 41 | - int dataLen, void *data, int dxfer_dir)
|
|---|
| 42 | +bool linux_sssraid_device::scsi_cmd(scsi_cmnd_io *iop)
|
|---|
| 43 | {
|
|---|
| 44 | - struct sg_io_v4 io_hdr_v4;
|
|---|
| 45 | - struct cmd_scsi_passthrough scsi_param;
|
|---|
| 46 | + struct sg_io_v4 io_hdr_v4{};
|
|---|
| 47 | + struct cmd_scsi_passthrough scsi_param{};
|
|---|
| 48 | unsigned char sense_buff[96] = { 0 };
|
|---|
| 49 | - struct bsg_ioctl_cmd bsg_param;
|
|---|
| 50 | - memset(&io_hdr_v4, 0, sizeof(io_hdr_v4));
|
|---|
| 51 | - memset(&scsi_param, 0, sizeof(scsi_param));
|
|---|
| 52 | - memset(&bsg_param, 0, sizeof(bsg_param));
|
|---|
| 53 | + struct bsg_ioctl_cmd bsg_param{};
|
|---|
| 54 | scsi_param.sense_buffer = sense_buff;
|
|---|
| 55 | scsi_param.sense_buffer_len = 96;
|
|---|
| 56 | - scsi_param.cdb_len = cdbLen;
|
|---|
| 57 | - memcpy(scsi_param.cdb, cdb, cdbLen);
|
|---|
| 58 | + scsi_param.cdb_len = iop->cmnd_len;
|
|---|
| 59 | + memcpy(scsi_param.cdb, iop->cmnd, iop->cmnd_len);
|
|---|
| 60 | scsi_param.loc.enc_id = m_eid;
|
|---|
| 61 | scsi_param.loc.slot_id = m_sid;
|
|---|
| 62 |
|
|---|
| 63 | @@ -1471,16 +1466,18 @@
|
|---|
| 64 | io_hdr_v4.request = (uintptr_t)(&bsg_param);
|
|---|
| 65 | io_hdr_v4.timeout = BSG_APPEND_TIMEOUT_MS + DEFAULT_CONMMAND_TIMEOUT_MS;
|
|---|
| 66 |
|
|---|
| 67 | - switch (dxfer_dir) {
|
|---|
| 68 | + switch (iop->dxfer_dir) {
|
|---|
| 69 | case DXFER_NONE:
|
|---|
| 70 | + bsg_param.ioctl_pthru.opcode = ADM_RAID_SET;
|
|---|
| 71 | + break;
|
|---|
| 72 | case DXFER_FROM_DEVICE:
|
|---|
| 73 | - io_hdr_v4.din_xferp = (uintptr_t)data;
|
|---|
| 74 | - io_hdr_v4.din_xfer_len = dataLen;
|
|---|
| 75 | + io_hdr_v4.din_xferp = (uintptr_t)iop->dxferp;
|
|---|
| 76 | + io_hdr_v4.din_xfer_len = iop->dxfer_len;
|
|---|
| 77 | bsg_param.ioctl_pthru.opcode = ADM_RAID_READ;
|
|---|
| 78 | break;
|
|---|
| 79 | case DXFER_TO_DEVICE:
|
|---|
| 80 | - io_hdr_v4.dout_xferp = (uintptr_t)data;
|
|---|
| 81 | - io_hdr_v4.dout_xfer_len = dataLen;
|
|---|
| 82 | + io_hdr_v4.dout_xferp = (uintptr_t)iop->dxferp;
|
|---|
| 83 | + io_hdr_v4.dout_xfer_len = iop->dxfer_len;
|
|---|
| 84 | bsg_param.ioctl_pthru.opcode = ADM_RAID_WRITE;
|
|---|
| 85 | break;
|
|---|
| 86 | default:
|
|---|
| 87 | @@ -1491,8 +1488,8 @@
|
|---|
| 88 | bsg_param.msgcode = ADM_BSG_MSGCODE_SCSI_PTHRU;
|
|---|
| 89 | bsg_param.ioctl_pthru.timeout_ms = DEFAULT_CONMMAND_TIMEOUT_MS;
|
|---|
| 90 | bsg_param.ioctl_pthru.info_1.subopcode = ADM_CMD_SCSI_PASSTHROUGH;
|
|---|
| 91 | - bsg_param.ioctl_pthru.addr = (uintptr_t)data;
|
|---|
| 92 | - bsg_param.ioctl_pthru.data_len = dataLen;
|
|---|
| 93 | + bsg_param.ioctl_pthru.addr = (uintptr_t)iop->dxferp;
|
|---|
| 94 | + bsg_param.ioctl_pthru.data_len = iop->dxfer_len;
|
|---|
| 95 |
|
|---|
| 96 | bsg_param.ioctl_pthru.info_0.cdb_len = scsi_param.cdb_len;
|
|---|
| 97 | bsg_param.ioctl_pthru.sense_addr = (uintptr_t)scsi_param.sense_buffer;
|
|---|
| 98 | @@ -1507,10 +1504,21 @@
|
|---|
| 99 | memcpy(&bsg_param.ioctl_pthru.cdw16, scsi_param.cdb, scsi_param.cdb_len);
|
|---|
| 100 |
|
|---|
| 101 | int r = ioctl(get_fd(), SG_IO, &io_hdr_v4);
|
|---|
| 102 | - if (r < 0) {
|
|---|
| 103 | - return (r);
|
|---|
| 104 | + if (r != 0) {
|
|---|
| 105 | + return set_err((errno ? errno : EIO), "scsi_cmd ioctl failed: %d %d,%d",
|
|---|
| 106 | + errno, scsi_param.loc.enc_id, scsi_param.loc.slot_id);
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | + iop->scsi_status = io_hdr_v4.device_status;
|
|---|
| 110 | +
|
|---|
| 111 | + int len = ( iop->max_sense_len < io_hdr_v4.max_response_len ) ?
|
|---|
| 112 | + iop->max_sense_len : io_hdr_v4.max_response_len;
|
|---|
| 113 | +
|
|---|
| 114 | + if (iop->sensep && len > 0) {
|
|---|
| 115 | + memcpy(iop->sensep, reinterpret_cast<void *>(io_hdr_v4.response), len);
|
|---|
| 116 | + iop->resp_sense_len = len;
|
|---|
| 117 | + }
|
|---|
| 118 | +
|
|---|
| 119 | return true;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | @@ -3257,13 +3265,11 @@
|
|---|
| 123 | int
|
|---|
| 124 | linux_smart_interface::sssraid_pdlist_cmd(int bus_no, uint16_t start_idx_param, void *buf, size_t bufsize, uint8_t *statusp)
|
|---|
| 125 | {
|
|---|
| 126 | - struct sg_io_v4 io_hdr_v4;
|
|---|
| 127 | + struct sg_io_v4 io_hdr_v4{};
|
|---|
| 128 | unsigned char sense_buff[ADM_SCSI_CDB_SENSE_MAX_LEN] = { 0 };
|
|---|
| 129 | - struct bsg_ioctl_cmd bsg_param;
|
|---|
| 130 | + struct bsg_ioctl_cmd bsg_param{};
|
|---|
| 131 | u8 cmd_param[24] = { 0 };
|
|---|
| 132 |
|
|---|
| 133 | - memset(&io_hdr_v4, 0, sizeof(io_hdr_v4));
|
|---|
| 134 | - memset(&bsg_param, 0, sizeof(bsg_param));
|
|---|
| 135 | io_hdr_v4.guard = 'Q';
|
|---|
| 136 | io_hdr_v4.protocol = BSG_PROTOCOL_SCSI;
|
|---|
| 137 | io_hdr_v4.subprotocol = BSG_SUB_PROTOCOL_SCSI_TRANSPORT;
|
|---|
| 138 | @@ -3286,7 +3292,7 @@
|
|---|
| 139 | bsg_param.ioctl_r64.info_1.data_len = bufsize;
|
|---|
| 140 | bsg_param.ioctl_r64.data_len = bufsize;
|
|---|
| 141 | bsg_param.ioctl_r64.info_1.param_len = sizeof(struct cmd_pdlist_idx);
|
|---|
| 142 | - memset(&cmd_param, 0, 24);
|
|---|
| 143 | +
|
|---|
| 144 | struct cmd_pdlist_idx *p_cmd_param = (struct cmd_pdlist_idx *)(&cmd_param);
|
|---|
| 145 | p_cmd_param->start_idx = start_idx_param;
|
|---|
| 146 | p_cmd_param->count = CMD_PDLIST_ONCE_NUM;
|
|---|
| 147 | @@ -3321,10 +3327,9 @@
|
|---|
| 148 | linux_smart_interface::sssraid_pd_add_list(int bus_no, smart_device_list & devlist)
|
|---|
| 149 | {
|
|---|
| 150 | unsigned disk_num = 0;
|
|---|
| 151 | - struct cmd_pdlist_entry pdlist[CMD_PDS_MAX_NUM];
|
|---|
| 152 | + struct cmd_pdlist_entry pdlist[CMD_PDS_MAX_NUM]{};
|
|---|
| 153 | while (disk_num < CMD_PDS_MAX_NUM) {
|
|---|
| 154 | - struct cmd_show_pdlist list;
|
|---|
| 155 | - memset(&list, 0, sizeof(list));
|
|---|
| 156 | + struct cmd_show_pdlist list{};
|
|---|
| 157 | if (sssraid_pdlist_cmd(bus_no, disk_num, &list, sizeof(struct cmd_show_pdlist), NULL) < 0)
|
|---|
| 158 | {
|
|---|
| 159 | return (-1);
|
|---|