Project

General

Profile

Bug #573 ยป iscsit-alias.diff

Yuri Pankov, 2010-12-27 05:30 AM

View differences:

usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c Thu Dec 16 09:43:44 2010 -0800 โ†’ usr/src/uts/common/io/comstar/port/iscsit/iscsit_login.c Mon Dec 27 08:07:45 2010 +0300
2565 2565
		ict->ict_sess->ist_initiator_alias =
2566 2566
		    kmem_alloc(strlen(string_val) + 1, KM_SLEEP);
2567 2567
		(void) strcpy(ict->ict_sess->ist_initiator_alias, string_val);
2568
		if (ict->ict_sess->ist_stmf_sess) {
2569
			if (!ict->ict_sess->ist_stmf_sess->ss_rport_alias) {
2570
				ict->ict_sess->ist_stmf_sess->ss_rport_alias = (char *)
2571
				    kmem_zalloc(MAX_ISCSI_NODENAMELEN + 1, KM_SLEEP);
2572
			}
2573
			(void) strncpy(ict->ict_sess->ist_stmf_sess->ss_rport_alias,
2574
			    string_val, MAX_ISCSI_NODENAMELEN);
2575
		}
2568 2576
	}
2569 2577

  
2570 2578
	if ((nvrc = nvlist_lookup_string(lsm->icl_negotiated_values,
usr/src/uts/common/io/comstar/port/iscsit/iscsit_sess.c Thu Dec 16 09:43:44 2010 -0800 โ†’ usr/src/uts/common/io/comstar/port/iscsit/iscsit_sess.c Mon Dec 27 08:07:45 2010 +0300
228 228
		kmem_free(iss->ss_rport_id, sizeof (scsi_devid_desc_t) +
229 229
		    strlen(ist->ist_initiator_name) + 1);
230 230
		stmf_remote_port_free(iss->ss_rport);
231
		if (iss->ss_rport_alias) {
232
			kmem_free(iss->ss_rport_alias,
233
			    MAX_ISCSI_NODENAMELEN + 1);
234
		}
231 235
		stmf_free(iss);
232 236
	}
233 237
	mutex_exit(&ist->ist_mutex);
usr/src/uts/common/io/comstar/port/iscsit/iscsit_tgt.c Thu Dec 16 09:43:44 2010 -0800 โ†’ usr/src/uts/common/io/comstar/port/iscsit/iscsit_tgt.c Mon Dec 27 08:07:45 2010 +0300
852 852
{
853 853
	iscsit_tgt_t		*result;
854 854
	stmf_local_port_t	*lport;
855
	char			*alias;
855 856

  
856 857
	/*
857 858
	 * Each target is an STMF local port.
......
889 890
	idm_refcnt_init(&result->target_refcnt, result);
890 891
	idm_refcnt_init(&result->target_sess_refcnt, result);
891 892

  
893
	/* Set target alias */
894
	if (nvlist_lookup_string(cfg_tgt->tgt_properties, "alias", &alias) == 0) {
895
		lport->lport_alias = (char *)
896
		    kmem_zalloc(MAX_ISCSI_NODENAMELEN + 1, KM_SLEEP);
897
		(void) strncpy(lport->lport_alias, alias,
898
		    MAX_ISCSI_NODENAMELEN);
899
	} else {
900
		lport->lport_alias = NULL;
901
	}
902

  
892 903
	/* Finish initializing local port */
893 904
	/*
894 905
	 * Would like infinite timeout, but this is about as long as can
......
939 950
{
940 951
	idm_status_t	idmrc = IDM_STATUS_SUCCESS;
941 952
	list_t		tpgt_del_list;
953
	char		*alias;
942 954

  
943 955
	/* Merge TPGT */
944 956
	list_create(&tpgt_del_list, sizeof (iscsit_tpgt_t),
......
952 964
	(void) nvlist_dup(cfg_tgt->tgt_properties, &tgt->target_props,
953 965
	    KM_SLEEP);
954 966

  
967
	/* Update alias */
968
	if (nvlist_lookup_string(tgt->target_props, "alias", &alias) == 0) {
969
		if (!tgt->target_stmf_lport->lport_alias) {
970
			tgt->target_stmf_lport->lport_alias = (char *)
971
			    kmem_zalloc(MAX_ISCSI_NODENAMELEN + 1, KM_SLEEP);
972
		}
973
		(void) strncpy(tgt->target_stmf_lport->lport_alias,
974
		    alias, MAX_ISCSI_NODENAMELEN);
975
	} else if (tgt->target_stmf_lport->lport_alias) {
976
		kmem_free(tgt->target_stmf_lport->lport_alias,
977
		    MAX_ISCSI_NODENAMELEN + 1);
978
		tgt->target_stmf_lport->lport_alias = NULL;
979
	}
980

  
955 981
	if ((idmrc = iscsit_tgt_merge_tpgt(tgt, cfg_tgt, &tpgt_del_list)) !=
956 982
	    IDM_STATUS_SUCCESS) {
957 983
		/* This should never happen */
......
1046 1072
	avl_destroy(&tgt->target_tpgt_list);
1047 1073
	avl_destroy(&tgt->target_sess_list);
1048 1074
	mutex_destroy(&tgt->target_mutex);
1075
	if (tgt->target_stmf_lport->lport_alias) {
1076
		kmem_free(tgt->target_stmf_lport->lport_alias,
1077
		   MAX_ISCSI_NODENAMELEN + 1);
1078
	}
1049 1079
	stmf_free(tgt->target_stmf_lport); /* Also frees "tgt' */
1050 1080
	iscsit_global_rele();
1051 1081
}
    (1-1/1)