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

lvm_querypv Subroutine

Purpose

Queries a physical volume and returns all pertinent information.

Library

Logical Volume Manager Library (liblvm.a)

Syntax

#include <lvm.h>
int lvm_querypv (VG_ID, PV_ID, QueryPV, PVName)
struct unique_id *VG_ID;
struct unique_id *PV_ID;
struct querypv **QueryPV;
char *PVName;

Description

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

The lvm_querypv subroutine returns information on the physical volume specified by the PV_ID parameter.

The querypv structure, defined in the lvm.h file, contains the following fields:

struct querypv {
      long ppsize;
      long pv_state;
      long pp_count;
      long alloc_ppcount;  
      struct pp_map *pp_map;
      long pvnum_vgdas;  
 }
 struct pp_map {  
      long pp_state;
      struct lv_id lv_id;
      long lp_num;
      long copy;
      struct unique_id fst_alt_vol;
      long fst_alt_part;
      struct unique_id snd_alt_vol;
      long snd_alt_part;  
  }
Field Description
ppsize Specifies the size of the physical partitions, which is the same for all partitions within a volume group. The size in bytes of a physical partition is 2 to the power of ppsize .
pv_state Contains the current state of the physical volume.
pp_count Contains the total number of physical partitions on the physical volume.
alloc_ppcount Contains the number of allocated physical partitions on the physical volume.
pp_map Points to an array that has entries for each physical partition of the physical volume. Each entry in this array will contain the pp_state that specifies the state of the physical partition (LVM_PPFREE, LVM_PPALLOC, or LVM_PPSTALE) and the lv_id , field, the ID of the logical volume that it is a member of. The pp_map array also contains the physical volume IDs (fst_alt_vol and snd_alt_vol ) and the physical partition numbers (fst_alt_part and snd_alt_part ) for the first and second alternate copies of the physical partition, and the logical partition number (lp_num) that the physical partition corresponds to.

If the physical partition is free (that is, not allocated), all of its pp_map fields will be zero.

fst_alt_vol
Contains zeros if the logical partition has only one physical copy.
fst_alt_part
Contains zeros if the logical partition has only one physical copy.
snd_alt_vol
Contains zeros if the logical partition has only one or two physical copies.
snd_alt_part
Contains zeros if the logical partition has only one or two physical copies.
copy
Specifies which copy of a logical partition this physical partition is allocated to. This field will contain one of the following values:
LVM_PRIMARY
Primary and only copy of a logical partition
LVM_PRIMOF2
Primary copy of a logical partition with two physical copies
LVM_PRIMOF3
Primary copy of a logical partition with three physical copies
LVM_SCNDOF2
Secondary copy of a logical partition with two physical copies
LVM_SCNDOF3
Secondary copy of a logical partition with three physical copies
LVM_TERTOF3
Tertiary copy of a logical partition with three physical copies.
pvnum_vgdas    Contains the number of volume group descriptor areas (0, 1, or 2) that are on the specified physical volume.

The PVName parameter enables the user to query from a volume group descriptor area on a specific physical volume instead of from the Logical Volume Manager's (LVM) most recent, in-memory copy of the descriptor area. This method should only be used if the volume group is varied off. The data returned is not guaranteed to be most recent or correct, and it can reflect a back level descriptor area.

The PVname parameter should specify either the full path name of the physical volume that contains the descriptor area to query or a single file name that must reside in the /dev directory (for example, rhdisk1). This field must be a null-terminated string of from 1 to LVM_NAMESIZ bytes, including the null byte, and represent a raw or character device. If a raw or character device is not specified for the PVName parameter, the LVM will add an r to the file name in order to have a raw device name. If there is no raw device entry for this name, the LVM will return the LVM_NOTCHARDEV error code. If a PVName is specified, the volume group identifier, VG_ID , will be returned by the LVM through the VG_ID parameter passed in by the user. If the user wishes to query from the LVM in-memory copy, the PVName parameter should be set to null. When using this method of query, the volume group must be varied on, or an error will be returned.

Note: As long as the PVName is not null, the LVM will attempt a query from a physical volume and not from its in-memory copy of data.

In addition to the PVName parameter, the caller passes the VG_ID parameter, indicating the volume group that contains the physical volume to be queried, the unique ID of the physical volume to be queried, the PV_ID parameter, and the address of a pointer of the type QueryPV. The LVM will separately allocate enough space for the querypv structure and the struct pp_map array and return the address of the querypv structure in the QueryPV pointer passed in. The user is responsible for freeing the space by freeing the struct pp_map pointer and then freeing the QueryPV pointer.

Parameters

VG_ID Points to a unique_id structure that specifies the volume group of which the physical volume to query is a member.
PV_ID Points to a unique_id structure that specifies the physical volume to query.
QueryPV Specifies the address of a pointer to a querypv structure.
PVName Names a physical volume from which to use the volume group descriptor area for the query. This parameter can be null.

Return Values

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

Error Codes

If the lvm_querypv subroutine fails it returns one of the following error codes:

LVM_ALLOCERR The routine cannot allocate enough space for a complete buffer.
LVM_INVALID_PARAM An invalid parameter was passed into the routine.
LVM_INV_DEVENT The device entry for the physical volume is invalid and cannot be checked to determine if it is raw.
LVM_OFFLINE The volume group specified is offline and should be online.

If the query originates from the varied-on volume group's current volume group descriptor area, one of the following error codes may be returned:

LVM_DALVOPN The volume group reserved logical volume could not be opened.
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 Either the mapped file could not be read, or it could not be written.

If a physical volume name has been passed, requesting that the query originate from a specific physical volume, then one of the following error codes may be returned:

LVM_BADBBDIR The bad-block directory could not be read or written.
LVM_LVMRECERR The LVM record, which contains information about the volume group descriptor area, could not be read.
LVM_NOPVVGDA There are no volume group descriptor areas on this physical volume.
LVM_NOTCHARDEV A device is not a raw or character device.
LVM_NOTVGMEM The physical volume is not a member of a volume group.
LVM_PVDAREAD An error occurred while trying to read the volume group descriptor area from the specified physical volume.
LVM_PVOPNERR The physical volume device could not be opened.
LVM_VGDA_BB A bad block was found in the volume group descriptor area located on the physical volume that was specified for the query. Therefore, a query cannot be done from the specified physical volume.

Implementation Specifics

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

Related Information

The 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.


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