Lines Matching refs:sc
53 struct stripe_c *sc = container_of(work, struct stripe_c, in trigger_event() local
55 dm_table_event(sc->ti->table); in trigger_event()
61 static int get_stripe(struct dm_target *ti, struct stripe_c *sc, in get_stripe() argument
72 &sc->stripe[stripe].dev); in get_stripe()
76 sc->stripe[stripe].physical_start = start; in get_stripe()
87 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()
139 INIT_WORK(&sc->trigger_event, trigger_event); in stripe_ctr()
142 sc->ti = ti; in stripe_ctr()
143 sc->stripes = stripes; in stripe_ctr()
144 sc->stripe_width = width; in stripe_ctr()
147 sc->stripes_shift = -1; in stripe_ctr()
149 sc->stripes_shift = __ffs(stripes); in stripe_ctr()
153 kfree(sc); in stripe_ctr()
163 sc->chunk_size = chunk_size; in stripe_ctr()
165 sc->chunk_size_shift = -1; in stripe_ctr()
167 sc->chunk_size_shift = __ffs(chunk_size); in stripe_ctr()
175 r = get_stripe(ti, sc, i, argv); in stripe_ctr()
179 dm_put_device(ti, sc->stripe[i].dev); in stripe_ctr()
180 kfree(sc); in stripe_ctr()
183 atomic_set(&(sc->stripe[i].error_count), 0); in stripe_ctr()
186 ti->private = sc; in stripe_ctr()
194 struct stripe_c *sc = (struct stripe_c *) ti->private; in stripe_dtr() local
196 for (i = 0; i < sc->stripes; i++) in stripe_dtr()
197 dm_put_device(ti, sc->stripe[i].dev); in stripe_dtr()
199 flush_work(&sc->trigger_event); in stripe_dtr()
200 kfree(sc); in stripe_dtr()
203 static void stripe_map_sector(struct stripe_c *sc, sector_t sector, in stripe_map_sector() argument
206 sector_t chunk = dm_target_offset(sc->ti, sector); in stripe_map_sector()
209 if (sc->chunk_size_shift < 0) in stripe_map_sector()
210 chunk_offset = sector_div(chunk, sc->chunk_size); in stripe_map_sector()
212 chunk_offset = chunk & (sc->chunk_size - 1); in stripe_map_sector()
213 chunk >>= sc->chunk_size_shift; in stripe_map_sector()
216 if (sc->stripes_shift < 0) in stripe_map_sector()
217 *stripe = sector_div(chunk, sc->stripes); in stripe_map_sector()
219 *stripe = chunk & (sc->stripes - 1); in stripe_map_sector()
220 chunk >>= sc->stripes_shift; in stripe_map_sector()
223 if (sc->chunk_size_shift < 0) in stripe_map_sector()
224 chunk *= sc->chunk_size; in stripe_map_sector()
226 chunk <<= sc->chunk_size_shift; in stripe_map_sector()
231 static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector, in stripe_map_range_sector() argument
236 stripe_map_sector(sc, sector, &stripe, result); in stripe_map_range_sector()
242 if (sc->chunk_size_shift < 0) in stripe_map_range_sector()
243 *result -= sector_div(sector, sc->chunk_size); in stripe_map_range_sector()
245 *result = sector & ~(sector_t)(sc->chunk_size - 1); in stripe_map_range_sector()
248 *result += sc->chunk_size; /* next chunk */ in stripe_map_range_sector()
251 static int stripe_map_range(struct stripe_c *sc, struct bio *bio, in stripe_map_range() argument
256 stripe_map_range_sector(sc, bio->bi_iter.bi_sector, in stripe_map_range()
258 stripe_map_range_sector(sc, bio_end_sector(bio), in stripe_map_range()
261 bio_set_dev(bio, sc->stripe[target_stripe].dev->bdev); in stripe_map_range()
263 sc->stripe[target_stripe].physical_start; in stripe_map_range()
275 struct stripe_c *sc = ti->private; in stripe_map() local
281 BUG_ON(target_bio_nr >= sc->stripes); in stripe_map()
282 bio_set_dev(bio, sc->stripe[target_bio_nr].dev->bdev); in stripe_map()
290 BUG_ON(target_bio_nr >= sc->stripes); in stripe_map()
291 return stripe_map_range(sc, bio, target_bio_nr); in stripe_map()
294 stripe_map_sector(sc, bio->bi_iter.bi_sector, in stripe_map()
297 bio->bi_iter.bi_sector += sc->stripe[stripe].physical_start; in stripe_map()
298 bio_set_dev(bio, sc->stripe[stripe].dev->bdev); in stripe_map()
308 struct stripe_c *sc = ti->private; in stripe_dax_direct_access() local
314 stripe_map_sector(sc, sector, &stripe, &dev_sector); in stripe_dax_direct_access()
315 dev_sector += sc->stripe[stripe].physical_start; in stripe_dax_direct_access()
316 dax_dev = sc->stripe[stripe].dev->dax_dev; in stripe_dax_direct_access()
317 bdev = sc->stripe[stripe].dev->bdev; in stripe_dax_direct_access()
329 struct stripe_c *sc = ti->private; in stripe_dax_copy_from_iter() local
334 stripe_map_sector(sc, sector, &stripe, &dev_sector); in stripe_dax_copy_from_iter()
335 dev_sector += sc->stripe[stripe].physical_start; in stripe_dax_copy_from_iter()
336 dax_dev = sc->stripe[stripe].dev->dax_dev; in stripe_dax_copy_from_iter()
337 bdev = sc->stripe[stripe].dev->bdev; in stripe_dax_copy_from_iter()
348 struct stripe_c *sc = ti->private; in stripe_dax_copy_to_iter() local
353 stripe_map_sector(sc, sector, &stripe, &dev_sector); in stripe_dax_copy_to_iter()
354 dev_sector += sc->stripe[stripe].physical_start; in stripe_dax_copy_to_iter()
355 dax_dev = sc->stripe[stripe].dev->dax_dev; in stripe_dax_copy_to_iter()
356 bdev = sc->stripe[stripe].dev->bdev; in stripe_dax_copy_to_iter()
368 struct stripe_c *sc = ti->private; in stripe_dax_zero_page_range() local
373 stripe_map_sector(sc, sector, &stripe, &dev_sector); in stripe_dax_zero_page_range()
374 dev_sector += sc->stripe[stripe].physical_start; in stripe_dax_zero_page_range()
375 dax_dev = sc->stripe[stripe].dev->dax_dev; in stripe_dax_zero_page_range()
376 bdev = sc->stripe[stripe].dev->bdev; in stripe_dax_zero_page_range()
407 struct stripe_c *sc = (struct stripe_c *) ti->private; in stripe_status() local
413 DMEMIT("%d ", sc->stripes); in stripe_status()
414 for (i = 0; i < sc->stripes; i++) { in stripe_status()
415 DMEMIT("%s ", sc->stripe[i].dev->name); in stripe_status()
418 for (i = 0; i < sc->stripes; i++) { in stripe_status()
419 DMEMIT("%c", atomic_read(&(sc->stripe[i].error_count)) ? in stripe_status()
425 DMEMIT("%d %llu", sc->stripes, in stripe_status()
426 (unsigned long long)sc->chunk_size); in stripe_status()
427 for (i = 0; i < sc->stripes; i++) in stripe_status()
428 DMEMIT(" %s %llu", sc->stripe[i].dev->name, in stripe_status()
429 (unsigned long long)sc->stripe[i].physical_start); in stripe_status()
434 DMEMIT(",stripes=%d,chunk_size=%llu", sc->stripes, in stripe_status()
435 (unsigned long long)sc->chunk_size); in stripe_status()
437 for (i = 0; i < sc->stripes; i++) { in stripe_status()
438 DMEMIT(",stripe_%d_device_name=%s", i, sc->stripe[i].dev->name); in stripe_status()
440 (unsigned long long)sc->stripe[i].physical_start); in stripe_status()
442 atomic_read(&(sc->stripe[i].error_count)) ? 'D' : 'A'); in stripe_status()
454 struct stripe_c *sc = ti->private; in stripe_end_io() local
474 for (i = 0; i < sc->stripes; i++) in stripe_end_io()
475 if (!strcmp(sc->stripe[i].dev->name, major_minor)) { in stripe_end_io()
476 atomic_inc(&(sc->stripe[i].error_count)); in stripe_end_io()
477 if (atomic_read(&(sc->stripe[i].error_count)) < in stripe_end_io()
479 schedule_work(&sc->trigger_event); in stripe_end_io()
488 struct stripe_c *sc = ti->private; in stripe_iterate_devices() local
493 ret = fn(ti, sc->stripe[i].dev, in stripe_iterate_devices()
494 sc->stripe[i].physical_start, in stripe_iterate_devices()
495 sc->stripe_width, data); in stripe_iterate_devices()
496 } while (!ret && ++i < sc->stripes); in stripe_iterate_devices()
504 struct stripe_c *sc = ti->private; in stripe_io_hints() local
505 unsigned chunk_size = sc->chunk_size << SECTOR_SHIFT; in stripe_io_hints()
508 blk_limits_io_opt(limits, chunk_size * sc->stripes); in stripe_io_hints()