Lines Matching refs:conf
93 static int check_mode(conf_t *conf, int mode)
95 if (conf->period[mode] == 0 &&
96 atomic_read(&conf->counters[mode]) <= 0)
100 if (atomic_dec_and_test(&conf->counters[mode])) {
101 if (conf->period[mode])
102 atomic_set(&conf->counters[mode], conf->period[mode]);
108 static int check_sector(conf_t *conf, sector_t start, sector_t end, int dir)
112 for (i=0; i<conf->nfaults; i++)
113 if (conf->faults[i] >= start &&
114 conf->faults[i] < end) {
116 switch (conf->modes[i] * 2 + dir) {
121 conf->modes[i] = NoPersist;
132 static void add_sector(conf_t *conf, sector_t start, int mode)
135 int n = conf->nfaults;
136 for (i=0; i<conf->nfaults; i++)
137 if (conf->faults[i] == start) {
139 case NoPersist: conf->modes[i] = mode; return;
141 if (conf->modes[i] == ReadPersistent ||
142 conf->modes[i] == ReadFixable)
143 conf->modes[i] = AllPersist;
145 conf->modes[i] = WritePersistent;
148 if (conf->modes[i] == WritePersistent)
149 conf->modes[i] = AllPersist;
151 conf->modes[i] = ReadPersistent;
154 if (conf->modes[i] == WritePersistent ||
155 conf->modes[i] == ReadPersistent)
156 conf->modes[i] = AllPersist;
158 conf->modes[i] = ReadFixable;
161 } else if (conf->modes[i] == NoPersist)
166 conf->faults[n] = start;
167 conf->modes[n] = mode;
168 if (conf->nfaults == n)
169 conf->nfaults = n+1;
174 conf_t *conf = mddev->private;
179 if (atomic_read(&conf->counters[WriteAll])) {
187 if (check_sector(conf, bio->bi_sector, bio->bi_sector+(bio->bi_size>>9),
190 if (check_mode(conf, WritePersistent)) {
191 add_sector(conf, bio->bi_sector, WritePersistent);
194 if (check_mode(conf, WriteTransient))
198 if (check_sector(conf, bio->bi_sector, bio->bi_sector + (bio->bi_size>>9),
201 if (check_mode(conf, ReadTransient))
203 if (check_mode(conf, ReadPersistent)) {
204 add_sector(conf, bio->bi_sector, ReadPersistent);
207 if (check_mode(conf, ReadFixable)) {
208 add_sector(conf, bio->bi_sector, ReadFixable);
214 b->bi_bdev = conf->rdev->bdev;
220 bio->bi_bdev = conf->rdev->bdev;
227 conf_t *conf = mddev->private;
230 if ((n=atomic_read(&conf->counters[WriteTransient])) != 0)
232 n, conf->period[WriteTransient]);
234 if ((n=atomic_read(&conf->counters[ReadTransient])) != 0)
236 n, conf->period[ReadTransient]);
238 if ((n=atomic_read(&conf->counters[WritePersistent])) != 0)
240 n, conf->period[WritePersistent]);
242 if ((n=atomic_read(&conf->counters[ReadPersistent])) != 0)
244 n, conf->period[ReadPersistent]);
247 if ((n=atomic_read(&conf->counters[ReadFixable])) != 0)
249 n, conf->period[ReadFixable]);
251 if ((n=atomic_read(&conf->counters[WriteAll])) != 0)
254 seq_printf(seq, " nfaults=%d", conf->nfaults);
262 conf_t *conf = mddev->private;
269 conf->nfaults = 0;
273 conf->period[i] = 0;
274 atomic_set(&conf->counters[i], 0);
277 conf->period[mode] = count;
279 atomic_set(&conf->counters[mode], count);
302 conf_t *conf;
307 conf = kmalloc(sizeof(*conf), GFP_KERNEL);
308 if (!conf)
312 atomic_set(&conf->counters[i], 0);
313 conf->period[i] = 0;
315 conf->nfaults = 0;
318 conf->rdev = rdev;
321 mddev->private = conf;
330 conf_t *conf = mddev->private;
332 kfree(conf);