aboutsummaryrefslogblamecommitdiffstats
path: root/fs/partitions/ldm.h
blob: 30e08e809c1dd7867801357ce71c12ecc028f132 (plain) (tree)
1
2
3
4
5
6
7
8



                                                           
                                             

                                                            
                                                                              





























































                                                                             
                                  























                                                                               
                                                                            



                                                                              


















































































































                                                                                
/**
 * ldm - Part of the Linux-NTFS project.
 *
 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
 * Copyright (c) 2001-2007 Anton Altaparmakov
 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
 *
 * Documentation is available at http://www.linux-ntfs.org/content/view/19/37/
 *
 * 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 (in the main directory of the Linux-NTFS source
 * in the file COPYING); if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _FS_PT_LDM_H_
#define _FS_PT_LDM_H_

#include <linux/types.h>
#include <linux/list.h>
#include <linux/genhd.h>
#include <linux/fs.h>
#include <asm/unaligned.h>
#include <asm/byteorder.h>

struct parsed_partitions;

/* Magic numbers in CPU format. */
#define MAGIC_VMDB	0x564D4442		/* VMDB */
#define MAGIC_VBLK	0x56424C4B		/* VBLK */
#define MAGIC_PRIVHEAD	0x5052495648454144ULL	/* PRIVHEAD */
#define MAGIC_TOCBLOCK	0x544F43424C4F434BULL	/* TOCBLOCK */

/* The defined vblk types. */
#define VBLK_VOL5		0x51		/* Volume,     version 5 */
#define VBLK_CMP3		0x32		/* Component,  version 3 */
#define VBLK_PRT3		0x33		/* Partition,  version 3 */
#define VBLK_DSK3		0x34		/* Disk,       version 3 */
#define VBLK_DSK4		0x44		/* Disk,       version 4 */
#define VBLK_DGR3		0x35		/* Disk Group, version 3 */
#define VBLK_DGR4		0x45		/* Disk Group, version 4 */

/* vblk flags indicating extra information will be present */
#define	VBLK_FLAG_COMP_STRIPE	0x10
#define	VBLK_FLAG_PART_INDEX	0x08
#define	VBLK_FLAG_DGR3_IDS	0x08
#define	VBLK_FLAG_DGR4_IDS	0x08
#define	VBLK_FLAG_VOLU_ID1	0x08
#define	VBLK_FLAG_VOLU_ID2	0x20
#define	VBLK_FLAG_VOLU_SIZE	0x80
#define	VBLK_FLAG_VOLU_DRIVE	0x02

/* size of a vblk's static parts */
#define VBLK_SIZE_HEAD		16
#define VBLK_SIZE_CMP3		22		/* Name and version */
#define VBLK_SIZE_DGR3		12
#define VBLK_SIZE_DGR4		44
#define VBLK_SIZE_DSK3		12
#define VBLK_SIZE_DSK4		45
#define VBLK_SIZE_PRT3		28
#define VBLK_SIZE_VOL5		58

/* component types */
#define COMP_STRIPE		0x01		/* Stripe-set */
#define COMP_BASIC		0x02		/* Basic disk */
#define COMP_RAID		0x03		/* Raid-set */

/* Other constants. */
#define LDM_DB_SIZE		2048		/* Size in sectors (= 1MiB). */

#define OFF_PRIV1		6		/* Offset of the first privhead
						   relative to the start of the
						   device in sectors */

/* Offsets to structures within the LDM Database in sectors. */
#define OFF_PRIV2		1856		/* Backup private headers. */
#define OFF_PRIV3		2047

#define OFF_TOCB1		1		/* Tables of contents. */
#define OFF_TOCB2		2
#define OFF_TOCB3		2045
#define OFF_TOCB4		2046

#define OFF_VMDB		17		/* List of partitions. */

#define LDM_PARTITION		0x42		/* Formerly SFS (Landis). */

