Lines Matching refs:conf

85 static int check_mode(struct faulty_conf *conf, int mode)  in check_mode()  argument
87 if (conf->period[mode] == 0 && in check_mode()
88 atomic_read(&conf->counters[mode]) <= 0) in check_mode()
92 if (atomic_dec_and_test(&conf->counters[mode])) { in check_mode()
93 if (conf->period[mode]) in check_mode()
94 atomic_set(&conf->counters[mode], conf->period[mode]); in check_mode()
100 static int check_sector(struct faulty_conf *conf, sector_t start, sector_t end, int dir) in check_sector() argument
104 for (i=0; i<conf->nfaults; i++) in check_sector()
105 if (conf->faults[i] >= start && in check_sector()
106 conf->faults[i] < end) { in check_sector()
108 switch (conf->modes[i] * 2 + dir) { in check_sector()
113 conf->modes[i] = NoPersist; in check_sector()
124 static void add_sector(struct faulty_conf *conf, sector_t start, int mode) in add_sector() argument
127 int n = conf->nfaults; in add_sector()
128 for (i=0; i<conf->nfaults; i++) in add_sector()
129 if (conf->faults[i] == start) { in add_sector()
131 case NoPersist: conf->modes[i] = mode; return; in add_sector()
133 if (conf->modes[i] == ReadPersistent || in add_sector()
134 conf->modes[i] == ReadFixable) in add_sector()
135 conf->modes[i] = AllPersist; in add_sector()
137 conf->modes[i] = WritePersistent; in add_sector()
140 if (conf->modes[i] == WritePersistent) in add_sector()
141 conf->modes[i] = AllPersist; in add_sector()
143 conf->modes[i] = ReadPersistent; in add_sector()
146 if (conf->modes[i] == WritePersistent || in add_sector()
147 conf->modes[i] == ReadPersistent) in add_sector()
148 conf->modes[i] = AllPersist; in add_sector()
150 conf->modes[i] = ReadFixable; in add_sector()
153 } else if (conf->modes[i] == NoPersist) in add_sector()
158 conf->faults[n] = start; in add_sector()
159 conf->modes[n] = mode; in add_sector()
160 if (conf->nfaults == n) in add_sector()
161 conf->nfaults = n+1; in add_sector()
166 struct faulty_conf *conf = mddev->private; in faulty_make_request() local
171 if (atomic_read(&conf->counters[WriteAll])) { in faulty_make_request()
179 if (check_sector(conf, bio->bi_iter.bi_sector, in faulty_make_request()
182 if (check_mode(conf, WritePersistent)) { in faulty_make_request()
183 add_sector(conf, bio->bi_iter.bi_sector, in faulty_make_request()
187 if (check_mode(conf, WriteTransient)) in faulty_make_request()
191 if (check_sector(conf, bio->bi_iter.bi_sector, in faulty_make_request()
194 if (check_mode(conf, ReadTransient)) in faulty_make_request()
196 if (check_mode(conf, ReadPersistent)) { in faulty_make_request()
197 add_sector(conf, bio->bi_iter.bi_sector, in faulty_make_request()
201 if (check_mode(conf, ReadFixable)) { in faulty_make_request()
202 add_sector(conf, bio->bi_iter.bi_sector, in faulty_make_request()
210 struct bio *b = bio_alloc_clone(conf->rdev->bdev, bio, GFP_NOIO, in faulty_make_request()
217 bio_set_dev(bio, conf->rdev->bdev); in faulty_make_request()
225 struct faulty_conf *conf = mddev->private; in faulty_status() local
228 if ((n=atomic_read(&conf->counters[WriteTransient])) != 0) in faulty_status()
230 n, conf->period[WriteTransient]); in faulty_status()
232 if ((n=atomic_read(&conf->counters[ReadTransient])) != 0) in faulty_status()
234 n, conf->period[ReadTransient]); in faulty_status()
236 if ((n=atomic_read(&conf->counters[WritePersistent])) != 0) in faulty_status()
238 n, conf->period[WritePersistent]); in faulty_status()
240 if ((n=atomic_read(&conf->counters[ReadPersistent])) != 0) in faulty_status()
242 n, conf->period[ReadPersistent]); in faulty_status()
245 if ((n=atomic_read(&conf->counters[ReadFixable])) != 0) in faulty_status()
247 n, conf->period[ReadFixable]); in faulty_status()
249 if ((n=atomic_read(&conf->counters[WriteAll])) != 0) in faulty_status()
252 seq_printf(seq, " nfaults=%d", conf->nfaults); in faulty_status()
260 struct faulty_conf *conf = mddev->private; in faulty_reshape() local
267 conf->nfaults = 0; in faulty_reshape()
271 conf->period[i] = 0; in faulty_reshape()
272 atomic_set(&conf->counters[i], 0); in faulty_reshape()
275 conf->period[mode] = count; in faulty_reshape()
277 atomic_set(&conf->counters[mode], count); in faulty_reshape()
300 struct faulty_conf *conf; in faulty_run() local
305 conf = kmalloc(sizeof(*conf), GFP_KERNEL); in faulty_run()
306 if (!conf) in faulty_run()
310 atomic_set(&conf->counters[i], 0); in faulty_run()
311 conf->period[i] = 0; in faulty_run()
313 conf->nfaults = 0; in faulty_run()
316 conf->rdev = rdev; in faulty_run()
322 mddev->private = conf; in faulty_run()
331 struct faulty_conf *conf = priv; in faulty_free() local
333 kfree(conf); in faulty_free()