[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

lvm_reducelv Subroutine

Purpose

Reduces the size of a logical volume by a specified number of partitions.

Library

Logical Volume Manager Library (liblvm.a)

Syntax

#include <lvm.h>
int lvm_reducelv (LV_ID, ReduceLV)
struct lv_id *LV_ID;
struct ext_redlv *ReduceLV;

Description

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.

Parameters

LV_ID Specifies the logical volume to be reduced.
ReduceLV Points to the ext_redlv structure.

Return Values

Upon successful completion, a value of 0 is returned.

Error Codes

If the lvm_reducelv subroutine does not complete successfully, it returns one of the following error codes:

LVM_ALLOCERR A memory allocation error occurred.
LVM_DALVOPN The volume group reserved logical volume could not be opened.
LVM_FORCEOFF The volume group has been forcefully varied off due to a loss of quorum.
LVM_INVALID_MIN_NUM A minor number received was not valid.
LVM_INVALID_PARAM One of the parameters passed in is not valid, or one of the fields in the structures pointed to by one of the parameters is not valid.
LVM_INVCONFIG An error occurred while attempting to configure this volume group into the kernel. This error will normally result if the module ID is not valid, the major number given is already in use, or the volume group device could not be opened.
LVM_INV_DEVENT The device entry for the physical volume is not valid and cannot be checked to determine if it is raw.
LVM_INVLPRED The reduction cannot be completed because a logical partition would exist with only stale copies remaining.
LVM_LPNUM_INVAL A logical partition number passed in is not valid.
LVM_MAPFBSY The volume group is currently locked because system management on the volume group is being done by another process.
LVM_MAPFOPN The mapped file, which contains a copy of the volume group descriptor area used for making changes to the volume group, could not be opened.
LVM_MAPFRDWR An error occurred while trying to read or write the mapped file.
LVM_NOTCHARDEV The device specified is not a raw or character device.
LVM_OFFLINE The volume group is offline and should be online.
LVM_PPNUM_INVAL A physical partition number passed in is not valid.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

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.


[ Previous | Next | Contents | Glossary | Home | Search ]