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/request.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
    3  *      Nan Yang Computer Services Limited.  All rights reserved.
    4  *
    5  *  This software is distributed under the so-called ``Berkeley
    6  *  License'':
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by Nan Yang Computer
   19  *      Services Limited.
   20  * 4. Neither the name of the Company nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * This software is provided ``as is'', and any express or implied
   25  * warranties, including, but not limited to, the implied warranties of
   26  * merchantability and fitness for a particular purpose are disclaimed.
   27  * In no event shall the company or contributors be liable for any
   28  * direct, indirect, incidental, special, exemplary, or consequential
   29  * damages (including, but not limited to, procurement of substitute
   30  * goods or services; loss of use, data, or profits; or business
   31  * interruption) however caused and on any theory of liability, whether
   32  * in contract, strict liability, or tort (including negligence or
   33  * otherwise) arising in any way out of the use of this software, even if
   34  * advised of the possibility of such damage.
   35  *
   36  * $Id: request.h,v 1.1.1.1 2003/10/10 03:07:33 grog Exp $
   37  * $FreeBSD$
   38  */
   39 
   40 /* Information needed to set up a transfer */
   41 
   42 enum xferinfo {
   43     XFR_NORMAL_READ = 1,
   44     XFR_NORMAL_WRITE = 2,                                   /* write request in normal mode */
   45     XFR_RECOVERY_READ = 4,
   46     XFR_DEGRADED_WRITE = 8,
   47     XFR_PARITYLESS_WRITE = 0x10,
   48     XFR_NO_PARITY_STRIPE = 0x20,                            /* parity stripe is not available */
   49     XFR_DATA_BLOCK = 0x40,                                  /* data block in request */
   50     XFR_PARITY_BLOCK = 0x80,                                /* parity block in request */
   51     XFR_BAD_SUBDISK = 0x100,                                /* this subdisk is dead */
   52     XFR_MALLOCED = 0x200,                                   /* this buffer is malloced */
   53 #ifdef VINUMDEBUG
   54     XFR_PHASE2 = 0x800,                                     /* documentation only: 2nd phase write */
   55 #endif
   56     XFR_REVIVECONFLICT = 0x1000,                            /* possible conflict with a revive operation */
   57     XFR_COPYBUF = 0x4000,                                   /* data buffer was copied */
   58     /* operations that need a parity block */
   59     XFR_PARITYOP = (XFR_NORMAL_WRITE | XFR_RECOVERY_READ | XFR_DEGRADED_WRITE),
   60     /* operations that use the group parameters */
   61     XFR_GROUPOP = (XFR_DEGRADED_WRITE | XFR_RECOVERY_READ),
   62     /* operations that that use the data parameters */
   63     XFR_DATAOP = (XFR_NORMAL_READ | XFR_NORMAL_WRITE | XFR_PARITYLESS_WRITE),
   64     /* operations requiring read before write */
   65     XFR_RBW = (XFR_NORMAL_WRITE | XFR_DEGRADED_WRITE),
   66     /* operations that need a malloced buffer */
   67     XFR_NEEDS_MALLOC = (XFR_NORMAL_WRITE | XFR_RECOVERY_READ | XFR_DEGRADED_WRITE)
   68 };
   69 
   70 /*
   71  * Describe one low-level request, part of a
   72  * high-level request.  This is an extended
   73  * struct buf buffer, and the first element
   74  * *must* be a struct buf.  We pass this
   75  * structure to the I/O routines instead of a
   76  * struct buf in order to be able to locate the
   77  * high-level request when it completes.
   78  *
   79  * All offsets and lengths are in sectors.
   80  */
   81 
   82 struct rqelement {
   83     struct buf b;                                           /* buf structure */
   84     struct rqgroup *rqg;                                    /* pointer to our group */
   85     /* Information about the transfer */
   86     daddr_t sdoffset;                                       /* offset in subdisk */
   87     int useroffset;                                         /* offset in user buffer of normal data */
   88     /*
   89      * dataoffset and datalen refer to "individual" data
   90      * transfers which involve only this drive (normal read,
   91      * parityless write) and also degraded write.
   92      *
   93      * groupoffset and grouplen refer to the other "group"
   94      * operations (normal write, recovery read) which involve
   95      * more than one drive.  Both the offsets are relative to
   96      * the start of the local buffer.
   97      */
   98     int dataoffset;                                         /* offset in buffer of the normal data */
   99     int groupoffset;                                        /* offset in buffer of group data */
  100     short datalen;                                          /* length of normal data (sectors) */
  101     short grouplen;                                         /* length of group data (sectors) */
  102     short buflen;                                           /* total buffer length to allocate */
  103     short flags;                                            /* really enum xferinfo (see above) */
  104     /* Ways to find other components */
  105     short sdno;                                             /* subdisk number */
  106     short driveno;                                          /* drive number */
  107     struct timeval launchtime;                              /* time of launch, for info function */
  108 };
  109 
  110 /*
  111  * A group of requests built to satisfy an I/O
  112  * transfer on a single plex.
  113  */
  114 struct rqgroup {
  115     struct rqgroup *next;                                   /* pointer to next group */
  116     struct request *rq;                                     /* pointer to the request */
  117     short count;                                            /* number of requests in this group */
  118     short active;                                           /* and number active */
  119     short plexno;                                           /* index of plex */
  120     int badsdno;                                            /* index of bad subdisk or -1 */
  121     enum xferinfo flags;                                    /* description of transfer */
  122     struct rangelock *lock;                                 /* lock for this transfer */
  123     daddr_t lockbase;                                       /* and lock address */
  124     struct rqelement rqe[0];                                /* and the elements of this request */
  125 };
  126 
  127 /*
  128  * Describe one high-level request and the
  129  * work we have to do to satisfy it.
  130  */
  131 struct request {
  132     struct buf *bp;                                         /* pointer to the high-level request */
  133     caddr_t save_data;                                      /* for copied write buffers */
  134     enum xferinfo flags;
  135     union {
  136         int volno;                                          /* volume index */
  137         int plexno;                                         /* or plex index */
  138     } volplex;
  139     int error;                                              /* current error indication */
  140     int sdno;                                               /* reviving subdisk (XFR_REVIVECONFLICT) */
  141     short isplex;                                           /* set if this is a plex request */
  142     short active;                                           /* number of subrequests still active */
  143     struct rqgroup *rqg;                                    /* pointer to the first group of requests */
  144     struct rqgroup *lrqg;                                   /* and to the last group of requests */
  145     struct request *next;                                   /* link of waiting requests */
  146 };
  147 
  148 /*
  149  * Extended buffer header for subdisk I/O.  Includes
  150  * a pointer to the user I/O request.
  151  */
  152 struct sdbuf {
  153     struct buf b;                                           /* our buffer */
  154     struct buf *bp;                                         /* and pointer to parent */
  155     short driveno;                                          /* drive index */
  156     short sdno;                                             /* and subdisk index */
  157 };
  158 
  159 /*
  160  * Values returned by rqe and friends.  Be careful
  161  * with these: they are in order of increasing
  162  * seriousness.  Some routines check for
  163  * > REQUEST_RECOVERED to indicate a failed request. XXX
  164  */
  165 enum requeststatus {
  166     REQUEST_OK,                                             /* request built OK */
  167     REQUEST_RECOVERED,                                      /* request OK, but involves RAID5 recovery */
  168     REQUEST_DEGRADED,                                       /* parts of request failed */
  169     REQUEST_EOF,                                            /* parts of request failed: outside plex */
  170     REQUEST_DOWN,                                           /* all of request failed: subdisk(s) down */
  171     REQUEST_ENOMEM                                          /* all of request failed: ran out of memory */
  172 };
  173 
  174 #ifdef VINUMDEBUG
  175 /* Trace entry for request info (DEBUG_LASTREQS) */
  176 enum rqinfo_type {
  177     loginfo_unused,                                         /* never been used */
  178     loginfo_user_bp,                                        /* this is the bp when strategy is called */
  179     loginfo_user_bpl,                                       /* and this is the bp at launch time */
  180     loginfo_rqe,                                            /* user RQE */
  181     loginfo_iodone,                                         /* iodone */
  182     loginfo_raid5_data,                                     /* write RAID-5 data block */
  183     loginfo_raid5_parity,                                   /* write RAID-5 parity block */
  184     loginfo_sdio,                                           /* subdisk I/O */
  185     loginfo_sdiol,                                          /* subdisk I/O launch */
  186     loginfo_sdiodone,                                       /* subdisk iodone */
  187     loginfo_lockwait,                                       /* wait for range lock */
  188     loginfo_lock,                                           /* lock range */
  189     loginfo_unlock,                                         /* unlock range */
  190 };
  191 
  192 /*
  193  * This is the rangelock structure with an added
  194  * buffer pointer and plex number.  We don't need
  195  * the plex number for the locking protocol, but
  196  * it does help a lot when logging.
  197  */
  198 struct rangelockinfo {
  199     daddr_t stripe;                                         /* address + 1 of the range being locked  */
  200     struct buf *bp;                                         /* user's buffer pointer */
  201     int plexno;
  202 };
  203 
  204 union rqinfou {                                             /* info to pass to logrq */
  205     struct buf *bp;
  206     struct rqelement *rqe;                                  /* address of request, for correlation */
  207     struct rangelockinfo *lockinfo;
  208 };
  209 
  210 struct rqinfo {
  211     enum rqinfo_type type;                                  /* kind of event */
  212     struct timeval timestamp;                               /* time it happened */
  213     struct buf *bp;                                         /* point to user buffer */
  214     int devmajor;                                           /* major and minor device info */
  215     int devminor;
  216     union {
  217         struct buf b;                                       /* yup, the *whole* buffer header */
  218         struct rqelement rqe;                               /* and the whole rqe */
  219         struct rangelock lockinfo;
  220     } info;
  221 };
  222 
  223 #define RQINFO_SIZE 128                                     /* number of info slots in buffer */
  224 
  225 void logrq(enum rqinfo_type type, union rqinfou info, struct buf *ubp);
  226 #endif
  227 
  228 /* Structures for the daemon */
  229 
  230 /* types of request to the daemon */
  231 enum daemonrq {
  232     daemonrq_none,                                          /* dummy to catch bugs */
  233     daemonrq_ioerror,                                       /* error occurred on I/O */
  234     daemonrq_saveconfig,                                    /* save configuration */
  235     daemonrq_return,                                        /* return to userland */
  236     daemonrq_ping,                                          /* show sign of life */
  237     daemonrq_init,                                          /* initialize a plex */
  238     daemonrq_revive,                                        /* revive a subdisk */
  239     daemonrq_closedrive,                                    /* close a drive */
  240 };
  241 
  242 /* info field for daemon requests */
  243 union daemoninfo {                                          /* and the request information */
  244     struct request *rq;                                     /* for daemonrq_ioerror */
  245     struct sd *sd;                                          /* for daemonrq_revive */
  246     struct plex *plex;                                      /* for daemonrq_init */
  247     struct drive *drive;                                    /* for daemonrq_closedrive */
  248     int nothing;                                            /* for passing NULL */
  249 };
  250 
  251 struct daemonq {
  252     struct daemonq *next;                                   /* pointer to next element in queue */
  253     enum daemonrq type;                                     /* type of request */
  254     int privateinuse;                                       /* private element, being used */
  255     union daemoninfo info;                                  /* and the request information */
  256 };
  257 
  258 void queue_daemon_request(enum daemonrq type, union daemoninfo info);
  259 
  260 extern int daemon_options;
  261 
  262 enum daemon_option {
  263     daemon_verbose = 1,                                     /* talk about what we're doing */
  264     daemon_stopped = 2,
  265     daemon_noupdate = 4,                                    /* don't update the disk config, for recovery */
  266 };
  267 
  268 void freerq(struct request *rq);
  269 void unlockrange(int plexno, struct rangelock *);
  270 /* Local Variables: */
  271 /* fill-column: 50 */
  272 /* End: */

Cache object: b9f762e6993ec028df850772e793c1ee


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