1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ****************************************************************************
11 ****************************************************************************/
12#ifndef _MD_K_H
13#define _MD_K_H
14
15#include "../../../drivers/md/dm-bio-list.h"
16
17#define LEVEL_MULTIPATH (-4)
18#define LEVEL_LINEAR (-1)
19#define LEVEL_FAULTY (-5)
20
21#define LEVEL_NONE (-1000000)
22
23#define MaxSector (~(sector_t)0)
24#define MD_THREAD_NAME_MAX 14
25
26typedef struct mddev_s mddev_t;
27typedef struct mdk_rdev_s mdk_rdev_t;
28
29#define MAX_MD_DEVS 256
30
31#define MAX_CHUNK_SIZE (1<<30)
32
33struct mdk_rdev_s
34{
35 struct list_head same_set;
36
37 sector_t size;
38 mddev_t *mddev;
39 unsigned long last_events;
40
41 struct block_device *bdev;
42
43 struct page *sb_page;
44 int sb_loaded;
45 __u64 sb_events;
46 sector_t data_offset;
47 sector_t sb_offset;
48 int sb_size;
49 int preferred_minor;
50
51 struct kobject kobj;
52
53 unsigned long flags;
54#define Faulty 1
55#define In_sync 2
56#define WriteMostly 4
57#define BarriersNotsupp 5
58
59 int desc_nr;
60 int raid_disk;
61 int saved_raid_disk;
62 sector_t recovery_offset;
63
64 atomic_t nr_pending;
65 atomic_t read_errors;
66 atomic_t corrected_errors;
67};
68
69struct mddev_s
70{
71 void *private;
72 struct mdk_personality *pers;
73 dev_t unit;
74 int md_minor;
75 struct list_head disks;
76 int sb_dirty;
77 int ro;
78
79 struct gendisk *gendisk;
80
81 struct kobject kobj;
82
83 int major_version,
84 minor_version,
85 patch_version;
86 int persistent;
87 int chunk_size;
88 time_t ctime, utime;
89 int level, layout;
90 char clevel[16];
91 int raid_disks;
92 int max_disks;
93 sector_t size;
94 sector_t array_size;
95 __u64 events;
96
97 char uuid[16];
98
99 sector_t reshape_position;
100 int delta_disks, new_level, new_layout, new_chunk;
101
102 struct mdk_thread_s *thread;
103 struct mdk_thread_s *sync_thread;
104 sector_t curr_resync;
105 unsigned long resync_mark;
106 sector_t resync_mark_cnt;
107 sector_t curr_mark_cnt;
108
109 sector_t resync_max_sectors;
110
111 sector_t resync_mismatches;
112
113 sector_t suspend_lo;
114 sector_t suspend_hi;
115
116 int sync_speed_min;
117 int sync_speed_max;
118
119 int ok_start_degraded;
120
121#define MD_RECOVERY_RUNNING 0
122#define MD_RECOVERY_SYNC 1
123#define MD_RECOVERY_ERR 2
124#define MD_RECOVERY_INTR 3
125#define MD_RECOVERY_DONE 4
126#define MD_RECOVERY_NEEDED 5
127#define MD_RECOVERY_REQUESTED 6
128#define MD_RECOVERY_CHECK 7
129#define MD_RECOVERY_RESHAPE 8
130#define MD_RECOVERY_FROZEN 9
131
132 unsigned long recovery;
133
134 int in_sync;
135 struct mutex reconfig_mutex;
136 atomic_t active;
137
138 int changed;
139 int degraded;
140 int barriers_work;
141 struct bio *biolist;
142
143 atomic_t recovery_active;
144 wait_queue_head_t recovery_wait;
145 sector_t recovery_cp;
146
147 spinlock_t write_lock;
148 wait_queue_head_t sb_wait;
149 atomic_t pending_writes;
150
151 unsigned int safemode;
152 unsigned int safemode_delay;
153 struct timer_list safemode_timer;
154 atomic_t writes_pending;
155 request_queue_t *queue;
156
157 atomic_t write_behind;
158 unsigned int max_write_behind;
159
160 struct bitmap *bitmap;
161 struct file *bitmap_file;
162 long bitmap_offset;
163 long default_bitmap_offset;
164
165 struct list_head all_mddevs;
166};
167
168struct md_sysfs_entry {
169 struct attribute attr;
170 ssize_t (*show)(mddev_t *, char *);
171 ssize_t (*store)(mddev_t *, const char *, size_t);
172};
173
174#define ITERATE_RDEV_GENERIC(head,rdev,tmp)     for ((tmp) = (head).next;   (rdev) = (list_entry((tmp), mdk_rdev_t, same_set)),   (tmp) = (tmp)->next, (tmp)->prev != &(head)   ; )
175#define ITERATE_RDEV(mddev,rdev,tmp)   ITERATE_RDEV_GENERIC((mddev)->disks,rdev,tmp)
176#define ITERATE_RDEV_PENDING(rdev,tmp)   ITERATE_RDEV_GENERIC(pending_raid_disks,rdev,tmp)
177
178#define THREAD_WAKEUP 0
179
180#define __wait_event_lock_irq(wq, condition, lock, cmd)  do {   wait_queue_t __wait;   init_waitqueue_entry(&__wait, current);     add_wait_queue(&wq, &__wait);   for (;;) {   set_current_state(TASK_UNINTERRUPTIBLE);   if (condition)   break;   spin_unlock_irq(&lock);   cmd;   schedule();   spin_lock_irq(&lock);   }   current->state = TASK_RUNNING;   remove_wait_queue(&wq, &__wait);  } while (0)
181
182#define wait_event_lock_irq(wq, condition, lock, cmd)  do {   if (condition)   break;   __wait_event_lock_irq(wq, condition, lock, cmd);  } while (0)
183
184#endif
185