Varies a volume group on-line.
Logical Volume Manager Library (liblvm.a)
#include <lvm.h>
int lvm_varyonvg (VaryOnVG) struct varyonvg *VaryOnVG;
Note: You must have root user authority to use this subroutine.
The lvm_varyonvg subroutine varies on the specified volume group. The lvm_varyonvg subroutine contacts the physical volumes in the volume group and recovers the volume group descriptor area if necessary.
The varyonvg structure pointed to by the VaryOnVG parameter is found in the lvm.h file and is defined as follows:
struct varyonvg { mid_t kmid; char *vgname; long vg_major; struct unique_id vg_id; long noopen_lvs; long reserved; long auto_resync; long misspv_von; long missname_von; short int override; struct { long num_pvs; struct { struct unique_id pv_id; char *pvname; } pv [LVM_MAXPVS]; } vvg_in; struct { long num_pvs; struct { struct unique_id pv_id; char *pvname; long pv_status; } pv [2 * LVM_MAXPVS]; } vvg_out; };
The vvg_in structure contains input from the caller to the lvm_varyonvg subroutine which describes the physical volumes in the volume group. The num_pvs field is the number of entries in the pv array of structures. Each entry in the pv array contains the ID (pv_id) and name (pvname) of a physical volume in the volume group. Unless the volume group is already varied on, this array should contain an entry for each physical volume in the volume group.
The vvg_out structure contains output from the lvm_varyonvg subroutine to the user. This subroutine describes the status of the physical volumes in the caller's input list and any additional physical volumes in the volume group, but not included in the input list. The num_pvs field is the number of entries in the pv array of structures. Each entry in the pv array contains the ID (pv_id), the name (pvname), and the status (pv_status) of a physical volume contained in the input list or the volume group.
The pv_status field contains one of the following values for each physical volume in the vvg_out structure if either the volume group is varied on successfully or an LVM_MISSPVNAME or LVM_MISSINGPV error is returned:
For physical volumes in the input list that are found to be members of the specified volume group, the pv_status field contains the physical volume state of either LVM_PVACTIVE, LVM_PVMISSING, or LVM_PVREMOVED. If a physical volume with the same pv_id has appeared previously in the input list, the pv_status field contains LVM_DUPPVID. For physical volumes in the list which are not members of the volume group, the pv_status field will be LVM_INVPVID.
In some cases, a physical volume that is a member of the volume group might have a pv_status field value of LVM_LVMRECNMTCH. This means that the LVM record on the physical volume has either invalid or nonmatching data and that the physical volume cannot be brought on line. If this happens, it is most likely because the physical volume has been installed into another volume group without first deleting it from this one. The user should now delete this physical volume from this volume group, since it can no longer be accessed as a member of this volume group.
For physical volumes that are members of the volume group but were not in the input list, the pv_status field value will be LVM_NONAME or LVM_NAMIDNMTCH. In this case the pv_id field contains the ID of the physical volume, and the pvname field contains a null pointer. An error code of LVM_MISSPVNAME is returned to the caller unless the subroutine was called with a value of TRUE for the missname_von field.
The pv_status field for each physical volume in the vvg_out structure contains one of the following values if either the LVM_NOQUORUM or LVM_NOVGDAS error is returned.
It is recommended that the missname_von field contain a value of FALSE for the first call to the lvm_varyonvg subroutine since a value of TRUE means that any physical volume for which a name was not passed in the input list is given a state of LVM_PVMISSING. Users of the volume group cannot have access to that physical volume until a subsequent call is made to the lvm_varyonvg subroutine for that volume group.
If the misspv_von field is TRUE, the volume group is varied on (provided a quorum exists) even if some of the physical volumes in the volume group have a state of LVM_PVMISSING. If the flag is FALSE, the volume group is varied on only if all physical volumes in the volume group that do not have a state of LVM_PVREMOVED are in the active state (LVM_PVACTIVE). The value recommended for this flag is TRUE. For any physical volume with a state of LVM_PVMISSING or LVM_PVREMOVED when the volume group is varied on, access to that physical volume is not available through LVM. If the state of a physical volume is changed from LVM_PVREMOVED to LVM_PVACTIVE through a call to the lvm_changepv subroutine, then that physical volume is available to LVM, provided that it is not missing at the time.
If the override field is TRUE, an attempt is made to vary on the volume group even if access to a quorum (or majority) of volume group descriptor area copies or a quorum of the volume group status area copies cannot be obtained. Provided that there is at least one valid copy of the descriptor area and at least one valid copy of the status area, the vary-on of the volume group will proceed with the latest available copies of the volume group descriptor area and status area.
If the volume group is forcefully varied on by overriding the absence of a quorum, the PV state of all missing physical volumes is changed to LVM_PVREMOVED. When a physical volume's state is changed to LVM_PVREMOVED, any copies of the volume group descriptor area and status area that it contains are removed. The physical volume no longer takes part in quorum checking until it is returned to the volume group. Also, the physical volume cannot become an active member of the volume group until it is returned. See the lvm_changepv subroutine for more information about removing and returning physical volumes.
The recommended value for the override field is FALSE. If the user chooses to override the LVM_NOQUORUM error and artificially force a quorum, LVM does not guarantee the data integrity of the data contained in the chosen copies of the volume group descriptor area and status area. For more information about quorums and quorum checking, see the "Logical Volume Storage Overview" in AIX Version 4.3 System Management Guide: Operating System and Devices.
If a physical volume's state is LVM_PVMISSING when the volume group is varied on, then access to that physical volume can be made available to the LVM only by again calling the lvm_varyonvg subroutine for that volume group. When the lvm_varyonvg subroutine is called for a volume group that is already varied on, a check is made for any physical volumes in the volume group with a state of LVM_PVMISSING, and an attempt will be made to open those physical volumes. Any previously missing physical volumes that are successfully opened are defined to the logical volume device driver, and access to those physical volumes will again be available through the LVM.
When the lvm_varyonvg subroutine is called for an already varied-on volume group for the purpose of changing previously missing physical volumes back to the active state, the caller does not need to pass an entire list of physical volumes in the vvg_in structure. The caller needs to pass only information for missing physical volumes that the caller is attempting to return to the LVM_PVACTIVE state.
VaryOnVG | Points to the varyonvg structure. |
Upon successful completion, the subroutine returns one or more of the following return codes:
LVM_SUCCESS | The volume group was successfully varied on. |
LVM_CHKVVGOUT | The volume group was varied on successfully, but there is information in the vvg_out structure that should be checked. |
If the lvm_varyonvg subroutine does not complete successfully, it returns one of the following error codes:
This subroutine is part of Base Operating System (BOS) Runtime.
The lvm_changepv subroutine, lvm_varyoffvg subroutine.
Logical Volume Storage Overview in AIX Version 4.3 System Management Guide: Operating System and Devices.
List of Logical Volume Subroutines and Logical Volume Programming Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.