/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _VOLUME_DEVCONFIG_H
#define _VOLUME_DEVCONFIG_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <libnvpair.h>
#include "volume_dlist.h"
/*
*/
/*
* Limits for attributes
*/
#define MIN_SIZE 0
#define MIN_SIZE_IN_BLOCKS 0
/* Attribute requested but not set */
/*
* Enumeration defining physical or logical device types
*/
typedef enum {
TYPE_UNKNOWN = 0,
/*
* enumerated constants for SVM Mirror read strategies
*/
typedef enum {
/*
* enumerated constants for SVM Mirror write strategies
*/
typedef enum {
/*
* devconfig_t - struct to hold a device configuration hierarchy
*/
typedef struct devconfig {
/* Attributes of this device */
/*
* Available devices for use in construction of this device
* and its subcomponents
*/
char **available;
/*
* Unavailable devices for use in construction of this device
* and its subcomponents
*/
char **unavailable;
/*
* Subcomponents (devconfig_t) of this device
*/
} devconfig_t;
/*
* Function prototypes
*/
/*
* Constructor: Create a devconfig_t struct. This devconfig_t must be
* freed with free_devconfig().
*
* @param devconfig
* RETURN: a new devconfig_t
*
* @param type
* the type of devconfig_t to create
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Free memory (recursively) allocated to a devconfig_t struct
*
* @param arg
* pointer to the devconfig_t to be freed
*/
extern void free_devconfig(void *arg);
/*
* Check the type of the given device.
*
* @param device
* the device whose type to check
*
* @param type
* the type of the device against which to compare
*
* @return B_TRUE if the device is of the given type, B_FALSE
* otherwise
*/
/*
* Get the first component of the given type from the given
* devconfig_t. Create the component if create is B_TRUE.
*
* @return ENOENT
* if the requested component does not exist and its
* creation was not requested
*
* @return 0
* if the requested component exists or was created
*
* @return non-zero
* if the requested component did not exist and could not
* be created
*/
/*
* Set the available devices for use in creating this device
*
* @param device
* a devconfig_t representing the device to modify
*
* @param available
* A NULL-terminated array of device names
*/
/*
* Get the available devices for use in creating this device
*
* @param device
* a devconfig_t representing the device to examine
*
* @return available
* A NULL-terminated array of device names
*/
/*
* Set the unavailable devices which may not be used in creating this
* device
*
* @param device
* a devconfig_t representing the device to modify
*
* @param available
* A NULL-terminated array of device names
*/
/*
* Get the unavailable devices for use in creating this device
*
* @param device
* a devconfig_t representing the device to examine
*
* @return unavailable
* A NULL-terminated array of device names
*/
/*
* Set the subcomponent devices of a given device
*
* @param device
* a devconfig_t representing the device to examine
*
* @param components
* A dlist_t containing devconfig_t devices
*/
/*
* Get the subcomponent devices of a given device
*
* @param device
* a devconfig_t representing the device to examine
*
* @return A dlist_t containing devconfig_t devices
*/
/*
* Set the device name
*
* @param device
* a devconfig_t representing the device to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the disk set name
*
* @param diskset
* a devconfig_t representing the diskset to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the device name
*
* @param hsp
* a devconfig_t representing the hsp to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the device name
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param name
* the value to set as the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get the device name
*
* @param volume
* a devconfig_t representing the volume to examine
*
* @param name
* RETURN: the device name
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the device type
*
* @param device
* a devconfig_t representing the device to modify
*
* @param type
* the value to set as the device type
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get the device type
*
* @param device
* a devconfig_t representing the device to examine
*
* @param type
* RETURN: the device type
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the device size (for volume, mirror, stripe, concat) in bytes
*
* Note that size in bytes in a 64-bit field cannot hold the size that
* can be accessed in a 16 byte CDB. Since CDBs operate on blocks,
* the max capacity is 2^73 bytes with 512 byte blocks.
*
* @param device
* a devconfig_t representing the device to modify
*
* @param size_in_bytes
* the value to set as the device size in bytes
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get the device size (for volume, mirror, stripe, concat) in bytes
*
* Note that size in bytes in a 64-bit field cannot hold the size that
* can be accessed in a 16 byte CDB. Since CDBs operate on blocks,
* the max capacity is 2^73 bytes with 512 byte blocks.
*
* @param device
* a devconfig_t representing the device to examine
*
* @param size_in_bytes
* RETURN: the device size in bytes
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the device size in blocks
*
* @param device
* a devconfig_t representing the device to modify
*
* @param type
* the value to set as the device size in blocks
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_set_size_in_blocks(
/*
* Get the device size in blocks
*
* @param device
* a devconfig_t representing the device to examine
*
* @param size_in_blocks
* RETURN: the device size in blocks
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_get_size_in_blocks(
/*
* Set the the slice index
*
* @param slice
* a devconfig_t representing the slice to modify
*
* @param index
* the value to set as the the slice index
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get the slice index
*
* @param device
* a devconfig_t representing the device to examine
*
* @param index
* RETURN: the slice index
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the the slice start block
*
* @param slice
* a devconfig_t representing the slice to modify
*
* @param start_block
* the value to set as the the slice start block
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_set_slice_start_block(
/*
* Get the slice start block
*
* @param device
* a devconfig_t representing the device to examine
*
* @param start_block
* RETURN: the slice start block
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_get_slice_start_block(
/*
* Set the number of subcomponents in mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param nsubs
* the value to set as the number of subcomponents in
* mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get number of subcomponents in mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param nsubs
* RETURN: number of subcomponents in mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the read strategy for mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param read
* the value to set as the read strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_set_mirror_read(
/*
* Get read strategy for mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param read
* RETURN: read strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_get_mirror_read(
/*
* Set the write strategy for mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param write
* the value to set as the write strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_set_mirror_write(
/*
* Get write strategy for mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param write
* RETURN: write strategy for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_get_mirror_write(
/*
* Set the resync pass for mirror
*
* @param mirror
* a devconfig_t representing the mirror to modify
*
* @param pass
* the value to set as the resync pass for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get resync pass for mirror
*
* @param device
* a devconfig_t representing the device to examine
*
* @param pass
* RETURN: resync pass for mirror
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the minimum number of components in stripe
*
* @param stripe
* a devconfig_t representing the stripe to modify
*
* @param mincomp
* the value to set as the minimum number of components
* in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get minimum number of components in stripe
*
* @param device
* a devconfig_t representing the device to examine
*
* @param mincomp
* RETURN: minimum number of components in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the maximum number of components in stripe
*
* @param stripe
* a devconfig_t representing the stripe to modify
*
* @param maxcomp
* the value to set as the maximum number of components
* in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get maximum number of components in stripe
*
* @param device
* a devconfig_t representing the device to examine
*
* @param maxcomp
* RETURN: maximum number of components in stripe
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the stripe interlace
*
* @param stripe
* a devconfig_t representing the stripe to modify
*
* @param interlace
* the value to set as the stripe interlace
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_set_stripe_interlace(
/*
* Get stripe interlace
*
* @param device
* a devconfig_t representing the device to examine
*
* @param interlace
* RETURN: stripe interlace
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_get_stripe_interlace(
/*
* Set the redundancy level for a volume.
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param rlevel
* If 0, a stripe will be created. If > 0, a mirror with
* this number of submirrors will be created.
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_set_volume_redundancy_level(
/*
* Get the redundancy level for a volume.
*
* @param device
* a devconfig_t representing the device to examine
*
* @param rlevel
* RETURN: the redundancy level for a volume
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
extern int devconfig_get_volume_redundancy_level(
/*
* Set the number of paths in volume
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param npaths
* the value to set as the number of paths in volume
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get number of paths in volume
*
* @param device
* a devconfig_t representing the device to examine
*
* @param npaths
* RETURN: number of paths in volume
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Set the HSP creation option (for volume, stripe, concat, mirror)
*
* @param volume
* a devconfig_t representing the volume to modify
*
* @param usehsp
* the value to set as the HSP creation option
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get HSP creation option (for volume, stripe, concat, mirror)
*
* @param device
* a devconfig_t representing the device to examine
*
* @param usehsp
* RETURN: HSP creation option (for volume, stripe,
* concat, mirror)
*
* @return 0
* if successful
*
* @return non-zero
* if an error occurred. Use get_error_string() to
* retrieve the associated error message.
*/
/*
* Get the string representation of the volume's type
*
* @param type
* a valid component_type_t
*
* @return an internationalized string representing the given
* type
*/
/*
* Get the string representation of the mirror's read strategy
*
* @param read
* a valid mirror_read_strategy_t
*
* @return an internationalized string representing the given
* read strategy
*/
/*
* Get the string representation of the mirror's write strategy
*
* @param write
* a valid mirror_write_strategy_t
*
* @return an internationalized string representing the given
* write strategy
*/
#ifdef DEBUG
/*
* Dump the contents of a devconfig_t struct to stdout.
*
* @param device
* the devconfig_t to examine
*
* @param prefix
* a prefix string to print before each line
*/
#endif /* DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _VOLUME_DEVCONFIG_H */