mgmt_remove.c revision 0b4fd3b107539afdb6ac991e02328c2176598b78
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file deals with XML data for removing various configuration data.
*/
#include <errno.h>
#include <strings.h>
#include <unistd.h>
#include <priv.h>
#include <syslog.h>
#include <libzfs.h>
#include <iscsitgt_impl.h>
#include "utility.h"
#include "queue.h"
#include "target.h"
#include "iscsi_cmd.h"
#include "errcode.h"
#include "isns_client.h"
#include "mgmt_scf.h"
static char *remove_initiator(tgt_node_t *x);
static char *remove_tpgt(tgt_node_t *x);
/*ARGSUSED*/
void
{
tgt_node_t *x;
char msgbuf[80];
x = p->x_child;
/*
* remove_zfs() does not affect SMF data
* therefore it is not covered by auth check
*/
if (x == NULL) {
} else {
reply_msg = remove_initiator(x);
reply_msg = remove_tpgt(x);
} else {
"Unknown object '%s' for delete element",
x->x_name);
}
}
}
/*
* remove_zfs -- remove a ZFS property, or the entire ZVOL
*/
static char *
{
tgt_node_t *n = NULL;
tgt_node_t *t = NULL;
tgt_node_t *c;
int status;
(void) pthread_rwlock_wrlock(&targ_config_mutex);
goto error;
}
/*
* Check for existance of ZFS shareiscsi properties
*/
(status != ERR_NULL_XML_MESSAGE)) {
goto error;
}
!= NULL) {
break;
}
if (t == NULL) {
if (status == ERR_ZFS_ISCSISHARE_OFF) {
/*
* This is iscsishare=off request from zfs on a target
* which is already unshared. In that case, zfs expects
* "success" result.
*/
} else {
}
goto error;
}
goto error;
}
if (status == ERR_ZFS_ISCSISHARE_OFF) {
goto error;
}
/*
* Due to the fact that the targets_config differs from the
* ZVOL properties stored in zfs_shareiscsi, two lists need to
* be updated
*/
NULL) {
}
NULL) {
}
tgt_node_free(c);
/* update isns */
if (isns_enabled()) {
}
change_made = True;
}
goto error;
}
if (status == ERR_ZFS_ISCSISHARE_OFF) {
goto error;
}
/*
* Due to the fact that the targets_config differs from the
* ZVOL properties stored in zfs_shareiscsi, two lists need to
* be updated
*/
NULL) {
}
NULL) {
}
tgt_node_free(c);
change_made = True;
}
if (change_made == False) {
goto error;
}
/* deregister zovl target from iSNS server. */
if (isns_enabled() == True) {
if (isns_dereg(prop) != 0)
}
/*
* Wait until here to issue a logout to any initiators that
* might be logged into the target. Certain initiators are
* sneaky in that if asked to logout they will, but turn right
* around and log back into the target. By waiting here to issue
* the logout we'll have removed reference to the target such
* that this can't happen.
*/
thick_provo_stop(prop, 0);
} else {
if (status != ERR_SUCCESS) {
goto error;
} else {
}
}
if (prop)
if (n)
tgt_node_free(n);
if (dataset)
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
static char *
{
tgt_node_t *c = NULL;
int lun_num;
(void) pthread_rwlock_wrlock(&targ_config_mutex);
goto error;
}
break;
}
goto error;
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (remove_zfs(x, cred));
}
}
goto error;
}
NULL) {
goto error;
}
goto error;
}
tgt_node_free(c);
change_made = True;
}
goto error;
}
NULL) {
goto error;
}
goto error;
}
tgt_node_free(c);
/* update isns */
if (isns_enabled()) {
}
change_made = True;
}
False) {
goto error;
}
/*
* Save the iscsi-name which we'll need to remove LUNs.
*/
False) {
goto error;
}
goto error;
/* ISNS de-register target if it's the last lun */
if (isns_dereg(prop) != 0)
}
change_made = True;
}
if (change_made == True) {
if (mgmt_config_save2scf() == True) {
} else {
}
} else {
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
if (c != NULL)
tgt_node_free(c);
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
static char *
{
char *name;
(void) pthread_rwlock_wrlock(&targ_config_mutex);
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
!= NULL) {
break;
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
if (mgmt_config_save2scf() == True) {
} else {
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
static char *
{
tgt_node_t *c = NULL;
(void) pthread_rwlock_wrlock(&targ_config_mutex);
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
!= NULL) {
break;
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
(void) pthread_rwlock_unlock(
return (msg);
}
}
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}
== NULL) {
goto error;
}
goto error;
}
tgt_node_free(c);
change_made = True;
}
if ((change_made != True) &&
change_made = True;
}
if (change_made == True) {
/* Isns re-register all target */
if (isns_enabled() == True)
(void) isns_reg_all();
if (mgmt_config_save2scf() == True) {
} else {
}
} else {
}
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
if (c != NULL)
tgt_node_free(c);
(void) pthread_rwlock_unlock(&targ_config_mutex);
return (msg);
}