/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* RCM module for managing dump device during dynamic
* reconfiguration.
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include <assert.h>
#include <errno.h>
#include <libintl.h>
#include "rcm_module.h"
/* cache flags */
typedef struct dump_conf {
int cache_flags;
} dump_conf_t;
/*
* Registration cache.
*
* N.B. Although we currently only support a single
* dump device, the cache is multi-entry since there
* may be multiple outstanding registrations.
*/
static int dump_register(rcm_handle_t *);
static int dump_unregister(rcm_handle_t *);
char **, char **, nvlist_t *, rcm_info_t **);
uint_t, char **, rcm_info_t **);
char **, rcm_info_t **);
char **, rcm_info_t **);
char **, rcm_info_t **);
char **, rcm_info_t **);
static int alloc_usage(char **, int);
static void cache_insert(dump_conf_t *);
static dump_conf_t *cache_lookup(char *);
static void cache_remove(dump_conf_t *);
static dump_conf_t *dump_conf_alloc(void);
static int dump_configure(dump_conf_t *, char **);
static int dump_relocate(dump_conf_t *, char **);
static void free_cache(void);
static void log_cmd_status(int);
static int update_cache(rcm_handle_t *);
{
NULL,
NULL,
};
struct rcm_mod_ops *
{
return (&dump_ops);
}
const char *
{
return ("RCM Dump module 1.3");
}
int
{
free_cache();
(void) mutex_destroy(&cache_lock);
return (RCM_SUCCESS);
}
static int
{
return (update_cache(hdl));
}
static int
{
(void) mutex_lock(&cache_lock);
}
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
/*ARGSUSED*/
static int
{
int conf_flags;
(void) mutex_lock(&cache_lock);
(void) mutex_unlock(&cache_lock);
rsrcname);
return (RCM_FAILURE);
}
(void) mutex_unlock(&cache_lock);
}
/*
* Relocate dump device to maintain availability during suspension.
* Fail request if unable to relocate.
*/
/*ARGSUSED*/
static int
{
int rv;
return (RCM_SUCCESS);
(void) mutex_lock(&cache_lock);
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*ARGSUSED*/
static int
{
int rv;
(void) mutex_lock(&cache_lock);
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*
* By default, reject offline. If offline request is
* forced, attempt to relocate the dump device.
*/
/*ARGSUSED*/
static int
{
int conf_flags;
int rv;
return (RCM_SUCCESS);
(void) mutex_lock(&cache_lock);
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
(void) mutex_unlock(&cache_lock);
return (rv);
}
/* default */
(void) mutex_unlock(&cache_lock);
return (RCM_FAILURE);
}
/*ARGSUSED*/
static int
{
int rv;
(void) mutex_lock(&cache_lock);
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*ARGSUSED*/
static int
{
(void) mutex_lock(&cache_lock);
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
(void) mutex_unlock(&cache_lock);
return (RCM_SUCCESS);
}
/*
* For dedicated dump devices, invoke dumpadm(1M)
* to relocate dump to swap. For dump device on
* swap, this is a no-op as the RCM swap module
* will relocate by invoking swap(1M).
*
* Call with cache_lock held.
*/
static int
{
int stat;
/*
* This state may get out of sync for a dump device on swap,
* since we will will not know if the swap module succeeds.
* Worst case is we end up invoking dumpadm to configure
* the same device during a rollback.
*/
/* RCM swap module will handle non-dedicated */
return (RCM_SUCCESS);
return (RCM_FAILURE);
}
return (RCM_SUCCESS);
}
/*
* (Re)Configure dump device.
* Call with cache_lock held.
*/
static int
{
int stat;
/* minor optimization */
return (RCM_SUCCESS);
return (RCM_FAILURE);
}
return (RCM_SUCCESS);
}
/*
* Returns current dump configuration
*/
static dump_conf_t *
dump_conf_alloc(void)
{
int fd;
char *err;
return (NULL);
}
/*
* Suppress reporting if no logical link.
*/
}
if (fd == -1) {
return (NULL);
}
}
} else {
return (NULL);
}
}
return (NULL);
}
}
return (dc);
}
static int
{
return (RCM_FAILURE);
(void) mutex_lock(&cache_lock);
/*
* pass 1 - mark all current registrations stale
*/
}
/*
* update current dump conf
*/
} else {
}
/*
* pass 2 - register, unregister, or no-op based on cache flags
*/
continue;
}
RCM_SUCCESS) {
}
continue;
}
continue;
}
RCM_SUCCESS) {
rv = RCM_FAILURE;
} else {
}
}
(void) mutex_unlock(&cache_lock);
return (rv);
}
/*
* Call with cache_lock held.
*/
static dump_conf_t *
{
return (dc);
}
}
return (NULL);
}
/*
* Link to front of list.
* Call with cache_lock held.
*/
static void
{
}
/*
* Call with cache_lock held.
*/
static void
{
}
} else {
}
}
static void
free_cache(void)
{
(void) mutex_lock(&cache_lock);
}
(void) mutex_unlock(&cache_lock);
}
static int
{
/* simplifies message translation */
if (conf_flags & DUMP_EXCL) {
} else {
}
return (-1);
}
return (0);
}
static void
{
char *err;
if (stat == -1) {
WEXITSTATUS(stat));
} else {
}
}