#define TOC_BITMAP1		"config"	/* Names of the two defined */
#define TOC_BITMAP2		"log"		/* bitmaps in the TOCBLOCK. */

/* Borrowed from msdos.c */
#define SYS_IND(p)		(get_unaligned(&(p)->sys_ind))

struct frag {				/* VBLK Fragment handling */
	struct list_head list;
	u32		group;
	u8		num;		/* Total number of records */
	u8		rec;		/* This is record number n */
	u8		map;		/* Which portions are in use */
	u8		data[0];
};

/* In memory LDM database structures. */

#define GUID_SIZE		16

struct privhead {			/* Offsets and sizes are in sectors. */
	u16	ver_major;
	u16	ver_minor;
	u64	logical_disk_start;
	u64	logical_disk_size;
	u64	config_start;
	u64	config_size;
	u8	disk_id[GUID_SIZE];
};

struct tocblock {			/* We have exactly two bitmaps. */
	u8	bitmap1_name[16];
	u64	bitmap1_start;
	u64	bitmap1_size;
	u8	bitmap2_name[16];
	u64	bitmap2_start;
	u64	bitmap2_size;
};

struct vmdb {				/* VMDB: The database header */
	u16	ver_major;
	u16	ver_minor;
	u32	vblk_size;
	u32	vblk_offset;
	u32	last_vblk_seq;
};

struct vblk_comp {			/* VBLK Component */
	u8	state[16];
	u64	parent_id;
	u8	type;
	u8	children;
	u16	chunksize;
};

struct vblk_dgrp {			/* VBLK Disk Group */
	u8	disk_id[64];
};

struct vblk_disk {			/* VBLK Disk */
	u8	disk_id[GUID_SIZE];
	u8	alt_name[128];
};

struct vblk_part {			/* VBLK Partition */
	u64	start;
	u64	size;			/* start, size and vol_off in sectors */
	u64	volume_offset;
	u64	parent_id;
	u64	disk_id;
	u8	partnum;
};

struct vblk_volu {			/* VBLK Volume */
	u8	volume_type[16];
	u8	volume_state[16];
	u8	guid[16];
	u8	drive_hint[4];
	u64	size;
	u8	partition_type;
};

struct vblk_head {			/* VBLK standard header */
	u32 group;
	u16 rec;
	u16 nrec;
};

struct vblk {				/* Generalised VBLK */
	u8	name[64];
	u64	obj_id;
	u32	sequence;
	u8	flags;
	u8	type;
	union {
		struct vblk_comp comp;
		struct vblk_dgrp dgrp;
		struct vblk_disk disk;
		struct vblk_part part;
		struct vblk_volu volu;
	} vblk;
	struct list_head list;
};

struct ldmdb {				/* Cache of the database */
	struct privhead ph;
	struct tocblock toc;
	struct vmdb     vm;
	struct list_head v_dgrp;
	struct list_head v_disk;
	struct list_head v_volu;
	struct list_head v_comp;
	struct list_head v_part;
};

int ldm_partition (struct parsed_partitions *state, struct block_device *bdev);

#endif /* _FS_PT_LDM_H_ */

