vinumvar.h
来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 581 行 · 第 1/2 页
H
581 行
/*- * Copyright (c) 1997, 1998 * Nan Yang Computer Services Limited. All rights reserved. * * This software is distributed under the so-called ``Berkeley * License'': * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Nan Yang Computer * Services Limited. * 4. Neither the name of the Company nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided ``as is'', and any express or implied * warranties, including, but not limited to, the implied warranties of * merchantability and fitness for a particular purpose are disclaimed. * In no event shall the company or contributors be liable for any * direct, indirect, incidental, special, exemplary, or consequential * damages (including, but not limited to, procurement of substitute * goods or services; loss of use, data, or profits; or business * interruption) however caused and on any theory of liability, whether * in contract, strict liability, or tort (including negligence or * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * * $Id: vinumvar.h,v 1.7.2.3 1999/05/05 05:21:39 grog Exp $ */#include <sys/time.h>#include <dev/vinum/vinumstate.h>/* * Some configuration maxima. They're an enum because * we can't define global constants. Sorry about that. * * These aren't as bad as they look: most of them are soft limits. */enum constants { VINUM_HEADER = 512, /* size of header on disk */ MAXCONFIGLINE = 1024, /* maximum size of a single config line */ /* XXX Do we still need this? */ MINVINUMSLICE = 1048576, /* minimum size of a slice */ CDEV_MAJOR = 91, /* major number for character device */ BDEV_MAJOR = 25, /* and block device */ ROUND_ROBIN_READPOL = -1, /* round robin read policy */ /* type field in minor number */ VINUM_VOLUME_TYPE = 0, VINUM_PLEX_TYPE = 1, VINUM_SD_TYPE = 2, VINUM_DRIVE_TYPE = 3, VINUM_SUPERDEV_TYPE = 4, /* super device. */ VINUM_RAWPLEX_TYPE = 5, /* anonymous plex */ VINUM_RAWSD_TYPE = 6, /* anonymous subdisk */ /* Shifts for the individual fields in the device */ VINUM_TYPE_SHIFT = 28, VINUM_VOL_SHIFT = 0, VINUM_PLEX_SHIFT = 16, VINUM_SD_SHIFT = 20, VINUM_VOL_WIDTH = 8, VINUM_PLEX_WIDTH = 3, VINUM_SD_WIDTH = 8,/* * Shifts for the second half of raw plex and * subdisk numbers */ VINUM_RAWPLEX_SHIFT = 8, /* shift the second half this much */ VINUM_RAWPLEX_WIDTH = 12, /* width of second half */ MAJORDEV_SHIFT = 8, MAXPLEX = 8, /* maximum number of plexes in a volume */ MAXSD = 256, /* maximum number of subdisks in a plex */ MAXDRIVENAME = 32, /* maximum length of a device name */ MAXSDNAME = 64, /* maximum length of a subdisk name */ MAXPLEXNAME = 64, /* maximum length of a plex name */ MAXVOLNAME = 64, /* maximum length of a volume name */ MAXNAME = 64, /* maximum length of any name *//* Create a block device number */#define VINUMBDEV(v,p,s,t) ((BDEV_MAJOR << MAJORDEV_SHIFT) \ | (v << VINUM_VOL_SHIFT) \ | (p << VINUM_PLEX_SHIFT) \ | (s << VINUM_SD_SHIFT) \ | (t << VINUM_TYPE_SHIFT) )/* Create a bit mask for x bits */#define MASK(x) ((1 << (x)) - 1)/* Create a raw block device number */#define VINUMRBDEV(d,t) ((BDEV_MAJOR << MAJORDEV_SHIFT) \ | ((d & MASK (VINUM_VOL_WIDTH)) << VINUM_VOL_SHIFT) \ | ((d & ~MASK (VINUM_VOL_WIDTH)) \ << (VINUM_PLEX_SHIFT + VINUM_VOL_WIDTH)) \ | (t << VINUM_TYPE_SHIFT) )/* And a character device number */#define VINUMCDEV(v,p,s,t) ((CDEV_MAJOR << MAJORDEV_SHIFT) \ | (v << VINUM_VOL_SHIFT) \ | (p << VINUM_PLEX_SHIFT) \ | (s << VINUM_SD_SHIFT) \ | (t << VINUM_TYPE_SHIFT) )/* extract device type */#define DEVTYPE(x) ((x >> VINUM_TYPE_SHIFT) & 7)/* * This mess is used to catch people who compile * a debug vinum(8) and non-debug kernel module, * or the other way round. */#ifdef VINUMDEBUG VINUM_SUPERDEV = VINUMBDEV(1, 0, 0, VINUM_SUPERDEV_TYPE), /* superdevice number */ VINUM_WRONGSUPERDEV = VINUMBDEV(2, 0, 0, VINUM_SUPERDEV_TYPE), /* non-debug superdevice number */#else VINUM_SUPERDEV = VINUMBDEV(2, 0, 0, VINUM_SUPERDEV_TYPE), /* superdevice number */ VINUM_WRONGSUPERDEV = VINUMBDEV(1, 0, 0, VINUM_SUPERDEV_TYPE), /* debug superdevice number */#endif VINUM_DAEMON_DEV = VINUMBDEV(0, 0, 0, VINUM_SUPERDEV_TYPE), /* daemon superdevice number *//* * the number of object entries to cater for initially, and also the * value by which they are incremented. It doesn't take long * to extend them, so theoretically we could start with 1 of each, but * it's untidy to allocate such small areas. These values are * probably too small. */ INITIAL_DRIVES = 4, INITIAL_VOLUMES = 4, INITIAL_PLEXES = 8, INITIAL_SUBDISKS = 16, INITIAL_SUBDISKS_IN_PLEX = 4, /* number of subdisks to allocate to a plex */ INITIAL_SUBDISKS_IN_DRIVE = 4, /* number of subdisks to allocate to a drive */ INITIAL_DRIVE_FREELIST = 16, /* number of entries in drive freelist */ PLEX_REGION_TABLE_SIZE = 8, /* number of entries in plex region tables */ INITIAL_LOCKS = 8, /* number of locks to allocate to a volume */ DEFAULT_REVIVE_BLOCKSIZE = 65536, /* size of block to transfer in one op */ VINUMHOSTNAMELEN = 32, /* host name field in label */};/* device numbers *//* * 31 30 28 27 20 19 18 16 15 8 7 0 * |-----------------------------------------------------------------------------------------------| * |X | Type | Subdisk number | X| Plex | Major number | volume number | * |-----------------------------------------------------------------------------------------------| * * 0x2 03 1 19 06 * * The fields in the minor number are interpreted as follows: * * Volume: Only type and volume number are relevant * Plex in volume: type, plex number in volume and volume number are relevant * raw plex: type, plex number is made of bits 27-16 and 7-0 * raw subdisk: type, subdisk number is made of bits 27-16 and 7-0 */struct devcode {/* * CARE. These fields assume a big-endian word. On a * little-endian system, they're the wrong way around */ unsigned volume:8; /* up to 256 volumes */ unsigned major:8; /* this is where the major number fits */ unsigned plex:3; /* up to 8 plexes per volume */ unsigned unused:1; /* up for grabs */ unsigned sd:8; /* up to 256 subdisks per plex */ unsigned type:3; /* type of object */ /* * type field VINUM_VOLUME = 0, VINUM_PLEX = 1, VINUM_SUBDISK = 2, VINUM_DRIVE = 3, VINUM_SUPERDEV = 4, VINUM_RAWPLEX = 5, VINUM_RAWSD = 6 */ unsigned signbit:1; /* to make 32 bits */};#define VINUM_DIR "/dev/vinum"#define VINUM_RDIR "/dev/rvinum"/* * These definitions help catch * userland/kernel mismatches. */#if VINUMDEBUG#define VINUM_WRONGSUPERDEV_NAME VINUM_DIR"/control" /* normal super device */#define VINUM_SUPERDEV_NAME VINUM_DIR"/Control" /* debug super device */#else#define VINUM_WRONGSUPERDEV_NAME VINUM_DIR"/Control" /* debug super device */#define VINUM_SUPERDEV_NAME VINUM_DIR"/control" /* normal super device */#endif#define VINUM_DAEMON_DEV_NAME VINUM_DIR"/controld" /* super device for daemon only *//* * Flags for all objects. Most of them only apply to * specific objects, but we have space for all in any * 32 bit flags word. */enum objflags { VF_LOCKED = 1, /* somebody has locked access to this object */ VF_LOCKING = 2, /* we want access to this object */ VF_OPEN = 4, /* object has openers */ VF_WRITETHROUGH = 8, /* volume: write through */ VF_INITED = 0x10, /* unit has been initialized */ VF_WLABEL = 0x20, /* label area is writable */ VF_LABELLING = 0x40, /* unit is currently being labelled */ VF_WANTED = 0x80, /* someone is waiting to obtain a lock */ VF_RAW = 0x100, /* raw volume (no file system) */ VF_LOADED = 0x200, /* module is loaded */ VF_CONFIGURING = 0x400, /* somebody is changing the config */ VF_WILL_CONFIGURE = 0x800, /* somebody wants to change the config */ VF_CONFIG_INCOMPLETE = 0x1000, /* haven't finished changing the config */ VF_CONFIG_SETUPSTATE = 0x2000, /* set a volume up if all plexes are empty */ VF_READING_CONFIG = 0x4000, /* we're reading config database from disk */ VF_FORCECONFIG = 0x8000, /* configure drives even with different names */ VF_NEWBORN = 0x10000, /* for objects: we've just created it */ VF_CONFIGURED = 0x20000, /* for drives: we read the config */ VF_STOPPING = 0x40000, /* for vinum_conf: stop on last close */ VF_DAEMONOPEN = 0x80000, /* the daemon has us open (only superdev) */ VF_CREATED = 0x100000, /* for volumes: freshly created, more then new */};/* Global configuration information for the vinum subsystem */struct _vinum_conf { /* Pointers to vinum structures */ struct drive *drive; struct sd *sd; struct plex *plex; struct volume *volume; /* the number allocated */ int drives_allocated; int subdisks_allocated; int plexes_allocated; int volumes_allocated; /* and the number currently in use */ int drives_used; int subdisks_used; int plexes_used; int volumes_used; int flags;#if VINUMDEBUG int lastrq; struct buf *lastbuf;#endif};/* Use these defines to simplify code */#define DRIVE vinum_conf.drive#define SD vinum_conf.sd#define PLEX vinum_conf.plex#define VOL vinum_conf.volume#define VFLAGS vinum_conf.flags/* * Slice header * * Vinum drives start with this structure: * *\ Sector * |--------------------------------------| * | PDP-11 memorial boot block | 0 * |--------------------------------------| * | Disk label, maybe | 1 * |--------------------------------------| * | Slice definition (vinum_hdr) | 8 * |--------------------------------------| * | |
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?