Re: No LVM in Woody (Was: writing a release announcement)
On Mon, Apr 29, 2002 at 12:58:30AM +0200, Petter Reinholdtsen wrote:
>
> [Patrick Caulfield]
> > LVM does work on SPARC, I have it running here (though build from
> > source rather than the debs) and have set up LVM on sparc64 systems.
>
> Will it work on sparc32 systems as well?
<fx tests it>
Yes it does.
> > Builing lvm-common using the lvm.h file from the latest release
> > should file the compile problem. Also the tools segfaulting should
> > have been fixed a while ago - it was caused by them being build -pg
>
> Submit patches, as my suggested hack defining __ASSEMBLY__ did not
> work.
OK, It's quite a large patch cos the lvm.h file in lvm-common is quite
out-of-date compared with the Sistina release version but this compiles for me
on Intel and SPARC. (attached).
The following patch also fixes bug #139169 in lvm10:
diff -u -r1.12 -r1.13
--- lvmsadc.c 22 Mar 2002 12:23:08 -0000 1.12
+++ lvmsadc.c 10 Apr 2002 21:38:25 -0000 1.13
@@ -150,7 +150,7 @@
LVM_LOCK ( 0);
ret = vg_status_with_pv_and_lv ( vg_name, &vg);
- LVM_LOCK ( 0);
+ LVM_UNLOCK ( 0);
if ( ret == 0) {
for ( l = 0; l < vg->lv_max; l++) {
lv_t *lv = vg->lv[l];
patrick
diff -ru --new-file lvm-common-pjc/liblvm.h lvm-common-1.5.4/liblvm.h
--- lvm-common-pjc/liblvm.h Mon Apr 29 08:42:37 2002
+++ lvm-common-1.5.4/liblvm.h Tue Dec 26 21:58:48 2000
@@ -1,15 +1,12 @@
/*
- * Tools/lib/liblvm.h
+ * tools/lib/liblvm.h
*
- * Copyright (C) 1997 - 2002 Heinz Mauelshagen, Sistina Software
+ * Copyright (C) 1997 - 2000 Heinz Mauelshagen, Sistina Software
*
* March-June 1997
* January 1998
* January,February,July 1999
* February,March 2000
- * March,June 2001
- * October 2001
- * January 2002
*
*
* This LVM library is free software; you can redistribute it and/or
@@ -25,7 +22,7 @@
* You should have received a copy of the GNU Library General Public
* License along with this LVM library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA
+ * MA 02111-1307, USA
*
*/
@@ -35,16 +32,6 @@
* 03/01/1999 - port to libc6
* 07/02/1999 - conditional data conversion macros
* 05/07/1999 - rearanged includes due to 2.3.x changes
- * 05/04/2001 - changed pv_move_pes() and pv_move_pe() prototypes
- * 09/04/2001 - added prototype for pv_get_partitioned_whole
- * 26/06/2001 - fixed pv_get_size() typecast on Alpha
- * 16/01/2001 - added new lvmtab functions
- * lvm_tab_check_free_vg_number and lvm_tab_get_all_vg_numbers
- * 23/10/2001 - added new lvmtab function lvm_tab_check_free_lv_numbers
- * 16/01/2002 - ATARAID support
- * 29/02/2002 - removed wrong PV size maximum error code
- * 11/02/2002 - changed pv_get_size() cast in order to support > 1TB volumes
- * 17/02/2002 - added pv_get_size_ll() for lib compatibility
*
*/
@@ -88,12 +75,13 @@
#include <dirent.h>
#include <stdarg.h>
#include <malloc.h>
-#include <string.h>
+#ifndef __sparc__
+# include <string.h>
+#endif
#include <ctype.h>
#include <time.h>
-#include <limits.h>
#ifdef _G_LSEEK64
-loff_t lseek64 ( unsigned int, unsigned long long, unsigned int);
+int lseek64 ( unsigned int, unsigned long long, unsigned int);
#define llseek lseek64
#else
int llseek ( unsigned int, unsigned long long, unsigned int);
@@ -103,26 +91,15 @@
#include <linux/major.h>
#include <linux/genhd.h>
-#ifdef major
-# undef major
-#endif
-#ifdef minor
-# undef minor
-#endif
#include <lvm.h>
-//#include "lvm_log.h"
-//#include "lvm_config.h"
-
-/* FIXME: get rid of these from lib code */
-#define FALSE 0
-#define TRUE 1
-
-extern struct config_file *config_file;
-
-#define BLKGETSIZE _IO(0x12,96) /* return device size */
+#define SECTOR_SIZE 512
+#define BLKGETSIZE _IO(0x12,96) /* return device size */
#define BLKRASET _IO(0x12,98) /* Set read ahead */
#define EXT2_SUPER_MAGIC 0xEF53
+#ifndef BLOCK_SIZE
+#define BLOCK_SIZE 1024
+#endif
#define LVM_ID "HM" /* Identifier PV (id in pv_t) */
#define EXPORTED "PV_EXP" /* Identifier exported PV (system_id in pv_t) */
@@ -136,39 +113,7 @@
#define LV_MIN_NAME_LEN 5
#define LV_MAX_NAME_LEN 7
#define MIN_PART 1
-#define MAX_PART 64
-
-/* some metadata on the disk need to be aligned */
-#define LVM_VGDA_ALIGN 4096UL
-
-/* base of PV structure in disk partition */
-#define LVM_PV_DISK_BASE 0L
-
-/* size reserved for PV structure on disk */
-#define LVM_PV_DISK_SIZE 1024L
-
-/* base of VG structure in disk partition */
-#define LVM_VG_DISK_BASE round_up(LVM_PV_DISK_BASE + LVM_PV_DISK_SIZE, \
- LVM_VGDA_ALIGN)
-
-/* size reserved for VG structure */
-#define LVM_VG_DISK_SIZE (8 * 512L)
-
-/* name list of physical volumes on disk */
-#define LVM_PV_UUIDLIST_DISK_BASE round_up(LVM_VG_DISK_BASE + \
- LVM_VG_DISK_SIZE, LVM_VGDA_ALIGN)
-
-/* now for the dynamically calculated parts of the VGDA */
-#define LVM_LV_DISK_OFFSET(a, b) ((a)->lv_on_disk.base + sizeof(lv_disk_t) * b)
-
-#define LVM_VGDA_SIZE(pv) ((pv)->pe_on_disk.base + (pv)->pe_on_disk.size)
-
-/* sector maximum based on max ~64k extents or 2TB in SECTORS of 512 byte */
-#define LVM_LV_SIZE_2TB(a) ( ( long long) LVM_PE_T_MAX * (a)->pe_size > ( long long) 4*1024*1024*1024-1 ? ( long long) 4*1024*1024*1024-1 : ( long long) LVM_PE_T_MAX * (a)->pe_size)
-
-#define LVM_PV_SIZE_MAX ( ( long long) (uint32_t) -1)
-
-#define LVM_PE_ALIGN (65536UL / SECTOR_SIZE)
+#define MAX_PART 15
extern int errno;
@@ -178,22 +123,6 @@
extern int opt_d;
#endif
-/* for device classification */
-typedef enum {
- LVM_DEVICE_TYPE_INVALID = -1, /* Unsupported device */
- LVM_DEVICE_TYPE_IDE = 0, /* IDE disk */
- LVM_DEVICE_TYPE_SD, /* SCSI disk */
- LVM_DEVICE_TYPE_MD, /* Multiple Disk driver (SoftRAID) */
- LVM_DEVICE_TYPE_LOOP, /* Loop device */
- LVM_DEVICE_TYPE_DASD, /* DASD disk (IBM S/390, zSeries) */
- LVM_DEVICE_TYPE_DAC960, /* DAC960 */
- LVM_DEVICE_TYPE_NBD, /* Network Block Device */
- LVM_DEVICE_TYPE_COMPAQ_SMART2,/* Compaq SMART2 */
- LVM_DEVICE_TYPE_COMPAQ_CISS, /* Compaq CCISS array */
- LVM_DEVICE_TYPE_UBD, /* User-mode virtual block device */
- LVM_DEVICE_TYPE_ATARAID, /* ATA Raid */
-} lvm_device_type_t;
-
/* for lvm_show_size () */
typedef enum { SHORT, LONG} size_len_t;
@@ -210,7 +139,7 @@
typedef struct {
char *dev_name;
dev_t st_rdev;
- mode_t st_mode;
+ short st_mode;
} dir_cache_t;
/* PE type data layer functions */
@@ -236,7 +165,7 @@
int vg_create_dir_and_group ( vg_t *);
int vg_create_dir_and_group_and_nodes ( vg_t *, int);
void vg_deactivate ( char *);
-int vg_extend ( char *, pv_t *, vg_t *);
+inline int vg_extend ( char *, pv_t *, vg_t *);
int vg_free ( vg_t *, int);
char *vg_name_of_lv ( char *);
int vg_remove ( char *);
@@ -244,12 +173,10 @@
int vg_read ( char *, vg_t **);
int vg_read_from_pv ( char *, vg_t **);
int vg_read_with_pv_and_lv ( char *, vg_t **);
-int vg_reduce ( char *, pv_t *, vg_t *);
+inline int vg_reduce ( char *, pv_t *, vg_t *);
int vg_remove_dir_and_group_and_nodes ( char *);
int vg_set_extendable ( char*);
-void vg_setup_pointers_for_snapshots ( vg_t*);
int vg_clear_extendable ( char*);
-int setup_pe_table(pv_t *p); /* used by the vg_setup_* functions */
int vg_setup_for_create ( char *, vg_t *, pv_t **, int, ulong, ulong);
int vg_setup_for_extend ( char **, int, pv_t **, vg_t *, char **);
int vg_setup_for_merge ( vg_t *, vg_t *);
@@ -273,6 +200,7 @@
int pv_change_all_pv_of_vg ( char *, vg_t *);
int pv_change_all_pv_for_lv_of_vg ( char *, char *, vg_t *);
int pv_check_active ( char *, char *);
+int pv_check_active_in_all_vg ( char *);
int pv_check_free ( pv_t *, ulong, ulong *);
int pv_check_free_contiguous ( pv_t *, ulong, ulong *);
int pv_check_in_vg ( vg_t *, char *);
@@ -285,26 +213,26 @@
int pv_check_volume ( char *, pv_t *);
pv_t *pv_copy_from_disk ( pv_disk_t *);
pv_disk_t *pv_copy_to_disk ( pv_t *);
+char **pv_find_all_pv_names ( void);
kdev_t pv_create_kdev_t ( char *);
char *pv_create_name_from_kdev_t ( kdev_t);
-char **pv_find_all_pv_names ( void);
int pv_find_vg ( char *, char **);
int pv_flush ( char *);
int pv_get_index_by_kdev_t ( vg_t *, kdev_t);
int pv_get_index_by_name ( vg_t *, char *);
kdev_t pv_get_kdev_t_by_number ( vg_t *, int);
-long pv_get_size(char *, struct partition *);
-long long pv_get_size_ll(char *, struct partition *);
-int pv_move_pes ( vg_t*, char*, size_t, char**, int, int,
+int pv_get_size ( char *, struct partition *);
+int pv_move_pes ( vg_t*, char*, char**, int, int,
long*, long*, long*, int, int);
-int pv_move_pe ( vg_t*, char*, size_t, long, long, long, long,
+int pv_move_pe ( vg_t*, char*, long, long, long, long,
int, int, int, int);
int pv_read ( char *, pv_t **, int *);
+int pv_read_already_red ( char *);
int pv_read_pe ( pv_t *, pe_disk_t **);
int pv_read_all_pv ( pv_t ***, int);
int pv_read_all_pv_of_vg ( char *, pv_t ***, int);
int pv_read_all_pe_of_vg ( char *, pe_disk_t ***, int);
-int pv_read_uuidlist ( pv_t *, char **);
+int pv_read_uuidlist ( char *, char **);
int pv_release_pe ( vg_t *, pe_disk_t *, uint *, uint);
int pv_reserve_pe ( pv_t *, pe_disk_t *, uint *, pe_t *, uint, int);
int pv_setup_for_create ( char *, pv_t *, uint);
@@ -322,7 +250,7 @@
int pv_write_uuidlist ( char *, vg_t *);
int pv_write_pe ( char*, pv_t *);
int pv_write_with_pe ( char*, pv_t *);
-int pv_check_partitioned_whole(char *pv_name);
+
/* LV functions */
char *lv_change_vgname ( char *, char *);
@@ -338,10 +266,10 @@
lv_t *lv_copy_from_disk ( lv_disk_t *);
lv_disk_t *lv_copy_to_disk ( lv_t *);
int lv_count_pe ( pv_t *, int);
-int lv_create ( vg_t *, lv_t *, char *);
+inline int lv_create ( vg_t *, lv_t *, char *);
int lv_create_name ( char *, char *, int);
int lv_create_node ( lv_t *);
-int lv_extend ( vg_t *, lv_t *, char *);
+inline int lv_extend ( vg_t *, lv_t *, char *);
int lv_get_index_by_kdev_t ( vg_t *, kdev_t);
int lv_get_index_by_minor ( vg_t *, int);
int lv_get_index_by_name ( vg_t *, char *);
@@ -356,9 +284,9 @@
int lv_read_COW_table ( vg_t * vg, lv_t * lv);
int lv_read_with_pe ( char *, char *, lv_t **);
int lv_read_all_lv ( char *, lv_t ***, int);
-int lv_reduce ( vg_t *, lv_t *, char *);
+inline int lv_reduce ( vg_t *, lv_t *, char *);
int lv_release ( vg_t *, char *);
-int lv_remove ( vg_t *, lv_t *, char *);
+inline int lv_remove ( vg_t *, lv_t *, char *);
int lv_rename ( char *, lv_t *);
int lv_setup_for_create ( char *, vg_t **, char *, int *,
uint, uint, uint, uint, uint, uint, char **);
@@ -380,19 +308,9 @@
/* print debug info on stdout */
-#ifdef DEBUG
-void lvm_debug(const char *fmt, ...);
-void lvm_debug_enter(const char *fmt, ...);
-void lvm_debug_leave(const char *fmt, ...);
-
-#define debug(fmt, args...) lvm_debug(fmt, ## args)
-#define debug_enter(fmt, args...) lvm_debug_enter(fmt, ## args)
-#define debug_leave(fmt, args...) lvm_debug_leave(fmt, ## args)
-#else
-#define debug(fmt, args...)
-#define debug_enter(fmt, args...)
-#define debug_leave(fmt, args...)
-#endif
+void debug ( const char *, ...);
+void debug_enter ( const char *, ...);
+void debug_leave ( const char *, ...);
/* generate nice KB/MB/... strings */
char *lvm_show_size ( unsigned long long, size_len_t);
@@ -412,14 +330,12 @@
/* LVM locking / interrupt masking etc. */
int lvm_check_chars ( char*);
int lvm_check_dev ( struct stat*, int);
-int lvm_check_devfs ();
int lvm_check_extended_partition ( dev_t);
int lvm_check_kernel_lvmtab_consistency ( void);
int lvm_check_partitioned_dev ( dev_t);
int lvm_check_whole_disk_dev ( dev_t);
void lvm_check_special ( void);
long lvm_check_number ( char *, int);
-long long lvm_check_number_ll ( char *, int);
int lvm_check_uuid ( char*);
unsigned char *lvm_create_uuid ( int);
char *lvm_show_uuid ( char *);
@@ -428,7 +344,6 @@
void lvm_dont_interrupt ( int);
int lvm_get_col_numbers ( char *, long **);
int lvm_get_iop_version ( void);
-void lvm_init(int argc, char **argv);
void lvm_interrupt ( void);
int lvm_lock ( void);
int lvm_partition_count ( dev_t);
@@ -440,11 +355,7 @@
/* LVMTAB based functions */
int lvm_tab_read ( char **, int *);
int lvm_tab_write ( char *, int);
-int lvm_tab_check_free_lv_number ( lv_t *);
-int lvm_tab_check_free_lv_numbers ( vg_t *);
-int lvm_tab_check_free_vg_number ( vg_t *);
int lvm_tab_create ( void);
-int *lvm_tab_get_all_vg_numbers ( void);
int lvm_tab_get_free_vg_number ( void);
int lvm_tab_lv_check_exist ( char *);
int lvm_tab_lv_read_by_name ( char *, char*, lv_t **);
@@ -456,44 +367,6 @@
int lvm_tab_get_free_blk_dev ( kdev_t **);
char **lvm_tab_vg_check_exist_all_vg ( void);
-/* core <-> disk conversion macros */
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define LVM_TO_CORE16(x) ( \
- ((uint16_t)((((uint16_t)(x) & 0x00FFU) << 8) | \
- (((uint16_t)(x) & 0xFF00U) >> 8))))
-
-#define LVM_TO_DISK16(x) LVM_TO_CORE16(x)
-
-#define LVM_TO_CORE32(x) ( \
- ((uint32_t)((((uint32_t)(x) & 0x000000FFU) << 24) | \
- (((uint32_t)(x) & 0x0000FF00U) << 8) | \
- (((uint32_t)(x) & 0x00FF0000U) >> 8) | \
- (((uint32_t)(x) & 0xFF000000U) >> 24))))
-
-#define LVM_TO_DISK32(x) LVM_TO_CORE32(x)
-
-#define LVM_TO_CORE64(x) \
- ((uint64_t)((((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \
- (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \
- (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \
- (((uint64_t)(x) & 0x00000000FF000000ULL) << 8) | \
- (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8) | \
- (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \
- (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \
- (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56)))
-
-#define LVM_TO_DISK64(x) LVM_TO_CORE64(x)
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
-#define LVM_TO_CORE16(x) x
-#define LVM_TO_DISK16(x) x
-#define LVM_TO_CORE32(x) x
-#define LVM_TO_DISK32(x) x
-#define LVM_TO_CORE64(x) x
-#define LVM_TO_DISK64(x) x
-#else
-#error "__BYTE_ORDER must be defined as __LITTLE_ENDIAN or __BIG_ENDIAN"
-#endif /* #if __BYTE_ORDER == __BIG_ENDIAN */
-
/* return codes */
#define LVM_VG_CFGBACKUP_NO_DIFF 100
@@ -773,7 +646,7 @@
#define LVM_EVG_READ_WITH_PV_AND_LV_PV_CUR 367
#define LVM_EVG_RENAME_OPEN 368
#define LVM_EVG_SETUP_FOR_CREATE_MALLOC 369
-#define LVM_EVG_SETUP_FOR_CREATE_PV_SIZE_MIN 370
+#define LVM_EVG_SETUP_FOR_CREATE_PV_SIZE 370
#define LVM_EVG_SETUP_FOR_CREATE_VG_NUMBER 371
#define LVM_EVG_SETUP_FOR_EXTEND_MALLOC 372
#define LVM_EVG_SETUP_FOR_EXTEND_MAX_PV 373
@@ -808,53 +681,5 @@
#define LVM_EVG_WRITE_LSEEK 402
#define LVM_EVG_WRITE_OPEN 403
#define LVM_EVG_WRITE_WRITE 404
-#define LVM_ELV_PV_CREATE_NAME_FROM_KDEV_T 405
-#define LVM_EPV_FLUSH_STAT 406
-#define LVM_MAX_ERROR 407
-
-
-/*
- * useful inlines
- */
-static inline unsigned long sectors_to_k(unsigned long sect)
-{
- if(SECTOR_SIZE > 1024) {
- return sect * (SECTOR_SIZE / 1024);
- }
-
- return sect / (1024 / SECTOR_SIZE);
-}
-
-static inline unsigned long get_pe_offset(ulong p, pv_t *pv)
-{
- return pv->pe_start + (p * pv->pe_size);
-}
-
-static inline ulong get_pe_from_offset(ulong offset, pv_t *pv)
-{
- return (offset - pv->pe_start) / pv->pe_size;
-}
-
-static inline int lvm_pv_check_version(pv_t *pv)
-{
- return (pv->version == 2 || pv->version == LVM_STRUCT_VERSION);
-}
-
-/* find next unused PV number */
-static inline int _find_unused_pv_number ( vg_t *vg) {
- int p, u;
- pv_t *pp;
-
- for ( u = 1; u <= vg->pv_max; u++) {
- for ( p = 0; p < vg->pv_max; p++) {
- pp = vg->pv[p];
- if ( pp == NULL) continue;
- if ( pp->pv_number == u) break;
- }
- if ( p == vg->pv_max) return u;
- }
-
- return -1;
-}
#endif /* #ifndef _LIBLVM_H_INCLUDE */
diff -ru --new-file lvm-common-pjc/lvm.h lvm-common-1.5.4/lvm.h
--- lvm-common-pjc/lvm.h Mon Apr 29 08:40:20 2002
+++ lvm-common-1.5.4/lvm.h Mon Apr 15 19:14:25 2002
@@ -3,28 +3,27 @@
* kernel/lvm.h
* tools/lib/lvm.h
*
- * Copyright (C) 1997 - 2001 Heinz Mauelshagen, Sistina Software
+ * Copyright (C) 1997 - 2000 Heinz Mauelshagen, Sistina Software
*
* February-November 1997
* May-July 1998
* January-March,July,September,October,Dezember 1999
* January,February,July,November 2000
- * January-March,June,July 2001
*
* lvm is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
- *
+ *
* lvm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Boston, MA 02111-1307, USA.
*
*/
@@ -52,26 +51,12 @@
* 08/12/1999 - changed LVM_LV_SIZE_MAX macro to reflect current 1TB limit
* 01/01/2000 - extended lv_v2 core structure by wait_queue member
* 12/02/2000 - integrated Andrea Arcagnelli's snapshot work
- * 18/02/2000 - seperated user and kernel space parts by
+ * 18/02/2000 - seperated user and kernel space parts by
* #ifdef them with __KERNEL__
* 08/03/2000 - implemented cluster/shared bits for vg_access
* 26/06/2000 - implemented snapshot persistency and resizing support
* 02/11/2000 - added hash table size member to lv structure
* 12/11/2000 - removed unneeded timestamp definitions
- * 24/12/2000 - removed LVM_TO_{CORE,DISK}*, use cpu_{from, to}_le*
- * instead - Christoph Hellwig
- * 22/01/2001 - Change ulong to uint32_t
- * 14/02/2001 - changed LVM_SNAPSHOT_MIN_CHUNK to 1 page
- * 20/02/2001 - incremented IOP version to 11 because of incompatible
- * change in VG activation (in order to support devfs better)
- * 01/03/2001 - Revert to IOP10 and add VG_CREATE_OLD call for compatibility
- * 08/03/2001 - new lv_t (in core) version number 5: changed page member
- * to (struct kiobuf *) to use for COW exception table io
- * 26/03/2001 - changed lv_v4 to lv_v5 in structure definition (HM)
- * 21/06/2001 - changed BLOCK_SIZE back to 1024 for non S/390
- * 22/06/2001 - added Andreas Dilger's PE on 4k boundary alignment enhancements
- * 19/07/2001 - added rwsem compatibility macros for 2.2 kernels
- * 13/11/2001 - reduced userspace inclusion of kernel headers to a minimum
*
*/
@@ -79,12 +64,10 @@
#ifndef _LVM_H_INCLUDE
#define _LVM_H_INCLUDE
-#define LVM_RELEASE_NAME "1.0.3"
-#define LVM_RELEASE_DATE "19/02/2002"
-
-#define _LVM_KERNEL_H_VERSION "LVM "LVM_RELEASE_NAME" ("LVM_RELEASE_DATE")"
+#define _LVM_KERNEL_H_VERSION "LVM 0.9 (13/11/2000)"
#include <linux/version.h>
+#include <endian.h>
/*
* preprocessor definitions
@@ -93,7 +76,7 @@
#define LVM_TOTAL_RESET
#ifdef __KERNEL__
-#undef LVM_HD_NAME /* display nice names in /proc/partitions */
+#define LVM_HD_NAME /* display nice names in /proc/partitions */
/* lots of debugging output (see driver source)
#define DEBUG_LVM_GET_INFO
@@ -104,26 +87,34 @@
#define DEBUG_READ
#define DEBUG_GENDISK
#define DEBUG_VG_CREATE
- #define DEBUG_DEVICE
+ #define DEBUG_LVM_BLK_OPEN
#define DEBUG_KFREE
*/
+#endif /* #ifdef __KERNEL__ */
+
+/*#ifndef __KERNEL__
+#if !defined(__s390__) && !defined(powerpc)
+#define __KERNEL__
+#endif */
+/* Avoid missing types on platforms where <asm/types.h> already was included
+ and where the u64 type is needed. This is a ugly hack and should be
+ removed if possible. */
+
+#define u64 __u64
#include <linux/kdev_t.h>
#include <linux/list.h>
-#include <asm/types.h>
-#include <linux/major.h>
+
+#undef u64
+/*
+#undef __KERNEL__
#else
-/* This prevents the need to include <linux/list.h> which
- causes problems on some platforms. It's not nice but then
- neither is the alternative. */
-struct list_head {
- struct list_head *next, *prev;
-};
-#define __KERNEL__
#include <linux/kdev_t.h>
-#undef __KERNEL__
-#endif /* #ifndef __KERNEL__ */
+#include <linux/list.h>
+#endif */ /* #ifndef __KERNEL__ */
+#include <asm/types.h>
+#include <linux/major.h>
#ifdef __KERNEL__
#if LINUX_VERSION_CODE >= KERNEL_VERSION ( 2, 3 ,0)
@@ -135,17 +126,6 @@
#include <asm/semaphore.h>
#endif /* #ifdef __KERNEL__ */
-#if LINUX_VERSION_CODE < KERNEL_VERSION ( 2, 3 ,0)
-/* Compatibility macros for 2.2 */
-#define rw_semaphore semaphore
-#define init_rwsem init_MUTEX
-#define down_read down
-#define down_write down
-#define up_read up
-#define up_write up
-#define DECLARE_RWSEM DECLARE_MUTEX
-#endif
-
#include <asm/page.h>
#if !defined ( LVM_BLK_MAJOR) || !defined ( LVM_CHAR_MAJOR)
@@ -156,7 +136,7 @@
#undef BLOCK_SIZE
#endif
-#ifdef CONFIG_ARCH_S390
+#ifdef CONFIG_ARCH_S390
#define BLOCK_SIZE 4096
#else
#define BLOCK_SIZE 1024
@@ -166,11 +146,31 @@
#define SECTOR_SIZE 512
#endif
-/* structure version */
-#define LVM_STRUCT_VERSION 1
+#define LVM_STRUCT_VERSION 1 /* structure version */
#define LVM_DIR_PREFIX "/dev/"
+#ifndef min
+#define min(a,b) (((a)<(b))?(a):(b))
+#endif
+#ifndef max
+#define max(a,b) (((a)>(b))?(a):(b))
+#endif
+
+/* set the default structure version */
+#if ( LVM_STRUCT_VERSION == 1)
+#define pv_t pv_v2_t
+#define lv_t lv_v4_t
+#define vg_t vg_v3_t
+#define pv_disk_t pv_disk_v2_t
+#define lv_disk_t lv_disk_v3_t
+#define vg_disk_t vg_disk_v2_t
+#define lv_block_exception_t lv_block_exception_v1_t
+#define lv_COW_table_disk_t lv_COW_table_disk_v1_t
+#endif
+
+
+
/*
* i/o protocol version
*
@@ -230,13 +230,15 @@
*
* 1K volume group structure ~200 byte
*
+ * 5K time stamp structure ~
+ *
* 6K namelist of physical volumes 128 byte each
*
- * 6k + n * ~300byte n logical volume structures ~300 byte each
+ * 6k + n * 128byte n logical volume structures ~300 byte each
*
- * + m * 4byte m physical extent alloc. structs 4 byte each
+ * + m * 328byte m physical extent alloc. structs 4 byte each
*
- * End of disk - first physical extent typically 4 megabyte
+ * End of disk - first physical extent typical 4 megabyte
* PE total *
* PE size
*
@@ -244,11 +246,40 @@
*/
/* DONT TOUCH THESE !!! */
+/* base of PV structure in disk partition */
+#define LVM_PV_DISK_BASE 0L
+/* size reserved for PV structure on disk */
+#define LVM_PV_DISK_SIZE 1024L
+/* base of VG structure in disk partition */
+#define LVM_VG_DISK_BASE LVM_PV_DISK_SIZE
-
-
+/* size reserved for VG structure */
+#define LVM_VG_DISK_SIZE ( 9 * 512L)
+
+/* size reserved for timekeeping */
+#define LVM_TIMESTAMP_DISK_BASE ( LVM_VG_DISK_BASE + LVM_VG_DISK_SIZE)
+#define LVM_TIMESTAMP_DISK_SIZE 512L /* reserved for timekeeping */
+
+/* name list of physical volumes on disk */
+#define LVM_PV_UUIDLIST_DISK_BASE ( LVM_TIMESTAMP_DISK_BASE + \
+ LVM_TIMESTAMP_DISK_SIZE)
+
+/* now for the dynamically calculated parts of the VGDA */
+#define LVM_LV_DISK_OFFSET(a, b) ( (a)->lv_on_disk.base + \
+ sizeof ( lv_disk_t) * b)
+#define LVM_DISK_SIZE(pv) ( (pv)->pe_on_disk.base + \
+ (pv)->pe_on_disk.size)
+#define LVM_PE_DISK_OFFSET(pe, pv) ( pe * pv->pe_size + \
+ ( LVM_DISK_SIZE ( pv) / SECTOR_SIZE))
+#define LVM_PE_ON_DISK_BASE(pv) \
+ { int rest; \
+ pv->pe_on_disk.base = pv->lv_on_disk.base + pv->lv_on_disk.size; \
+ if ( ( rest = pv->pe_on_disk.base % SECTOR_SIZE) != 0) \
+ pv->pe_on_disk.base += ( SECTOR_SIZE - rest); \
+ }
+/* END default disk spaces and offsets for PVs */
/*
@@ -280,9 +311,8 @@
#define LVM_MAX_STRIPES 128 /* max # of stripes */
#define LVM_MAX_SIZE ( 1024LU * 1024 / SECTOR_SIZE * 1024 * 1024) /* 1TB[sectors] */
#define LVM_MAX_MIRRORS 2 /* future use */
-#define LVM_MIN_READ_AHEAD 0 /* minimum read ahead sectors */
-#define LVM_DEFAULT_READ_AHEAD 1024 /* sectors for 512k scsi segments */
-#define LVM_MAX_READ_AHEAD 10000 /* maximum read ahead sectors */
+#define LVM_MIN_READ_AHEAD 2 /* minimum read ahead sectors */
+#define LVM_MAX_READ_AHEAD 120 /* maximum read ahead sectors */
#define LVM_MAX_LV_IO_TIMEOUT 60 /* seconds I/O timeout (future use) */
#define LVM_PARTITION 0xfe /* LVM partition id */
#define LVM_NEW_PARTITION 0x8e /* new LVM partition id (10/09/1999) */
@@ -290,18 +320,76 @@
#define LVM_SNAPSHOT_MAX_CHUNK 1024 /* 1024 KB */
#define LVM_SNAPSHOT_DEF_CHUNK 64 /* 64 KB */
-#define LVM_SNAPSHOT_MIN_CHUNK (PAGE_SIZE/1024) /* 4 or 8 KB */
+#define LVM_SNAPSHOT_MIN_CHUNK 1 /* 1 KB */
#define UNDEF -1
+#define FALSE 0
+#define TRUE 1
+
+
+#define LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg, lv) ( \
+ vg->pe_size / lv->lv_chunk_size)
+
+#define LVM_GET_COW_TABLE_ENTRIES_PER_PE(vg, lv) ( \
+{ \
+ int COW_table_entries_per_PE; \
+ int COW_table_chunks_per_PE; \
+\
+ COW_table_entries_per_PE = LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg, lv); \
+ COW_table_chunks_per_PE = ( COW_table_entries_per_PE * sizeof(lv_COW_table_disk_t) / SECTOR_SIZE + lv->lv_chunk_size - 1) / lv->lv_chunk_size; \
+ COW_table_entries_per_PE - COW_table_chunks_per_PE;})
+
+
+/* to disk and to core data conversion macros */
+#if __BYTE_ORDER == __BIG_ENDIAN
+
+#define LVM_TO_CORE16(x) ( \
+ ((uint16_t)((((uint16_t)(x) & 0x00FFU) << 8) | \
+ (((uint16_t)(x) & 0xFF00U) >> 8))))
+
+#define LVM_TO_DISK16(x) LVM_TO_CORE16(x)
+
+#define LVM_TO_CORE32(x) ( \
+ ((uint32_t)((((uint32_t)(x) & 0x000000FFU) << 24) | \
+ (((uint32_t)(x) & 0x0000FF00U) << 8))) \
+ (((uint32_t)(x) & 0x00FF0000U) >> 8))) \
+ (((uint32_t)(x) & 0xFF000000U) >> 24))))
+
+#define LVM_TO_DISK32(x) LVM_TO_CORE32(x)
+
+#define LVM_TO_CORE64(x) \
+ ((uint64_t)((((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \
+ (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \
+ (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \
+ (((uint64_t)(x) & 0x00000000FF000000ULL) << 8) | \
+ (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8) | \
+ (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \
+ (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \
+ (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56)))
+
+#define LVM_TO_DISK64(x) LVM_TO_CORE64(x)
+
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+
+#define LVM_TO_CORE16(x) x
+#define LVM_TO_DISK16(x) x
+#define LVM_TO_CORE32(x) x
+#define LVM_TO_DISK32(x) x
+#define LVM_TO_CORE64(x) x
+#define LVM_TO_DISK64(x) x
+
+#else
+
+#error "__BYTE_ORDER must be defined as __LITTLE_ENDIAN or __BIG_ENDIAN"
+
+#endif /* #if __BYTE_ORDER == __BIG_ENDIAN */
+
/*
* ioctls
- * FIXME: the last parameter to _IO{W,R,WR} is a data type. The macro will
- * expand this using sizeof(), so putting "1" there is misleading
- * because sizeof(1) = sizeof(int) = sizeof(2) = 4 on a 32-bit machine!
*/
/* volume group */
-#define VG_CREATE_OLD _IOW ( 0xfe, 0x00, 1)
+#define VG_CREATE _IOW ( 0xfe, 0x00, 1)
#define VG_REMOVE _IOW ( 0xfe, 0x01, 1)
#define VG_EXTEND _IOW ( 0xfe, 0x03, 1)
@@ -314,8 +402,6 @@
#define VG_SET_EXTENDABLE _IOW ( 0xfe, 0x08, 1)
#define VG_RENAME _IOW ( 0xfe, 0x09, 1)
-/* Since 0.9beta6 */
-#define VG_CREATE _IOW ( 0xfe, 0x0a, 1)
/* logical volume */
#define LV_CREATE _IOW ( 0xfe, 0x20, 1)
@@ -362,12 +448,7 @@
#endif
/* lock the logical volume manager */
-#if LVM_DRIVER_IOP_VERSION > 11
-#define LVM_LOCK_LVM _IO ( 0xfe, 0x9A)
-#else
-/* This is actually the same as _IO ( 0xff, 0x00), oops. Remove for IOP 12+ */
#define LVM_LOCK_LVM _IO ( 0xfe, 0x100)
-#endif
/* END ioctls */
@@ -403,9 +484,6 @@
#define PV_ALLOCATABLE 0x02 /* pv_allocatable */
-/* misc */
-#define LVM_SNAPSHOT_DROPPED_SECTOR 1
-
/*
* Structure definitions core/disk follow
*
@@ -418,21 +496,21 @@
#define UUID_LEN 32 /* don't change!!! */
/* copy on write tables in disk format */
-typedef struct lv_COW_table_disk_v1 {
+typedef struct {
uint64_t pv_org_number;
uint64_t pv_org_rsector;
uint64_t pv_snap_number;
uint64_t pv_snap_rsector;
-} lv_COW_table_disk_t;
+} lv_COW_table_disk_v1_t;
/* remap physical sector/rdev pairs including hash */
-typedef struct lv_block_exception_v1 {
+typedef struct {
struct list_head hash;
- uint32_t rsector_org;
- kdev_t rdev_org;
- uint32_t rsector_new;
- kdev_t rdev_new;
-} lv_block_exception_t;
+ ulong rsector_org;
+ kdev_t rdev_org;
+ ulong rsector_new;
+ kdev_t rdev_new;
+} lv_block_exception_v1_t;
/* disk stored pe information */
typedef struct {
@@ -448,11 +526,37 @@
/*
- * physical volume structures
+ * Structure Physical Volume (PV) Version 1
*/
/* core */
-typedef struct pv_v2 {
+typedef struct {
+ char id[2]; /* Identifier */
+ unsigned short version; /* HM lvm version */
+ lvm_disk_data_t pv_on_disk;
+ lvm_disk_data_t vg_on_disk;
+ lvm_disk_data_t pv_namelist_on_disk;
+ lvm_disk_data_t lv_on_disk;
+ lvm_disk_data_t pe_on_disk;
+ char pv_name[NAME_LEN];
+ char vg_name[NAME_LEN];
+ char system_id[NAME_LEN]; /* for vgexport/vgimport */
+ kdev_t pv_dev;
+ uint pv_number;
+ uint pv_status;
+ uint pv_allocatable;
+ uint pv_size; /* HM */
+ uint lv_cur;
+ uint pe_size;
+ uint pe_total;
+ uint pe_allocated;
+ uint pe_stale; /* for future use */
+ pe_disk_t *pe; /* HM */
+ struct inode *inode; /* HM */
+} pv_v1_t;
+
+/* core */
+typedef struct {
char id[2]; /* Identifier */
unsigned short version; /* HM lvm version */
lvm_disk_data_t pv_on_disk;
@@ -474,17 +578,36 @@
uint pe_allocated;
uint pe_stale; /* for future use */
pe_disk_t *pe; /* HM */
- struct block_device *bd;
+ struct inode *inode; /* HM */
char pv_uuid[UUID_LEN+1];
+} pv_v2_t;
-#ifndef __KERNEL__
- uint32_t pe_start; /* in sectors */
-#endif
-} pv_t;
+/* disk */
+typedef struct {
+ uint8_t id[2]; /* Identifier */
+ uint16_t version; /* HM lvm version */
+ lvm_disk_data_t pv_on_disk;
+ lvm_disk_data_t vg_on_disk;
+ lvm_disk_data_t pv_namelist_on_disk;
+ lvm_disk_data_t lv_on_disk;
+ lvm_disk_data_t pe_on_disk;
+ uint8_t pv_name[NAME_LEN];
+ uint8_t vg_name[NAME_LEN];
+ uint8_t system_id[NAME_LEN]; /* for vgexport/vgimport */
+ uint32_t pv_major;
+ uint32_t pv_number;
+ uint32_t pv_status;
+ uint32_t pv_allocatable;
+ uint32_t pv_size; /* HM */
+ uint32_t lv_cur;
+ uint32_t pe_size;
+ uint32_t pe_total;
+ uint32_t pe_allocated;
+} pv_disk_v1_t;
/* disk */
-typedef struct pv_disk_v2 {
+typedef struct {
uint8_t id[2]; /* Identifier */
uint16_t version; /* HM lvm version */
lvm_disk_data_t pv_on_disk;
@@ -504,11 +627,7 @@
uint32_t pe_size;
uint32_t pe_total;
uint32_t pe_allocated;
-
- /* new in struct version 2 */
- uint32_t pe_start; /* in sectors */
-
-} pv_disk_t;
+} pv_disk_v2_t;
/*
@@ -518,21 +637,21 @@
/* core PE information */
typedef struct {
kdev_t dev;
- uint32_t pe; /* to be changed if > 2TB */
- uint32_t reads;
- uint32_t writes;
+ ulong pe; /* to be changed if > 2TB */
+ ulong reads;
+ ulong writes;
} pe_t;
typedef struct {
char lv_name[NAME_LEN];
kdev_t old_dev;
kdev_t new_dev;
- uint32_t old_pe;
- uint32_t new_pe;
+ ulong old_pe;
+ ulong new_pe;
} le_remap_req_t;
typedef struct lv_bmap {
- uint32_t lv_block;
+ ulong lv_block;
dev_t lv_dev;
} lv_bmap_t;
@@ -541,7 +660,7 @@
*/
/* core */
-typedef struct lv_v5 {
+typedef struct lv_v4 {
char lv_name[NAME_LEN];
char vg_name[NAME_LEN];
uint lv_access;
@@ -564,9 +683,9 @@
uint lv_read_ahead;
/* delta to version 1 starts here */
- struct lv_v5 *lv_snapshot_org;
- struct lv_v5 *lv_snapshot_prev;
- struct lv_v5 *lv_snapshot_next;
+ struct lv_v4 *lv_snapshot_org;
+ struct lv_v4 *lv_snapshot_prev;
+ struct lv_v4 *lv_snapshot_next;
lv_block_exception_t *lv_block_exception;
uint lv_remap_ptr;
uint lv_remap_end;
@@ -574,30 +693,25 @@
uint lv_snapshot_minor;
#ifdef __KERNEL__
struct kiobuf *lv_iobuf;
- struct kiobuf *lv_COW_table_iobuf;
- struct rw_semaphore lv_lock;
+ struct semaphore lv_snapshot_sem;
struct list_head *lv_snapshot_hash_table;
- uint32_t lv_snapshot_hash_table_size;
- uint32_t lv_snapshot_hash_mask;
+ ulong lv_snapshot_hash_table_size;
+ ulong lv_snapshot_hash_mask;
+ struct page *lv_COW_table_page;
#if LINUX_VERSION_CODE > KERNEL_VERSION ( 2, 3, 0)
wait_queue_head_t lv_snapshot_wait;
#else
struct wait_queue *lv_snapshot_wait;
#endif
int lv_snapshot_use_rate;
- struct vg_v3 *vg;
-
- uint lv_allocated_snapshot_le;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
- struct buffer_head **bheads;
-#endif
+ void *vg;
#else
char dummy[200];
#endif
-} lv_t;
+} lv_v4_t;
/* disk */
-typedef struct lv_disk_v3 {
+typedef struct {
uint8_t lv_name[NAME_LEN];
uint8_t vg_name[NAME_LEN];
uint32_t lv_access;
@@ -619,14 +733,36 @@
uint32_t lv_allocation;
uint32_t lv_io_timeout; /* for future use */
uint32_t lv_read_ahead; /* HM */
-} lv_disk_t;
+} lv_disk_v3_t;
/*
* Structure Volume Group (VG) Version 1
*/
/* core */
-typedef struct vg_v3 {
+typedef struct {
+ char vg_name[NAME_LEN]; /* volume group name */
+ uint vg_number; /* volume group number */
+ uint vg_access; /* read/write */
+ uint vg_status; /* active or not */
+ uint lv_max; /* maximum logical volumes */
+ uint lv_cur; /* current logical volumes */
+ uint lv_open; /* open logical volumes */
+ uint pv_max; /* maximum physical volumes */
+ uint pv_cur; /* current physical volumes FU */
+ uint pv_act; /* active physical volumes */
+ uint dummy; /* was obsolete max_pe_per_pv */
+ uint vgda; /* volume group descriptor arrays FU */
+ uint pe_size; /* physical extent size in sectors */
+ uint pe_total; /* total of physical extents */
+ uint pe_allocated; /* allocated physical extents */
+ uint pvg_total; /* physical volume groups FU */
+ struct proc_dir_entry *proc;
+ pv_t *pv[ABS_MAX_PV + 1]; /* physical volume struct pointers */
+ lv_t *lv[ABS_MAX_LV + 1]; /* logical volume struct pointers */
+} vg_v1_t;
+
+typedef struct {
char vg_name[NAME_LEN]; /* volume group name */
uint vg_number; /* volume group number */
uint vg_access; /* read/write */
@@ -654,11 +790,30 @@
#else
char dummy1[200];
#endif
-} vg_t;
+} vg_v3_t;
/* disk */
-typedef struct vg_disk_v2 {
+typedef struct {
+ uint8_t vg_name[NAME_LEN]; /* volume group name */
+ uint32_t vg_number; /* volume group number */
+ uint32_t vg_access; /* read/write */
+ uint32_t vg_status; /* active or not */
+ uint32_t lv_max; /* maximum logical volumes */
+ uint32_t lv_cur; /* current logical volumes */
+ uint32_t lv_open; /* open logical volumes */
+ uint32_t pv_max; /* maximum physical volumes */
+ uint32_t pv_cur; /* current physical volumes FU */
+ uint32_t pv_act; /* active physical volumes */
+ uint32_t dummy;
+ uint32_t vgda; /* volume group descriptor arrays FU */
+ uint32_t pe_size; /* physical extent size in sectors */
+ uint32_t pe_total; /* total of physical extents */
+ uint32_t pe_allocated; /* allocated physical extents */
+ uint32_t pvg_total; /* physical volume groups FU */
+} vg_disk_v1_t;
+
+typedef struct {
uint8_t vg_uuid[UUID_LEN]; /* volume group UUID */
uint8_t vg_name_dummy[NAME_LEN-UUID_LEN]; /* rest of v1 VG name */
uint32_t vg_number; /* volume group number */
@@ -676,7 +831,7 @@
uint32_t pe_total; /* total of physical extents */
uint32_t pe_allocated; /* allocated physical extents */
uint32_t pvg_total; /* physical volume groups FU */
-} vg_disk_t;
+} vg_disk_v2_t;
/*
@@ -704,7 +859,7 @@
struct {
kdev_t lv_dev;
kdev_t pv_dev;
- uint32_t pv_offset;
+ ulong pv_offset;
} data;
} pe_lock_req_t;
@@ -717,7 +872,7 @@
/* Request structure LV_STATUS_BYINDEX */
typedef struct {
- uint32_t lv_index;
+ ulong lv_index;
lv_t *lv;
/* Transfer size because user space and kernel space differ */
ushort size;
@@ -726,7 +881,7 @@
/* Request structure LV_STATUS_BYDEV... */
typedef struct {
dev_t dev;
- lv_t *lv;
+ pv_t *lv;
} lv_status_bydev_req_t;
@@ -736,41 +891,4 @@
int rate;
} lv_snapshot_use_rate_req_t;
-
-
-/* useful inlines */
-static inline ulong round_up(ulong n, ulong size) {
- size--;
- return (n + size) & ~size;
-}
-
-static inline ulong div_up(ulong n, ulong size) {
- return round_up(n, size) / size;
-}
-
-/* FIXME: nasty capital letters */
-static int inline LVM_GET_COW_TABLE_CHUNKS_PER_PE(vg_t *vg, lv_t *lv) {
- return vg->pe_size / lv->lv_chunk_size;
-}
-
-static int inline LVM_GET_COW_TABLE_ENTRIES_PER_PE(vg_t *vg, lv_t *lv) {
- ulong chunks = vg->pe_size / lv->lv_chunk_size;
- ulong entry_size = sizeof(lv_COW_table_disk_t);
- ulong chunk_size = lv->lv_chunk_size * SECTOR_SIZE;
- ulong entries = (vg->pe_size * SECTOR_SIZE) /
- (entry_size + chunk_size);
-
- if(chunks < 2)
- return 0;
-
- for(; entries; entries--)
- if((div_up(entries * entry_size, chunk_size) + entries) <=
- chunks)
- break;
-
- return entries;
-}
-
-
#endif /* #ifndef _LVM_H_INCLUDE */
-
Reply to: