Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: target: core: Add emulate_rsoc attribute

Allow support for RSOC to be turned off via the emulate_rsoc attibute.
This is just for testing purposes.

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Link: https://lore.kernel.org/r/20220906103421.22348-5-d.bogdanov@yadro.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Dmitry Bogdanov and committed by
Martin K. Petersen
bd217b8c 553b08d9

+36
+20
drivers/target/target_core_configfs.c
··· 547 547 DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment); 548 548 DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data); 549 549 DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len); 550 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_rsoc); 550 551 551 552 #define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \ 552 553 static ssize_t _name##_store(struct config_item *item, const char *page,\ ··· 1187 1186 return count; 1188 1187 } 1189 1188 1189 + static ssize_t emulate_rsoc_store(struct config_item *item, 1190 + const char *page, size_t count) 1191 + { 1192 + struct se_dev_attrib *da = to_attrib(item); 1193 + bool flag; 1194 + int ret; 1195 + 1196 + ret = strtobool(page, &flag); 1197 + if (ret < 0) 1198 + return ret; 1199 + 1200 + da->emulate_rsoc = flag; 1201 + pr_debug("dev[%p]: SE Device REPORT_SUPPORTED_OPERATION_CODES_EMULATION flag: %d\n", 1202 + da->da_dev, flag); 1203 + return count; 1204 + } 1205 + 1190 1206 CONFIGFS_ATTR(, emulate_model_alias); 1191 1207 CONFIGFS_ATTR(, emulate_dpo); 1192 1208 CONFIGFS_ATTR(, emulate_fua_write); ··· 1216 1198 CONFIGFS_ATTR(, emulate_caw); 1217 1199 CONFIGFS_ATTR(, emulate_3pc); 1218 1200 CONFIGFS_ATTR(, emulate_pr); 1201 + CONFIGFS_ATTR(, emulate_rsoc); 1219 1202 CONFIGFS_ATTR(, pi_prot_type); 1220 1203 CONFIGFS_ATTR_RO(, hw_pi_prot_type); 1221 1204 CONFIGFS_ATTR(, pi_prot_format); ··· 1280 1261 &attr_max_write_same_len, 1281 1262 &attr_alua_support, 1282 1263 &attr_pgr_support, 1264 + &attr_emulate_rsoc, 1283 1265 NULL, 1284 1266 }; 1285 1267 EXPORT_SYMBOL(sbc_attrib_attrs);
+1
drivers/target/target_core_device.c
··· 785 785 dev->dev_attrib.emulate_caw = DA_EMULATE_CAW; 786 786 dev->dev_attrib.emulate_3pc = DA_EMULATE_3PC; 787 787 dev->dev_attrib.emulate_pr = DA_EMULATE_PR; 788 + dev->dev_attrib.emulate_rsoc = DA_EMULATE_RSOC; 788 789 dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE0_PROT; 789 790 dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS; 790 791 dev->dev_attrib.force_pr_aptpl = DA_FORCE_PR_APTPL;
+12
drivers/target/target_core_spc.c
··· 1889 1889 0xff, 0xff, 0x00, SCSI_CONTROL_MASK}, 1890 1890 }; 1891 1891 1892 + 1893 + static bool spc_rsoc_enabled(struct se_cmd *cmd) 1894 + { 1895 + struct se_device *dev = cmd->se_dev; 1896 + 1897 + return dev->dev_attrib.emulate_rsoc; 1898 + } 1899 + 1892 1900 static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = { 1893 1901 .support = SCSI_SUPPORT_FULL, 1894 1902 .serv_action_valid = 1, ··· 1907 1899 0x87, 0xff, 1908 1900 0xff, 0xff, 0xff, 0xff, 1909 1901 0xff, 0xff, 0x00, SCSI_CONTROL_MASK}, 1902 + .enabled = spc_rsoc_enabled, 1910 1903 }; 1911 1904 1912 1905 static bool tcm_is_set_tpg_enabled(struct se_cmd *cmd) ··· 2143 2134 unsigned char *rbuf; 2144 2135 sense_reason_t ret = 0; 2145 2136 int i; 2137 + 2138 + if (!cmd->se_dev->dev_attrib.emulate_rsoc) 2139 + return TCM_UNSUPPORTED_SCSI_OPCODE; 2146 2140 2147 2141 rbuf = transport_kmap_data_sg(cmd); 2148 2142 if (cmd->data_length && !rbuf) {
+3
include/target/target_core_base.h
··· 91 91 #define DA_EMULATE_ALUA 0 92 92 /* Emulate SCSI2 RESERVE/RELEASE and Persistent Reservations by default */ 93 93 #define DA_EMULATE_PR 1 94 + /* Emulation for REPORT SUPPORTED OPERATION CODES */ 95 + #define DA_EMULATE_RSOC 1 94 96 /* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */ 95 97 #define DA_ENFORCE_PR_ISIDS 1 96 98 /* Force SPC-3 PR Activate Persistence across Target Power Loss */ ··· 692 690 bool emulate_caw; 693 691 bool emulate_3pc; 694 692 bool emulate_pr; 693 + bool emulate_rsoc; 695 694 enum target_prot_type pi_prot_type; 696 695 enum target_prot_type hw_pi_prot_type; 697 696 bool pi_prot_verify;