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.5+" 84#define LVM_RELEASE_DATE "22/07/2002" 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 ( 4096L * 1024 / SECTOR_SIZE) /* 4 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/* volume group */ 285#define VG_CREATE_OLD _IOW ( 0xfe, 0x00, 1) 286#define VG_REMOVE _IOW ( 0xfe, 0x01, 1) 287 288#define VG_EXTEND _IOW ( 0xfe, 0x03, 1) 289#define VG_REDUCE _IOW ( 0xfe, 0x04, 1) 290 291#define VG_STATUS _IOWR ( 0xfe, 0x05, 1) 292#define VG_STATUS_GET_COUNT _IOWR ( 0xfe, 0x06, 1) 293#define VG_STATUS_GET_NAMELIST _IOWR ( 0xfe, 0x07, 1) 294 295#define VG_SET_EXTENDABLE _IOW ( 0xfe, 0x08, 1) 296#define VG_RENAME _IOW ( 0xfe, 0x09, 1) 297 298/* Since 0.9beta6 */ 299#define VG_CREATE _IOW ( 0xfe, 0x0a, 1) 300 301/* logical volume */ 302#define LV_CREATE _IOW ( 0xfe, 0x20, 1) 303#define LV_REMOVE _IOW ( 0xfe, 0x21, 1) 304 305#define LV_ACTIVATE _IO ( 0xfe, 0x22) 306#define LV_DEACTIVATE _IO ( 0xfe, 0x23) 307 308#define LV_EXTEND _IOW ( 0xfe, 0x24, 1) 309#define LV_REDUCE _IOW ( 0xfe, 0x25, 1) 310 311#define LV_STATUS_BYNAME _IOWR ( 0xfe, 0x26, 1) 312#define LV_STATUS_BYINDEX _IOWR ( 0xfe, 0x27, 1) 313 314#define LV_SET_ACCESS _IOW ( 0xfe, 0x28, 1) 315#define LV_SET_ALLOCATION _IOW ( 0xfe, 0x29, 1) 316#define LV_SET_STATUS _IOW ( 0xfe, 0x2a, 1) 317 318#define LE_REMAP _IOW ( 0xfe, 0x2b, 1) 319 320#define LV_SNAPSHOT_USE_RATE _IOWR ( 0xfe, 0x2c, 1) 321 322#define LV_STATUS_BYDEV _IOWR ( 0xfe, 0x2e, 1) 323 324#define LV_RENAME _IOW ( 0xfe, 0x2f, 1) 325 326#define LV_BMAP _IOWR ( 0xfe, 0x30, 1) 327 328 329/* physical volume */ 330#define PV_STATUS _IOWR ( 0xfe, 0x40, 1) 331#define PV_CHANGE _IOWR ( 0xfe, 0x41, 1) 332#define PV_FLUSH _IOW ( 0xfe, 0x42, 1) 333 334/* physical extent */ 335#define PE_LOCK_UNLOCK _IOW ( 0xfe, 0x50, 1) 336 337/* i/o protocol version */ 338#define LVM_GET_IOP_VERSION _IOR ( 0xfe, 0x98, 1) 339 340#ifdef LVM_TOTAL_RESET 341/* special reset function for testing purposes */ 342#define LVM_RESET _IO ( 0xfe, 0x99) 343#endif 344 345/* lock the logical volume manager */ 346#if LVM_DRIVER_IOP_VERSION > 11 347#define LVM_LOCK_LVM _IO ( 0xfe, 0x9A) 348#else 349/* This is actually the same as _IO ( 0xff, 0x00), oops. Remove for IOP 12+ */ 350#define LVM_LOCK_LVM _IO ( 0xfe, 0x100) 351#endif 352/* END ioctls */ 353 354 355/* 356 * Status flags 357 */ 358/* volume group */ 359#define VG_ACTIVE 0x01 /* vg_status */ 360#define VG_EXPORTED 0x02 /* " */ 361#define VG_EXTENDABLE 0x04 /* " */ 362 363#define VG_READ 0x01 /* vg_access */ 364#define VG_WRITE 0x02 /* " */ 365#define VG_CLUSTERED 0x04 /* " */ 366#define VG_SHARED 0x08 /* " */ 367 368/* logical volume */ 369#define LV_ACTIVE 0x01 /* lv_status */ 370#define LV_SPINDOWN 0x02 /* " */ 371 372#define LV_READ 0x01 /* lv_access */ 373#define LV_WRITE 0x02 /* " */ 374#define LV_SNAPSHOT 0x04 /* " */ 375#define LV_SNAPSHOT_ORG 0x08 /* " */ 376 377#define LV_BADBLOCK_ON 0x01 /* lv_badblock */ 378 379#define LV_STRICT 0x01 /* lv_allocation */ 380#define LV_CONTIGUOUS 0x02 /* " */ 381 382/* physical volume */ 383#define PV_ACTIVE 0x01 /* pv_status */ 384#define PV_ALLOCATABLE 0x02 /* pv_allocatable */ 385 386 387/* misc */ 388#define LVM_SNAPSHOT_DROPPED_SECTOR 1 389 390/* 391 * Structure definitions core/disk follow 392 * 393 * conditional conversion takes place on big endian architectures 394 * in functions * pv_copy_*(), vg_copy_*() and lv_copy_*() 395 * 396 */ 397 398#define NAME_LEN 128 /* don't change!!! */ 399#define UUID_LEN 32 /* don't change!!! */ 400 401/* copy on write tables in disk format */ 402typedef struct lv_COW_table_disk_v1 { 403 uint64_t pv_org_number; 404 uint64_t pv_org_rsector; 405 uint64_t pv_snap_number; 406 uint64_t pv_snap_rsector; 407} lv_COW_table_disk_t; 408 409/* remap physical sector/rdev pairs including hash */ 410typedef struct lv_block_exception_v1 { 411 struct list_head hash; 412 uint32_t rsector_org; 413 kdev_t rdev_org; 414 uint32_t rsector_new; 415 kdev_t rdev_new; 416} lv_block_exception_t; 417 418/* disk stored pe information */ 419typedef struct { 420 uint16_t lv_num; 421 uint16_t le_num; 422} pe_disk_t; 423 424/* disk stored PV, VG, LV and PE size and offset information */ 425typedef struct { 426 uint32_t base; 427 uint32_t size; 428} lvm_disk_data_t; 429 430 431/* 432 * physical volume structures 433 */ 434 435/* core */ 436typedef struct pv_v2 { 437 char id[2]; /* Identifier */ 438 unsigned short version; /* HM lvm version */ 439 lvm_disk_data_t pv_on_disk; 440 lvm_disk_data_t vg_on_disk; 441 lvm_disk_data_t pv_uuidlist_on_disk; 442 lvm_disk_data_t lv_on_disk; 443 lvm_disk_data_t pe_on_disk; 444 char pv_name[NAME_LEN]; 445 char vg_name[NAME_LEN]; 446 char system_id[NAME_LEN]; /* for vgexport/vgimport */ 447 kdev_t pv_dev; 448 uint pv_number; 449 uint pv_status; 450 uint pv_allocatable; 451 uint pv_size; /* HM */ 452 uint lv_cur; 453 uint pe_size; 454 uint pe_total; 455 uint pe_allocated; 456 uint pe_stale; /* for future use */ 457 pe_disk_t *pe; /* HM */ 458 struct block_device *bd; 459 char pv_uuid[UUID_LEN+1]; 460 461#ifndef __KERNEL__ 462 uint32_t pe_start; /* in sectors */ 463#endif 464} pv_t; 465 466 467/* disk */ 468typedef struct pv_disk_v2 { 469 uint8_t id[2]; /* Identifier */ 470 uint16_t version; /* HM lvm version */ 471 lvm_disk_data_t pv_on_disk; 472 lvm_disk_data_t vg_on_disk; 473 lvm_disk_data_t pv_uuidlist_on_disk; 474 lvm_disk_data_t lv_on_disk; 475 lvm_disk_data_t pe_on_disk; 476 uint8_t pv_uuid[NAME_LEN]; 477 uint8_t vg_name[NAME_LEN]; 478 uint8_t system_id[NAME_LEN]; /* for vgexport/vgimport */ 479 uint32_t pv_major; 480 uint32_t pv_number; 481 uint32_t pv_status; 482 uint32_t pv_allocatable; 483 uint32_t pv_size; /* HM */ 484 uint32_t lv_cur; 485 uint32_t pe_size; 486 uint32_t pe_total; 487 uint32_t pe_allocated; 488 489 /* new in struct version 2 */ 490 uint32_t pe_start; /* in sectors */ 491 492} pv_disk_t; 493 494 495/* 496 * Structures for Logical Volume (LV) 497 */ 498 499/* core PE information */ 500typedef struct { 501 kdev_t dev; 502 uint32_t pe; /* to be changed if > 2TB */ 503 uint32_t reads; 504 uint32_t writes; 505} pe_t; 506 507typedef struct { 508 char lv_name[NAME_LEN]; 509 kdev_t old_dev; 510 kdev_t new_dev; 511 uint32_t old_pe; 512 uint32_t new_pe; 513} le_remap_req_t; 514 515typedef struct lv_bmap { 516 uint32_t lv_block; 517 dev_t lv_dev; 518} lv_bmap_t; 519 520/* 521 * Structure Logical Volume (LV) Version 3 522 */ 523 524/* core */ 525typedef struct lv_v5 { 526 char lv_name[NAME_LEN]; 527 char vg_name[NAME_LEN]; 528 uint lv_access; 529 uint lv_status; 530 uint lv_open; /* HM */ 531 kdev_t lv_dev; /* HM */ 532 uint lv_number; /* HM */ 533 uint lv_mirror_copies; /* for future use */ 534 uint lv_recovery; /* " */ 535 uint lv_schedule; /* " */ 536 uint lv_size; 537 pe_t *lv_current_pe; /* HM */ 538 uint lv_current_le; /* for future use */ 539 uint lv_allocated_le; 540 uint lv_stripes; 541 uint lv_stripesize; 542 uint lv_badblock; /* for future use */ 543 uint lv_allocation; 544 uint lv_io_timeout; /* for future use */ 545 uint lv_read_ahead; 546 547 /* delta to version 1 starts here */ 548 struct lv_v5 *lv_snapshot_org; 549 struct lv_v5 *lv_snapshot_prev; 550 struct lv_v5 *lv_snapshot_next; 551 lv_block_exception_t *lv_block_exception; 552 uint lv_remap_ptr; 553 uint lv_remap_end; 554 uint lv_chunk_size; 555 uint lv_snapshot_minor; 556#ifdef __KERNEL__ 557 struct kiobuf *lv_iobuf; 558 struct kiobuf *lv_COW_table_iobuf; 559 struct rw_semaphore lv_lock; 560 struct list_head *lv_snapshot_hash_table; 561 uint32_t lv_snapshot_hash_table_size; 562 uint32_t lv_snapshot_hash_mask; 563 wait_queue_head_t lv_snapshot_wait; 564 int lv_snapshot_use_rate; 565 struct vg_v3 *vg; 566 567 uint lv_allocated_snapshot_le; 568#else 569 char dummy[200]; 570#endif 571} lv_t; 572 573/* disk */ 574typedef struct lv_disk_v3 { 575 uint8_t lv_name[NAME_LEN]; 576 uint8_t vg_name[NAME_LEN]; 577 uint32_t lv_access; 578 uint32_t lv_status; 579 uint32_t lv_open; /* HM */ 580 uint32_t lv_dev; /* HM */ 581 uint32_t lv_number; /* HM */ 582 uint32_t lv_mirror_copies; /* for future use */ 583 uint32_t lv_recovery; /* " */ 584 uint32_t lv_schedule; /* " */ 585 uint32_t lv_size; 586 uint32_t lv_snapshot_minor;/* minor number of original */ 587 uint16_t lv_chunk_size; /* chunk size of snapshot */ 588 uint16_t dummy; 589 uint32_t lv_allocated_le; 590 uint32_t lv_stripes; 591 uint32_t lv_stripesize; 592 uint32_t lv_badblock; /* for future use */ 593 uint32_t lv_allocation; 594 uint32_t lv_io_timeout; /* for future use */ 595 uint32_t lv_read_ahead; /* HM */ 596} lv_disk_t; 597 598/* 599 * Structure Volume Group (VG) Version 1 600 */ 601 602/* core */ 603typedef struct vg_v3 { 604 char vg_name[NAME_LEN]; /* volume group name */ 605 uint vg_number; /* volume group number */ 606 uint vg_access; /* read/write */ 607 uint vg_status; /* active or not */ 608 uint lv_max; /* maximum logical volumes */ 609 uint lv_cur; /* current logical volumes */ 610 uint lv_open; /* open logical volumes */ 611 uint pv_max; /* maximum physical volumes */ 612 uint pv_cur; /* current physical volumes FU */ 613 uint pv_act; /* active physical volumes */ 614 uint dummy; /* was obsolete max_pe_per_pv */ 615 uint vgda; /* volume group descriptor arrays FU */ 616 uint pe_size; /* physical extent size in sectors */ 617 uint pe_total; /* total of physical extents */ 618 uint pe_allocated; /* allocated physical extents */ 619 uint pvg_total; /* physical volume groups FU */ 620 struct proc_dir_entry *proc; 621 pv_t *pv[ABS_MAX_PV + 1]; /* physical volume struct pointers */ 622 lv_t *lv[ABS_MAX_LV + 1]; /* logical volume struct pointers */ 623 char vg_uuid[UUID_LEN+1]; /* volume group UUID */ 624#ifdef __KERNEL__ 625 struct proc_dir_entry *vg_dir_pde; 626 struct proc_dir_entry *lv_subdir_pde; 627 struct proc_dir_entry *pv_subdir_pde; 628#else 629 char dummy1[200]; 630#endif 631} vg_t; 632 633 634/* disk */ 635typedef struct vg_disk_v2 { 636 uint8_t vg_uuid[UUID_LEN]; /* volume group UUID */ 637 uint8_t vg_name_dummy[NAME_LEN-UUID_LEN]; /* rest of v1 VG name */ 638 uint32_t vg_number; /* volume group number */ 639 uint32_t vg_access; /* read/write */ 640 uint32_t vg_status; /* active or not */ 641 uint32_t lv_max; /* maximum logical volumes */ 642 uint32_t lv_cur; /* current logical volumes */ 643 uint32_t lv_open; /* open logical volumes */ 644 uint32_t pv_max; /* maximum physical volumes */ 645 uint32_t pv_cur; /* current physical volumes FU */ 646 uint32_t pv_act; /* active physical volumes */ 647 uint32_t dummy; 648 uint32_t vgda; /* volume group descriptor arrays FU */ 649 uint32_t pe_size; /* physical extent size in sectors */ 650 uint32_t pe_total; /* total of physical extents */ 651 uint32_t pe_allocated; /* allocated physical extents */ 652 uint32_t pvg_total; /* physical volume groups FU */ 653} vg_disk_t; 654 655 656/* 657 * Request structures for ioctls 658 */ 659 660/* Request structure PV_STATUS_BY_NAME... */ 661typedef struct { 662 char pv_name[NAME_LEN]; 663 pv_t *pv; 664} pv_status_req_t, pv_change_req_t; 665 666/* Request structure PV_FLUSH */ 667typedef struct { 668 char pv_name[NAME_LEN]; 669 kdev_t pv_dev; 670} pv_flush_req_t; 671 672 673/* Request structure PE_MOVE */ 674typedef struct { 675 enum { 676 LOCK_PE, UNLOCK_PE 677 } lock; 678 struct { 679 kdev_t lv_dev; 680 kdev_t pv_dev; 681 uint32_t pv_offset; 682 } data; 683} pe_lock_req_t; 684 685 686/* Request structure LV_STATUS_BYNAME */ 687typedef struct { 688 char lv_name[NAME_LEN]; 689 lv_t *lv; 690} lv_status_byname_req_t, lv_req_t; 691 692/* Request structure LV_STATUS_BYINDEX */ 693typedef struct { 694 uint32_t lv_index; 695 lv_t *lv; 696 /* Transfer size because user space and kernel space differ */ 697 ushort size; 698} lv_status_byindex_req_t; 699 700/* Request structure LV_STATUS_BYDEV... */ 701typedef struct { 702 dev_t dev; 703 lv_t *lv; 704} lv_status_bydev_req_t; 705 706 707/* Request structure LV_SNAPSHOT_USE_RATE */ 708typedef struct { 709 int block; 710 int rate; 711} lv_snapshot_use_rate_req_t; 712 713 714 715/* useful inlines */ 716static inline ulong round_up(ulong n, ulong size) { 717 size--; 718 return (n + size) & ~size; 719} 720 721static inline ulong div_up(ulong n, ulong size) { 722 return round_up(n, size) / size; 723} 724 725static int inline LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg_t *vg, lv_t *lv) { 726 return vg->pe_size / lv->lv_chunk_size; 727} 728 729static int inline LVM_GET_COW_TABLE_ENTRIES_PER_PE(vg_t *vg, lv_t *lv) { 730 ulong chunks = vg->pe_size / lv->lv_chunk_size; 731 ulong entry_size = sizeof(lv_COW_table_disk_t); 732 ulong chunk_size = lv->lv_chunk_size * SECTOR_SIZE; 733 ulong entries = (vg->pe_size * SECTOR_SIZE) / 734 (entry_size + chunk_size); 735 736 if(chunks < 2) 737 return 0; 738 739 for(; entries; entries--) 740 if((div_up(entries * entry_size, chunk_size) + entries) <= 741 chunks) 742 break; 743 744 return entries; 745} 746 747 748#endif /* #ifndef _LVM_H_INCLUDE */ 749 750