Lines Matching refs:sc
51 struct stripe_c *sc = container_of(work, struct stripe_c, in trigger_event() local
53 dm_table_event(sc->ti->table); in trigger_event()
72 static int get_stripe(struct dm_target *ti, struct stripe_c *sc, in get_stripe() argument
82 &sc->stripe[stripe].dev)) in get_stripe()
85 sc->stripe[stripe].physical_start = start; in get_stripe()
96 struct stripe_c *sc; in stripe_ctr() local
141 sc = alloc_context(stripes); in stripe_ctr()
142 if (!sc) { in stripe_ctr()
148 INIT_WORK(&sc->trigger_event, trigger_event); in stripe_ctr()
151 sc->ti = ti; in stripe_ctr()
152 sc->stripes = stripes; in stripe_ctr()
153 sc->stripe_width = width; in stripe_ctr()
156 sc->stripes_shift = -1; in stripe_ctr()
158 sc->stripes_shift = __ffs(stripes); in stripe_ctr()
168 sc->chunk_size = chunk_size; in stripe_ctr()
170 sc->chunk_size_shift = -1; in stripe_ctr()
172 sc->chunk_size_shift = __ffs(chunk_size); in stripe_ctr()
180 r = get_stripe(ti, sc, i, argv); in stripe_ctr()
184 dm_put_device(ti, sc->stripe[i].dev); in stripe_ctr()
185 kfree(sc); in stripe_ctr()
188 atomic_set(&(sc->stripe[i].error_count), 0); in stripe_ctr()
191 ti->private = sc; in stripe_ctr()
199 struct stripe_c *sc = (struct stripe_c *) ti->private; in stripe_dtr() local
201 for (i = 0; i < sc->stripes; i++) in stripe_dtr()
202 dm_put_device(ti, sc->stripe[i].dev); in stripe_dtr()
204 flush_work(&sc->trigger_event); in stripe_dtr()
205 kfree(sc); in stripe_dtr()
208 static void stripe_map_sector(struct stripe_c *sc, sector_t sector, in stripe_map_sector() argument
211 sector_t chunk = dm_target_offset(sc->ti, sector); in stripe_map_sector()
214 if (sc->chunk_size_shift < 0) in stripe_map_sector()
215 chunk_offset = sector_div(chunk, sc->chunk_size); in stripe_map_sector()
217 chunk_offset = chunk & (sc->chunk_size - 1); in stripe_map_sector()
218 chunk >>= sc->chunk_size_shift; in stripe_map_sector()
221 if (sc->stripes_shift < 0) in stripe_map_sector()
222 *stripe = sector_div(chunk, sc->stripes); in stripe_map_sector()
224 *stripe = chunk & (sc->stripes - 1); in stripe_map_sector()
225 chunk >>= sc->stripes_shift; in stripe_map_sector()
228 if (sc->chunk_size_shift < 0) in stripe_map_sector()
229 chunk *= sc->chunk_size; in stripe_map_sector()
231 chunk <<= sc->chunk_size_shift; in stripe_map_sector()
236 static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector, in stripe_map_range_sector() argument
241 stripe_map_sector(sc, sector, &stripe, result); in stripe_map_range_sector()
247 if (sc->chunk_size_shift < 0) in stripe_map_range_sector()
248 *result -= sector_div(sector, sc->chunk_size); in stripe_map_range_sector()
250 *result = sector & ~(sector_t)(sc->chunk_size - 1); in stripe_map_range_sector()
253 *result += sc->chunk_size; /* next chunk */ in stripe_map_range_sector()
256 static int stripe_map_range(struct stripe_c *sc, struct bio *bio, in stripe_map_range() argument
261 stripe_map_range_sector(sc, bio->bi_sector, target_stripe, &begin); in stripe_map_range()
262 stripe_map_range_sector(sc, bio_end_sector(bio), in stripe_map_range()
265 bio->bi_bdev = sc->stripe[target_stripe].dev->bdev; in stripe_map_range()
266 bio->bi_sector = begin + sc->stripe[target_stripe].physical_start; in stripe_map_range()
278 struct stripe_c *sc = ti->private; in stripe_map() local
284 BUG_ON(target_bio_nr >= sc->stripes); in stripe_map()
285 bio->bi_bdev = sc->stripe[target_bio_nr].dev->bdev; in stripe_map()
291 BUG_ON(target_bio_nr >= sc->stripes); in stripe_map()
292 return stripe_map_range(sc, bio, target_bio_nr); in stripe_map()
295 stripe_map_sector(sc, bio->bi_sector, &stripe, &bio->bi_sector); in stripe_map()
297 bio->bi_sector += sc->stripe[stripe].physical_start; in stripe_map()
298 bio->bi_bdev = sc->stripe[stripe].dev->bdev; in stripe_map()
319 struct stripe_c *sc = (struct stripe_c *) ti->private; in stripe_status() local
320 char buffer[sc->stripes + 1]; in stripe_status()
326 DMEMIT("%d ", sc->stripes); in stripe_status()
327 for (i = 0; i < sc->stripes; i++) { in stripe_status()
328 DMEMIT("%s ", sc->stripe[i].dev->name); in stripe_status()
329 buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ? in stripe_status()
337 DMEMIT("%d %llu", sc->stripes, in stripe_status()
338 (unsigned long long)sc->chunk_size); in stripe_status()
339 for (i = 0; i < sc->stripes; i++) in stripe_status()
340 DMEMIT(" %s %llu", sc->stripe[i].dev->name, in stripe_status()
341 (unsigned long long)sc->stripe[i].physical_start); in stripe_status()
350 struct stripe_c *sc = ti->private; in stripe_end_io() local
372 for (i = 0; i < sc->stripes; i++) in stripe_end_io()
373 if (!strcmp(sc->stripe[i].dev->name, major_minor)) { in stripe_end_io()
374 atomic_inc(&(sc->stripe[i].error_count)); in stripe_end_io()
375 if (atomic_read(&(sc->stripe[i].error_count)) < in stripe_end_io()
377 schedule_work(&sc->trigger_event); in stripe_end_io()
386 struct stripe_c *sc = ti->private; in stripe_iterate_devices() local
391 ret = fn(ti, sc->stripe[i].dev, in stripe_iterate_devices()
392 sc->stripe[i].physical_start, in stripe_iterate_devices()
393 sc->stripe_width, data); in stripe_iterate_devices()
394 } while (!ret && ++i < sc->stripes); in stripe_iterate_devices()
402 struct stripe_c *sc = ti->private; in stripe_io_hints() local
403 unsigned chunk_size = sc->chunk_size << SECTOR_SHIFT; in stripe_io_hints()
406 blk_limits_io_opt(limits, chunk_size * sc->stripes); in stripe_io_hints()
412 struct stripe_c *sc = ti->private; in stripe_merge() local
417 stripe_map_sector(sc, bvm_sector, &stripe, &bvm_sector); in stripe_merge()
419 q = bdev_get_queue(sc->stripe[stripe].dev->bdev); in stripe_merge()
423 bvm->bi_bdev = sc->stripe[stripe].dev->bdev; in stripe_merge()
424 bvm->bi_sector = sc->stripe[stripe].physical_start + bvm_sector; in stripe_merge()