Reduces the size of a logical volume by a specified number of partitions.
Logical Volume Manager Library (liblvm.a)
#include <lvm.h>
int lvm_reducelv (LV_ID, ReduceLV) struct lv_id *LV_ID; struct ext_redlv *ReduceLV;
Note: You must have root user authority to use this subroutine.
The lvm_reducelv subroutine reduces a logical volume specified by the LV_ID parameter. This logical volume should be closed and should be a member of an online volume group. On partial reductions of a logical volume, all remaining logical partitions must have one good (non-stale) copy allocated to them. The Logical Volume Manager (LVM) does not reduce the last good (non-stale) copy of a logical partition on partial reductions to a logical volume. If a reduction is refused for this reason, the resync routines can be used to make all stale copies of a logical partition good so that a reduction can then be performed.
The ext_redlv structure, pointed to by the ReduceLV parameter, is found in the lvm.h file and is defined as follows:
struct ext_redlv{ long size; struct pp *parts; } struct pp { struct unique_id pv_id; long lp_num; long pp_num; }
Following is an example of a correct parts array and size value:
size = 4 (The size field is set to 4 because there are 4 struct pp entries.) parts: entry1 pv_id = 4321 lp_num = 2 pp_num = 1 entry2 pv_id = 1234 lp_num = 2 pp_num = 3 entry3 pv_id = 5432 lp_num = 3 pp_num = 5 entry4 pv_id = 4242 lp_num = 2 pp_num = 12
The ReduceLV parameter is a pointer to an ext_redlv structure. Within this structure is the parts field, which is a pointer to an array of pp structures. Also in the ext_redlv structure is the size field, which is the number of entries in the array that is pointed to by the parts field. The parts array should have one entry for each physical partition being deallocated, and the size field should reflect a total of these entries. Also, the size field should never be 0; if it is, an error code is returned.
Within the pp structure is a lp_num field which is the number of the logical partitions that you are reducing. This number should be between 1 and the value of the maxsize field. The maxsize field is returned from the lvm_querylv subroutine and is the maximum number of logical partitions allowed for a logical volume. Also in the pp structure are the pp_num and pv_id fields. The pp_num field is the number of the physical partition to be deallocated as a copy of the logical partition. This number must range from 1 to the value of the pp_count field. The pp_count field is returned from the lvm_querypv subroutine and is the maximum number of physical partitions allowed on a physical volume. Also, the physical partition specified by the pp_num field should have a state of LVM_PPALLOC (that is, should be allocated). The pv_id field should contain the valid ID of a physical volume that is a member of the same volume group as the logical volume being reduced.
LV_ID | Specifies the logical volume to be reduced. |
ReduceLV | Points to the ext_redlv structure. |
Upon successful completion, a value of 0 is returned.
If the lvm_reducelv 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_createlv subroutine, lvm_deletelv subroutine, lvm_extendlv subroutine, lvm_resynclp subroutine, lvm_resynclv subroutine, lvm_resyncpv subroutine.
List of Logical Volume Subroutines and Logical Volume Programming Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.