/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <meta.h>
#include "volume_string.h"
#include "volume_devconfig.h"
#include "volume_error.h"
#include "volume_dlist.h"
#include "volume_output.h"
#include "layout_device_cache.h"
#include "layout_device_util.h"
#include "layout_discovery.h"
#include "layout_dlist_util.h"
#include "layout_messages.h"
#include "layout_request.h"
#include "layout_slice.h"
#define _LAYOUT_SLICE_C
static int pick_from_best_hba_and_disk(
static int slice_has_same_disk_geom(
boolean_t *bool);
static int slice_on_unique_disk(
boolean_t *bool);
static int slice_on_unique_hba(
boolean_t *bool);
static int slice_on_similar_bus(
boolean_t *bool);
static int slice_has_n_paths(
boolean_t *bool);
static int compare_modslice_names(
void *obj1,
void *obj2);
static int compare_string_to_modslice_name(
void *str,
void *modslice);
static int create_new_slice(
devconfig_t **nslice);
static int create_modified_slice(
char *oname,
char *nname,
devconfig_t **nslice);
/*
* list to track resized slices
*/
/*
* struct to track used slices and their disks...
*/
typedef struct {
char *slicename;
} usedslice_t;
/*
* list to of usedslice_t to track slices that have been
* used for any reason.
*/
static void free_used_slice(void *obj);
/*
* list of slices reserved to be used for explicit
* volume requests
*/
/*
* list of slices needing to be removed (zeroed out) prior to
* applying any metassist modifications to the system.
*/
/*
* FUNCTION: choose_slice(
* uint64_t nbytes,
* uint16_t npaths,
* dlist_t *slices,
* dlist_t *used,
* dlist_t *used_hbas,
* dlist_t *used_disks,
* boolean_t unused_disk,
* boolean_t nbytes_is_min,
* boolean_t add_extra_cyl,
* devconfig_t **chosen)
*
* INPUT: nbytes - required size
* npaths - minimum required data paths
* *slices - slices from which to choose
* *used - slices used by the volume under construction
* *used_hbas - hbas used by other volumes relevant to
* the volume under construction
* *used_disks - disks used by other volumes relevant to
* the volume under construction
* unused_disk - if true, the chosen slice must be from an
* unused disk
* nbytes_is_min - if true, the chosen slice may be larger than
* nbytes.
* add_extra_cyl - passed to create_new_slice, see comment there.
* **chosen - pointer to hold the chosen slice
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Choosen a slice from the list of those available.
*
* Of those available, choose in order of preference:
*
* - one on a unique HBA and disk that is of the exact size
* - one on a unique HBA and disk that is of sufficient size
* - one on unique HBA that is of the exact size
* - one on unique HBA that is of sufficient size
* - one on unique disk that is of the exact size
* - one on unique disk that is of sufficient size
* - one on any HBA that is of exact size
* - one on any HBA that is of sufficient size
* - one on a unique HBA that is the largest size
* - one on a unique disk that is the largest size
* - one on any HBA that is the largest size
*
* The function scans the available slices and builds lists of
* those meeting the criteria above. After the scan is complete,
* the lists are examined in order, the first non-empty list is
* chosen. If there are several possibilities in the chosen list,
* see if it is possible select the slice from the least used HBA
*
* If nbytes_is_min is true, the returned slice will be
* at least nbytes in capacity.
*
* If unused_disk is true, the returned slice will be from
* a disk with no other known uses.
*/
int
{
int error = 0;
/*
* indexes into the list array:
* i -> unique controller 0 = yes, 1 = no
* j -> same bus type 0 = yes, 1 = no
* k -> unique disk 0 = yes, 1 = no
* l -> same disk geom 0 = yes, 1 = no
* m -> size 0 == exact, 1 = larger, 2 = any
*/
int i, j, k, l, m;
/* output string arrays for each array dimension and index */
/* other output strings */
/* only initialize the output strings if needed */
/* BEGIN CSTYLED */
"\tlooking at slice: %s (%s)\n");
"\t has the requested number of data paths (%d)\n");
"\t has the same disk geometry relative to used slices\n");
"\t on a unique HBA relative to used slices\n");
"\t on a unique disk relative to used slices\n");
"\t the exact size necessary\n");
"\t larger than necessary\n");
"\t smaller than necessary\n");
"\t rejected: not enough paths (%d requested)\n");
"\t rejected: too small\n");
"\t rejected: on a disk with other volume component(s)\n");
/* END CSTYLED */
}
/* init list array pointers */
&uniqdisk)) ||
if (error != 0) {
continue;
}
universal_units, B_FALSE) == 0) {
}
}
if (npaths > 1) {
/* specifically asked for more paths, ... */
}
} else if (npaths == 1) {
/* every disk has at least 1 path */
}
if (uniqhba) {
}
if (uniqdisk) {
}
if (samebus) {
}
if (samegeom) {
}
}
} else {
}
}
/* filter slices not meeting minimum criteria */
/* not large enough */
}
continue;
}
/* not connected thru enough paths */
}
continue;
}
/* not on a unique disk */
}
continue;
}
/* map slice properties into array indices */
i = (uniqhba ? 0 : 1);
j = (samebus ? 0 : 1);
k = (uniqdisk ? 0 : 1);
l = (samegeom ? 0 : 1);
/*
* insert slice into the list array using derived indices.
* NB: lists of slices larger than necessary are kept in
* ascending order (results in best fit, not worst fit)
*/
} else {
list[i][j][k][l][m] =
item,
list[i][j][k][l][m],
}
}
/*
* Select a slice from one of the lists.
*
* The list with the combination of lowest indices
* is the most preferred list... in rough order:
*
* one on a unique HBA and disk that is of the exact size
* one on a unique HBA and disk that is of sufficient size (resize)
* one on unique HBA that is of the exact size
* one on unique HBA that is of sufficient size (resize)
* one on unique disk that is of the exact size
* one on unique disk that is of sufficient size (resize)
* one on any HBA that is of exact size
* one on any HBA that is of sufficient size (resize)
* one on a unique HBA that is the largest size
* one on a unique disk that is the largest size
* one on any HBA that is the largest size
*/
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
for (k = 0; k < 2; k++) {
for (l = 0; l < 2; l++) {
for (m = 0; m < 3; m++) {
/* pick least used slice from this list */
list[i][j][k][l][m],
resize = (m == 1);
/* terminate all loops */
goto stop;
}
}
}
}
}
}
stop:
/*
* Slice chosen, is a resize necessary?
*/
if (error == 0) {
universal_units, B_FALSE) == 0) {
gettext(" selected %s (%s)\n"
" it is %s on a\n"
" %s (%s) and a\n"
" %s (%s)\n"),
sizes[m],
}
}
if (resize) {
gettext(" it has excess space, "
"resizing...\n"));
}
chosen);
gettext(" exactly resized\n"));
}
}
if (error == 0) {
/* either no resize was necessary or the resize failed */
/*
* use the original slice as it is.
* Make a devconfig_t for it.
*/
}
}
}
gettext(" no possible slice\n"));
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
for (k = 0; k < 2; k++) {
for (l = 0; l < 2; l++) {
for (m = 0; m < 3; m++) {
}
}
}
}
}
}
return (error);
}
/*
* FUNCTION: create_devconfig_for_slice(dm_descriptor_t slice,
* devconfig_t **nslice)
*
* INPUT: slice - dm_descriptor_t handle to an existing slice
* nslice - devconfig_t pointer to hold the new slice
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Creates a devconfig_t struct representation of the input
* slice dm_descriptor.
*/
int
{
int error = 0;
if (error != 0) {
return (error);
}
if (error != 0) {
}
return (error);
}
/*
* FUNCTION: make_slicename_for_disk_and_index(dm_descriptor_t disk,
* uint32_t index, char **slicename)
*
* INPUT: disk - a dm_descriptor_t disk handle
* index - a slice index
*
* OUTPUT slicename - a char * pointer to hold the resulting slicename
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Utility function to manufacture a new slice name given the
* "parent" disk and an available slice index.
*
* The caller should free the returned name when done with it.
*/
static int
char **slicename)
{
char *dname;
int error = 0;
}
return (error);
}
/*
* FUNCTION: make_slicename_for_diskname_and_index(char *diskname,
* uint32_t index, char **slicename)
*
* INPUT: diskname - a char * disk name
* index - a slice index
*
* OUTPUT slicename - a char * pointer to hold the resulting slicename
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Utility function to manufacture a new slice name given the
* name of a disk and an available slice index.
*
* The caller should free the returned name when done with it.
*/
int
char *diskname,
char **slicename)
{
int error = 0;
}
return (error);
}
/*
* FUNCTION: create_new_slice(dm_descriptor_t oslice, uint64_t nbytes,
* boolean_t add_extra_cyl, devconfig_t **nslice)
*
* INPUT: oslice - dm_descriptor_t handle to an existing slice
* nbytes - desired minimum size of the new slice
* add_extra_cyl - boolean indicating whether the resized slice
* needs to be oversized by 1 cylinder to account for
* interlace rounding done for stripe components.
* nslice - devconfig_t pointer to hold the new slice
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Creates a new slice object using space from the input slice.
*
* If there is an open slice slot in the disk VTOC, it will be
* reserved for the new slice. Space for the new slice will be
* taken from the original slice.
*
* If there is no open slice slot, the original slice will be
* returned as the usable new slice.
*
* The new slice will be of at least 'nbytes' bytes and possibly
* larger due to sector and cylinder boundary alignment.
*
* For EFI labeled disks, nbytes is rounded up to the next block
* boundary.
*
* For VTOC labeled disks, nbytes is rounded up to the next
* cylinder boundary.
*
* Additionally, if add_extra_cyl is true, the new slice will be
* made 1 cylinder larger than necessary. This accounts for the
* interlace rounding done within libmeta when computing the
* usable size of stripe components on disks with VTOC labels.
* Rounding the size up to the next cylinder boundary is not
* sufficient because libmeta will round this size down to an
* integral multiple of the stripe interlace and then round that
* result down to a cylinder boundary. This makes the usable
* size of the slice one cylinder smaller and possibly less than
* nbytes. Adding an extra cylinder ensures the usable size is
* greater than nbytes despite the rounding.
*
* If the resize is successful a pointer to the devconfig_t
* representing the new slice will be returned in "newslice".
*
* If the resize cannot be done, the newslice pointer will
* be NULL.
*/
static int
{
int error = 0;
if (error != 0) {
return (error);
}
/* find an unused slice number, default to oindex */
return (error);
}
if (error != 0) {
return (error);
}
if (efi) {
/* EFI: round size to an integral number of blocks (sectors) */
nsize = bytes_per_sect *
gettext(" "
"rounded up to %10.2f blocks\n"),
(double)(nsize/bytes_per_sect));
} else {
/* VTOC: round size to an integral number of cylinders */
if (error == 0) {
nsize = bytes_per_cyl *
if (add_extra_cyl == TRUE) {
nsize += bytes_per_cyl;
}
gettext(" "
"rounded VTOC slice to %10.2f cylinders "
"(out of %llu)\n"),
}
}
/* is sufficient space still available? */
if (error == 0) {
/* use existing slice as is */
/* no more slices, resize existing slice */
nslice)) != 0) ||
} else {
/* make a new slice */
nslice)) ||
/* mark the new slice's index as used */
}
}
}
}
return (error);
}
/*
* FUNCTION: create_modified_slice(dm_descriptor_t oslice, char *oname,
* uint32_t oindex, uint64_t ostart, uint64_t osize,
* uint64_t bytes_per_sect, uint64_t nsize,
* char *nname, uint32_t nindex, devconfig_t **nslice)
*
* INPUT: oslice - dm_descriptor_t handle for the original slice
* oname - existing source slice name
* oindex - existing source slice VTOC index
* ostart - existing source slice start byte
* osize - existing source slice size in bytes
* bytes_per_sect - bytes per block (sector) for the disk
* nname - new slice name
* nindex - new slice VTOC index
* nsize - new slice size in bytes (cylinder and block aligned)
*
* SIDEEFFECTS: updates the module private list of modified slices
*
* OUTPUT: nslice - pointer to a devconfig_t to hold the new slice
*
* PURPOSE: create a new VTOC slice by taking space from an
* existing slice.
*
* The input size for the new slice is expected to be
* cylinder aligned.
*/
static int
char *oname,
char *nname,
{
int error = 0;
/* compute start sector and size in sectors for the new slice */
/* subtract nsize from original slice to get starting byte */
/* convert starting byte to a sector */
/* convert nsize to an integral number of blocks (sectors) */
/* create a modified slice record for the new slice */
if (error != 0) {
return (error);
}
/* update the existing source slice's new size */
return (error);
}
/*
* FUNCTION: assemble_modified_slice(dm_descriptor_t src_slice,
* char *mod_name, uint32_t mod_index,
* uint64_t mod_stblk, uint64_t mod_nblks,
* uint64_t mod_size, devconfig_t **modslice)
*
* INPUT: src_slice - dm_descriptor_t handle of the slice space
* was taken from to create the modified slice
* mod_name - name of the modified slice
* mod_index - name of the modified slice
* mod_stblk - start block of the modified slice
* mod_nblks - size in blocks of the modified slice
* mod_size - size in bytes of the modified slice
*
* OUTPUT: mod_slice - if non-NULL, will be populated with a
* devconfig_t representing the modified slice.
*
* SIDEEFFECTS: adds or updates an entry in the modified slice list
* tracking the slices that have been explicitly modified
* by the layout code.
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Utility function to which updates or creates a devconfig_t
* representing a slice that needs to be modified.
*
* If a modified slice record does not exist for the named
* slice, a new devconfig_t struct is allocated and added
* to the modified slice list.
*
* The existing or created devconfig_t struct is updated with
* the input values.
*
* The information about the slices in the modified slice list
* will eventually be handed to fmthard.
*/
int
char *mod_name,
{
int error = 0;
/* see if the slice has been modified before */
compare_string_to_modslice_name)) != NULL) {
/* yes, update the resize count and attributes */
mod_stblk)) != 0) ||
} else {
/* no, first modification... */
/* create a devconfig_t representing the new slice */
if (error == 0) {
/* add to list of modified slices */
if ((mstp = (modslice_t *)
/* count # of times source slice has been modified */
if (src_slice != (dm_descriptor_t)0) {
mstp->times_modified = 0;
} else {
}
item,
} else {
}
} else {
}
}
if (error != 0) {
}
}
if (error == 0) {
" "
"modified %s (start blk: %9llu, nblks: %9llu)\n",
/* return devconfig_t for modified slice */
}
}
return (error);
}
/*
* FUNCTION: dlist_t *get_modified_slices()
*
* RETURNS: pointer to the list of modslice_t structs representing
* modified slices
*
* PURPOSE: public accessor to the list of slices modified while
* processing a request.
*/
dlist_t *
{
return (_modified_slices);
}
/*
* FUNCTION: free_modslice_object(void *obj)
*
* INPUT: obj - opaque pointer
*
* PURPOSE: Frees memory associated with a modslice_t struct.
*/
static void
void *obj)
{
}
}
}
/*
* FUNCTION: void release_modified_slices()
*
* INPUT: none -
* OUTPUT: none -
*
* PURPOSE: cleanup the module global list of slices modified
* while processing a request.
*/
int
{
return (0);
}
/*
* FUNCTION: destroy_new_slice(devconfig_t *dev)
*
* INPUT: dev - a devconfig_t pointer to a slice object
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Undoes slice creation done by create_new_slice():
*
* release index
* remove from used_slices
* remove from modified_slices
* return space to source slice
* free memory
*/
int
{
int error = 0;
if (error != 0) {
return (error);
}
/* remove from the modified_slices list */
}
/* space from an existing slice? if so reclaim it. */
if (src != (dm_descriptor_t)0) {
srcitem =
}
}
if (error == 0) {
/* was only modification undone? */
if (source->times_modified == 0) {
&srcitem);
}
}
}
}
return (error);
}
/*
* FUNCTION: pick_from_best_hba_and_disk(dlist_t *slices,
* dlist_t *used, dm_descriptor_t *chosen)
*
* INPUT: slices - a dlist_t poitner to a list of slices
* used - a dlist_t pointer to a list of used slices
* chosen - a dm_descriptor_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Examines the input list of slices and chooses the one
* that is on the least used HBA and disk.
*
* HBA and disk usage is determined by examining the input
* list of used slices and counting the number of slices
* each HBA and disk contributes.
*
* The HBA which contributes the fewest is selected, and
* then the disk on that HBA which contributes the fewest
* is selected.
*
* The largest slice from that disk is then returned.
*/
static int
{
int i = 0;
int error = 0;
/*
* allocate an array to hold lists of slices grouped by
* HBA contribution... the list indexed by N is the list
* of slices that are on HBAs contributing N slices
*/
/*
* allocate an array to hold lists of slices grouped by
* disk contribution... the list indexed by N is the list
* of slices that are on disks contributing N slices
*/
*chosen = (dm_descriptor_t)0;
return (ENOMEM);
}
/*
* precompute the used slices' lists of HBAS: iterate the list
* of used slices and determine the HBA(s) each is connected thru.
* construct a list of lists containing the HBAs.
*/
/* need to use disk to get to HBAs because */
/* the slice doesn't exist yet */
if (error == 0) {
} else {
}
}
}
/*
* iterate the list of chosen slices and for each,
* determine how many other slices from its HBA(s)
* are already being used...
*
* iter steps thru the list of slices
* iter1 steps thru each of the slice's HBAs
* iter2 steps thru the precomputed list of used slice's HBAs
* dlist_contains then searches each used slice's HBAs
* to see if it contains iter1's HBA
*
* If it does, increment the count for that HBA.
*/
int n = 0; /* # slices each HBA contributes */
continue;
}
compare_descriptor_names) == B_TRUE) {
n++;
}
}
}
/* group slices from HBAs contributing more than maxuses */
if (n >= maxuses) {
n = maxuses - 1;
}
/* add slice to list in descending size order */
} else {
prefhbas[n] =
item,
prefhbas[n],
}
}
/* free list of lists of used slices HBAs */
}
/*
* Select the list of slices that are on the HBA(s) contributing
* the fewest slices... iterate these slices and for each, detemmine
* how many other slices from its disk are already being used...
*/
int n = 0;
/*
* count how many slices this slice's disk is contributing
* by comparing it to the list of used slices
*/
n++;
}
}
/* add slice to list in descending size order */
} else {
prefdisks[n] =
item,
prefdisks[n],
}
}
}
if (error == 0) {
/* select largest slice from least used disk */
}
}
}
for (i = 0; i < maxuses; i++) {
}
for (i = 0; i < maxslices; i++) {
}
return (error);
}
/*
* FUNCTION: slice_on_unique_hba(dm_descriptor_t slice,
* dlist_t *used, dlist_t *used_hbas,
* boolean_t *unique)
*
* INPUT: slice - a dm_descriptor_t handle for the slice of interest
* used - a dlist_t pointer to a list of used slices
* used_hbas - a dlist_t pointer to a list of used_hbas
* unique - a boolean_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Determines if the input slice is connected thru the same HBA
* as a slice in the used list.
*
* Also checks to see if the input slice is connected thru any
* HBA in the used_hbas list.
*
* If the slice is found to be on a unique HBA, bool is set
* to B_TRUE, B_FALSE otherwise.
*/
static int
{
int error = 0;
return (error);
}
/*
* check to see if any of slice's HBAs is the same
* as the HBA for any of the used
*/
/* get HBAs for other slice using its disk */
/* because the slice doesn't exist yet. */
/* any HBA overlap? */
compare_descriptor_names) == B_TRUE) {
}
}
}
}
/*
* check to see if any of slice's HBAs is the contained
* in the list of used hbas
*/
if (dlist_contains(used_hbas,
}
}
return (error);
}
/*
* FUNCTION: slice_on_unique_disk(dm_descriptor_t slice,
* dlist_t *used, dlist_t *used_disks,
* boolean_t *unique)
*
* INPUT: slice - a dm_descriptor_t handle for the slice of interest
* used - a dlist_t pointer to a list of used slices
* othervols - a dlist_t pointer to a list of other volumes
* bool - a boolean_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Determines if the input slice is on a drive that is not
* part of any volume in the othervols list, or on the same
* drive as any slice in the used list.
*
* If the slice is found to be on a unique disk, bool is set
* to B_TRUE, B_FALSE otherwise.
*/
static int
{
int error = 0;
return (error);
}
/*
* check to see if this disk is the same as the
* disk for any of the used
*/
/* get disk for otherslice */
if ((error == 0) &&
/* origslice is on same disk, stop */
}
}
}
/* check disk against the used disks */
compare_descriptor_names) == B_TRUE) {
}
return (error);
}
/*
* FUNCTION: slice_has_same_disk_geom(dm_descriptor_t slice,
* dlist_t *used, boolean_t *has_same_geom)
*
* INPUT: slice - a dm_descriptor_t handle for the slice of interest
* used - a dlist_t pointer to a list of used slices
* bool - a boolean_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Determines if the input slice is on a drive with similar
* hardware geometry as the slices in the used list.
*
* If the slice is found to be on a disk with similar geometry,
* bool is set to B_TRUE, B_FALSE otherwise.
*
* The comparison is based on the available disk geometry
* information which may not be relevant or accurate for
* EFI labeled disks, so the disk drive type needs to be
* checked as well.
*/
static int
{
int error = 0;
*has_same_geom = B_TRUE;
}
if (error != 0) {
return (error);
}
/*
* check to see if slice's disk has the same geometry
* as the disks for the slices in the used list
*/
/* get disk info for otherslice */
}
if (error == 0) {
/* this disk has a different geometry */
*has_same_geom = B_FALSE;
}
}
}
}
return (error);
}
/*
* FUNCTION: slice_on_similar_bus(dm_descriptor_t slice,
* dlist_t *used, boolean_t *on_smlr_bus)
*
* INPUT: slice - a dm_descriptor_t handle for the slice of interest
* used - a dlist_t pointer to a list of used slices
* bool - a boolean_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Determines if the input slice is connected thru a bus with
* characteristics similar to the slices in the used list.
*
* If the slice is found to be on a similar bus, bool is set
* to B_TRUE, B_FALSE otherwise.
*
* The comparison is actually between any of the HBA/controllers
* thru which the slices are connected to the system.
* If any are of similar type (e.g., fibre, SCSI) and
* considered to be on similar busses.
*/
static int
{
int error = 0;
/* if there are no used slices, then the bus is similar */
*on_smlr_bus = B_TRUE;
if (dlist_length(used) == 0) {
return (0);
}
if (error != 0) {
return (error);
}
/* if there are used slices, then make sure the bus is similar */
*on_smlr_bus = B_FALSE;
if (error != 0) {
continue;
}
/* check against the HBAs for the used slices */
/* get HBAs for otherslice */
(error == 0);
if (error == 0) {
/* check sync speed ? */
*on_smlr_bus = B_TRUE;
}
}
}
}
}
return (error);
}
/*
* FUNCTION: slice_has_n_paths(dm_descriptor_t slice,
* uint16_t npaths, boolean_t *has_n_paths)
* INPUT: slice - a dm_descriptor_t handle for the slice of interest
* npaths - the number of paths desired
* has_n_paths - a boolean_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Determines if the input slice is connected via npaths.
* has_n_paths is set to B_TRUE if so, B_FALSE otherwise.
*
* In order for a disk to have multiple paths, MPXIO must
* be enabled and these conditions should hold:
*
* Slice will have one drive object.
* Drive will have one HBA (scsi_vhci)
* Drive will have one alias.
* Drive will have possibly > 1 paths.
*
* Getting the HBAs and aliases for the disk is relatively
* expensive, so they aren't checked. The actual number of
* paths is only checked if MPXIO is known to be enabled on
* the system and the input npaths is > 1.
*/
static int
{
int error = 0;
*has_n_paths = B_FALSE;
*has_n_paths = B_TRUE;
}
}
return (error);
}
/*
* FUNCTION: compare_string_to_modslice_name(void *str, void *modslice)
*
* INPUT: str - opaque char * pointer
* modslice - opaque modslice_t pointer
*
* RETURNS: int - <0 - if str < modslice->slice_devcfg.name
* 0 - if str == modslice->slice_devcfg.name
* >0 - if str > modslice->slice_devcfg.name
*
* PURPOSE: dlist_t helper which compares the input string to
* the name of a slice represented as modslice_t struct.
*
* Comparison is done via string_case_compare.
*/
static int
void *str,
void *modslice)
{
(void) devconfig_get_name(
}
/*
* FUNCTION: compare_modslice_names(void *obj1, void *obj2)
*
* INPUT: obj1 - opaque pointer
* obj2 - opaque pointer
*
* RETURNS: int - <0 - if obj1 name < obj2 name
* 0 - if obj1 name == obj2 name
* >0 - if obj1 name > obj2 name
*
* PURPOSE: dlist_t helper which compares the names of two slices
* represented as modslice_t structs.
*
* Comparison is done by string_case_compare
*/
static int
void *obj1,
void *obj2)
{
(void) devconfig_get_name(
(void) devconfig_get_name(
}
/*
* FUNCTION: release_used_slices()
*
* PURPOSE: Helper which cleans up the module private list of used
* slices.
*/
void
{
_used_slices = NULL;
}
static void
void *obj)
{
}
}
/*
* FUNCTION: is_used_slice(dm_descriptor_t slice, boolean_t *is_used)
*
* INPUT: slice - a dm_descriptor_t slice handle
*
* OUTPUT: is_reserved - pointer to a boolean_t to hold the
* return result.
*
* PURPOSE: Helper which checks to see if the input slice
* is in the used_slice list.
*
* Check the input name against any used slice name or alias.
* is_used is set to B_TRUE if the input slice is already used,
* B_FALSE otherwise.
*/
int
{
char *name;
int error = 0;
}
return (error);
}
/*
* FUNCTIONS: add_used_slice(dm_descriptor_t slice)
* add_used_slice_by_name(char *slicename)
* add_used_slice_list_entry(char *slice)
* remove_used_slice_by_name(char *slicename)
*
* INPUT: diskset - a char * diskset name.
* slice - a dm_descriptor_t slice handle
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Access or maintain the list of used slices.
*/
int
{
char *name;
int error = 0;
return (error);
}
int
char *slicename)
{
int error = 0;
/* find disk for slice */
if (error == 0) {
}
return (error);
}
static int
char *slicename,
{
int error = 0;
} else {
} else {
} else {
}
}
}
return (error);
}
int
char *slice)
{
}
return (0);
}
/*
* FUNCTION: compare_usedslice_name_to_string(void *obj1, void *obj2)
* INPUT: obj1 - opaque pointer
* obj2 - opaque pointer
*
* RETURNS: int - <0 - if obj1 name < obj2 name
* 0 - if obj1 name == obj2 name
* >0 - if obj1 name > obj2 name
*
* PURPOSE: dlist_t helper which compares the names of a slice
* represented as modslice_t struct to a string.
*
* obj1 is assumed to be a char *
* obj2 is assumed to be a usedslice_t *
*
* Comparison is done via string_case_compare.
*/
static int
void *obj1,
void *obj2)
{
return (string_case_compare((char *)obj1,
}
/*
* FUNCTION: disk_has_used_slice(dm_descriptor_t disk, boolean_t *hasused)
*
* INPUT: disk - a dm_descriptor_t disk handle.
* inuse - a boolean_t pointer to hold the result
*
* RETURNS: int - 0 on success
* !0 othersize.
*
* PURPOSE: Determines if any of the known used slices is on the
* input disk.
*/
int
{
int error = 0;
for (iter = _used_slices;
/* compare used slice's disk to disk */
}
}
return (error);
}
/*
* FUNCTION: add_reserved_slice(dm_descriptor_t slice)
*
* INPUT: slice - a dm_descriptor_t slice handle
*
* RETURNS: int - 0 on success
* !0 otherwise.
*
* PURPOSE: Helper which remembers specfically requested slices
* in a private list to ensure that the same slice isn't
* requested more than once.
*
* Does not check to see if the slice already exists
* in the list of reserved slices. Assumes that the
* caller has checked using is_reserved_slice().
*
* The reserved slice list is used by several functions:
*
* 1. layout_validate.validate_slice_components() adds user
* requested slices to the list.
*
* 2. After all potentially usable slices have been scanned,
* layout_validate.validate_reserved_slices() checks the
* slices in the reserved and ensures that each slice is
* actually usable as a volume component.
*
* 3. layout.disk_get_avail_space(), layout.disk_get_avail_slices()
* exclude slices in the reserved list from being considered
* available for general layout use.
*/
int
{
return (ENOMEM);
}
return (0);
}
/*
* FUNCTION: is_reserved_slice(dm_descriptor_t slice,
* boolean_t *is_reserved)
*
* INPUT: slice - a dm_descriptor_t slice handle
*
* OUTPUT: is_reserved - pointer to a boolean_t to hold the
* return result.
*
* PURPOSE: Helper which checks to see if the input slice
* was previously reserved.
*
* Check the input name against any reserved slice
* name or alias. is_reserved is set to B_TRUE if the
* input slice is already reserved, B_FALSE otherwise.
*/
int
{
return (0);
}
/*
* FUNCTION: release_reserved_slice()
*
* PURPOSE: Helper which cleans up the module private list of reserved
* slices.
*/
void
{
_rsvd_slices = NULL;
}
/*
* FUNCTION: get_reserved_slices(dlist_t **list)
*
* OUTPUT: list - a dlist_t pointer to hold the returned list of
* reserverd slices.
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Accessor to retrieve the current list of reserved slice
* dm_descriptor_t handles.
*/
int
{
*list = _rsvd_slices;
return (0);
}
/*
* FUNCTION: add_slice_to_remove(char *name, uint32_t index)
*
* INPUT: name - name of a slice
* index - index for the slice
*
* RETURNS: int - 0 on success
* !0 otherwise
*
* PURPOSE: Utility function to add the named slice to the list of
* those that need to be "removed" by having their sizes
* set to 0.
*/
int
char *name,
{
int error = 0;
} else {
} else {
} else {
}
}
}
return (error);
}
/*
* FUNCTION: get_removed_slices()
*
* RETURNS: dlist_t * - pointer to a list of rmvdslice_t structs
*
* PURPOSE: Accessor to retrieve the current list of names of slices
* to be removed.
*/
dlist_t *
{
return (_rmvd_slices);
}
static void
void *obj)
{
}
}
/*
* FUNCTION: release_removed_slices()
*
* PURPOSE: Helper which cleans up the module private list of removed
* slices.
*/
void
{
_rmvd_slices = NULL;
}