4 #include <linux/raid/md.h>
5 #include <linux/raid/xor.h>
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 */
48 #define PHASE_READ_OLD 1
51 #define PHASE_COMPLETE 4
57 #define RECONSTRUCT_WRITE 1
58 #define READ_MODIFY_WRITE 2
63 #define STRIPE_LOCKED 0
64 #define STRIPE_ERROR 1
70 #define STRIPE_WRITE 1
74 struct raid5_private_data
{
75 struct stripe_head
**stripe_hashtbl
;
77 mdk_thread_t
*thread
, *resync_thread
;
78 struct disk_info disks
[MD_SB_DISKS
];
79 struct disk_info
*spare
;
81 int chunk_size
, level
, algorithm
;
82 int raid_disks
, working_disks
, failed_disks
;
83 unsigned long next_sector
;
85 struct stripe_head
*next_free_stripe
;
90 atomic_t nr_hashed_stripes
;
91 atomic_t nr_locked_stripes
;
92 atomic_t nr_pending_stripes
;
93 atomic_t nr_cached_stripes
;
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