fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / linux / genhd.h
index 749992d..0a022b2 100644 (file)
@@ -9,13 +9,9 @@
  *             <drew@colorado.edu>
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
-#include <linux/major.h>
-#include <linux/device.h>
-#include <linux/smp.h>
-#include <linux/string.h>
-#include <linux/fs.h>
+
+#ifdef CONFIG_BLOCK
 
 enum {
 /* These three have identical behaviour; use the second one if DOS FDISK gets
@@ -28,6 +24,7 @@ enum {
        LINUX_RAID_PARTITION = 0xfd,    /* autodetect RAID partition */
 
        SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
+       NEW_SOLARIS_X86_PARTITION = 0xbf,
 
        DM6_AUX1PARTITION = 0x51,       /* no DDO:  use xlated geom */
        DM6_AUX3PARTITION = 0x53,       /* no DDO:  use xlated geom */
@@ -60,6 +57,12 @@ struct partition {
 #endif
 
 #ifdef __KERNEL__
+#include <linux/major.h>
+#include <linux/device.h>
+#include <linux/smp.h>
+#include <linux/string.h>
+#include <linux/fs.h>
+
 struct partition {
        unsigned char boot_ind;         /* 0x80 - active */
        unsigned char head;             /* starting head */
@@ -77,8 +80,12 @@ struct hd_struct {
        sector_t start_sect;
        sector_t nr_sects;
        struct kobject kobj;
-       unsigned reads, read_sectors, writes, write_sectors;
+       struct kobject *holder_dir;
+       unsigned ios[2], sectors[2];    /* READs and WRITEs */
        int policy, partno;
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+       int make_it_fail;
+#endif
 };
 
 #define GENHD_FL_REMOVABLE                     1
@@ -86,14 +93,15 @@ struct hd_struct {
 #define GENHD_FL_CD                            8
 #define GENHD_FL_UP                            16
 #define GENHD_FL_SUPPRESS_PARTITION_INFO       32
+#define GENHD_FL_FAIL                          64
 
 struct disk_stats {
-       unsigned read_sectors, write_sectors;
-       unsigned reads, writes;
-       unsigned read_merges, write_merges;
-       unsigned read_ticks, write_ticks;
-       unsigned io_ticks;
-       unsigned time_in_queue;
+       unsigned long sectors[2];       /* READs and WRITEs */
+       unsigned long ios[2];
+       unsigned long merges[2];
+       unsigned long ticks[2];
+       unsigned long io_ticks;
+       unsigned long time_in_queue;
 };
        
 struct gendisk {
@@ -103,22 +111,23 @@ struct gendisk {
                                          * disks that can't be partitioned. */
        char disk_name[32];             /* name of major driver */
        struct hd_struct **part;        /* [indexed by minor] */
+       int part_uevent_suppress;
        struct block_device_operations *fops;
        struct request_queue *queue;
        void *private_data;
        sector_t capacity;
 
        int flags;
-       char devfs_name[64];            /* devfs crap */
-       int number;                     /* more of the same */
        struct device *driverfs_dev;
        struct kobject kobj;
+       struct kobject *holder_dir;
+       struct kobject *slave_dir;
 
        struct timer_rand_state *random;
        int policy;
 
        atomic_t sync_io;               /* RAID */
-       unsigned long stamp, stamp_idle;
+       unsigned long stamp;
        int in_flight;
 #ifdef CONFIG_SMP
        struct disk_stats *dkstats;
@@ -127,39 +136,42 @@ struct gendisk {
 #endif
 };
 
+/* Structure for sysfs attributes on block devices */
+struct disk_attribute {
+       struct attribute attr;
+       ssize_t (*show)(struct gendisk *, char *);
+       ssize_t (*store)(struct gendisk *, const char *, size_t);
+};
+
 /* 
  * Macros to operate on percpu disk statistics:
- * Since writes to disk_stats are serialised through the queue_lock,
- * smp_processor_id() should be enough to get to the per_cpu versions
- * of statistics counters
+ *
+ * The __ variants should only be called in critical sections. The full
+ * variants disable/enable preemption.
  */
 #ifdef CONFIG_SMP
-#define disk_stat_add(gendiskp, field, addnd)  \
+#define __disk_stat_add(gendiskp, field, addnd)        \
        (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd)
+
 #define disk_stat_read(gendiskp, field)                                        \
 ({                                                                     \
        typeof(gendiskp->dkstats->field) res = 0;                       \
        int i;                                                          \
-       for (i=0; i < NR_CPUS; i++) {                                   \
-               if (!cpu_possible(i))                                   \
-                       continue;                                       \
+       for_each_possible_cpu(i)                                        \
                res += per_cpu_ptr(gendiskp->dkstats, i)->field;        \
-       }                                                               \
        res;                                                            \
 })
 
 static inline void disk_stat_set_all(struct gendisk *gendiskp, int value)      {
        int i;
-       for (i=0; i < NR_CPUS; i++) {
-               if (cpu_possible(i)) {
-                       memset(per_cpu_ptr(gendiskp->dkstats, i), value,        
-                                       sizeof (struct disk_stats));
-               }
-       }
+       for_each_possible_cpu(i)
+               memset(per_cpu_ptr(gendiskp->dkstats, i), value,
+                               sizeof (struct disk_stats));
 }              
                                
 #else
-#define disk_stat_add(gendiskp, field, addnd) (gendiskp->dkstats.field += addnd)
+#define __disk_stat_add(gendiskp, field, addnd) \
+                               (gendiskp->dkstats.field += addnd)
 #define disk_stat_read(gendiskp, field)        (gendiskp->dkstats.field)
 
 static inline void disk_stat_set_all(struct gendisk *gendiskp, int value)      {
@@ -167,8 +179,21 @@ static inline void disk_stat_set_all(struct gendisk *gendiskp, int value)  {
 }
 #endif
 
-#define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1)
+#define disk_stat_add(gendiskp, field, addnd)                  \
+       do {                                                    \
+               preempt_disable();                              \
+               __disk_stat_add(gendiskp, field, addnd);        \
+               preempt_enable();                               \
+       } while (0)
+
+#define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1)
 #define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1)
+
+#define __disk_stat_inc(gendiskp, field) __disk_stat_add(gendiskp, field, 1)
+#define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1)
+
+#define __disk_stat_sub(gendiskp, field, subnd) \
+               __disk_stat_add(gendiskp, field, -subnd)
 #define disk_stat_sub(gendiskp, field, subnd) \
                disk_stat_add(gendiskp, field, -subnd)
 
@@ -202,6 +227,7 @@ static inline void free_disk_stats(struct gendisk *disk)
 extern void disk_round_stats(struct gendisk *disk);
 
 /* drivers/block/genhd.c */
+extern int get_blkdev_list(char *, int);
 extern void add_disk(struct gendisk *disk);
 extern void del_gendisk(struct gendisk *gp);
 extern void unlink_gendisk(struct gendisk *gp);
@@ -380,6 +406,7 @@ extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
 extern void add_partition(struct gendisk *, int, sector_t, sector_t);
 extern void delete_partition(struct gendisk *, int);
 
+extern struct gendisk *alloc_disk_node(int minors, int node_id);
 extern struct gendisk *alloc_disk(int minors);
 extern struct kobject *get_disk(struct gendisk *disk);
 extern void put_disk(struct gendisk *disk);
@@ -399,3 +426,5 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
 #endif
 
 #endif
+
+#endif