depends on EXPERIMENTAL || ARCH_SELECT_MEMORY_MODEL choice prompt "Memory model" depends on SELECT_MEMORY_MODEL default DISCONTIGMEM_MANUAL if ARCH_DISCONTIGMEM_DEFAULT default SPARSEMEM_MANUAL if ARCH_SPARSEMEM_DEFAULT default FLATMEM_MANUAL config FLATMEM_MANUAL bool "Flat Memory" depends on !(ARCH_DISCONTIGMEM_ENABLE || ARCH_SPARSEMEM_ENABLE) || ARCH_FLATMEM_ENABLE help This option allows you to change some of the ways that Linux manages its memory internally. Most users will only have one option here: FLATMEM. This is normal and a correct option. Some users of more advanced features like NUMA and memory hotplug may have different options here. DISCONTIGMEM is an more mature, better tested system, but is incompatible with memory hotplug and may suffer decreased performance over SPARSEMEM. If unsure between "Sparse Memory" and "Discontiguous Memory", choose "Discontiguous Memory". If unsure, choose this option (Flat Memory) over any other. config DISCONTIGMEM_MANUAL bool "Discontiguous Memory" depends on ARCH_DISCONTIGMEM_ENABLE help This option provides enhanced support for discontiguous memory systems, over FLATMEM. These systems have holes in their physical address spaces, and this option provides more efficient handling of these holes. However, the vast majority of hardware has quite flat address spaces, and can have degraded performance from extra overhead that this option imposes. Many NUMA configurations will have this as the only option. If unsure, choose "Flat Memory" over this option. config SPARSEMEM_MANUAL bool "Sparse Memory" depends on ARCH_SPARSEMEM_ENABLE help This will be the only option for some systems, including memory hotplug systems. This is normal. For many other systems, this will be an alternative to "Discontiguous Memory". This option provides some potential performance benefits, along with decreased code complexity, but it is newer, and more experimental. If unsure, choose "Discontiguous Memory" or "Flat Memory" over this option. endchoice config DISCONTIGMEM def_bool y depends on (!SELECT_MEMORY_MODEL && ARCH_DISCONTIGMEM_ENABLE) || DISCONTIGMEM_MANUAL config SPARSEMEM def_bool y depends on SPARSEMEM_MANUAL config FLATMEM def_bool y depends on (!DISCONTIGMEM && !SPARSEMEM) || FLATMEM_MANUAL config FLAT_NODE_MEM_MAP def_bool y depends on !SPARSEMEM # # Both the NUMA code and DISCONTIGMEM use arrays of pg_data_t's # to represent different areas of memory. This variable allows # those dependencies to exist individually. # config NEED_MULTIPLE_NODES def_bool y depends on DISCONTIGMEM || NUMA config HAVE_MEMORY_PRESENT def_bool y depends on ARCH_HAVE_MEMORY_PRESENT || SPARSEMEM # # SPARSEMEM_EXTREME (which is the default) does some bootmem # allocations when memory_present() is called. If this can not # be done on your architecture, select this option. However, # statically allocating the mem_section[] array can potentially # consume vast quantities of .bss, so be careful. # # This option will also potentially produce smaller runtime code # with gcc 3.4 and later. # config SPARSEMEM_STATIC def_bool n # # Architectecture platforms which require a two level mem_section in SPARSEMEM # must select this option. This is usually for architecture platforms with # an extremely sparse physical address space. # config SPARSEMEM_EXTREME def_bool y depends on SPARSEMEM && !SPARSEMEM_STATIC # eventually, we can have this option just 'select SPARSEMEM' config MEMORY_HOTPLUG bool "Allow for memory hot-add" depends on SPARSEMEM && HOTPLUG && !SOFTWARE_SUSPEND comment "Memory hotplug is currently incompatible with Software Suspend" depends on SPARSEMEM && HOTPLUG && SOFTWARE_SUSPEND # Heavily threaded applications may benefit from splitting the mm-wide # page_table_lock, so that faults on different parts of the user address # space can be handled with less contention: split it at this NR_CPUS. # Default to 4 for wider testing, though 8 might be more appropriate. # ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock. # PA-RISC 7xxx's spinlock_t would enlarge struct page from 32 to 44 bytes. # config SPLIT_PTLOCK_CPUS int default "4096" if ARM && !CPU_CACHE_VIPT default "4096" if PARISC && !PA20 default "4" # # support for page migration # config MIGRATION bool "Page migration" def_bool y if NUMA || SPARSEMEM || DISCONTIGMEM depends on SWAP help Allows the migration of the physical location of pages of processes while the virtual addresses are not changed. This is useful for example on NUMA systems to put pages nearer to the processors accessing the page.