The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/vinum/vinumobj.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1997, 1998, 1999
    3  *      Nan Yang Computer Services Limited.  All rights reserved.
    4  *
    5  *  Parts copyright (c) 1997, 1998 Cybernet Corporation, NetMAX project.
    6  *
    7  *  Written by Greg Lehey
    8  *
    9  *  This software is distributed under the so-called ``Berkeley
   10  *  License'':
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. All advertising materials mentioning features or use of this software
   21  *    must display the following acknowledgement:
   22  *      This product includes software developed by Nan Yang Computer
   23  *      Services Limited.
   24  * 4. Neither the name of the Company nor the names of its contributors
   25  *    may be used to endorse or promote products derived from this software
   26  *    without specific prior written permission.
   27  *
   28  * This software is provided ``as is'', and any express or implied
   29  * warranties, including, but not limited to, the implied warranties of
   30  * merchantability and fitness for a particular purpose are disclaimed.
   31  * In no event shall the company or contributors be liable for any
   32  * direct, indirect, incidental, special, exemplary, or consequential
   33  * damages (including, but not limited to, procurement of substitute
   34  * goods or services; loss of use, data, or profits; or business
   35  * interruption) however caused and on any theory of liability, whether
   36  * in contract, strict liability, or tort (including negligence or
   37  * otherwise) arising in any way out of the use of this software, even if
   38  * advised of the possibility of such damage.
   39  *
   40  * $Id: vinumobj.h,v 1.1.1.1 2003/10/10 03:08:48 grog Exp $
   41  * $FreeBSD$
   42  */
   43 
   44 /*
   45  * Definitions of Vinum objects: drive, subdisk, plex and volume.
   46  * This file is included both by userland programs and by kernel code.
   47  * The userland structures are a subset of the kernel structures, and
   48  * all userland fields are at the beginning, so that a simple copy in
   49  * the length of the userland structure will be sufficient.  In order
   50  * to perform this copy, vinumioctl must know both structures, so it
   51  * includes this file again with _KERNEL reset.
   52  */
   53 
   54 #ifndef _KERNEL
   55 /*
   56  * Flags for all objects.  Most of them only apply
   57  * to specific objects, but we currently have
   58  * space for all in any 32 bit flags word.
   59  */
   60 enum objflags {
   61     VF_LOCKED = 1,                                          /* somebody has locked access to this object */
   62     VF_LOCKING = 2,                                         /* we want access to this object */
   63     VF_OPEN = 4,                                            /* object has openers */
   64     VF_WRITETHROUGH = 8,                                    /* volume: write through */
   65     VF_INITED = 0x10,                                       /* unit has been initialized */
   66     VF_WLABEL = 0x20,                                       /* label area is writable */
   67     VF_LABELLING = 0x40,                                    /* unit is currently being labelled */
   68     VF_WANTED = 0x80,                                       /* someone is waiting to obtain a lock */
   69     VF_RAW = 0x100,                                         /* raw volume (no file system) */
   70     VF_LOADED = 0x200,                                      /* module is loaded */
   71     VF_CONFIGURING = 0x400,                                 /* somebody is changing the config */
   72     VF_WILL_CONFIGURE = 0x800,                              /* somebody wants to change the config */
   73     VF_CONFIG_INCOMPLETE = 0x1000,                          /* haven't finished changing the config */
   74     VF_CONFIG_SETUPSTATE = 0x2000,                          /* set a volume up if all plexes are empty */
   75     VF_READING_CONFIG = 0x4000,                             /* we're reading config database from disk */
   76     VF_FORCECONFIG = 0x8000,                                /* configure drives even with different names */
   77     VF_NEWBORN = 0x10000,                                   /* for objects: we've just created it */
   78     VF_CONFIGURED = 0x20000,                                /* for drives: we read the config */
   79     VF_STOPPING = 0x40000,                                  /* for vinum_conf: stop on last close */
   80     VF_DAEMONOPEN = 0x80000,                                /* the daemon has us open (only superdev) */
   81     VF_CREATED = 0x100000,                                  /* for volumes: freshly created, more then new */
   82     VF_HOTSPARE = 0x200000,                                 /* for drives: use as hot spare */
   83     VF_RETRYERRORS = 0x400000,                              /* don't down subdisks on I/O errors */
   84     VF_HASDEBUG = 0x800000,                                 /* set if we support debug */
   85 };
   86 
   87 #endif
   88 
   89 /* Global configuration information for the vinum subsystem */
   90 #ifdef _KERNEL
   91 struct _vinum_conf
   92 #else
   93 struct __vinum_conf
   94 #endif
   95 {
   96     int version;                                            /* version of structures */
   97 #ifdef _KERNEL
   98     /* Pointers to vinum structures */
   99     struct drive *drive;
  100     struct sd *sd;
  101     struct plex *plex;
  102     struct volume *volume;
  103 #else
  104     /* Pointers to vinum structures */
  105     struct _drive *drive;
  106     struct _sd *sd;
  107     struct _plex *plex;
  108     struct _volume *volume;
  109 #endif
  110 
  111     /* the number allocated */
  112     int drives_allocated;
  113     int subdisks_allocated;
  114     int plexes_allocated;
  115     int volumes_allocated;
  116 
  117     /* and the number currently in use */
  118     int drives_used;
  119     int subdisks_used;
  120     int plexes_used;
  121     int volumes_used;
  122 
  123     int flags;                                              /* see above */
  124 
  125 #define VINUM_MAXACTIVE  30000                              /* maximum number of active requests */
  126     int active;                                             /* current number of requests outstanding */
  127     int maxactive;                                          /* maximum number of requests ever outstanding */
  128 #ifdef _KERNEL
  129 #ifdef VINUMDEBUG
  130     struct request *lastrq;
  131     struct buf *lastbuf;
  132 #endif
  133 #endif
  134 };
  135 
  136 /* Use these defines to simplify code */
  137 #define DRIVE vinum_conf.drive
  138 #define SD vinum_conf.sd
  139 #define PLEX vinum_conf.plex
  140 #define VOL vinum_conf.volume
  141 #define VFLAGS vinum_conf.flags
  142 
  143 /*
  144  * A drive corresponds to a disk slice.  We use a different term to show
  145  * the difference in usage: it doesn't have to be a slice, and could
  146  * theoretically be a complete, unpartitioned disk
  147  */
  148 
  149 #ifdef _KERNEL
  150 struct drive
  151 #else
  152 struct _drive
  153 #endif
  154 {
  155     char devicename[MAXDRIVENAME];                          /* name of the slice it's on */
  156     struct vinum_label label;                               /* and the label information */
  157     enum drivestate state;                                  /* current state */
  158     int flags;                                              /* flags */
  159     int subdisks_allocated;                                 /* number of entries in sd */
  160     int subdisks_used;                                      /* and the number used */
  161     int blocksize;                                          /* size of fs blocks */
  162     int pid;                                                /* of locker */
  163     u_int64_t sectors_available;                            /* number of sectors still available */
  164     int secsperblock;
  165     int lasterror;                                          /* last error on drive */
  166     int driveno;                                            /* index of drive in vinum_conf */
  167     int opencount;                                          /* number of up subdisks */
  168     u_int64_t reads;                                        /* number of reads on this drive */
  169     u_int64_t writes;                                       /* number of writes on this drive */
  170     u_int64_t bytes_read;                                   /* number of bytes read */
  171     u_int64_t bytes_written;                                /* number of bytes written */
  172 #define DRIVE_MAXACTIVE  30000                              /* maximum number of active requests */
  173     int active;                                             /* current number of requests outstanding */
  174     int maxactive;                                          /* maximum number of requests ever outstanding */
  175     int freelist_size;                                      /* number of entries alloced in free list */
  176     int freelist_entries;                                   /* number of entries used in free list */
  177     struct drive_freelist *freelist;                        /* sorted list of free space on drive */
  178 #ifdef _KERNEL
  179     struct partinfo partinfo;                               /* partition information */
  180     dev_t dev;                                              /* device information */
  181 #ifdef VINUMDEBUG
  182     char lockfilename[16];                                  /* name of file from which we were locked */
  183     int lockline;                                           /* and the line number */
  184 #endif
  185     struct vnode *vp;
  186     struct proc *p;
  187 #endif
  188 };
  189 
  190 #ifdef _KERNEL
  191 struct sd
  192 #else
  193 struct _sd
  194 #endif
  195 {
  196     char name[MAXSDNAME];                                   /* name of subdisk */
  197     enum sdstate state;                                     /* state */
  198     int flags;
  199     int lasterror;                                          /* last error occurred */
  200     /* offsets in blocks */
  201     int64_t driveoffset;                                    /* offset on drive */
  202     /*
  203      * plexoffset is the offset from the beginning
  204      * of the plex to the very first part of the
  205      * subdisk, in sectors.  For striped, RAID-4 and
  206      * RAID-5 plexes, only the first stripe is
  207      * located at this offset
  208      */
  209     int64_t plexoffset;                                     /* offset in plex */
  210     u_int64_t sectors;                                      /* and length in sectors */
  211     int plexno;                                             /* index of plex, if it belongs */
  212     int driveno;                                            /* index of the drive on which it is located */
  213     int sdno;                                               /* our index in vinum_conf */
  214     int plexsdno;                                           /* and our number in our plex */
  215     /* (undefined if no plex) */
  216     u_int64_t reads;                                        /* number of reads on this subdisk */
  217     u_int64_t writes;                                       /* number of writes on this subdisk */
  218     u_int64_t bytes_read;                                   /* number of bytes read */
  219     u_int64_t bytes_written;                                /* number of bytes written */
  220     /* revive parameters */
  221     u_int64_t revived;                                      /* block number of current revive request */
  222     int revive_blocksize;                                   /* revive block size (bytes) */
  223     int revive_interval;                                    /* and time to wait between transfers */
  224     pid_t reviver;                                          /* PID of reviving process */
  225     /* init parameters */
  226     u_int64_t initialized;                                  /* block number of current init request */
  227     int init_blocksize;                                     /* init block size (bytes) */
  228     int init_interval;                                      /* and time to wait between transfers */
  229 #ifdef _KERNEL
  230     struct request *waitlist;                               /* list of requests waiting on revive op */
  231 #endif
  232 };
  233 
  234 #ifdef _KERNEL
  235 struct plex
  236 #else
  237 struct _plex
  238 #endif
  239 {
  240     enum plexorg organization;                              /* Plex organization */
  241     enum plexstate state;                                   /* and current state */
  242     u_int64_t length;                                       /* total length of plex (sectors) */
  243     int flags;
  244     int stripesize;                                         /* size of stripe or raid band, in sectors */
  245     int subdisks;                                           /* number of associated subdisks */
  246     int subdisks_allocated;                                 /* number of subdisks allocated space for */
  247     int *sdnos;                                             /* list of component subdisks */
  248     int plexno;                                             /* index of plex in vinum_conf */
  249     int volno;                                              /* index of volume */
  250     int volplexno;                                          /* number of plex in volume */
  251     /* Statistics */
  252     u_int64_t reads;                                        /* number of reads on this plex */
  253     u_int64_t writes;                                       /* number of writes on this plex */
  254     u_int64_t bytes_read;                                   /* number of bytes read */
  255     u_int64_t bytes_written;                                /* number of bytes written */
  256     u_int64_t recovered_reads;                              /* number of recovered read operations */
  257     u_int64_t degraded_writes;                              /* number of degraded writes */
  258     u_int64_t parityless_writes;                            /* number of parityless writes */
  259     u_int64_t multiblock;                                   /* requests that needed more than one block */
  260     u_int64_t multistripe;                                  /* requests that needed more than one stripe */
  261     int sddowncount;                                        /* number of subdisks down */
  262     /* Lock information */
  263     int usedlocks;                                          /* number currently in use */
  264     int lockwaits;                                          /* and number of waits for locks */
  265     off_t checkblock;                                       /* block number for parity op */
  266     char name[MAXPLEXNAME];                                 /* name of plex */
  267 #ifdef _KERNEL
  268     struct rangelock *lock;                                 /* ranges of locked addresses */
  269 #endif
  270 };
  271 
  272 #ifdef _KERNEL
  273 struct volume
  274 #else
  275 struct _volume
  276 #endif
  277 {
  278     char name[MAXVOLNAME];                                  /* name of volume */
  279     enum volumestate state;                                 /* current state */
  280     int plexes;                                             /* number of plexes */
  281     int preferred_plex;                                     /* plex to read from, -1 for round-robin */
  282     /*
  283      * index of plex used for last read, for
  284      * round-robin.
  285      */
  286     int last_plex_read;
  287     int volno;                                              /* volume number */
  288     int flags;                                              /* status and configuration flags */
  289     int openflags;                                          /* flags supplied to last open(2) */
  290     u_int64_t size;                                         /* size of volume */
  291     int blocksize;                                          /* logical block size */
  292     int active;                                             /* number of outstanding requests active */
  293     int subops;                                             /* and the number of suboperations */
  294     /* Statistics */
  295     u_int64_t bytes_read;                                   /* number of bytes read */
  296     u_int64_t bytes_written;                                /* number of bytes written */
  297     u_int64_t reads;                                        /* number of reads on this volume */
  298     u_int64_t writes;                                       /* number of writes on this volume */
  299     u_int64_t recovered_reads;                              /* reads recovered from another plex */
  300     /*
  301      * Unlike subdisks in the plex, space for the
  302      * plex pointers is static.
  303      */
  304     int plex[MAXPLEX];                                      /* index of plexes */
  305 #ifdef _KERNEL
  306     struct disklabel label;                                 /* for DIOCGPART */
  307 #endif
  308 };

Cache object: 339e65800795b32c92eed16e442c50ac


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.