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

scsi: target: core: UA on all LUNs after reset

Allocate UNIT ATTENTION "BUS DEVICE RESET OCCURRED" on all LUNs on all
target ports of the device upon reception of TMF LUN RESET.

This change passes libiscsi test SCSI.MultipathIO.Reset.

Link: https://lore.kernel.org/r/20220913163602.20597-1-d.bogdanov@yadro.com
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Dmitry Bogdanov and committed by
Martin K. Petersen
6290e23f 3e2deba7

+21 -2
+19
drivers/target/target_core_device.c
··· 284 284 complete(&deve->pr_comp); 285 285 } 286 286 287 + /* 288 + * Establish UA condition on SCSI device - all LUNs 289 + */ 290 + void target_dev_ua_allocate(struct se_device *dev, u8 asc, u8 ascq) 291 + { 292 + struct se_dev_entry *se_deve; 293 + struct se_lun *lun; 294 + 295 + spin_lock(&dev->se_port_lock); 296 + list_for_each_entry(lun, &dev->dev_sep_list, lun_dev_link) { 297 + 298 + spin_lock(&lun->lun_deve_lock); 299 + list_for_each_entry(se_deve, &lun->lun_deve_list, lun_link) 300 + core_scsi3_ua_allocate(se_deve, asc, ascq); 301 + spin_unlock(&lun->lun_deve_lock); 302 + } 303 + spin_unlock(&dev->se_port_lock); 304 + } 305 + 287 306 static void 288 307 target_luns_data_has_changed(struct se_node_acl *nacl, struct se_dev_entry *new, 289 308 bool skip_new)
+1
drivers/target/target_core_internal.h
··· 89 89 void target_free_device(struct se_device *); 90 90 int target_for_each_device(int (*fn)(struct se_device *dev, void *data), 91 91 void *data); 92 + void target_dev_ua_allocate(struct se_device *dev, u8 asc, u8 ascq); 92 93 93 94 /* target_core_configfs.c */ 94 95 extern struct configfs_item_operations target_core_dev_item_ops;
+1 -2
drivers/target/target_core_transport.c
··· 3531 3531 tmr->response = (!ret) ? TMR_FUNCTION_COMPLETE : 3532 3532 TMR_FUNCTION_REJECTED; 3533 3533 if (tmr->response == TMR_FUNCTION_COMPLETE) { 3534 - target_ua_allocate_lun(cmd->se_sess->se_node_acl, 3535 - cmd->orig_fe_lun, 0x29, 3534 + target_dev_ua_allocate(dev, 0x29, 3536 3535 ASCQ_29H_BUS_DEVICE_RESET_FUNCTION_OCCURRED); 3537 3536 } 3538 3537 break;