Lines Matching refs:sc

56 	struct stripe_c *sc = container_of(work, struct stripe_c,  in trigger_event()  local
58 dm_table_event(sc->ti->table); in trigger_event()
64 static int get_stripe(struct dm_target *ti, struct stripe_c *sc, in get_stripe() argument
75 &sc->stripe[stripe].dev); in get_stripe()
79 sc->stripe[stripe].physical_start = start; in get_stripe()
90 struct stripe_c *sc; in stripe_ctr() local
132 sc = kmalloc(struct_size(sc, stripe, stripes), GFP_KERNEL); in stripe_ctr()
133 if (!sc) { in stripe_ctr()
138 INIT_WORK(&sc->trigger_event, trigger_event); in stripe_ctr()
141 sc->ti = ti; in stripe_ctr()
142 sc->stripes = stripes; in stripe_ctr()
143 sc->stripe_width = width; in stripe_ctr()
146 sc->stripes_shift = -1; in stripe_ctr()
148 sc->stripes_shift = __ffs(stripes); in stripe_ctr()
152 kfree(sc); in stripe_ctr()
161 sc->chunk_size = chunk_size; in stripe_ctr()
163 sc->chunk_size_shift = -1; in stripe_ctr()
165 sc->chunk_size_shift = __ffs(chunk_size); in stripe_ctr()
173 r = get_stripe(ti, sc, i, argv); in stripe_ctr()
177 dm_put_device(ti, sc->stripe[i].dev); in stripe_ctr()
178 kfree(sc); in stripe_ctr()
181 atomic_set(&(sc->stripe[i].error_count), 0); in stripe_ctr()
184 ti->private = sc; in stripe_ctr()
192 struct stripe_c *sc = ti->private; in stripe_dtr() local
194 for (i = 0; i < sc->stripes; i++) in stripe_dtr()
195 dm_put_device(ti, sc->stripe[i].dev); in stripe_dtr()
197 flush_work(&sc->trigger_event); in stripe_dtr()
198 kfree(sc); in stripe_dtr()
201 static void stripe_map_sector(struct stripe_c *sc, sector_t sector, in stripe_map_sector() argument
204 sector_t chunk = dm_target_offset(sc->ti, sector); in stripe_map_sector()
207 if (sc->chunk_size_shift < 0) in stripe_map_sector()
208 chunk_offset = sector_div(chunk, sc->chunk_size); in stripe_map_sector()
210 chunk_offset = chunk & (sc->chunk_size - 1); in stripe_map_sector()
211 chunk >>= sc->chunk_size_shift; in stripe_map_sector()
214 if (sc->stripes_shift < 0) in stripe_map_sector()
215 *stripe = sector_div(chunk, sc->stripes); in stripe_map_sector()
217 *stripe = chunk & (sc->stripes - 1); in stripe_map_sector()
218 chunk >>= sc->stripes_shift; in stripe_map_sector()
221 if (sc->chunk_size_shift < 0) in stripe_map_sector()
222 chunk *= sc->chunk_size; in stripe_map_sector()
224 chunk <<= sc->chunk_size_shift; in stripe_map_sector()
229 static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector, in stripe_map_range_sector() argument
234 stripe_map_sector(sc, sector, &stripe, result); in stripe_map_range_sector()
240 if (sc->chunk_size_shift < 0) in stripe_map_range_sector()
241 *result -= sector_div(sector, sc->chunk_size); in stripe_map_range_sector()
243 *result = sector & ~(sector_t)(sc->chunk_size - 1); in stripe_map_range_sector()
246 *result += sc->chunk_size; /* next chunk */ in stripe_map_range_sector()
249 static int stripe_map_range(struct stripe_c *sc, struct bio *bio, in stripe_map_range() argument
254 stripe_map_range_sector(sc, bio->bi_iter.bi_sector, in stripe_map_range()
256 stripe_map_range_sector(sc, bio_end_sector(bio), in stripe_map_range()
259 bio_set_dev(bio, sc->stripe[target_stripe].dev->bdev); in stripe_map_range()
261 sc->stripe[target_stripe].physical_start; in stripe_map_range()
273 struct stripe_c *sc = ti->private; in stripe_map() local
279 BUG_ON(target_bio_nr >= sc->stripes); in stripe_map()
280 bio_set_dev(bio, sc->stripe[target_bio_nr].dev->bdev); in stripe_map()
287 BUG_ON(target_bio_nr >= sc->stripes); in stripe_map()
288 return stripe_map_range(sc, bio, target_bio_nr); in stripe_map()
291 stripe_map_sector(sc, bio->bi_iter.bi_sector, in stripe_map()
294 bio->bi_iter.bi_sector += sc->stripe[stripe].physical_start; in stripe_map()
295 bio_set_dev(bio, sc->stripe[stripe].dev->bdev); in stripe_map()
303 struct stripe_c *sc = ti->private; in stripe_dax_pgoff() local
308 stripe_map_sector(sc, *pgoff * PAGE_SECTORS, &stripe, &dev_sector); in stripe_dax_pgoff()
309 dev_sector += sc->stripe[stripe].physical_start; in stripe_dax_pgoff()
310 bdev = sc->stripe[stripe].dev->bdev; in stripe_dax_pgoff()
313 return sc->stripe[stripe].dev->dax_dev; in stripe_dax_pgoff()
363 struct stripe_c *sc = ti->private; in stripe_status() local
369 DMEMIT("%d ", sc->stripes); in stripe_status()
370 for (i = 0; i < sc->stripes; i++) in stripe_status()
371 DMEMIT("%s ", sc->stripe[i].dev->name); in stripe_status()
374 for (i = 0; i < sc->stripes; i++) in stripe_status()
375 DMEMIT("%c", atomic_read(&(sc->stripe[i].error_count)) ? 'D' : 'A'); in stripe_status()
379 DMEMIT("%d %llu", sc->stripes, in stripe_status()
380 (unsigned long long)sc->chunk_size); in stripe_status()
381 for (i = 0; i < sc->stripes; i++) in stripe_status()
382 DMEMIT(" %s %llu", sc->stripe[i].dev->name, in stripe_status()
383 (unsigned long long)sc->stripe[i].physical_start); in stripe_status()
388 DMEMIT(",stripes=%d,chunk_size=%llu", sc->stripes, in stripe_status()
389 (unsigned long long)sc->chunk_size); in stripe_status()
391 for (i = 0; i < sc->stripes; i++) { in stripe_status()
392 DMEMIT(",stripe_%d_device_name=%s", i, sc->stripe[i].dev->name); in stripe_status()
394 (unsigned long long)sc->stripe[i].physical_start); in stripe_status()
396 atomic_read(&(sc->stripe[i].error_count)) ? 'D' : 'A'); in stripe_status()
408 struct stripe_c *sc = ti->private; in stripe_end_io() local
428 for (i = 0; i < sc->stripes; i++) in stripe_end_io()
429 if (!strcmp(sc->stripe[i].dev->name, major_minor)) { in stripe_end_io()
430 atomic_inc(&(sc->stripe[i].error_count)); in stripe_end_io()
431 if (atomic_read(&(sc->stripe[i].error_count)) < in stripe_end_io()
433 queue_work(dm_stripe_wq, &sc->trigger_event); in stripe_end_io()
442 struct stripe_c *sc = ti->private; in stripe_iterate_devices() local
447 ret = fn(ti, sc->stripe[i].dev, in stripe_iterate_devices()
448 sc->stripe[i].physical_start, in stripe_iterate_devices()
449 sc->stripe_width, data); in stripe_iterate_devices()
450 } while (!ret && ++i < sc->stripes); in stripe_iterate_devices()
458 struct stripe_c *sc = ti->private; in stripe_io_hints() local
459 unsigned int chunk_size = sc->chunk_size << SECTOR_SHIFT; in stripe_io_hints()
462 blk_limits_io_opt(limits, chunk_size * sc->stripes); in stripe_io_hints()