Lines Matching full:md

20 static int dm_blk_do_report_zones(struct mapped_device *md, struct dm_table *t,  in dm_blk_do_report_zones()  argument
24 struct gendisk *disk = md->disk; in dm_blk_do_report_zones()
58 struct mapped_device *md = disk->private_data; in dm_blk_report_zones() local
62 if (dm_suspended_md(md)) in dm_blk_report_zones()
65 map = dm_get_live_table(md, &srcu_idx); in dm_blk_report_zones()
69 ret = dm_blk_do_report_zones(md, map, sector, nr_zones, cb, data); in dm_blk_report_zones()
71 dm_put_live_table(md, srcu_idx); in dm_blk_report_zones()
124 bool dm_is_zone_write(struct mapped_device *md, struct bio *bio) in dm_is_zone_write() argument
126 struct request_queue *q = md->queue; in dm_is_zone_write()
140 void dm_cleanup_zoned_dev(struct mapped_device *md) in dm_cleanup_zoned_dev() argument
142 if (md->disk) { in dm_cleanup_zoned_dev()
143 kfree(md->disk->conv_zones_bitmap); in dm_cleanup_zoned_dev()
144 md->disk->conv_zones_bitmap = NULL; in dm_cleanup_zoned_dev()
145 kfree(md->disk->seq_zones_wlock); in dm_cleanup_zoned_dev()
146 md->disk->seq_zones_wlock = NULL; in dm_cleanup_zoned_dev()
149 kvfree(md->zwp_offset); in dm_cleanup_zoned_dev()
150 md->zwp_offset = NULL; in dm_cleanup_zoned_dev()
151 md->nr_zones = 0; in dm_cleanup_zoned_dev()
179 struct mapped_device *md = data; in dm_zone_revalidate_cb() local
180 struct gendisk *disk = md->disk; in dm_zone_revalidate_cb()
202 if (!md->zwp_offset) { in dm_zone_revalidate_cb()
203 md->zwp_offset = in dm_zone_revalidate_cb()
206 if (!md->zwp_offset) in dm_zone_revalidate_cb()
209 md->zwp_offset[idx] = dm_get_zone_wp_offset(zone); in dm_zone_revalidate_cb()
227 static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t) in dm_revalidate_zones() argument
229 struct gendisk *disk = md->disk; in dm_revalidate_zones()
237 if (!disk->nr_zones || disk->nr_zones != md->nr_zones) in dm_revalidate_zones()
238 dm_cleanup_zoned_dev(md); in dm_revalidate_zones()
239 if (md->nr_zones) in dm_revalidate_zones()
247 ret = dm_blk_do_report_zones(md, t, 0, disk->nr_zones, in dm_revalidate_zones()
248 dm_zone_revalidate_cb, md); in dm_revalidate_zones()
257 md->nr_zones = disk->nr_zones; in dm_revalidate_zones()
263 dm_cleanup_zoned_dev(md); in dm_revalidate_zones()
292 struct mapped_device *md = t->md; in dm_set_zones_restrictions() local
299 md->disk->nr_zones = bdev_nr_zones(md->disk->part0); in dm_set_zones_restrictions()
303 clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); in dm_set_zones_restrictions()
304 dm_cleanup_zoned_dev(md); in dm_set_zones_restrictions()
312 set_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); in dm_set_zones_restrictions()
313 if (!get_capacity(md->disk)) in dm_set_zones_restrictions()
316 return dm_revalidate_zones(md, t); in dm_set_zones_restrictions()
329 static int dm_update_zone_wp_offset(struct mapped_device *md, unsigned int zno, in dm_update_zone_wp_offset() argument
332 sector_t sector = zno * bdev_zone_sectors(md->disk->part0); in dm_update_zone_wp_offset()
337 t = dm_get_live_table(md, &srcu_idx); in dm_update_zone_wp_offset()
346 ret = dm_blk_do_report_zones(md, t, sector, 1, in dm_update_zone_wp_offset()
350 dm_put_live_table(md, srcu_idx); in dm_update_zone_wp_offset()
368 static bool dm_zone_map_bio_begin(struct mapped_device *md, in dm_zone_map_bio_begin() argument
371 sector_t zsectors = bdev_zone_sectors(md->disk->part0); in dm_zone_map_bio_begin()
372 unsigned int zwp_offset = READ_ONCE(md->zwp_offset[zno]); in dm_zone_map_bio_begin()
381 if (dm_update_zone_wp_offset(md, zno, &zwp_offset)) in dm_zone_map_bio_begin()
383 WRITE_ONCE(md->zwp_offset[zno], zwp_offset); in dm_zone_map_bio_begin()
424 static blk_status_t dm_zone_map_bio_end(struct mapped_device *md, unsigned int zno, in dm_zone_map_bio_end() argument
428 unsigned int zwp_offset = READ_ONCE(md->zwp_offset[zno]); in dm_zone_map_bio_end()
437 WRITE_ONCE(md->zwp_offset[zno], 0); in dm_zone_map_bio_end()
440 WRITE_ONCE(md->zwp_offset[zno], in dm_zone_map_bio_end()
441 bdev_zone_sectors(md->disk->part0)); in dm_zone_map_bio_end()
445 WRITE_ONCE(md->zwp_offset[zno], zwp_offset + nr_sectors); in dm_zone_map_bio_end()
456 WRITE_ONCE(md->zwp_offset[zno], zwp_offset + nr_sectors); in dm_zone_map_bio_end()
517 struct mapped_device *md = io->md; in dm_zone_map_bio() local
533 dm_zone_lock(md->disk, zno, clone); in dm_zone_map_bio()
542 if (!dm_zone_map_bio_begin(md, zno, clone)) { in dm_zone_map_bio()
543 dm_zone_unlock(md->disk, zno, clone); in dm_zone_map_bio()
555 sts = dm_zone_map_bio_end(md, zno, &orig_bio_details, in dm_zone_map_bio()
564 sts = dm_zone_map_bio_end(md, zno, &orig_bio_details, in dm_zone_map_bio()
567 dm_zone_unlock(md->disk, zno, clone); in dm_zone_map_bio()
572 dm_zone_unlock(md->disk, zno, clone); in dm_zone_map_bio()
588 struct mapped_device *md = io->md; in dm_zone_endio() local
589 struct gendisk *disk = md->disk; in dm_zone_endio()
598 if (!dm_emulate_zone_append(md)) { in dm_zone_endio()
632 WRITE_ONCE(md->zwp_offset[zno], DM_ZONE_INVALID_WP_OFST); in dm_zone_endio()
638 zwp_offset = READ_ONCE(md->zwp_offset[zno]); in dm_zone_endio()
640 WRITE_ONCE(md->zwp_offset[zno], in dm_zone_endio()