.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * SCSI Primary Commands (SPC) parsing and emulation. |
---|
3 | 4 | * |
---|
4 | 5 | * (c) Copyright 2002-2013 Datera, Inc. |
---|
5 | 6 | * |
---|
6 | 7 | * Nicholas A. Bellinger <nab@kernel.org> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
11 | | - * (at your option) any later version. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | | - * |
---|
18 | | - * You should have received a copy of the GNU General Public License |
---|
19 | | - * along with this program; if not, write to the Free Software |
---|
20 | | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
21 | 8 | */ |
---|
22 | 9 | |
---|
23 | 10 | #include <linux/kernel.h> |
---|
.. | .. |
---|
113 | 100 | * unused bytes at the end of the field (i.e., highest offset) and the |
---|
114 | 101 | * unused bytes shall be filled with ASCII space characters (20h). |
---|
115 | 102 | */ |
---|
116 | | - memset(&buf[8], 0x20, 8 + 16 + 4); |
---|
117 | | - memcpy(&buf[8], "LIO-ORG", sizeof("LIO-ORG") - 1); |
---|
| 103 | + memset(&buf[8], 0x20, |
---|
| 104 | + INQUIRY_VENDOR_LEN + INQUIRY_MODEL_LEN + INQUIRY_REVISION_LEN); |
---|
| 105 | + memcpy(&buf[8], dev->t10_wwn.vendor, |
---|
| 106 | + strnlen(dev->t10_wwn.vendor, INQUIRY_VENDOR_LEN)); |
---|
118 | 107 | memcpy(&buf[16], dev->t10_wwn.model, |
---|
119 | | - strnlen(dev->t10_wwn.model, 16)); |
---|
| 108 | + strnlen(dev->t10_wwn.model, INQUIRY_MODEL_LEN)); |
---|
120 | 109 | memcpy(&buf[32], dev->t10_wwn.revision, |
---|
121 | | - strnlen(dev->t10_wwn.revision, 4)); |
---|
| 110 | + strnlen(dev->t10_wwn.revision, INQUIRY_REVISION_LEN)); |
---|
122 | 111 | buf[4] = 31; /* Set additional length to 31 */ |
---|
123 | 112 | |
---|
124 | 113 | return 0; |
---|
.. | .. |
---|
257 | 246 | buf[off+1] = 0x1; /* T10 Vendor ID */ |
---|
258 | 247 | buf[off+2] = 0x0; |
---|
259 | 248 | /* left align Vendor ID and pad with spaces */ |
---|
260 | | - memset(&buf[off+4], 0x20, 8); |
---|
261 | | - memcpy(&buf[off+4], "LIO-ORG", sizeof("LIO-ORG") - 1); |
---|
| 249 | + memset(&buf[off+4], 0x20, INQUIRY_VENDOR_LEN); |
---|
| 250 | + memcpy(&buf[off+4], dev->t10_wwn.vendor, |
---|
| 251 | + strnlen(dev->t10_wwn.vendor, INQUIRY_VENDOR_LEN)); |
---|
262 | 252 | /* Extra Byte for NULL Terminator */ |
---|
263 | 253 | id_len++; |
---|
264 | 254 | /* Identifier Length */ |
---|
.. | .. |
---|
643 | 633 | |
---|
644 | 634 | /* |
---|
645 | 635 | * The unmap_zeroes_data set means that the underlying device supports |
---|
646 | | - * REQ_DISCARD and has the discard_zeroes_data bit set. This satisfies |
---|
647 | | - * the SBC requirements for LBPRZ, meaning that a subsequent read |
---|
648 | | - * will return zeroes after an UNMAP or WRITE SAME (16) to an LBA |
---|
| 636 | + * REQ_OP_DISCARD and has the discard_zeroes_data bit set. This |
---|
| 637 | + * satisfies the SBC requirements for LBPRZ, meaning that a subsequent |
---|
| 638 | + * read will return zeroes after an UNMAP or WRITE SAME (16) to an LBA |
---|
649 | 639 | * See sbc4r36 6.6.4. |
---|
650 | 640 | */ |
---|
651 | 641 | if (((dev->dev_attrib.emulate_tpu != 0) || |
---|
.. | .. |
---|
857 | 847 | * for a BUSY, TASK SET FULL, or RESERVATION CONFLICT status regardless |
---|
858 | 848 | * to the number of commands completed with one of those status codes. |
---|
859 | 849 | */ |
---|
860 | | - p[4] = (dev->dev_attrib.emulate_ua_intlck_ctrl == 2) ? 0x30 : |
---|
861 | | - (dev->dev_attrib.emulate_ua_intlck_ctrl == 1) ? 0x20 : 0x00; |
---|
| 850 | + switch (dev->dev_attrib.emulate_ua_intlck_ctrl) { |
---|
| 851 | + case TARGET_UA_INTLCK_CTRL_ESTABLISH_UA: |
---|
| 852 | + p[4] = 0x30; |
---|
| 853 | + break; |
---|
| 854 | + case TARGET_UA_INTLCK_CTRL_NO_CLEAR: |
---|
| 855 | + p[4] = 0x20; |
---|
| 856 | + break; |
---|
| 857 | + default: /* TARGET_UA_INTLCK_CTRL_CLEAR */ |
---|
| 858 | + p[4] = 0x00; |
---|
| 859 | + break; |
---|
| 860 | + } |
---|
862 | 861 | /* |
---|
863 | 862 | * From spc4r17, section 7.4.6 Control mode Page |
---|
864 | 863 | * |
---|
.. | .. |
---|
1288 | 1287 | struct se_device *dev = cmd->se_dev; |
---|
1289 | 1288 | unsigned char *cdb = cmd->t_task_cdb; |
---|
1290 | 1289 | |
---|
| 1290 | + if (!dev->dev_attrib.emulate_pr && |
---|
| 1291 | + ((cdb[0] == PERSISTENT_RESERVE_IN) || |
---|
| 1292 | + (cdb[0] == PERSISTENT_RESERVE_OUT) || |
---|
| 1293 | + (cdb[0] == RELEASE || cdb[0] == RELEASE_10) || |
---|
| 1294 | + (cdb[0] == RESERVE || cdb[0] == RESERVE_10))) { |
---|
| 1295 | + return TCM_UNSUPPORTED_SCSI_OPCODE; |
---|
| 1296 | + } |
---|
| 1297 | + |
---|
1291 | 1298 | switch (cdb[0]) { |
---|
1292 | 1299 | case MODE_SELECT: |
---|
1293 | 1300 | *size = cdb[4]; |
---|