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.7 2003/05/23 01:08:58 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 of each object */
  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     /*
  119      * Note that drives_used is not valid during drive recognition
  120      * (vinum_scandisk and friends).  Many invalid drives are added and
  121      * later removed; the count isn't correct until we leave
  122      * vinum_scandisk.
  123      */
  124     int drives_used;
  125     int subdisks_used;
  126     int plexes_used;
  127     int volumes_used;
  128 
  129     int flags;                                              /* see above */
  130 
  131 #define VINUM_MAXACTIVE  30000                              /* maximum number of active requests */
  132     int active;                                             /* current number of requests outstanding */
  133     int maxactive;                                          /* maximum number of requests ever outstanding */
  134 #ifdef _KERNEL
  135 #ifdef VINUMDEBUG
  136     struct request *lastrq;
  137     struct buf *lastbuf;
  138 #endif
  139 #endif
  140 };
  141 
  142 /* Use these defines to simplify code */
  143 #define DRIVE vinum_conf.drive
  144 #define SD vinum_conf.sd
  145 #define PLEX vinum_conf.plex
  146 #define VOL vinum_conf.volume
  147 #define VFLAGS vinum_conf.flags
  148 
  149 /*
  150  * A drive corresponds to a disk slice.  We use a different term to show
  151  * the difference in usage: it doesn't have to be a slice, and could
  152  * theoretically be a complete, unpartitioned disk
  153  */
  154 
  155 #ifdef _KERNEL
  156 struct drive
  157 #else
  158 struct _drive
  159 #endif
  160 {
  161     char devicename[MAXDRIVENAME];                          /* name of the slice it's on */
  162     struct vinum_label label;                               /* and the label information */
  163     enum drivestate state;                                  /* current state */
  164     int flags;                                              /* flags */
  165     int subdisks_allocated;                                 /* number of entries in sd */
  166     int subdisks_used;                                      /* and the number used */
  167     int blocksize;                                          /* size of fs blocks */
  168     int pid;                                                /* of locker */
  169     u_int64_t sectors_available;                            /* number of sectors still available */
  170     int secsperblock;
  171     int lasterror;                                          /* last error on drive */
  172     int driveno;                                            /* index of drive in vinum_conf */
  173     int opencount;                                          /* number of up subdisks */
  174     u_int64_t reads;                                        /* number of reads on this drive */
  175     u_int64_t writes;                                       /* number of writes on this drive */
  176     u_int64_t bytes_read;                                   /* number of bytes read */
  177     u_int64_t bytes_written;                                /* number of bytes written */
  178 #define DRIVE_MAXACTIVE  30000                              /* maximum number of active requests */
  179     int active;                                             /* current number of requests outstanding */
  180     int maxactive;                                          /* maximum number of requests ever outstanding */
  181     int freelist_size;                                      /* number of entries alloced in free list */
  182     int freelist_entries;                                   /* number of entries used in free list */
  183     struct drive_freelist *freelist;                        /* sorted list of free space on drive */
  184 #ifdef _KERNEL
  185     u_int sectorsize;
  186     off_t mediasize;
  187     struct cdev *dev;                                               /* device information */
  188 #ifdef VINUMDEBUG
  189     char lockfilename[16];                                  /* name of file from which we were locked */
  190     int lockline;                                           /* and the line number */
  191 #endif
  192 #endif
  193 };
  194 
  195 #ifdef _KERNEL
  196 struct sd
  197 #else
  198 struct _sd
  199 #endif
  200 {
  201     char name[MAXSDNAME];                                   /* name of subdisk */
  202     enum sdstate state;                                     /* state */
  203     int flags;
  204     int lasterror;                                          /* last error occurred */
  205     /* offsets in blocks */
  206     int64_t driveoffset;                                    /* offset on drive */
  207     /*
  208      * plexoffset is the offset from the beginning
  209      * of the plex to the very first part of the
  210      * subdisk, in sectors.  For striped, RAID-4 and
  211      * RAID-5 plexes, only the first stripe is
  212      * located at this offset
  213      */
  214     int64_t plexoffset;                                     /* offset in plex */
  215     u_int64_t sectors;                                      /* and length in sectors */
  216     int sectorsize;                                         /* sector size for DIOCGSECTORSIZE */
  217     int plexno;                                             /* index of plex, if it belongs */
  218     int driveno;                                            /* index of the drive on which it is located */
  219     int sdno;                                               /* our index in vinum_conf */
  220     int plexsdno;                                           /* and our number in our plex */
  221     /* (undefined if no plex) */
  222     u_int64_t reads;                                        /* number of reads on this subdisk */
  223     u_int64_t writes;                                       /* number of writes on this subdisk */
  224     u_int64_t bytes_read;                                   /* number of bytes read */
  225     u_int64_t bytes_written;                                /* number of bytes written */
  226     /* revive parameters */
  227     u_int64_t revived;                                      /* block number of current revive request */
  228     int revive_blocksize;                                   /* revive block size (bytes) */
  229     int revive_interval;                                    /* and time to wait between transfers */
  230     pid_t reviver;                                          /* PID of reviving process */
  231     /* init parameters */
  232     u_int64_t initialized;                                  /* block number of current init request */
  233     int init_blocksize;                                     /* init block size (bytes) */
  234     int init_interval;                                      /* and time to wait between transfers */
  235 #ifdef _KERNEL
  236     struct request *waitlist;                               /* list of requests waiting on revive op */
  237     struct cdev *dev;                                               /* associated device */
  238 #endif
  239 };
  240 
  241 #ifdef _KERNEL
  242 struct plex
  243 #else
  244 struct _plex
  245 #endif
  246 {
  247     enum plexorg organization;                              /* Plex organization */
  248     enum plexstate state;                                   /* and current state */
  249     u_int64_t length;                                       /* total length of plex (sectors) */
  250     int flags;
  251     int stripesize;                                         /* size of stripe or raid band, in sectors */
  252     int sectorsize;                                         /* sector size for DIOCGSECTORSIZE */
  253     int subdisks;                                           /* number of associated subdisks */
  254     int subdisks_allocated;                                 /* number of subdisks allocated space for */
  255     int *sdnos;                                             /* list of component subdisks */
  256     int plexno;                                             /* index of plex in vinum_conf */
  257     int volno;                                              /* index of volume */
  258     int volplexno;                                          /* number of plex in volume */
  259     /* Statistics */
  260     u_int64_t reads;                                        /* number of reads on this plex */
  261     u_int64_t writes;                                       /* number of writes on this plex */
  262     u_int64_t bytes_read;                                   /* number of bytes read */
  263     u_int64_t bytes_written;                                /* number of bytes written */
  264     u_int64_t recovered_reads;                              /* number of recovered read operations */
  265     u_int64_t degraded_writes;                              /* number of degraded writes */
  266     u_int64_t parityless_writes;                            /* number of parityless writes */
  267     u_int64_t multiblock;                                   /* requests that needed more than one block */
  268     u_int64_t multistripe;                                  /* requests that needed more than one stripe */
  269     int sddowncount;                                        /* number of subdisks down */
  270     /* Lock information */
  271     int usedlocks;                                          /* number currently in use */
  272     int lockwaits;                                          /* and number of waits for locks */
  273     off_t checkblock;                                       /* block number for parity op */
  274     char name[MAXPLEXNAME];                                 /* name of plex */
  275 #ifdef _KERNEL
  276     struct rangelock *lock;                                 /* ranges of locked addresses */
  277     struct mtx *lockmtx;                                    /* lock mutex, one of plexmutex [] */
  278     daddr_t last_addr;                                      /* last address read from this plex */
  279     struct cdev *dev;                                               /* associated device */
  280 #endif
  281 };
  282 
  283 #ifdef _KERNEL
  284 struct volume
  285 #else
  286 struct _volume
  287 #endif
  288 {
  289     char name[MAXVOLNAME];                                  /* name of volume */
  290     enum volumestate state;                                 /* current state */
  291     int plexes;                                             /* number of plexes */
  292     int preferred_plex;                                     /* index of plex to read from,
  293                                                             * -1 for round-robin */
  294     /*
  295      * index of plex used for last read, for
  296      * round-robin.
  297      */
  298     int last_plex_read;
  299     int volno;                                              /* volume number */
  300     int flags;                                              /* status and configuration flags */
  301     int openflags;                                          /* flags supplied to last open(2) */
  302     u_int64_t size;                                         /* size of volume */
  303     int blocksize;                                          /* logical block size */
  304     int sectorsize;                                         /* sector size for DIOCGSECTORSIZE */
  305     int active;                                             /* number of outstanding requests active */
  306     int subops;                                             /* and the number of suboperations */
  307     /* Statistics */
  308     u_int64_t bytes_read;                                   /* number of bytes read */
  309     u_int64_t bytes_written;                                /* number of bytes written */
  310     u_int64_t reads;                                        /* number of reads on this volume */
  311     u_int64_t writes;                                       /* number of writes on this volume */
  312     u_int64_t recovered_reads;                              /* reads recovered from another plex */
  313     /*
  314      * Unlike subdisks in the plex, space for the
  315      * plex pointers is static.
  316      */
  317     int plex[MAXPLEX];                                      /* index of plexes */
  318 #ifdef _KERNEL
  319     struct cdev *dev;                                               /* associated device */
  320 #endif
  321 };

Cache object: 86561894eebada3c0df0581155ff0366


[ 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.