Linux 2.3.1pre3
[davej-history.git] / include / linux / raid5.h
blob655d41d54ad1bccc7ec74b9a9050d4adbf16799f
1 #ifndef _RAID5_H
2 #define _RAID5_H
4 #ifdef __KERNEL__
5 #include <linux/md.h>
6 #include <asm/atomic.h>
8 struct disk_info {
9 kdev_t dev;
10 int operational;
11 int number;
12 int raid_disk;
13 int write_only;
14 int spare;
17 struct stripe_head {
18 struct stripe_head *hash_next, **hash_pprev; /* hash pointers */
19 struct stripe_head *free_next; /* pool of free sh's */
20 struct buffer_head *buffer_pool; /* pool of free buffers */
21 struct buffer_head *bh_pool; /* pool of free bh's */
22 struct raid5_data *raid_conf;
23 struct buffer_head *bh_old[MD_SB_DISKS]; /* disk image */
24 struct buffer_head *bh_new[MD_SB_DISKS]; /* buffers of the MD device (present in buffer cache) */
25 struct buffer_head *bh_copy[MD_SB_DISKS]; /* copy on write of bh_new (bh_new can change from under us) */
26 struct buffer_head *bh_req[MD_SB_DISKS]; /* copy of bh_new (only the buffer heads), queued to the lower levels */
27 int cmd_new[MD_SB_DISKS]; /* READ/WRITE for new */
28 int new[MD_SB_DISKS]; /* buffer added since the last handle_stripe() */
29 unsigned long sector; /* sector of this row */
30 int size; /* buffers size */
31 int pd_idx; /* parity disk index */
32 int nr_pending; /* nr of pending cmds */
33 unsigned long state; /* state flags */
34 int cmd; /* stripe cmd */
35 int count; /* nr of waiters */
36 int write_method; /* reconstruct-write / read-modify-write */
37 int phase; /* PHASE_BEGIN, ..., PHASE_COMPLETE */
38 wait_queue_head_t wait; /* processes waiting for this stripe */
42 * Phase
44 #define PHASE_BEGIN 0
45 #define PHASE_READ_OLD 1
46 #define PHASE_WRITE 2
47 #define PHASE_READ 3
48 #define PHASE_COMPLETE 4
51 * Write method
53 #define METHOD_NONE 0
54 #define RECONSTRUCT_WRITE 1
55 #define READ_MODIFY_WRITE 2
58 * Stripe state
60 #define STRIPE_LOCKED 0
61 #define STRIPE_ERROR 1
64 * Stripe commands
66 #define STRIPE_NONE 0
67 #define STRIPE_WRITE 1
68 #define STRIPE_READ 2
70 struct raid5_data {
71 struct stripe_head **stripe_hashtbl;
72 struct md_dev *mddev;
73 struct md_thread *thread, *resync_thread;
74 struct disk_info disks[MD_SB_DISKS];
75 struct disk_info *spare;
76 int buffer_size;
77 int chunk_size, level, algorithm;
78 int raid_disks, working_disks, failed_disks;
79 int sector_count;
80 unsigned long next_sector;
81 atomic_t nr_handle;
82 struct stripe_head *next_free_stripe;
83 int nr_stripes;
84 int resync_parity;
85 int max_nr_stripes;
86 int clock;
87 int nr_hashed_stripes;
88 int nr_locked_stripes;
89 int nr_pending_stripes;
90 int nr_cached_stripes;
93 * Free stripes pool
95 int nr_free_sh;
96 struct stripe_head *free_sh_list;
97 wait_queue_head_t wait_for_stripe;
100 #endif
103 * Our supported algorithms
105 #define ALGORITHM_LEFT_ASYMMETRIC 0
106 #define ALGORITHM_RIGHT_ASYMMETRIC 1
107 #define ALGORITHM_LEFT_SYMMETRIC 2
108 #define ALGORITHM_RIGHT_SYMMETRIC 3
110 #endif