fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (Un)Freeze Module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module provides a means to 'freeze' a device and ensure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that no SP software has an open reference to that device. Later
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the device can be 'unfrozen' and the SP software can resume
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * normal operations.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This module is required because it is possible to place a virtual
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * volume driver (RAID-0, 1 or 5) into a state whereby it needs to be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * disabled for corrective action. The (un)freeze facility provides a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * method of doing this without downtime.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A device that is frozen should be frozen on all nodes. It is the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * responsibility of the management software or the user to perform
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the freeze and unfreeze on the required nodes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _nsc_frz_stop(char *, int *); /* forward decl */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_init(&_nsc_frz_sleep, NULL, MUTEX_DRIVER, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "nsctl: _nsc_init_frz: register failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * int _nsc_frz_start(char *path, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Freeze a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called from a context that can block.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns 0 for success, or one of the following error codes:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EINVAL - invalid 'path' argument
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ENOMEM - failed to allocate memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EALREADY - 'path' is already frozen
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Registers 'path' to be accessed through the NSC_FREEZE_ID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * io module, and forces any open file descriptors for 'path'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to be re-opened as appropriate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte frz = nsc_kmem_zalloc(sizeof (*frz), KM_SLEEP, _nsc_local_mem);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (xfrz = _nsc_frz_top; xfrz; xfrz = xfrz->next)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte frz->token = nsc_register_path(path, NSC_DEVICE, _nsc_frz_io);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * int _nsc_frz_stop(char *path, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Unfreeze a device
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Must be called from a context that can block.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns 0 or an error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Removes the path registration for the NSC_FREEZE_ID io module
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and forces any re-opens as appropriate.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (xfrz = &_nsc_frz_top; *xfrz; xfrz = &(*xfrz)->next)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = nsc_unregister_path(frz->token, NSC_PCATCH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * int _nsc_frz_isfrozen(char *path, int *rvp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Tests whether a device is frozen.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns 0 or EINVAL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Sets *rvp to 1 if the device was not frozen, and 0 otherwise.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function returns historical information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * static int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _nsc_frz_open(char *path, int flag, blind_t *cdp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dummy open function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the "Open" function for the I/O module.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is just a dummy.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * static int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _nsc_frz_close()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dummy close function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the "Close" function for the I/O module.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It is just a dummy.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * static int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * _nsc_frz_attach()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Attach a device to this i/o module.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns EACCES in all cricumstances.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function is called by the nsctl module when it wishes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to attach the device to this I/O module (ie. as part of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nsc_reserve() processing). This function unconditionally
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns an error which forces the nsc_reserve() to fail, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so no access to possible to the underlying device.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Provide", 0, 0,