root/include/linux/md.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 
   2 /*
   3    md.h : Multiple Devices driver for Linux
   4           Copyright (C) 1994-96 Marc ZYNGIER
   5           <zyngier@ufr-info-p7.ibp.fr> or
   6           <maz@gloups.fdn.fr>
   7           
   8    This program is free software; you can redistribute it and/or modify
   9    it under the terms of the GNU General Public License as published by
  10    the Free Software Foundation; either version 2, or (at your option)
  11    any later version.
  12    
  13    You should have received a copy of the GNU General Public License
  14    (for example /usr/src/linux/COPYING); if not, write to the Free
  15    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
  16 */
  17 
  18 #ifndef _MD_H
  19 #define _MD_H
  20 
  21 #include <linux/major.h>
  22 #include <linux/mm.h>
  23 #include <linux/ioctl.h>
  24 
  25 #define MD_VERSION "0.34"
  26 
  27 /* ioctls */
  28 #define REGISTER_DEV _IO (MD_MAJOR, 1)
  29 #define START_MD     _IO (MD_MAJOR, 2)
  30 #define STOP_MD      _IO (MD_MAJOR, 3)
  31 #define MD_INVALID   _IO (MD_MAJOR, 4)
  32 #define MD_VALID     _IO (MD_MAJOR, 5)
  33 
  34 /*
  35    personalities :
  36    Byte 0 : Chunk size factor
  37    Byte 1 : Fault tolerance count for each physical device
  38             (   0 means no fault tolerance,
  39              0xFF means always tolerate faults)
  40    Byte 2 : Personality
  41    Byte 3 : Reserved.
  42  */
  43 
  44 #define FAULT_SHIFT       8
  45 #define PERSONALITY_SHIFT 16
  46 
  47 #define FACTOR_MASK       0xFFUL
  48 #define FAULT_MASK        0xFF00UL
  49 #define PERSONALITY_MASK  0xFF0000UL
  50 
  51 #define MD_RESERVED       0     /* Not used by now */
  52 #define LINEAR            (1UL << PERSONALITY_SHIFT)
  53 #define STRIPED           (2UL << PERSONALITY_SHIFT)
  54 #define STRIPPED          STRIPED /* Long lasting spelling mistake... */
  55 #define RAID0             STRIPED
  56 #define RAID1             (3UL << PERSONALITY_SHIFT)
  57 #define RAID5             (4UL << PERSONALITY_SHIFT)
  58 #define MAX_PERSONALITY   5
  59 
  60 #ifdef __KERNEL__
  61 
  62 #include <linux/config.h>
  63 #include <sys/types.h>
  64 #include <linux/fs.h>
  65 #include <linux/blkdev.h>
  66 
  67 #undef MD_COUNT_SIZE            /* Define this to have stats about
  68                                    chunk size in /proc/mdstat */
  69 #define MAX_REAL     8          /* Max number of physical dev per md dev */
  70 #define MAX_MD_DEV   4          /* Max number of md dev */
  71 
  72 #define FACTOR(a)         ((a)->repartition & FACTOR_MASK)
  73 #define MAX_FAULT(a)      (((a)->repartition & FAULT_MASK)>>8)
  74 #define PERSONALITY(a)    ((a)->repartition & PERSONALITY_MASK)
  75 
  76 #define FACTOR_SHIFT(a) (PAGE_SHIFT + (a) - 10)
  77 
  78 /* Invalidation modes */
  79 #define VALID          0
  80 #define INVALID_NEXT   1
  81 #define INVALID_ALWAYS 2
  82 #define INVALID        3        /* Only useful to md_valid_device */
  83 
  84 /* Return values from personalities to md driver */
  85 #define REDIRECTED_BHREQ 0 /* Redirected individual buffers
  86                               (shouldn't be used anymore since 0.31) */
  87 #define REDIRECTED_REQ   1 /* Redirected whole request */
  88 #define REDIRECT_FAILED -1 /* For RAID-1 */
  89 
  90 struct real_dev
  91 {
  92   kdev_t dev;                   /* Device number */
  93   int size;                     /* Device size (in blocks) */
  94   int offset;                   /* Real device offset (in blocks) in md dev
  95                                    (only used in linear mode) */
  96   struct inode *inode;          /* Lock inode */
  97   int fault_count;              /* Fault counter for invalidation */
  98   int invalid;                  /* Indicate if the device is disabled :
  99                                    VALID          - valid
 100                                    INVALID_NEXT   - disabled for next access
 101                                    INVALID_ALWAYS - permanently disabled
 102                                    (for redundancy modes only) */
 103 };
 104 
 105 struct md_dev;
 106 
 107 struct md_personality
 108 {
 109   char *name;
 110   int (*map)(int minor, struct md_dev *md_dev, struct request *req);
 111   int (*run)(int minor, struct md_dev *md_dev);
 112   int (*stop)(int minor, struct md_dev *md_dev);
 113   int (*status)(char *page, int minor, struct md_dev *md_dev);
 114   int (*ioctl)(struct inode *inode, struct file *file,
 115                unsigned int cmd, unsigned long arg);
 116   int max_invalid_dev;
 117 };
 118 
 119 struct md_dev
 120 {
 121   struct md_personality *pers;
 122   int repartition;
 123   int invalid_dev_count;
 124   int busy;
 125   int nb_dev;
 126   void *private;
 127 #ifdef MD_COUNT_SIZE
 128   unsigned int smallest_count;
 129   unsigned int biggest_count;
 130   unsigned int equal_count;
 131 #endif
 132 };
 133 
 134 extern struct real_dev devices[MAX_MD_DEV][MAX_REAL];
 135 extern struct md_dev md_dev[MAX_MD_DEV];
 136 extern int md_size[MAX_MD_DEV];
 137 
 138 extern void make_md_request(struct request *pending, int n);
 139 extern char *partition_name (kdev_t dev);
 140 
 141 #if defined(CONFIG_MD_SUPPORT_RAID1) || defined(CONFIG_MD_SUPPORT_RAID5)
 142 extern int md_valid_device (int minor, kdev_t dev, int mode);
 143 extern int md_can_reemit (int minor);
 144 #endif
 145 
 146 extern int register_md_personality (int p_num, struct md_personality *p);
 147 extern int unregister_md_personality (int p_num);
 148 
 149 #endif __KERNEL__
 150 #endif _MD_H

/* [previous][next][first][last][top][bottom][index][help] */