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
)];
102 TYPE_OF_PARENT
[obj
->type
] == ptype
) {
103 (void) set_parent_obj(obj
, puid
);
105 ec
= register_object(obj
, &uid
, NULL
);
107 ec
= ISNS_RSP_INTERNAL_ERROR
;
110 ec
= buff_child_obj(ptype
, type
,
113 if (ec
== 0 && scn_bitmap
!= NULL
) {
119 scn_bitmap
->value
.ui
);
124 TYPE_OF_PARENT
[OBJ_PG
] == ptype
) {
125 (void) set_parent_obj(obj
, puid
);
126 ec
= register_object(obj
, NULL
, NULL
);
128 ec
= ISNS_RSP_INTERNAL_ERROR
;
131 case OBJ_ASSOC_ISCSI
:
133 TYPE_OF_PARENT
[OBJ_ASSOC_ISCSI
] == ptype
) {
134 /* ignore adding member to default dd */
135 /* during loading objects from data store */
136 if (puid
!= ISNS_DEFAULT_DD_ID
) {
137 (void) set_parent_obj(obj
, puid
);
138 ec
= add_dd_member(obj
);
141 ec
= ISNS_RSP_INTERNAL_ERROR
;
147 TYPE_OF_PARENT
[OBJ_ASSOC_DD
] == ptype
) {
148 /* ignore adding member to default dd-set */
149 /* and adding default dd to any dd-set */
150 /* during loading objects from data store */
151 if (puid
!= ISNS_DEFAULT_DD_SET_ID
&&
152 get_obj_uid(obj
) != ISNS_DEFAULT_DD_ID
) {
153 (void) set_parent_obj(obj
, puid
);
154 ec
= add_dds_member(obj
);
157 ec
= ISNS_RSP_INTERNAL_ERROR
;
163 ec
= ISNS_RSP_INTERNAL_ERROR
;
167 ec
= target_load_obj(&prev
, &obj
, &phase
);
171 NUM_OF_CHILD
[ptype
] > 0 &&
173 TYPE_OF_PARENT
[obj
->type
] != ptype
)) {
174 ec
= update_child_obj(ptype
, puid
, child
, 0);
178 /* unlock the cache */
179 (void) cache_unlock_sync(0);
181 /* free the child buffer */
183 while (uid
< MAX_CHILD_TYPE
) {
184 if (child
[uid
] != NULL
) {
196 const isns_obj_t
*obj
203 ec
= target_add_obj(obj
);
206 ec
= target_modify_obj(obj
);
209 ec
= target_delete_obj(obj
);
211 case DATA_DELETE_ASSOC
:
212 ec
= target_delete_assoc(obj
);
215 ec
= target_update_commit();
218 ec
= target_update_retreat();