4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #include "isns_server.h"
31 #include "isns_cache.h"
33 #include "isns_dsapi.h"
34 #include "isns_dseng.h"
35 #include "isns_msgq.h"
43 extern const int NUM_OF_CHILD
[MAX_OBJ_TYPE
];
44 extern const int TYPE_OF_PARENT
[MAX_OBJ_TYPE_FOR_SIZE
];
50 return (target_init_data());
60 uint32_t uid
= 0, type
= 0;
62 isns_type_t ptype
= 0;
63 void const **child
[MAX_CHILD_TYPE
] = { NULL
};
66 isns_attr_t
*scn_bitmap
;
67 isns_attr_t
*scn_name
;
69 isns_attr_t
*eid_attr
;
72 (void) cache_lock_write();
74 ec
= target_load_obj(&prev
, &obj
, &phase
);
75 while (ec
== 0 && obj
!= NULL
) {
81 ec
= register_object(obj
, &puid
, NULL
);
85 ec
= register_object(obj
, &puid
, NULL
);
87 eid_attr
= &obj
->attrs
[
88 ATTR_INDEX_ENTITY(ISNS_EID_ATTR_ID
)];
95 scn_bitmap
= &obj
->attrs
[ATTR_INDEX_ISCSI(
96 ISNS_ISCSI_SCN_BITMAP_ATTR_ID
)];
97 scn_name
= &obj
->attrs
[ATTR_INDEX_ISCSI(
98 ISNS_ISCSI_NAME_ATTR_ID
)];
101 TYPE_OF_PARENT
[obj
->type
] == ptype
) {
102 (void) set_parent_obj(obj
, puid
);
104 ec
= register_object(obj
, &uid
, NULL
);
106 ec
= ISNS_RSP_INTERNAL_ERROR
;
109 ec
= buff_child_obj(ptype
, type
,
112 if (ec
== 0 && scn_bitmap
!= NULL
) {
118 scn_bitmap
->value
.ui
);
123 TYPE_OF_PARENT
[OBJ_PG
] == ptype
) {
124 (void) set_parent_obj(obj
, puid
);
125 ec
= register_object(obj
, NULL
, NULL
);
127 ec
= ISNS_RSP_INTERNAL_ERROR
;
130 case OBJ_ASSOC_ISCSI
:
132 TYPE_OF_PARENT
[OBJ_ASSOC_ISCSI
] == ptype
) {
133 /* ignore adding member to default dd */
134 /* during loading objects from data store */
135 if (puid
!= ISNS_DEFAULT_DD_ID
) {
136 (void) set_parent_obj(obj
, puid
);
137 ec
= add_dd_member(obj
);
140 ec
= ISNS_RSP_INTERNAL_ERROR
;
146 TYPE_OF_PARENT
[OBJ_ASSOC_DD
] == ptype
) {
147 /* ignore adding member to default dd-set */
148 /* and adding default dd to any dd-set */
149 /* during loading objects from data store */
150 if (puid
!= ISNS_DEFAULT_DD_SET_ID
&&
151 get_obj_uid(obj
) != ISNS_DEFAULT_DD_ID
) {
152 (void) set_parent_obj(obj
, puid
);
153 ec
= add_dds_member(obj
);
156 ec
= ISNS_RSP_INTERNAL_ERROR
;
162 ec
= ISNS_RSP_INTERNAL_ERROR
;
166 ec
= target_load_obj(&prev
, &obj
, &phase
);
170 NUM_OF_CHILD
[ptype
] > 0 &&
172 TYPE_OF_PARENT
[obj
->type
] != ptype
)) {
173 ec
= update_child_obj(ptype
, puid
, child
, 0);
177 /* unlock the cache */
178 (void) cache_unlock_sync(0);
180 /* free the child buffer */
182 while (uid
< MAX_CHILD_TYPE
) {
183 if (child
[uid
] != NULL
) {
195 const isns_obj_t
*obj
202 ec
= target_add_obj(obj
);
205 ec
= target_modify_obj(obj
);
208 ec
= target_delete_obj(obj
);
210 case DATA_DELETE_ASSOC
:
211 ec
= target_delete_assoc(obj
);
214 ec
= target_update_commit();
217 ec
= target_update_retreat();