⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evms_lvm.h

📁 unxi下共享内存的使用
💻 H
字号:
/* -*- linux-c -*- *//* *   Copyright (c) International Business Machines  Corp., 2000 * *   This program 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 of the License, or  *   (at your option) any later version. *  *   This program 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 this program;  if not, write to the Free Software  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//* * linux/include/linux/evms_lvm.h * * EVMS LVM VGE kernel header file */#ifndef __EVMS_LVM_H__#define __EVMS_LVM_H__#define EVMS_LVM_VERSION_MAJOR	1#define EVMS_LVM_VERSION_MINOR	0#define EVMS_LVM_VERSION_PATCH	0// The following definitions and data structures are copied from lvm.h and// liblvm.h from the LVM 0.9.1beta8 distribution. Since the metadata format// changed in beta8, lvm.h changed significantly enough that this module would// no longer compile. Instead of requiring evms users to install the latest lvm // release, the required definitions and data structures will now be included// in this header file.#ifndef	SECTOR_SIZE#define SECTOR_SIZE		512#endif#define MAX_VG  		99#define MAX_LV			256#define	MAX_PV			256			/* caused by 8 bit minor */#define	NAME_LEN		128			/* don't change!!! */#define	UUID_LEN		32			/* don't change!!! */#define LV_SET_ACCESS           _IOW ( 0xfe, 0x28, 1)#define LV_SET_ALLOCATION       _IOW ( 0xfe, 0x29, 1)#define LV_SET_STATUS           _IOW ( 0xfe, 0x2a, 1)#define LV_SNAPSHOT_USE_RATE    _IOWR ( 0xfe, 0x2c, 1)#define	LV_BMAP			_IOWR ( 0xfe, 0x30, 1)#define LVM_VGDA_ALIGN		4096UL			/* some metadata on the disk need to be aligned */#define	LVM_PV_DISK_BASE	0L			/* base of PV structure in disk partition */#define	LVM_PV_DISK_SIZE	1024L			/* size reserved for PV structure on disk */#define	LVM_VG_DISK_BASE	round_up(LVM_PV_DISK_BASE + LVM_PV_DISK_SIZE, LVM_VGDA_ALIGN)							/* base of VG structure in disk partition */#define	LVM_VG_DISK_SIZE  	(8*512L)		/* size reserved for VG structure *//* * Status flags *//* logical volume */#define	LV_ACTIVE            0x01	/* lv_status */#define	LV_READ              0x01	/* lv_access */#define	LV_WRITE             0x02	/*     "     */#define	LV_SNAPSHOT          0x04	/*     "     */#define	LV_SNAPSHOT_ORG      0x08	/*     "     *//* copy on write tables in disk format */typedef struct lv_COW_table_disk_v1 {	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;/* disk stored pe information */typedef struct {	uint16_t lv_num;	uint16_t le_num;} pe_disk_t;/* disk stored PV, VG, LV and PE size and offset information */typedef struct {	uint32_t base;	uint32_t size;} lvm_disk_data_t;/* disk */typedef struct pv_disk_v2 {	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_uuidlist_on_disk;	lvm_disk_data_t lv_on_disk;	lvm_disk_data_t pe_on_disk;	uint8_t pv_uuid[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;		/* new in struct version 2 */	uint32_t pe_start;	        /* in sectors */} pv_disk_t;/* disk */typedef struct lv_disk_v3 {	uint8_t lv_name[NAME_LEN];	uint8_t vg_name[NAME_LEN];	uint32_t lv_access;	uint32_t lv_status;	uint32_t lv_open;		/* HM */	uint32_t lv_dev;		/* HM */	uint32_t lv_number;	/* HM */	uint32_t lv_mirror_copies;	/* for future use */	uint32_t lv_recovery;	/*       "        */	uint32_t lv_schedule;	/*       "        */	uint32_t lv_size;	uint32_t lv_snapshot_minor;/* minor number of original */	uint16_t lv_chunk_size;	/* chunk size of snapshot */	uint16_t dummy;	uint32_t lv_allocated_le;	uint32_t lv_stripes;	uint32_t lv_stripesize;	uint32_t lv_badblock;	/* for future use */	uint32_t lv_allocation;	uint32_t lv_io_timeout;	/* for future use */	uint32_t lv_read_ahead;	/* HM */} lv_disk_t;/* disk */typedef struct vg_disk_v2 {	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 */	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_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;}// End of lvm.h imported data structures#define DEV_DIRECTORY		"/dev/"#define LVM_DEV_DIRECTORY	"lvm/"#define LVM_PROC_NAME		"lvm"#define LVM_PROC_VG_NAME	"VGs"#define LVM_PROC_LV_NAME	"LVs"#define LVM_PROC_PV_NAME	"PVs"#define LVM_PROC_GLOBAL_NAME	"global"#define IO_BUFFER_SECTORS	8#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,9)#define max(a,b) (((a)>(b))?(a):(b))#endif// Structure for doing PV remove ioctls#define EVMS_LVM_PV_REMOVE_IOCTL	0x01#define EVMS_LVM_SNAPSHOT_STAT_IOCTL	0x02typedef struct lvm_pv_remove_ioctl_s {	unsigned char			vg_uuid[UUID_LEN];	int				pv_number;	struct lvm_pv_remove_ioctl_s	* next;} lvm_pv_remove_ioctl_t;// Structure for doing snapshot stat ioctlstypedef struct lvm_snapshot_stat_ioctl_s {	unsigned char	vg_uuid[UUID_LEN];	int		lv_number;	evms_sector_t	next_free_chunk;	u_int32_t	lv_status;} lvm_snapshot_stat_ioctl_t;// Entries in the list of physical volumes (PV)// in a volume group (VG)typedef struct lvm_physical_volume_s {	evms_logical_node_t		* logical_node;	pv_disk_t			* pv;		// Copy of on-disk PV struct	pe_disk_t			* pe_map;	u_int32_t			pv_number;	struct lvm_physical_volume_s	* next;} lvm_physical_volume_t;// Table for mapping logical extents (LE) to physical extents (PE)typedef struct le_table_entry_s {	lvm_physical_volume_t	* owning_pv;	evms_sector_t		pe_sector_offset;} le_table_entry_t;// Entries in the snapshot remapping structuretypedef struct snapshot_map_entry_s {	evms_sector_t			org_sector;	evms_sector_t			snap_sector;	lvm_physical_volume_t		* snap_pv;	struct snapshot_map_entry_s	* next;	struct snapshot_map_entry_s	* prev;} snapshot_map_entry_t;// Logical volumes (LV) in a volume group (VG)#define EVMS_LV_NEW		0x10	// volume was created during the current discovery pass#define EVMS_LV_INCOMPLETE	0x20	// volume has an incomplete LE map#define EVMS_LV_INVALID		0x40	// volume has a memory-corruption problem#define EVMS_LV_QUIESCED	0x80	// volume is in quiesced state#define MAX_HASH_CHAIN_ENTRIES	10#define CHUNK_DATA_BUFFER_SIZE	128	// 64k in sectors. Feel free to change, but must be power of 2!typedef struct lvm_logical_volume_s {	u_int32_t		lv_number;	evms_sector_t		lv_size;	// Sectors	u_int32_t		lv_access;	// Flags: LV_READ, LV_WRITE, LV_SNAPSHOT, LV_SNAPSHOT_ORG, EVMS_LV_*	u_int32_t		lv_status;	// Flags: LV_ACTIVE, LV_SPINDOWN	u_int32_t		lv_minor;	// Device minor number	u_int32_t		stripes;	u_int32_t		stripe_size;	// Sectors	u_int32_t		stripe_size_shift; // Number of bits to shift right instead of dividing by stripe_size	u_int32_t		pe_size;	// Sectors	u_int32_t		pe_size_shift;	// Number of bits to shift right instead of dividing by pe_size	u_int32_t		num_le;		// Number of entries in the le_to_pe_map	struct lvm_volume_group_s * group;	// Pointer back to parent volume group	unsigned char		name[NAME_LEN];	// Dev-tree volume name (eg: /dev/group0/vol0)	le_table_entry_t	* le_map;	// Mapping of logical to physical extents	evms_logical_node_t	* volume_node;	// Pointer to the parent EVMS node representing this volume	// Snapshotting information	u_int32_t		chunk_size;		// Sectors	u_int32_t		num_chunks;		// lv_size/chunk_size	u_int32_t		snap_org_minor;		// Minor number of snapshot original	u_int32_t		next_cow_entry;		// Index into current COW table	evms_sector_t		current_cow_sector;	// LOGICAL sector of current COW table	evms_sector_t		next_free_chunk;	// Starting LOGICAL sector of next free chunk	u_int32_t		hash_table_size;	// Number of pointers in each hash table	lv_COW_table_disk_t	* cow_table;		// Pointer to one sector's worth of COW tables	unsigned char		* chunk_data_buffer;	// Buffer for reading data when doing a copy-on-write	struct semaphore	snap_semaphore;		// For locking during snapshot I/O operations	snapshot_map_entry_t	*** snapshot_map;	// Pointer to the remapping hash tables	struct lvm_logical_volume_s * snapshot_next;	// Linked list of volumes snapshotting the original	struct lvm_logical_volume_s * snapshot_org;	// Pointer to volume being snapshotted} lvm_logical_volume_t;// Volume groups (VG)#define EVMS_VG_DIRTY			(1 << 0)	// group is new or has had a PV added during this discovery#define EVMS_VG_PARTIAL_PVS		(1 << 1)	// group contains at least one partial PV.#define EVMS_VG_REMOVABLE_PVS		(1 << 2)	// group contains at least one removeable PV.typedef struct lvm_volume_group_s {	vg_disk_t		* vg;			// Copy of on-disk VG metadata	lvm_physical_volume_t	* pv_list;		// List of PVs that make up this group	lvm_logical_volume_t	* volume_list[MAX_LV+1]; // Array of volumes	lv_disk_t		* lv_array;		// Array of LV metadata	unsigned char		* uuid_list;		// List of PV UUIDs	unsigned char		vg_uuid[UUID_LEN];	// UUID from the VG metadata	char			vg_name[NAME_LEN];	// Name from the PV metadata	u_int32_t		pv_count;		// Number of PVs found in this group	u_int32_t		volume_count;		// Number of LVs found in this group	int			hard_sect_size;		// The largest hard_sect_size and block_size	int			block_size;		//   values of all PVs in this group.	u_int32_t		flags;			// EVMS_VG_?	struct lvm_volume_group_s * next_group;} lvm_volume_group_t;#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -