[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

lvm_extendlv Subroutine

Purpose

Extends a logical volume by a specified number of partitions.

Library

Logical Volume Manager Library (liblvm.a)

Syntax

#include <lvm.h>
int lvm_extendlv (LV_ID, ExtendLV)
struct Lv_id *LV_ID;
struct ext_redlv *ExtendLV;

Description

Note: You must have root user authority to use this subroutine.

The lvm_extendlv subroutine extends a logical volume specified by the LV_ID parameter by adding a completely new logical partition or by adding another copy to an existing logical partition.

The ext_redlv structure pointed to by the ExtendLV parameter is defined in the lvm.h file and contains the following fields:

struct ext_redlv{
     long       size;
     struct pp *parts;
   }  
struct pp {
     struct unique_id pv_id;
     long              lp_num;
     long              pp_num;
   }
Field Description
parts Points to an array of pp structures. The parts array should have one entry for each physical partition being allocated. The parts field is in the ext_redlv structure.
size Specifies the number of entries in the array pointed to by the parts variable. The parts array should have one entry for each physical partition being allocated, and the size field should reflect a total of these entries. The size field should never be 0; if it is, an error will be returned. The size field is in the ext_redlv structure.
lp_num Indicates the number of the logical partition that you are extending. The lp_numb value must range from 1 to the maximum number of logical partitions allowed in the logical volume being extended. The maximum number of logical partitions allowed on the logical volume is the maxsize field returned from a query of the logical volume, and must range from 1 to LVM_MAXLPS. The lp_num field is in the pp structure.
pv_id Contains the valid ID of a physical volume that is a member of the same volume group as the logical volume being extended. The volume group should be varied on, or an error is returned. The pp_id field is in the pp structure.
pp_num Specifies the number of the physical partition to be allocated as a copy of the logical partition. This number must range from 1 to the number of physical partitions allowed on the physical volume specified by the pv_id field. (The pp_count field returned from a query of the physical volume. This field ranges from 1 to LVM_MAXPPS). The physical partition specified by the pp_num should have a state of LVM_PPFREE (that is, should not be allocated). The pp_num field is in the pp structure.

An example of a correct parts array and size value follows:

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

Up to three copies (physical partitions) can be allocated to the same logical partition. An error is returned if an attempt is made to add more. It is also possible to have entries with a valid lp_num field and zeroes for the pv_id and pp_num fields; this type of entry specifies that this logical partition should be ignored (nothing will be allocated for the logical partition). Another way to have a logical partition ignored is simply to skip an entry for it.

EXAMPLE 1
  size = 2
  parts:
         entry1    pv_id  = 0  (Entry 1 would indicate that lp 3
                   lp_num = 3    should be ignored.)
                   pp_num = 0
         entry2    pv_id = 4467
                   lp_num = 5
                   pp_num = 3
EXAMPLE 2
  size = 3
  parts:
         entry1    pv_id = 5347
                   lp_num = 1
                   pp_num = 1
         entry2    pv_id = 8790
                   lp_num = 3
                   pp_num = 3
         entry3    pv_id = 2938
                   lp_num = 6
                   pp_num = 6

Logical partition numbers 2, 4, and 5 are ignored since there were no entries for them in the array.

Parameters

ExtendLV Points to the ext_redlv structure.
LV_ID Points to the lv_id structure, which specifies the logical volume to extend.

Return Values

The lvm_extendlv subroutine returns a value of 0 upon successful completion.

Error Codes

If the lvm_extendlv subroutine fails, it returns one of the following values:

LVM_ALLOCERR A memory allocation error occurred.
LVM_DALVOPN The logical volume reserved by the volume group could not be opened.
LVM_FORCEOFF The volume group has been forcefully varied off due to a loss of quorum.
LVM_INRESYNC The logical partition to be extended is being resynced and cannot be extended while the resync is in progress.
LVM_INVALID_MIN_NUM An invalid minor number was received.
LVM_INVALID_PARAM One or both of the ExtendLV or LV_ID parameters are invalid, or the LV_ID parameter is not a valid logical volume. This could also mean that one of the fields in the ext_redlv structure 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 major number in the mapped file is not valid.
LVM_INV_DEVENT The device entry for the physical volume is not valid and cannot be checked to determine if it is raw.
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_NOALLOCLP The specified logical partition already has three copies.
LVM_NOTCHARDEV The specified device 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.
LVM_PVSTATE_INVAL A physical volume ID sent in specifies a physical volume with a state of LVM_PVNOALLOC.

Implementation Specifics

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

Related Information

The lvm_changelv subroutine, lvm_createlv subroutine, lvm_reducelv subroutine, lvm_varyonvg subroutine.

List of Logical Volume Subroutines and Logical Volume Programming Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]