/*
* 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"
/*
*
* As the size of a metadevice used to be stored in 32 bit signed variables,
* there was a limit of 1 TB for the size (2^31 * 512 byte).
* In order to be able to create larger metadevices, a 2nd set of structures
* with wider variables for the size has been created.
* There's one structure being shared by all types (mdc_unit_t) and one
* for each type of metadevice (mm_unit_t, ms_unit_t, mr_unit_t, ...).
* the wide structures are named like mdc_unit_t, mm_unit_t,..
* The narrow structures are named like mdc_unit32_od_t, mm_unit32_od_t,...
*
* The wide structures are used for md's >= 1TB, the narrow structures
* are used for md's < 1TB.
* Once a metadevice grows from < 1TB to >= 1TB the record has to be
* converted from a narrow one to a wide one.
*
* Incore (commands, libs and drivers) we only use the wide structures,
* in order to keep it simple.
* This means when we snarf a narrow struct, we have to convert it to a
* wide incore instance before we can use the md.
*
*
* This file contains conversion routines for the various metadevices.
* All the conversion routines take as input two pointers to memory areas
* and a direction. The directions specifies which memory area is the
* source and which is the destination.
*/
#include <sys/sysmacros.h>
#ifdef _KERNEL
#else /* !_KERNEL */
#include <meta_basic.h>
#endif /* _KERNEL */
/*
* SVM private devt expansion routine
* INPUT: dev a 64 bit container holding either a 32 bit or a 64 bit device
* OUTPUT: always an expanded 64 bit device, even if we are running in a
* 32 bit Kernel.
*/
{
/* Here we were given a 64bit dev, return unchanged */
return (dev);
/* otherwise we were given a 32 bit dev */
}
/*
* SVM private devt compact routine
* INPUT: dev a 64 bit container holding either a 32 bit or a 64 bit device
* OUTPUT: always a compacted 32 bit device, even if we are running in a
* 64 bit Kernel.
*/
{
/* Here we were given a 32bit dev, return unchanged */
if (major == 0) {
}
/* otherwise we were given a 64 bit dev */
}
/*
* given a small stripe unit, compute the size of an appropriate
* big stripe unit.
* if first_comp_only is set just return the offset of the first component
* in the new big unit.
*
* The function:
* contains code derived from this function and thus if any changes are made to
* this function get_stripe_req_size() should be evaluated to determine whether
* or not code changes will also be necessary there.
*
*/
{
/* Compute the offset of the first component */
first_comp = sizeof (ms_unit_t) +
if (first_comp_only == FIRST_COMP_OFFSET)
return (first_comp);
/*
* Requestor wants to have the total size, add the sizes of
* all components
*/
return (mdsize);
}
/*
* given a big stripe unit, compute the size of an appropriate
* small stripe unit.
* if first_comp_only is set just return the offset of the first component
* in the new small unit.
*/
{
/* Compute the size of the new small ms_unit */
first_comp = sizeof (ms_unit32_od_t) +
if (first_comp_only == FIRST_COMP_OFFSET)
return (first_comp);
/*
* Requestor wants to have the total size, add the sizes of
* all components
*/
return (mdsize);
}
/*
* stripe_convert(small, big, dir)
*
* Parameters:
* small is the address of a ms_unit32_od_t structure
* big is the address of a ms_unit_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: big and small must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
if (direction == BIG_2_SMALL) {
/* walk through all rows */
}
/* Now copy the components */
}
}
if (direction == SMALL_2_BIG) {
/* walk through all rows */
}
/* Now copy the components */
}
}
}
/*
* mirror_convert(small, big, dir)
*
* Parameters:
* small is the address of a mm_unit32_od_t structure
* big is the address of a mm_unit_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: big and small must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
int i;
if (direction == BIG_2_SMALL) {
roundup(sizeof (mm_unit32_od_t), sizeof (long long));
for (i = 0; i < NMIRROR; i++) {
}
}
if (direction == SMALL_2_BIG) {
for (i = 0; i < NMIRROR; i++) {
}
/* Now back to the simple things again */
}
}
/*
* raid_convert(small, big, dir)
*
* Parameters:
* small is the address of a mr_unit32_od_t structure
* big is the address of a mr_unit_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: big and small must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
int i;
if (direction == BIG_2_SMALL) {
for (i = 0; i < ncol; i++) {
}
}
if (direction == SMALL_2_BIG) {
for (i = 0; i < ncol; i++) {
}
}
}
/*
* softpart_convert(small, big, dir)
*
* Parameters:
* small is the address of a mp_unit32_od_t structure
* big is the address of a mp_unit_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: big and small must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
if (direction == BIG_2_SMALL) {
/*
* Note that there isn't a mp_ext32_od_t, it's right to use
* mp_ext_t here, too.
*/
}
if (direction == SMALL_2_BIG) {
}
}
/*
* trans_master_convert(smallp, bigp, dir)
*
* Parameters:
* smallp is the address of a mt_unit32_od_t structure
* bigp is the address of a mt_unit_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: bigp and smallp must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
if (direction == SMALL_2_BIG) {
}
if (direction == BIG_2_SMALL) {
roundup(sizeof (mt_unit32_od_t), sizeof (long long));
}
}
/*
* trans_log_convert(smallp, bigp, dir)
*
* Parameters:
* smallp is the address of a ml_unit32_od_t structure
* bigp is the address of a ml_unit_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: bigp and smallp must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
if (direction == SMALL_2_BIG) {
}
if (direction == BIG_2_SMALL) {
}
}
/*
* hs_convert(small, big, dir)
*
* Parameters:
* small is the address of a hot_spare32_od_t structure
* big is the address of a hot_spare_t structure
* dir is either BIG2SMALL or SMALL2BIG
* Return value is void
*
* what it does:
* if dir is BIG2SMALL, convert from big to small (updating old records)
* if dir is SMALL2BIG, convert from small to big (snarfing old records)
*
* Caveat emptor: big and small must be well allocated memory areas.
*/
void
{
/*LINTED*/
/*LINTED*/
if (direction == BIG_2_SMALL) {
}
if (direction == SMALL_2_BIG) {
}
}