vdmaggr(7) DG/UX 5.4R3.00 vdmaggr(7)
NAME
vdmaggr - Aggregation Subdriver of the Virtual Disk Manager
SYNOPSIS
#include <types.h>
#include <ioctl.h>
ioctl(int fildes, int command, int argument);
DESCRIPTION
The Aggregation Subdriver is a pseudo-device driver that works under
the Virtual Disk Management (VDM) framework (see vdm(7)). The
purpose of the Aggregation Subdriver is to bring distributed groups
of disk blocks together to provide a contiguous span of disk blocks.
STRUCTURES
The structures defined in this section are pointed to by fields
described in VDM commands (see vdm(7)). The VDM command and the
field in the argument structure will be described. For many VDM
commands, a subdriver ID is required as an input value. The
subdriver ID for the Aggregation Subdriver is defined by
DGVDMAGGRSUBDRIVERID.
Unless otherwise noted, the version field in the following structures
is an input field that must be set to
DGVDMAGGRIOCTLPACKETVERSION0. Additionally, all packets must
have every byte set to zero before it is used.
DGVDMCREATEINSTANCE
The subdriverattributespacketptr field points to the following
structure:
struct dgvdmaggrcreatepacket
{
int version;
unsigned int stripesize;
unsigned short numberofpieces;
devt * piecearrayptr;
};
The stripesize field is an input field indicating an interleaved
access to the blocks contained in a piece. If this field is not
zero, then the blocks in the aggregation are addressed starting at
the beginning of the first piece for stripesize number of blocks.
The next set of stripesize blocks is accessed in the next piece.
After the last piece, addressing of the blocks starts back at the
first piece, but at the block stripesize+1 for the next stripesize
set of blocks.
The numberofpieces identifies the number of pieces contained in the
aggregation and the number of elements in the piecearrayptr array.
Although the piecearrayptr field is only one element, it can be
increased by dynamically allocating the packet in incremental sizes
of the device number. The piecearrayptr array contains the device
Licensed material--property of copyright holder(s) 1
vdmaggr(7) DG/UX 5.4R3.00 vdmaggr(7)
numbers of instances participating in the aggregation.
The request for the aggregation will fail if the stripesize field is
greater than zero and the pieces are not the same size. It will also
fail if the stripesize is greater than zero and does not divide
evenly into the size of a piece. If the these conditions are not met,
-1 will be returned and errno will be set to EINVAL.
DGVDMLINKCHILDINSTANCE
This command adds a piece to an aggregation instance. The
childpacketptr points to the following structure:
struct dgvdmaggrlinkchildpacket
{
int version;
unsigned short piecenumber;
};
The piece numbers of an aggregation are zero based.
The piecenumber field is an input field indicating the piece number
the piece will have after it is added. The piece currently in the
position of the piece (and all following pieces) will be shifted down
one position so they follow the piece being added.
A piece can be added to at any location in the aggregation when the
instance is not open. If the instance is open, then a piece can be
linked to the aggregation if it will become the last piece. If the
instance is open and the piece to be linked is not intended to be the
last piece, then the call will fail and errno will be set to EBUSY.
DGVDMUNLINKCHILDINSTANCE
The use of this VDM command requires no subdriver specific packet.
The use of this command will remove a piece from an aggregation.
A piece can be removed from any location in the aggregation when the
instance is not open. If the instance is open, then a piece can be
unlinked from the aggregation if it is the last piece. If the
instance is open and the piece is not the last piece, then the call
will fail and errno will be set to EBUSY.
DGVDMGETCHILDINSTANCE
The childpacketptr points to the following structure:
struct dgvdmaggrgetchildpacket
{
int version;
unsigned short piecenumber;
};
The piece numbers of an aggregation are zero based.
The piecenumber field is set to the piece number of the child
returned the VDM packet.
Licensed material--property of copyright holder(s) 2
vdmaggr(7) DG/UX 5.4R3.00 vdmaggr(7)
DGVDMGETATTRIBUTES
The subdriverattributespacketptr field points to the following
structure: The subdriverattributespacketptr field points to the
following structure:
struct dgvdmaggrgetpacket
{
int version;
unsigned int stripesize;
};
The stripesize field is an output field and is set to the value
supplied for the same field when the instance was create (see above).
DGVDMUPDATEATTRIBUTES
The subdriverattributespacketptr field points to the following
structure:
struct dgvdmaggrupdatepacket
{
int version;
unsigned int stripesize;
};
The stripesize field is an input field and its purpose is the same
as it is for creating an aggregation. Note that data written under
the previous stripe size will no longer be read correctly.
Therefore, this command is destructive and should be used cautiously.
Additionally, this command cannot be performed while the instance is
open. If this is done, then the command will fail and errno will be
set to EBUSY.
IOCTLS
The ioctls supported by the Aggregation Subdriver are listed below.
The ioctl(2) command can be issued to the Aggregation Subdriver in
two ways:
1. Issue the command to an exported instance of the Aggregation
Subdriver. In this case, the fd is an open file descriptor of
the device node created when the instance was exported. The
command and the argument are described below.
2. Use the DGVDMIOCTLSUBDRIVER command described in more
detail in vdm(7). In this case, the fd is an open file
descriptor of /dev/vdm device node. The argument is a pointer
to a structure that contains command and argument fields. The
values supplied for these fields are described below.
DSKIOCGET
This command returns the size of an instance and is described in more
detail in dsk(7).
DSKIOCUSAGE
This command returns statistics associated with the use of an
Licensed material--property of copyright holder(s) 3
vdmaggr(7) DG/UX 5.4R3.00 vdmaggr(7)
instance and is described in more detail in dsk(7).
DSKIOCGETADDRESS
This command returns the logical address at which a given memory
address to the specified instance should be mapped.
EXAMPLE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/dgsysctl.h>
#include <sys/ioctl.h>
#include <unistd.h>
/*
* This example makes use of functions defined in the vdm(7) man page,
* the vdmpart(7) man page, and the vdmphys(7) man page. These functions
* defined in vdm(7) all begin with a vdm prefix, the functions
* defined in the vdmpart(7) man page begin with a vdmpart prefix, and
* the functions defined in the vdmphys(7) man page begin with a vdmphys
* prefix.
*/
/***********************************************************************
* This macro initializes a packet used by the Physical Subdriver.
***********************************************************************/
#define vdmaggrinitpacket(pptr) \
(bzero((char *)(pptr), sizeof(*pptr)), \
(pptr)->version = DGVDMAGGRIOCTLPACKETVERSION0);
/***********************************************************************
* This function creates a physical instance for the given device
* specification - like sd(insc(),0).
***********************************************************************/
devt vdmaggrcreateinstance (
char * instancename,
unsigned int numberofpieces,
devt pieces[],
unsigned int stripesize
)
{
struct dgvdmaggrcreatepacket createpkt;
devt devicenumber;
int pieceindex;
/*
* The create packet for an aggregation is a variable length structure
* that changes size based on the number of pieces in the aggregation
* being created. The default packet contains enough space for
* one piece so a packet needs to be allocated that is the size
* of the default packet plus the size of a devt for each addition
* piece over 1.
*/
Licensed material--property of copyright holder(s) 4
vdmaggr(7) DG/UX 5.4R3.00 vdmaggr(7)
vdmaggrinitpacket(&createpkt);
createpkt.piecearrayptr = (devt *) malloc(
sizeof(devt) * (numberofpieces));
if (createpkt.piecearrayptr == NULL)
{
return (NODEV);
}
createpkt.stripesize = 0;
createpkt.numberofpieces = numberofpieces;
for (pieceindex = 0; pieceindex < numberofpieces; pieceindex++)
{
createpkt.piecearrayptr[pieceindex] = pieces[pieceindex];
}
devicenumber = vdmcreateinstance(
instancename, DGVDMAGGRSUBDRIVERID, &createpkt);
return (devicenumber);
}
int vdmaggrexample (void)
{
int status;
devt physdevicenumber;
devt pieces[2];
devt aggrdevicenumber;
/*
* Create a physical instance.
*/
physdevicenumber = vdmphyscreateinstance("a", "sd(insc(),0)", ORDWR);
if (physdevicenumber == NODEV)
{
perror("sd(insc(),0)");
exit(1);
}
/*
* Create two non-adjacent partitions to aggregate together.
*/
pieces[0] = vdmpartcreateinstance(
"piece0", 0, 10000, physdevicenumber, NODEV);
if (pieces[0] == NODEV)
{
perror("piece 0");
exit(1);
}
pieces[1] = vdmpartcreateinstance(
"piece1", 15000, 5000, physdevicenumber, NODEV);
if (pieces[1] == NODEV)
{
Licensed material--property of copyright holder(s) 5
vdmaggr(7) DG/UX 5.4R3.00 vdmaggr(7)
perror("piece 1");
exit(1);
}
/*
* Create the aggregation.
*/
aggrdevicenumber = vdmaggrcreateinstance("b", 2, pieces, 0);
if (aggrdevicenumber == NODEV)
{
perror("b");
exit(1);
}
exit(0);
}
FILES
Files in or under /dev
SEE ALSO
vdm(7), vdmphys(7), vdmpart(7) ioctl(2).
Licensed material--property of copyright holder(s) 6