linux/drivers/target/target_core_ua.c
/*
 * Dequeue a unit attention from the unit attention list. This function
 * returns true if the dequeuing succeeded and if *@key, *@asc and *@ascq have
 * been set.
 */
Dequeue a unit attention from the unit attention list. This function
returns true if the dequeuing succeeded and if *@key, *@asc and *@ascq have
been set.
Dequeue a unit attention from the unit attention list . This function returns true if the dequeuing succeeded and if * @key * @asc and * @ascq have been set .
bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc,
				       u8 *ascq)
{
	struct se_device *dev = cmd->se_dev;
	struct se_dev_entry *deve;
	struct se_session *sess = cmd->se_sess;
	struct se_node_acl *nacl;
	struct se_ua *ua = NULL, *ua_p;
	int head = 1;
	if (WARN_ON_ONCE(!sess))
		return false;
	nacl = sess->se_node_acl;
	if (WARN_ON_ONCE(!nacl))
		return false;
	rcu_read_lock();
	deve = target_nacl_find_deve(nacl, cmd->orig_fe_lun);
	if (!deve) {
		rcu_read_unlock();
		*key = ILLEGAL_REQUEST;
		*asc = 0x25; 
		*ascq = 0;
		return true;
	}
	*key = UNIT_ATTENTION;
	spin_lock(&deve->ua_lock);
	list_for_each_entry_safe(ua, ua_p, &deve->ua_list, ua_nacl_list) {
		if (dev->dev_attrib.emulate_ua_intlck_ctrl != 0) {
			*asc = ua->ua_asc;
			*ascq = ua->ua_ascq;
			break;
		}
		if (head) {
			*asc = ua->ua_asc;
			*ascq = ua->ua_ascq;
			head = 0;
		}
		list_del(&ua->ua_nacl_list);
		kmem_cache_free(se_ua_cache, ua);
	}
	spin_unlock(&deve->ua_lock);
	rcu_read_unlock();
	pr_debug("[%s]: %s UNIT ATTENTION condition with"
		" INTLCK_CTRL: %d, mapped LUN: %llu, got CDB: 0x%02x"
		" reported ASC: 0x%02x, ASCQ: 0x%02x\n",
		nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
		(dev->dev_attrib.emulate_ua_intlck_ctrl != 0) ? "Reporting" :
		"Releasing", dev->dev_attrib.emulate_ua_intlck_ctrl,
		cmd->orig_fe_lun, cmd->t_task_cdb[0], *asc, *ascq);
	return head == 0;
}
bool core_scsi3_ua_for_check_condition ( struct se_cmd * cmd , u8 * key , u8 * asc , u8 * ascq ) { struct se_device * dev = cmd -> se_dev ; struct se_dev_entry * deve ; struct se_session * sess = cmd -> se_sess ; struct se_node_acl * nacl ; struct se_ua * ua = NULL , * ua_p ; int head = 1 ; if ( WARN_ON_ONCE ( ! sess ) ) return false ; nacl = sess -> se_node_acl ; if ( WARN_ON_ONCE ( ! nacl ) ) return false ; rcu_read_lock ( ) ; deve = target_nacl_find_deve ( nacl , cmd -> orig_fe_lun ) ; if ( ! deve ) { rcu_read_unlock ( ) ; * key = ILLEGAL_REQUEST ; * asc = 0x25 ; * ascq = 0 ; return true ; } * key = UNIT_ATTENTION ; spin_lock ( & deve -> ua_lock ) ; list_for_each_entry_safe ( ua , ua_p , & deve -> ua_list , ua_nacl_list ) { if ( dev -> dev_attrib . emulate_ua_intlck_ctrl != 0 ) { * asc = ua -> ua_asc ; * ascq = ua -> ua_ascq ; break ; } if ( head ) { * asc = ua -> ua_asc ; * ascq = ua -> ua_ascq ; head = 0 ; } list_del ( & ua -> ua_nacl_list ) ; kmem_cache_free ( se_ua_cache , ua ) ; } spin_unlock ( & deve -> ua_lock ) ; rcu_read_unlock ( ) ; pr_debug ( " " " " " \n " , nacl -> se_tpg -> se_tpg_tfo -> get_fabric_name ( ) , ( dev -> dev_attrib . emulate_ua_intlck_ctrl != 0 ) ? " " : " " , dev -> dev_attrib . emulate_ua_intlck_ctrl , cmd -> orig_fe_lun , cmd -> t_task_cdb [ 0 ] , * asc , * ascq ) ; return head == 0 ; }
Dequeue a unit attention from the unit attention list.
Dequeue a unit attention from the unit attention list .
/* LOGICAL UNIT NOT SUPPORTED */ /*
	 * The highest priority Unit Attentions are placed at the head of the
	 * struct se_dev_entry->ua_list, and will be returned in CHECK_CONDITION +
	 * sense data for the received CDB.
	 */ /*
		 * For ua_intlck_ctrl code not equal to 00b, only report the
		 * highest priority UNIT_ATTENTION and ASC/ASCQ without
		 * clearing it.
		 */ /*
		 * Otherwise for the default 00b, release the UNIT ATTENTION
		 * condition.  Return the ASC/ASCQ of the highest priority UA
		 * (head of the list) in the outgoing CHECK_CONDITION + sense.
		 */