linux-old/include/linux/lvm.h
<<
>>
Prefs
   1/*
   2 * include/linux/lvm.h
   3 * kernel/lvm.h
   4 * tools/lib/lvm.h
   5 *
   6 * Copyright (C) 1997 - 2002  Heinz Mauelshagen, Sistina Software
   7 *
   8 * February-November 1997
   9 * May-July 1998
  10 * January-March,July,September,October,Dezember 1999
  11 * January,February,July,November 2000
  12 * January-March,June,July 2001
  13 * May 2002
  14 *
  15 * lvm is free software; you can redistribute it and/or modify
  16 * it under the terms of the GNU General Public License as published by
  17 * the Free Software Foundation; either version 2, or (at your option)
  18 * any later version.
  19 *
  20 * lvm is distributed in the hope that it will be useful,
  21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23 * GNU General Public License for more details.
  24 *
  25 * You should have received a copy of the GNU General Public License
  26 * along with GNU CC; see the file COPYING.  If not, write to
  27 * the Free Software Foundation, 59 Temple Place - Suite 330,
  28 * Boston, MA 02111-1307, USA.
  29 *
  30 */
  31
  32/*
  33 * Changelog
  34 *
  35 *    10/10/1997 - beginning of new structure creation
  36 *    12/05/1998 - incorporated structures from lvm_v1.h and deleted lvm_v1.h
  37 *    07/06/1998 - avoided LVM_KMALLOC_MAX define by using vmalloc/vfree
  38 *                 instead of kmalloc/kfree
  39 *    01/07/1998 - fixed wrong LVM_MAX_SIZE
  40 *    07/07/1998 - extended pe_t structure by ios member (for statistic)
  41 *    02/08/1998 - changes for official char/block major numbers
  42 *    07/08/1998 - avoided init_module() and cleanup_module() to be static
  43 *    29/08/1998 - seprated core and disk structure type definitions
  44 *    01/09/1998 - merged kernel integration version (mike)
  45 *    20/01/1999 - added LVM_PE_DISK_OFFSET macro for use in
  46 *                 vg_read_with_pv_and_lv(), pv_move_pe(), pv_show_pe_text()...
  47 *    18/02/1999 - added definition of time_disk_t structure for;
  48 *                 keeps time stamps on disk for nonatomic writes (future)
  49 *    15/03/1999 - corrected LV() and VG() macro definition to use argument
  50 *                 instead of minor
  51 *    03/07/1999 - define for genhd.c name handling
  52 *    23/07/1999 - implemented snapshot part
  53 *    08/12/1999 - changed LVM_LV_SIZE_MAX macro to reflect current 1TB limit
  54 *    01/01/2000 - extended lv_v2 core structure by wait_queue member
  55 *    12/02/2000 - integrated Andrea Arcagnelli's snapshot work
  56 *    18/02/2000 - seperated user and kernel space parts by
  57 *                 #ifdef them with __KERNEL__
  58 *    08/03/2000 - implemented cluster/shared bits for vg_access
  59 *    26/06/2000 - implemented snapshot persistency and resizing support
  60 *    02/11/2000 - added hash table size member to lv structure
  61 *    12/11/2000 - removed unneeded timestamp definitions
  62 *    24/12/2000 - removed LVM_TO_{CORE,DISK}*, use cpu_{from, to}_le*
  63 *                 instead - Christoph Hellwig
  64 *    22/01/2001 - Change ulong to uint32_t
  65 *    14/02/2001 - changed LVM_SNAPSHOT_MIN_CHUNK to 1 page
  66 *    20/02/2001 - incremented IOP version to 11 because of incompatible
  67 *                 change in VG activation (in order to support devfs better)
  68 *    01/03/2001 - Revert to IOP10 and add VG_CREATE_OLD call for compatibility
  69 *    08/03/2001 - new lv_t (in core) version number 5: changed page member
  70 *                 to (struct kiobuf *) to use for COW exception table io
  71 *    26/03/2001 - changed lv_v4 to lv_v5 in structure definition (HM)
  72 *    21/06/2001 - changed BLOCK_SIZE back to 1024 for non S/390
  73 *    22/06/2001 - added Andreas Dilger's PE on 4k boundary alignment enhancements
  74 *    19/07/2001 - added rwsem compatibility macros for 2.2 kernels
  75 *    13/11/2001 - reduced userspace inclusion of kernel headers to a minimum
  76 *
  77 */
  78
  79
  80#ifndef _LVM_H_INCLUDE
  81#define _LVM_H_INCLUDE
  82
  83#define LVM_RELEASE_NAME "1.0.8"
  84#define LVM_RELEASE_DATE "17/11/2003"
  85
  86#define _LVM_KERNEL_H_VERSION   "LVM "LVM_RELEASE_NAME" ("LVM_RELEASE_DATE")"
  87
  88#include <linux/version.h>
  89
  90/*
  91 * preprocessor definitions
  92 */
  93/* if you like emergency reset code in the driver */
  94#define LVM_TOTAL_RESET
  95
  96#ifdef __KERNEL__
  97#undef LVM_HD_NAME              /* display nice names in /proc/partitions */
  98
  99/* lots of debugging output (see driver source)
 100   #define DEBUG_LVM_GET_INFO
 101   #define DEBUG
 102   #define DEBUG_MAP
 103   #define DEBUG_MAP_SIZE
 104   #define DEBUG_IOCTL
 105   #define DEBUG_READ
 106   #define DEBUG_GENDISK
 107   #define DEBUG_VG_CREATE
 108   #define DEBUG_DEVICE
 109   #define DEBUG_KFREE
 110 */
 111
 112#include <linux/kdev_t.h>
 113#include <linux/list.h>
 114#include <asm/types.h>
 115#include <linux/major.h>
 116#else
 117/* This prevents the need to include <linux/list.h> which
 118   causes problems on some platforms. It's not nice but then
 119   neither is the alternative. */
 120struct list_head {
 121        struct list_head *next, *prev;
 122};
 123#define __KERNEL__
 124#include <linux/kdev_t.h>
 125#undef __KERNEL__
 126#endif                          /* #ifndef __KERNEL__ */
 127
 128
 129#ifdef __KERNEL__
 130#include <linux/spinlock.h>
 131
 132#include <asm/semaphore.h>
 133#endif                          /* #ifdef __KERNEL__ */
 134
 135
 136#include <asm/page.h>
 137
 138#if !defined ( LVM_BLK_MAJOR) || !defined ( LVM_CHAR_MAJOR)
 139#error Bad include/linux/major.h - LVM MAJOR undefined
 140#endif
 141
 142#ifdef  BLOCK_SIZE
 143#undef  BLOCK_SIZE
 144#endif
 145
 146#ifdef CONFIG_ARCH_S390
 147#define BLOCK_SIZE      4096
 148#else
 149#define BLOCK_SIZE      1024
 150#endif
 151
 152#ifndef SECTOR_SIZE
 153#define SECTOR_SIZE     512
 154#endif
 155
 156/* structure version */
 157#define LVM_STRUCT_VERSION 1
 158
 159#define LVM_DIR_PREFIX  "/dev/"
 160
 161/*
 162 * i/o protocol version
 163 *
 164 * defined here for the driver and defined seperate in the
 165 * user land tools/lib/liblvm.h
 166 *
 167 */
 168#define LVM_DRIVER_IOP_VERSION          10
 169
 170#define LVM_NAME        "lvm"
 171#define LVM_GLOBAL      "global"
 172#define LVM_DIR         "lvm"
 173#define LVM_VG_SUBDIR   "VGs"
 174#define LVM_LV_SUBDIR   "LVs"
 175#define LVM_PV_SUBDIR   "PVs"
 176
 177/*
 178 * VG/LV indexing macros
 179 */
 180/* character minor maps directly to volume group */
 181#define VG_CHR(a) ( a)
 182
 183/* block minor indexes into a volume group/logical volume indirection table */
 184#define VG_BLK(a)       ( vg_lv_map[a].vg_number)
 185#define LV_BLK(a)       ( vg_lv_map[a].lv_number)
 186
 187/*
 188 * absolute limits for VGs, PVs per VG and LVs per VG
 189 */
 190#define ABS_MAX_VG      99
 191#define ABS_MAX_PV      256
 192#define ABS_MAX_LV      256     /* caused by 8 bit minor */
 193
 194#define MAX_VG  ABS_MAX_VG
 195#define MAX_LV  ABS_MAX_LV
 196#define MAX_PV  ABS_MAX_PV
 197
 198#if ( MAX_VG > ABS_MAX_VG)
 199#undef MAX_VG
 200#define MAX_VG ABS_MAX_VG
 201#endif
 202
 203#if ( MAX_LV > ABS_MAX_LV)
 204#undef MAX_LV
 205#define MAX_LV ABS_MAX_LV
 206#endif
 207
 208
 209/*
 210 * VGDA: default disk spaces and offsets
 211 *
 212 *   there's space after the structures for later extensions.
 213 *
 214 *   offset            what                                size
 215 *   ---------------   ----------------------------------  ------------
 216 *   0                 physical volume structure           ~500 byte
 217 *
 218 *   1K                volume group structure              ~200 byte
 219 *
 220 *   6K                namelist of physical volumes        128 byte each
 221 *
 222 *   6k + n * ~300byte n logical volume structures         ~300 byte each
 223 *
 224 *   + m * 4byte       m physical extent alloc. structs    4 byte each
 225 *
 226 *   End of disk -     first physical extent               typically 4 megabyte
 227 *   PE total *
 228 *   PE size
 229 *
 230 *
 231 */
 232
 233/* DONT TOUCH THESE !!! */
 234
 235
 236
 237
 238
 239
 240
 241/*
 242 * LVM_PE_T_MAX corresponds to:
 243 *
 244 * 8KB PE size can map a ~512 MB logical volume at the cost of 1MB memory,
 245 *
 246 * 128MB PE size can map a 8TB logical volume at the same cost of memory.
 247 *
 248 * Default PE size of 4 MB gives a maximum logical volume size of 256 GB.
 249 *
 250 * Maximum PE size of 16GB gives a maximum logical volume size of 1024 TB.
 251 *
 252 * AFAIK, the actual kernels limit this to 1 TB.
 253 *
 254 * Should be a sufficient spectrum ;*)
 255 */
 256
 257/* This is the usable size of pe_disk_t.le_num !!!        v     v */
 258#define LVM_PE_T_MAX            ( ( 1 << ( sizeof ( uint16_t) * 8)) - 2)
 259
 260#define LVM_LV_SIZE_MAX(a)      ( ( long long) LVM_PE_T_MAX * (a)->pe_size > ( long long) 1024*1024/SECTOR_SIZE*1024*1024 ? ( long long) 1024*1024/SECTOR_SIZE*1024*1024 : ( long long) LVM_PE_T_MAX * (a)->pe_size)
 261#define LVM_MIN_PE_SIZE         ( 8192L / SECTOR_SIZE)  /* 8 KB in sectors */
 262#define LVM_MAX_PE_SIZE         ( 16L * 1024L * 1024L / SECTOR_SIZE * 1024)     /* 16GB in sectors */
 263#define LVM_DEFAULT_PE_SIZE     ( 32768L * 1024 / SECTOR_SIZE)  /* 32 MB in sectors */
 264#define LVM_DEFAULT_STRIPE_SIZE 16L     /* 16 KB  */
 265#define LVM_MIN_STRIPE_SIZE     ( PAGE_SIZE/SECTOR_SIZE)        /* PAGESIZE in sectors */
 266#define LVM_MAX_STRIPE_SIZE     ( 512L * 1024 / SECTOR_SIZE)    /* 512 KB in sectors */
 267#define LVM_MAX_STRIPES         128     /* max # of stripes */
 268#define LVM_MAX_SIZE            ( 1024LU * 1024 / SECTOR_SIZE * 1024 * 1024)    /* 1TB[sectors] */
 269#define LVM_MAX_MIRRORS         2       /* future use */
 270#define LVM_MIN_READ_AHEAD      0       /* minimum read ahead sectors */
 271#define LVM_DEFAULT_READ_AHEAD  1024    /* sectors for 512k scsi segments */
 272#define LVM_MAX_READ_AHEAD      1024    /* maximum read ahead sectors */
 273#define LVM_MAX_LV_IO_TIMEOUT   60      /* seconds I/O timeout (future use) */
 274#define LVM_PARTITION           0xfe    /* LVM partition id */
 275#define LVM_NEW_PARTITION       0x8e    /* new LVM partition id (10/09/1999) */
 276#define LVM_PE_SIZE_PV_SIZE_REL 5       /* max relation PV size and PE size */
 277
 278#define LVM_SNAPSHOT_MAX_CHUNK  1024    /* 1024 KB */
 279#define LVM_SNAPSHOT_DEF_CHUNK  64      /* 64  KB */
 280#define LVM_SNAPSHOT_MIN_CHUNK  (PAGE_SIZE/1024)        /* 4 or 8 KB */
 281
 282#define UNDEF   -1
 283
 284/*
 285 * ioctls
 286 * FIXME: the last parameter to _IO{W,R,WR} is a data type.  The macro will
 287 *        expand this using sizeof(), so putting "1" there is misleading
 288 *        because sizeof(1) = sizeof(int) = sizeof(2) = 4 on a 32-bit machine!
 289 */
 290/* volume group */
 291#define VG_CREATE_OLD           _IOW ( 0xfe, 0x00, 1)
 292#define VG_REMOVE               _IOW ( 0xfe, 0x01, 1)
 293
 294#define VG_EXTEND               _IOW ( 0xfe, 0x03, 1)
 295#define VG_REDUCE               _IOW ( 0xfe, 0x04, 1)
 296
 297#define VG_STATUS               _IOWR ( 0xfe, 0x05, 1)
 298#define VG_STATUS_GET_COUNT     _IOWR ( 0xfe, 0x06, 1)
 299#define VG_STATUS_GET_NAMELIST  _IOWR ( 0xfe, 0x07, 1)
 300
 301#define VG_SET_EXTENDABLE       _IOW ( 0xfe, 0x08, 1)
 302#define VG_RENAME               _IOW ( 0xfe, 0x09, 1)
 303
 304/* Since 0.9beta6 */
 305#define VG_CREATE               _IOW ( 0xfe, 0x0a, 1)
 306
 307/* logical volume */
 308#define LV_CREATE               _IOW ( 0xfe, 0x20, 1)
 309#define LV_REMOVE               _IOW ( 0xfe, 0x21, 1)
 310
 311#define LV_ACTIVATE             _IO ( 0xfe, 0x22)
 312#define LV_DEACTIVATE           _IO ( 0xfe, 0x23)
 313
 314#define LV_EXTEND               _IOW ( 0xfe, 0x24, 1)
 315#define LV_REDUCE               _IOW ( 0xfe, 0x25, 1)
 316
 317#define LV_STATUS_BYNAME        _IOWR ( 0xfe, 0x26, 1)
 318#define LV_STATUS_BYINDEX       _IOWR ( 0xfe, 0x27, 1)
 319
 320#define LV_SET_ACCESS           _IOW ( 0xfe, 0x28, 1)
 321#define LV_SET_ALLOCATION       _IOW ( 0xfe, 0x29, 1)
 322#define LV_SET_STATUS           _IOW ( 0xfe, 0x2a, 1)
 323
 324#define LE_REMAP                _IOW ( 0xfe, 0x2b, 1)
 325
 326#define LV_SNAPSHOT_USE_RATE    _IOWR ( 0xfe, 0x2c, 1)
 327
 328#define LV_STATUS_BYDEV         _IOWR ( 0xfe, 0x2e, 1)
 329
 330#define LV_RENAME               _IOW ( 0xfe, 0x2f, 1)
 331
 332#define LV_BMAP                 _IOWR ( 0xfe, 0x30, 1)
 333
 334
 335/* physical volume */
 336#define PV_STATUS               _IOWR ( 0xfe, 0x40, 1)
 337#define PV_CHANGE               _IOWR ( 0xfe, 0x41, 1)
 338#define PV_FLUSH                _IOW ( 0xfe, 0x42, 1)
 339
 340/* physical extent */
 341#define PE_LOCK_UNLOCK          _IOW ( 0xfe, 0x50, 1)
 342
 343/* i/o protocol version */
 344#define LVM_GET_IOP_VERSION     _IOR ( 0xfe, 0x98, 1)
 345
 346#ifdef LVM_TOTAL_RESET
 347/* special reset function for testing purposes */
 348#define LVM_RESET               _IO ( 0xfe, 0x99)
 349#endif
 350
 351/* lock the logical volume manager */
 352#if LVM_DRIVER_IOP_VERSION > 11
 353#define LVM_LOCK_LVM            _IO ( 0xfe, 0x9A)
 354#else
 355/* This is actually the same as _IO ( 0xff, 0x00), oops.  Remove for IOP 12+ */
 356#define LVM_LOCK_LVM            _IO ( 0xfe, 0x100)
 357#endif
 358/* END ioctls */
 359
 360
 361/*
 362 * Status flags
 363 */
 364/* volume group */
 365#define VG_ACTIVE            0x01       /* vg_status */
 366#define VG_EXPORTED          0x02       /*     "     */
 367#define VG_EXTENDABLE        0x04       /*     "     */
 368
 369#define VG_READ              0x01       /* vg_access */
 370#define VG_WRITE             0x02       /*     "     */
 371#define VG_CLUSTERED         0x04       /*     "     */
 372#define VG_SHARED            0x08       /*     "     */
 373
 374/* logical volume */
 375#define LV_ACTIVE            0x01       /* lv_status */
 376#define LV_SPINDOWN          0x02       /*     "     */
 377
 378#define LV_READ              0x01       /* lv_access */
 379#define LV_WRITE             0x02       /*     "     */
 380#define LV_SNAPSHOT          0x04       /*     "     */
 381#define LV_SNAPSHOT_ORG      0x08       /*     "     */
 382
 383#define LV_BADBLOCK_ON       0x01       /* lv_badblock */
 384
 385#define LV_STRICT            0x01       /* lv_allocation */
 386#define LV_CONTIGUOUS        0x02       /*       "       */
 387
 388/* physical volume */
 389#define PV_ACTIVE            0x01       /* pv_status */
 390#define PV_ALLOCATABLE       0x02       /* pv_allocatable */
 391
 392
 393/* misc */
 394#define LVM_SNAPSHOT_DROPPED_SECTOR 1
 395
 396/*
 397 * Structure definitions core/disk follow
 398 *
 399 * conditional conversion takes place on big endian architectures
 400 * in functions * pv_copy_*(), vg_copy_*() and lv_copy_*()
 401 *
 402 */
 403
 404#define NAME_LEN                128     /* don't change!!! */
 405#define UUID_LEN                32      /* don't change!!! */
 406
 407/* copy on write tables in disk format */
 408typedef struct lv_COW_table_disk_v1 {
 409        uint64_t pv_org_number;
 410        uint64_t pv_org_rsector;
 411        uint64_t pv_snap_number;
 412        uint64_t pv_snap_rsector;
 413} lv_COW_table_disk_t;
 414
 415/* remap physical sector/rdev pairs including hash */
 416typedef struct lv_block_exception_v1 {
 417        struct list_head hash;
 418        uint32_t rsector_org;
 419        kdev_t rdev_org;
 420        uint32_t rsector_new;
 421        kdev_t rdev_new;
 422} lv_block_exception_t;
 423
 424/* disk stored pe information */
 425typedef struct {
 426        uint16_t lv_num;
 427        uint16_t le_num;
 428} pe_disk_t;
 429
 430/* disk stored PV, VG, LV and PE size and offset information */
 431typedef struct {
 432        uint32_t base;
 433        uint32_t size;
 434} lvm_disk_data_t;
 435
 436
 437/*
 438 * physical volume structures
 439 */
 440
 441/* core */
 442typedef struct pv_v2 {
 443        char id[2];             /* Identifier */
 444        unsigned short version; /* HM lvm version */
 445        lvm_disk_data_t pv_on_disk;
 446        lvm_disk_data_t vg_on_disk;
 447        lvm_disk_data_t pv_uuidlist_on_disk;
 448        lvm_disk_data_t lv_on_disk;
 449        lvm_disk_data_t pe_on_disk;
 450        char pv_name[NAME_LEN];
 451        char vg_name[NAME_LEN];
 452        char system_id[NAME_LEN];       /* for vgexport/vgimport */
 453        kdev_t pv_dev;
 454        uint pv_number;
 455        uint pv_status;
 456        uint pv_allocatable;
 457        uint pv_size;           /* HM */
 458        uint lv_cur;
 459        uint pe_size;
 460        uint pe_total;
 461        uint pe_allocated;
 462        uint pe_stale;          /* for future use */
 463        pe_disk_t *pe;          /* HM */
 464        struct block_device *bd;
 465        char pv_uuid[UUID_LEN + 1];
 466
 467#ifndef __KERNEL__
 468        uint32_t pe_start;      /* in sectors */
 469#endif
 470} pv_t;
 471
 472
 473/* disk */
 474typedef struct pv_disk_v2 {
 475        uint8_t id[2];          /* Identifier */
 476        uint16_t version;       /* HM lvm version */
 477        lvm_disk_data_t pv_on_disk;
 478        lvm_disk_data_t vg_on_disk;
 479        lvm_disk_data_t pv_uuidlist_on_disk;
 480        lvm_disk_data_t lv_on_disk;
 481        lvm_disk_data_t pe_on_disk;
 482        uint8_t pv_uuid[NAME_LEN];
 483        uint8_t vg_name[NAME_LEN];
 484        uint8_t system_id[NAME_LEN];    /* for vgexport/vgimport */
 485        uint32_t pv_major;
 486        uint32_t pv_number;
 487        uint32_t pv_status;
 488        uint32_t pv_allocatable;
 489        uint32_t pv_size;       /* HM */
 490        uint32_t lv_cur;
 491        uint32_t pe_size;
 492        uint32_t pe_total;
 493        uint32_t pe_allocated;
 494
 495        /* new in struct version 2 */
 496        uint32_t pe_start;      /* in sectors */
 497
 498} pv_disk_t;
 499
 500
 501/*
 502 * Structures for Logical Volume (LV)
 503 */
 504
 505/* core PE information */
 506typedef struct {
 507        kdev_t dev;
 508        uint32_t pe;            /* to be changed if > 2TB */
 509        uint32_t reads;
 510        uint32_t writes;
 511} pe_t;
 512
 513typedef struct {
 514        char lv_name[NAME_LEN];
 515        kdev_t old_dev;
 516        kdev_t new_dev;
 517        uint32_t old_pe;
 518        uint32_t new_pe;
 519} le_remap_req_t;
 520
 521typedef struct lv_bmap {
 522        uint32_t lv_block;
 523        dev_t lv_dev;
 524} lv_bmap_t;
 525
 526/*
 527 * Structure Logical Volume (LV) Version 3
 528 */
 529
 530/* core */
 531typedef struct lv_v5 {
 532        char lv_name[NAME_LEN];
 533        char vg_name[NAME_LEN];
 534        uint lv_access;
 535        uint lv_status;
 536        uint lv_open;           /* HM */
 537        kdev_t lv_dev;          /* HM */
 538        uint lv_number;         /* HM */
 539        uint lv_mirror_copies;  /* for future use */
 540        uint lv_recovery;       /*       "        */
 541        uint lv_schedule;       /*       "        */
 542        uint lv_size;
 543        pe_t *lv_current_pe;    /* HM */
 544        uint lv_current_le;     /* for future use */
 545        uint lv_allocated_le;
 546        uint lv_stripes;
 547        uint lv_stripesize;
 548        uint lv_badblock;       /* for future use */
 549        uint lv_allocation;
 550        uint lv_io_timeout;     /* for future use */
 551        uint lv_read_ahead;
 552
 553        /* delta to version 1 starts here */
 554        struct lv_v5 *lv_snapshot_org;
 555        struct lv_v5 *lv_snapshot_prev;
 556        struct lv_v5 *lv_snapshot_next;
 557        lv_block_exception_t *lv_block_exception;
 558        uint lv_remap_ptr;
 559        uint lv_remap_end;
 560        uint lv_chunk_size;
 561        uint lv_snapshot_minor;
 562#ifdef __KERNEL__
 563        struct kiobuf *lv_iobuf;
 564        struct kiobuf *lv_COW_table_iobuf;
 565        struct rw_semaphore lv_lock;
 566        struct list_head *lv_snapshot_hash_table;
 567        uint32_t lv_snapshot_hash_table_size;
 568        uint32_t lv_snapshot_hash_mask;
 569        wait_queue_head_t lv_snapshot_wait;
 570        int lv_snapshot_use_rate;
 571        struct vg_v3 *vg;
 572
 573        uint lv_allocated_snapshot_le;
 574#else
 575        char dummy[200];
 576#endif
 577} lv_t;
 578
 579/* disk */
 580typedef struct lv_disk_v3 {
 581        uint8_t lv_name[NAME_LEN];
 582        uint8_t vg_name[NAME_LEN];
 583        uint32_t lv_access;
 584        uint32_t lv_status;
 585        uint32_t lv_open;       /* HM */
 586        uint32_t lv_dev;        /* HM */
 587        uint32_t lv_number;     /* HM */
 588        uint32_t lv_mirror_copies;      /* for future use */
 589        uint32_t lv_recovery;   /*       "        */
 590        uint32_t lv_schedule;   /*       "        */
 591        uint32_t lv_size;
 592        uint32_t lv_snapshot_minor;     /* minor number of original */
 593        uint16_t lv_chunk_size; /* chunk size of snapshot */
 594        uint16_t dummy;
 595        uint32_t lv_allocated_le;
 596        uint32_t lv_stripes;
 597        uint32_t lv_stripesize;
 598        uint32_t lv_badblock;   /* for future use */
 599        uint32_t lv_allocation;
 600        uint32_t lv_io_timeout; /* for future use */
 601        uint32_t lv_read_ahead; /* HM */
 602} lv_disk_t;
 603
 604/*
 605 * Structure Volume Group (VG) Version 1
 606 */
 607
 608/* core */
 609typedef struct vg_v3 {
 610        char vg_name[NAME_LEN]; /* volume group name */
 611        uint vg_number;         /* volume group number */
 612        uint vg_access;         /* read/write */
 613        uint vg_status;         /* active or not */
 614        uint lv_max;            /* maximum logical volumes */
 615        uint lv_cur;            /* current logical volumes */
 616        uint lv_open;           /* open    logical volumes */
 617        uint pv_max;            /* maximum physical volumes */
 618        uint pv_cur;            /* current physical volumes FU */
 619        uint pv_act;            /* active physical volumes */
 620        uint dummy;             /* was obsolete max_pe_per_pv */
 621        uint vgda;              /* volume group descriptor arrays FU */
 622        uint pe_size;           /* physical extent size in sectors */
 623        uint pe_total;          /* total of physical extents */
 624        uint pe_allocated;      /* allocated physical extents */
 625        uint pvg_total;         /* physical volume groups FU */
 626        struct proc_dir_entry *proc;
 627        pv_t *pv[ABS_MAX_PV + 1];       /* physical volume struct pointers */
 628        lv_t *lv[ABS_MAX_LV + 1];       /* logical  volume struct pointers */
 629        char vg_uuid[UUID_LEN + 1];     /* volume group UUID */
 630#ifdef __KERNEL__
 631        struct proc_dir_entry *vg_dir_pde;
 632        struct proc_dir_entry *lv_subdir_pde;
 633        struct proc_dir_entry *pv_subdir_pde;
 634#else
 635        char dummy1[200];
 636#endif
 637} vg_t;
 638
 639
 640/* disk */
 641typedef struct vg_disk_v2 {
 642        uint8_t vg_uuid[UUID_LEN];      /* volume group UUID */
 643        uint8_t vg_name_dummy[NAME_LEN - UUID_LEN];     /* rest of v1 VG name */
 644        uint32_t vg_number;     /* volume group number */
 645        uint32_t vg_access;     /* read/write */
 646        uint32_t vg_status;     /* active or not */
 647        uint32_t lv_max;        /* maximum logical volumes */
 648        uint32_t lv_cur;        /* current logical volumes */
 649        uint32_t lv_open;       /* open    logical volumes */
 650        uint32_t pv_max;        /* maximum physical volumes */
 651        uint32_t pv_cur;        /* current physical volumes FU */
 652        uint32_t pv_act;        /* active physical volumes */
 653        uint32_t dummy;
 654        uint32_t vgda;          /* volume group descriptor arrays FU */
 655        uint32_t pe_size;       /* physical extent size in sectors */
 656        uint32_t pe_total;      /* total of physical extents */
 657        uint32_t pe_allocated;  /* allocated physical extents */
 658        uint32_t pvg_total;     /* physical volume groups FU */
 659} vg_disk_t;
 660
 661
 662/*
 663 * Request structures for ioctls
 664 */
 665
 666/* Request structure PV_STATUS_BY_NAME... */
 667typedef struct {
 668        char pv_name[NAME_LEN];
 669        pv_t *pv;
 670} pv_status_req_t, pv_change_req_t;
 671
 672/* Request structure PV_FLUSH */
 673typedef struct {
 674        char pv_name[NAME_LEN];
 675        kdev_t pv_dev;
 676} pv_flush_req_t;
 677
 678
 679/* Request structure PE_MOVE */
 680typedef struct {
 681        enum {
 682                LOCK_PE, UNLOCK_PE
 683        } lock;
 684        struct {
 685                kdev_t lv_dev;
 686                kdev_t pv_dev;
 687                uint32_t pv_offset;
 688        } data;
 689} pe_lock_req_t;
 690
 691
 692/* Request structure LV_STATUS_BYNAME */
 693typedef struct {
 694        char lv_name[NAME_LEN];
 695        lv_t *lv;
 696} lv_status_byname_req_t, lv_req_t;
 697
 698/* Request structure LV_STATUS_BYINDEX */
 699typedef struct {
 700        uint32_t lv_index;
 701        lv_t *lv;
 702        /* Transfer size because user space and kernel space differ */
 703        ushort size;
 704} lv_status_byindex_req_t;
 705
 706/* Request structure LV_STATUS_BYDEV... */
 707typedef struct {
 708        dev_t dev;
 709        lv_t *lv;
 710} lv_status_bydev_req_t;
 711
 712
 713/* Request structure LV_SNAPSHOT_USE_RATE */
 714typedef struct {
 715        int block;
 716        int rate;
 717} lv_snapshot_use_rate_req_t;
 718
 719
 720
 721/* useful inlines */
 722static inline ulong round_up(ulong n, ulong size)
 723{
 724        size--;
 725        return (n + size) & ~size;
 726}
 727
 728static inline ulong div_up(ulong n, ulong size)
 729{
 730        return round_up(n, size) / size;
 731}
 732
 733/* FIXME: nasty capital letters */
 734static int inline LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg_t * vg, lv_t * lv)
 735{
 736        return vg->pe_size / lv->lv_chunk_size;
 737}
 738
 739static int inline LVM_GET_COW_TABLE_ENTRIES_PER_PE(vg_t * vg, lv_t * lv)
 740{
 741        ulong chunks = vg->pe_size / lv->lv_chunk_size;
 742        ulong entry_size = sizeof(lv_COW_table_disk_t);
 743        ulong chunk_size = lv->lv_chunk_size * SECTOR_SIZE;
 744        ulong entries = (vg->pe_size * SECTOR_SIZE) /
 745            (entry_size + chunk_size);
 746
 747        if (chunks < 2)
 748                return 0;
 749
 750        for (; entries; entries--)
 751                if ((div_up(entries * entry_size, chunk_size) + entries) <=
 752                    chunks)
 753                        break;
 754
 755        return entries;
 756}
 757
 758
 759#endif                          /* #ifndef _LVM_H_INCLUDE */
 760
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.