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 bio_set_dev(b, conf->rdev->bdev); in faulty_make_request()
215 bio_set_dev(bio, conf->rdev->bdev); in faulty_make_request()
223 struct faulty_conf *conf = mddev->private; in faulty_status() local
226 if ((n=atomic_read(&conf->counters[WriteTransient])) != 0) in faulty_status()
228 n, conf->period[WriteTransient]); in faulty_status()
230 if ((n=atomic_read(&conf->counters[ReadTransient])) != 0) in faulty_status()
232 n, conf->period[ReadTransient]); in faulty_status()
234 if ((n=atomic_read(&conf->counters[WritePersistent])) != 0) in faulty_status()
236 n, conf->period[WritePersistent]); in faulty_status()
238 if ((n=atomic_read(&conf->counters[ReadPersistent])) != 0) in faulty_status()
240 n, conf->period[ReadPersistent]); in faulty_status()
243 if ((n=atomic_read(&conf->counters[ReadFixable])) != 0) in faulty_status()
245 n, conf->period[ReadFixable]); in faulty_status()
247 if ((n=atomic_read(&conf->counters[WriteAll])) != 0) in faulty_status()
250 seq_printf(seq, " nfaults=%d", conf->nfaults); in faulty_status()
258 struct faulty_conf *conf = mddev->private; in faulty_reshape() local
265 conf->nfaults = 0; in faulty_reshape()
269 conf->period[i] = 0; in faulty_reshape()
270 atomic_set(&conf->counters[i], 0); in faulty_reshape()
273 conf->period[mode] = count; in faulty_reshape()
275 atomic_set(&conf->counters[mode], count); in faulty_reshape()
298 struct faulty_conf *conf; in faulty_run() local
303 conf = kmalloc(sizeof(*conf), GFP_KERNEL); in faulty_run()
304 if (!conf) in faulty_run()
308 atomic_set(&conf->counters[i], 0); in faulty_run()
309 conf->period[i] = 0; in faulty_run()
311 conf->nfaults = 0; in faulty_run()
314 conf->rdev = rdev; in faulty_run()
320 mddev->private = conf; in faulty_run()
329 struct faulty_conf *conf = priv; in faulty_free() local
331 kfree(conf); in faulty_free()