Merge with Linux 2.4.0-test6-pre9.
[linux-2.6/linux-mips.git] / include / linux / raid / raid5.h
blobdd5ad01ae269d56e5f8853601c603f5853bcb8b4
1 #ifndef _RAID5_H
2 #define _RAID5_H
4 #include <linux/raid/md.h>
5 #include <linux/raid/xor.h>
7 struct disk_info {
8 kdev_t dev;
9 int operational;
10 int number;
11 int raid_disk;
12 int write_only;
13 int spare;
14 int used_slot;
17 struct stripe_head {
18 md_spinlock_t stripe_lock;
19 struct stripe_head *hash_next, **hash_pprev; /* hash pointers */
20 struct stripe_head *free_next; /* pool of free sh's */
21 struct buffer_head *buffer_pool; /* pool of free buffers */
22 struct buffer_head *bh_pool; /* pool of free bh's */
23 struct raid5_private_data *raid_conf;
24 struct buffer_head *bh_old[MD_SB_DISKS]; /* disk image */
25 struct buffer_head *bh_new[MD_SB_DISKS]; /* buffers of the MD device (present in buffer cache) */
26 struct buffer_head *bh_copy[MD_SB_DISKS]; /* copy on write of bh_new (bh_new can change from under us) */
27 struct buffer_head *bh_req[MD_SB_DISKS]; /* copy of bh_new (only the buffer heads), queued to the lower levels */
28 int cmd_new[MD_SB_DISKS]; /* READ/WRITE for new */
29 int new[MD_SB_DISKS]; /* buffer added since the last handle_stripe() */
30 unsigned long sector; /* sector of this row */
31 int size; /* buffers size */
32 int pd_idx; /* parity disk index */
33 atomic_t nr_pending; /* nr of pending cmds */
34 unsigned long state; /* state flags */
35 int cmd; /* stripe cmd */
36 atomic_t count; /* nr of waiters */
37 int write_method; /* reconstruct-write / read-modify-write */
38 int phase; /* PHASE_BEGIN, ..., PHASE_COMPLETE */
39 md_wait_queue_head_t wait; /* processes waiting for this stripe */
41 int sync_redone;
45 * Phase
47 #define PHASE_BEGIN 0
48 #define PHASE_READ_OLD 1
49 #define PHASE_WRITE 2
50 #define PHASE_READ 3
51 #define PHASE_COMPLETE 4
54 * Write method
56 #define METHOD_NONE 0
57 #define RECONSTRUCT_WRITE 1
58 #define READ_MODIFY_WRITE 2
61 * Stripe state
63 #define STRIPE_LOCKED 0
64 #define STRIPE_ERROR 1
67 * Stripe commands
69 #define STRIPE_NONE 0
70 #define STRIPE_WRITE 1
71 #define STRIPE_READ 2
72 #define STRIPE_SYNC 3
74 struct raid5_private_data {
75 struct stripe_head **stripe_hashtbl;
76 mddev_t *mddev;
77 mdk_thread_t *thread, *resync_thread;
78 struct disk_info disks[MD_SB_DISKS];
79 struct disk_info *spare;
80 int buffer_size;
81 int chunk_size, level, algorithm;
82 int raid_disks, working_disks, failed_disks;
83 unsigned long next_sector;
84 atomic_t nr_handle;
85 struct stripe_head *next_free_stripe;
86 atomic_t nr_stripes;
87 int resync_parity;
88 int max_nr_stripes;
89 int clock;
90 atomic_t nr_hashed_stripes;
91 atomic_t nr_locked_stripes;
92 atomic_t nr_pending_stripes;
93 atomic_t nr_cached_stripes;
96 * Free stripes pool
98 atomic_t nr_free_sh;
99 struct stripe_head *free_sh_list;
100 md_wait_queue_head_t wait_for_stripe;
102 md_spinlock_t device_lock;
105 typedef struct raid5_private_data raid5_conf_t;
107 #define mddev_to_conf(mddev) ((raid5_conf_t *) mddev->private)
110 * Our supported algorithms
112 #define ALGORITHM_LEFT_ASYMMETRIC 0
113 #define ALGORITHM_RIGHT_ASYMMETRIC 1
114 #define ALGORITHM_LEFT_SYMMETRIC 2
115 #define ALGORITHM_RIGHT_SYMMETRIC 3
117 #endif