zmd 190 drivers/md/dm-zoned-metadata.c unsigned int dmz_id(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 192 drivers/md/dm-zoned-metadata.c return ((unsigned int)(zone - zmd->zones)); zmd 195 drivers/md/dm-zoned-metadata.c sector_t dmz_start_sect(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 197 drivers/md/dm-zoned-metadata.c return (sector_t)dmz_id(zmd, zone) << zmd->dev->zone_nr_sectors_shift; zmd 200 drivers/md/dm-zoned-metadata.c sector_t dmz_start_block(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 202 drivers/md/dm-zoned-metadata.c return (sector_t)dmz_id(zmd, zone) << zmd->dev->zone_nr_blocks_shift; zmd 205 drivers/md/dm-zoned-metadata.c unsigned int dmz_nr_chunks(struct dmz_metadata *zmd) zmd 207 drivers/md/dm-zoned-metadata.c return zmd->nr_chunks; zmd 210 drivers/md/dm-zoned-metadata.c unsigned int dmz_nr_rnd_zones(struct dmz_metadata *zmd) zmd 212 drivers/md/dm-zoned-metadata.c return zmd->nr_rnd; zmd 215 drivers/md/dm-zoned-metadata.c unsigned int dmz_nr_unmap_rnd_zones(struct dmz_metadata *zmd) zmd 217 drivers/md/dm-zoned-metadata.c return atomic_read(&zmd->unmap_nr_rnd); zmd 224 drivers/md/dm-zoned-metadata.c void dmz_lock_map(struct dmz_metadata *zmd) zmd 226 drivers/md/dm-zoned-metadata.c mutex_lock(&zmd->map_lock); zmd 229 drivers/md/dm-zoned-metadata.c void dmz_unlock_map(struct dmz_metadata *zmd) zmd 231 drivers/md/dm-zoned-metadata.c mutex_unlock(&zmd->map_lock); zmd 241 drivers/md/dm-zoned-metadata.c void dmz_lock_metadata(struct dmz_metadata *zmd) zmd 243 drivers/md/dm-zoned-metadata.c down_read(&zmd->mblk_sem); zmd 246 drivers/md/dm-zoned-metadata.c void dmz_unlock_metadata(struct dmz_metadata *zmd) zmd 248 drivers/md/dm-zoned-metadata.c up_read(&zmd->mblk_sem); zmd 256 drivers/md/dm-zoned-metadata.c void dmz_lock_flush(struct dmz_metadata *zmd) zmd 258 drivers/md/dm-zoned-metadata.c mutex_lock(&zmd->mblk_flush_lock); zmd 261 drivers/md/dm-zoned-metadata.c void dmz_unlock_flush(struct dmz_metadata *zmd) zmd 263 drivers/md/dm-zoned-metadata.c mutex_unlock(&zmd->mblk_flush_lock); zmd 269 drivers/md/dm-zoned-metadata.c static struct dmz_mblock *dmz_alloc_mblock(struct dmz_metadata *zmd, zmd 275 drivers/md/dm-zoned-metadata.c if (zmd->max_nr_mblks && atomic_read(&zmd->nr_mblks) > zmd->max_nr_mblks) { zmd 276 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 277 drivers/md/dm-zoned-metadata.c mblk = list_first_entry_or_null(&zmd->mblk_lru_list, zmd 281 drivers/md/dm-zoned-metadata.c rb_erase(&mblk->node, &zmd->mblk_rbtree); zmd 284 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 307 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->nr_mblks); zmd 315 drivers/md/dm-zoned-metadata.c static void dmz_free_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk) zmd 320 drivers/md/dm-zoned-metadata.c atomic_dec(&zmd->nr_mblks); zmd 326 drivers/md/dm-zoned-metadata.c static void dmz_insert_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk) zmd 328 drivers/md/dm-zoned-metadata.c struct rb_root *root = &zmd->mblk_rbtree; zmd 348 drivers/md/dm-zoned-metadata.c static struct dmz_mblock *dmz_get_mblock_fast(struct dmz_metadata *zmd, zmd 351 drivers/md/dm-zoned-metadata.c struct rb_root *root = &zmd->mblk_rbtree; zmd 400 drivers/md/dm-zoned-metadata.c static struct dmz_mblock *dmz_get_mblock_slow(struct dmz_metadata *zmd, zmd 404 drivers/md/dm-zoned-metadata.c sector_t block = zmd->sb[zmd->mblk_primary].block + mblk_no; zmd 407 drivers/md/dm-zoned-metadata.c if (dmz_bdev_is_dying(zmd->dev)) zmd 411 drivers/md/dm-zoned-metadata.c mblk = dmz_alloc_mblock(zmd, mblk_no); zmd 417 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 421 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 427 drivers/md/dm-zoned-metadata.c m = dmz_get_mblock_fast(zmd, mblk_no); zmd 429 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 430 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 437 drivers/md/dm-zoned-metadata.c dmz_insert_mblock(zmd, mblk); zmd 439 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 443 drivers/md/dm-zoned-metadata.c bio_set_dev(bio, zmd->dev->bdev); zmd 456 drivers/md/dm-zoned-metadata.c static unsigned long dmz_shrink_mblock_cache(struct dmz_metadata *zmd, zmd 462 drivers/md/dm-zoned-metadata.c if (!zmd->max_nr_mblks) zmd 465 drivers/md/dm-zoned-metadata.c while (!list_empty(&zmd->mblk_lru_list) && zmd 466 drivers/md/dm-zoned-metadata.c atomic_read(&zmd->nr_mblks) > zmd->min_nr_mblks && zmd 468 drivers/md/dm-zoned-metadata.c mblk = list_first_entry(&zmd->mblk_lru_list, zmd 471 drivers/md/dm-zoned-metadata.c rb_erase(&mblk->node, &zmd->mblk_rbtree); zmd 472 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 485 drivers/md/dm-zoned-metadata.c struct dmz_metadata *zmd = container_of(shrink, struct dmz_metadata, mblk_shrinker); zmd 487 drivers/md/dm-zoned-metadata.c return atomic_read(&zmd->nr_mblks); zmd 496 drivers/md/dm-zoned-metadata.c struct dmz_metadata *zmd = container_of(shrink, struct dmz_metadata, mblk_shrinker); zmd 499 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 500 drivers/md/dm-zoned-metadata.c count = dmz_shrink_mblock_cache(zmd, sc->nr_to_scan); zmd 501 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 509 drivers/md/dm-zoned-metadata.c static void dmz_release_mblock(struct dmz_metadata *zmd, zmd 516 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 521 drivers/md/dm-zoned-metadata.c rb_erase(&mblk->node, &zmd->mblk_rbtree); zmd 522 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 524 drivers/md/dm-zoned-metadata.c list_add_tail(&mblk->link, &zmd->mblk_lru_list); zmd 525 drivers/md/dm-zoned-metadata.c dmz_shrink_mblock_cache(zmd, 1); zmd 529 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 536 drivers/md/dm-zoned-metadata.c static struct dmz_mblock *dmz_get_mblock(struct dmz_metadata *zmd, zmd 542 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 543 drivers/md/dm-zoned-metadata.c mblk = dmz_get_mblock_fast(zmd, mblk_no); zmd 544 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 548 drivers/md/dm-zoned-metadata.c mblk = dmz_get_mblock_slow(zmd, mblk_no); zmd 557 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, mblk); zmd 558 drivers/md/dm-zoned-metadata.c dmz_check_bdev(zmd->dev); zmd 568 drivers/md/dm-zoned-metadata.c static void dmz_dirty_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk) zmd 570 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 572 drivers/md/dm-zoned-metadata.c list_add_tail(&mblk->link, &zmd->mblk_dirty_list); zmd 573 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 579 drivers/md/dm-zoned-metadata.c static int dmz_write_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk, zmd 582 drivers/md/dm-zoned-metadata.c sector_t block = zmd->sb[set].block + mblk->no; zmd 585 drivers/md/dm-zoned-metadata.c if (dmz_bdev_is_dying(zmd->dev)) zmd 597 drivers/md/dm-zoned-metadata.c bio_set_dev(bio, zmd->dev->bdev); zmd 610 drivers/md/dm-zoned-metadata.c static int dmz_rdwr_block(struct dmz_metadata *zmd, int op, sector_t block, zmd 616 drivers/md/dm-zoned-metadata.c if (dmz_bdev_is_dying(zmd->dev)) zmd 624 drivers/md/dm-zoned-metadata.c bio_set_dev(bio, zmd->dev->bdev); zmd 631 drivers/md/dm-zoned-metadata.c dmz_check_bdev(zmd->dev); zmd 638 drivers/md/dm-zoned-metadata.c static int dmz_write_sb(struct dmz_metadata *zmd, unsigned int set) zmd 640 drivers/md/dm-zoned-metadata.c sector_t block = zmd->sb[set].block; zmd 641 drivers/md/dm-zoned-metadata.c struct dmz_mblock *mblk = zmd->sb[set].mblk; zmd 642 drivers/md/dm-zoned-metadata.c struct dmz_super *sb = zmd->sb[set].sb; zmd 643 drivers/md/dm-zoned-metadata.c u64 sb_gen = zmd->sb_gen + 1; zmd 652 drivers/md/dm-zoned-metadata.c sb->nr_meta_blocks = cpu_to_le32(zmd->nr_meta_blocks); zmd 653 drivers/md/dm-zoned-metadata.c sb->nr_reserved_seq = cpu_to_le32(zmd->nr_reserved_seq); zmd 654 drivers/md/dm-zoned-metadata.c sb->nr_chunks = cpu_to_le32(zmd->nr_chunks); zmd 656 drivers/md/dm-zoned-metadata.c sb->nr_map_blocks = cpu_to_le32(zmd->nr_map_blocks); zmd 657 drivers/md/dm-zoned-metadata.c sb->nr_bitmap_blocks = cpu_to_le32(zmd->nr_bitmap_blocks); zmd 662 drivers/md/dm-zoned-metadata.c ret = dmz_rdwr_block(zmd, REQ_OP_WRITE, block, mblk->page); zmd 664 drivers/md/dm-zoned-metadata.c ret = blkdev_issue_flush(zmd->dev->bdev, GFP_NOIO, NULL); zmd 672 drivers/md/dm-zoned-metadata.c static int dmz_write_dirty_mblocks(struct dmz_metadata *zmd, zmd 683 drivers/md/dm-zoned-metadata.c ret = dmz_write_mblock(zmd, mblk, set); zmd 698 drivers/md/dm-zoned-metadata.c dmz_check_bdev(zmd->dev); zmd 706 drivers/md/dm-zoned-metadata.c ret = blkdev_issue_flush(zmd->dev->bdev, GFP_NOIO, NULL); zmd 714 drivers/md/dm-zoned-metadata.c static int dmz_log_dirty_mblocks(struct dmz_metadata *zmd, zmd 717 drivers/md/dm-zoned-metadata.c unsigned int log_set = zmd->mblk_primary ^ 0x1; zmd 721 drivers/md/dm-zoned-metadata.c ret = dmz_write_dirty_mblocks(zmd, write_list, log_set); zmd 729 drivers/md/dm-zoned-metadata.c ret = dmz_write_sb(zmd, log_set); zmd 739 drivers/md/dm-zoned-metadata.c int dmz_flush_metadata(struct dmz_metadata *zmd) zmd 745 drivers/md/dm-zoned-metadata.c if (WARN_ON(!zmd)) zmd 755 drivers/md/dm-zoned-metadata.c down_write(&zmd->mblk_sem); zmd 761 drivers/md/dm-zoned-metadata.c dmz_lock_flush(zmd); zmd 763 drivers/md/dm-zoned-metadata.c if (dmz_bdev_is_dying(zmd->dev)) { zmd 769 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 770 drivers/md/dm-zoned-metadata.c list_splice_init(&zmd->mblk_dirty_list, &write_list); zmd 771 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 775 drivers/md/dm-zoned-metadata.c ret = blkdev_issue_flush(zmd->dev->bdev, GFP_NOIO, NULL); zmd 784 drivers/md/dm-zoned-metadata.c ret = dmz_log_dirty_mblocks(zmd, &write_list); zmd 792 drivers/md/dm-zoned-metadata.c ret = dmz_write_dirty_mblocks(zmd, &write_list, zmd->mblk_primary); zmd 796 drivers/md/dm-zoned-metadata.c ret = dmz_write_sb(zmd, zmd->mblk_primary); zmd 804 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 807 drivers/md/dm-zoned-metadata.c list_add_tail(&mblk->link, &zmd->mblk_lru_list); zmd 808 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 811 drivers/md/dm-zoned-metadata.c zmd->sb_gen++; zmd 813 drivers/md/dm-zoned-metadata.c dmz_unlock_flush(zmd); zmd 814 drivers/md/dm-zoned-metadata.c up_write(&zmd->mblk_sem); zmd 820 drivers/md/dm-zoned-metadata.c spin_lock(&zmd->mblk_lock); zmd 821 drivers/md/dm-zoned-metadata.c list_splice(&write_list, &zmd->mblk_dirty_list); zmd 822 drivers/md/dm-zoned-metadata.c spin_unlock(&zmd->mblk_lock); zmd 824 drivers/md/dm-zoned-metadata.c if (!dmz_check_bdev(zmd->dev)) zmd 832 drivers/md/dm-zoned-metadata.c static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_super *sb) zmd 835 drivers/md/dm-zoned-metadata.c struct dmz_dev *dev = zmd->dev; zmd 864 drivers/md/dm-zoned-metadata.c nr_meta_zones >= zmd->nr_rnd_zones) { zmd 870 drivers/md/dm-zoned-metadata.c le32_to_cpu(sb->nr_reserved_seq) >= (zmd->nr_useable_zones - nr_meta_zones)) { zmd 875 drivers/md/dm-zoned-metadata.c nr_data_zones = zmd->nr_useable_zones - zmd 884 drivers/md/dm-zoned-metadata.c zmd->nr_meta_blocks = le32_to_cpu(sb->nr_meta_blocks); zmd 885 drivers/md/dm-zoned-metadata.c zmd->nr_reserved_seq = le32_to_cpu(sb->nr_reserved_seq); zmd 886 drivers/md/dm-zoned-metadata.c zmd->nr_chunks = le32_to_cpu(sb->nr_chunks); zmd 887 drivers/md/dm-zoned-metadata.c zmd->nr_map_blocks = le32_to_cpu(sb->nr_map_blocks); zmd 888 drivers/md/dm-zoned-metadata.c zmd->nr_bitmap_blocks = le32_to_cpu(sb->nr_bitmap_blocks); zmd 889 drivers/md/dm-zoned-metadata.c zmd->nr_meta_zones = nr_meta_zones; zmd 890 drivers/md/dm-zoned-metadata.c zmd->nr_data_zones = nr_data_zones; zmd 898 drivers/md/dm-zoned-metadata.c static int dmz_read_sb(struct dmz_metadata *zmd, unsigned int set) zmd 900 drivers/md/dm-zoned-metadata.c return dmz_rdwr_block(zmd, REQ_OP_READ, zmd->sb[set].block, zmd 901 drivers/md/dm-zoned-metadata.c zmd->sb[set].mblk->page); zmd 909 drivers/md/dm-zoned-metadata.c static int dmz_lookup_secondary_sb(struct dmz_metadata *zmd) zmd 911 drivers/md/dm-zoned-metadata.c unsigned int zone_nr_blocks = zmd->dev->zone_nr_blocks; zmd 916 drivers/md/dm-zoned-metadata.c mblk = dmz_alloc_mblock(zmd, 0); zmd 920 drivers/md/dm-zoned-metadata.c zmd->sb[1].mblk = mblk; zmd 921 drivers/md/dm-zoned-metadata.c zmd->sb[1].sb = mblk->data; zmd 924 drivers/md/dm-zoned-metadata.c zmd->sb[1].block = zmd->sb[0].block + zone_nr_blocks; zmd 925 drivers/md/dm-zoned-metadata.c for (i = 0; i < zmd->nr_rnd_zones - 1; i++) { zmd 926 drivers/md/dm-zoned-metadata.c if (dmz_read_sb(zmd, 1) != 0) zmd 928 drivers/md/dm-zoned-metadata.c if (le32_to_cpu(zmd->sb[1].sb->magic) == DMZ_MAGIC) zmd 930 drivers/md/dm-zoned-metadata.c zmd->sb[1].block += zone_nr_blocks; zmd 933 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 934 drivers/md/dm-zoned-metadata.c zmd->sb[1].mblk = NULL; zmd 942 drivers/md/dm-zoned-metadata.c static int dmz_get_sb(struct dmz_metadata *zmd, unsigned int set) zmd 948 drivers/md/dm-zoned-metadata.c mblk = dmz_alloc_mblock(zmd, 0); zmd 952 drivers/md/dm-zoned-metadata.c zmd->sb[set].mblk = mblk; zmd 953 drivers/md/dm-zoned-metadata.c zmd->sb[set].sb = mblk->data; zmd 956 drivers/md/dm-zoned-metadata.c ret = dmz_read_sb(zmd, set); zmd 958 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 959 drivers/md/dm-zoned-metadata.c zmd->sb[set].mblk = NULL; zmd 969 drivers/md/dm-zoned-metadata.c static int dmz_recover_mblocks(struct dmz_metadata *zmd, unsigned int dst_set) zmd 975 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "Metadata set %u invalid: recovering", dst_set); zmd 978 drivers/md/dm-zoned-metadata.c zmd->sb[0].block = dmz_start_block(zmd, zmd->sb_zone); zmd 980 drivers/md/dm-zoned-metadata.c zmd->sb[1].block = zmd->sb[0].block + zmd 981 drivers/md/dm-zoned-metadata.c (zmd->nr_meta_zones << zmd->dev->zone_nr_blocks_shift); zmd 989 drivers/md/dm-zoned-metadata.c for (i = 1; i < zmd->nr_meta_blocks; i++) { zmd 990 drivers/md/dm-zoned-metadata.c ret = dmz_rdwr_block(zmd, REQ_OP_READ, zmd 991 drivers/md/dm-zoned-metadata.c zmd->sb[src_set].block + i, page); zmd 994 drivers/md/dm-zoned-metadata.c ret = dmz_rdwr_block(zmd, REQ_OP_WRITE, zmd 995 drivers/md/dm-zoned-metadata.c zmd->sb[dst_set].block + i, page); zmd 1001 drivers/md/dm-zoned-metadata.c if (!zmd->sb[dst_set].mblk) { zmd 1002 drivers/md/dm-zoned-metadata.c zmd->sb[dst_set].mblk = dmz_alloc_mblock(zmd, 0); zmd 1003 drivers/md/dm-zoned-metadata.c if (!zmd->sb[dst_set].mblk) { zmd 1007 drivers/md/dm-zoned-metadata.c zmd->sb[dst_set].sb = zmd->sb[dst_set].mblk->data; zmd 1010 drivers/md/dm-zoned-metadata.c ret = dmz_write_sb(zmd, dst_set); zmd 1020 drivers/md/dm-zoned-metadata.c static int dmz_load_sb(struct dmz_metadata *zmd) zmd 1027 drivers/md/dm-zoned-metadata.c zmd->sb[0].block = dmz_start_block(zmd, zmd->sb_zone); zmd 1028 drivers/md/dm-zoned-metadata.c ret = dmz_get_sb(zmd, 0); zmd 1030 drivers/md/dm-zoned-metadata.c dmz_dev_err(zmd->dev, "Read primary super block failed"); zmd 1034 drivers/md/dm-zoned-metadata.c ret = dmz_check_sb(zmd, zmd->sb[0].sb); zmd 1039 drivers/md/dm-zoned-metadata.c zmd->sb[1].block = zmd->sb[0].block + zmd 1040 drivers/md/dm-zoned-metadata.c (zmd->nr_meta_zones << zmd->dev->zone_nr_blocks_shift); zmd 1041 drivers/md/dm-zoned-metadata.c ret = dmz_get_sb(zmd, 1); zmd 1043 drivers/md/dm-zoned-metadata.c ret = dmz_lookup_secondary_sb(zmd); zmd 1046 drivers/md/dm-zoned-metadata.c dmz_dev_err(zmd->dev, "Read secondary super block failed"); zmd 1050 drivers/md/dm-zoned-metadata.c ret = dmz_check_sb(zmd, zmd->sb[1].sb); zmd 1056 drivers/md/dm-zoned-metadata.c dmz_dev_err(zmd->dev, "No valid super block found"); zmd 1061 drivers/md/dm-zoned-metadata.c sb_gen[0] = le64_to_cpu(zmd->sb[0].sb->gen); zmd 1063 drivers/md/dm-zoned-metadata.c ret = dmz_recover_mblocks(zmd, 0); zmd 1066 drivers/md/dm-zoned-metadata.c sb_gen[1] = le64_to_cpu(zmd->sb[1].sb->gen); zmd 1068 drivers/md/dm-zoned-metadata.c ret = dmz_recover_mblocks(zmd, 1); zmd 1071 drivers/md/dm-zoned-metadata.c dmz_dev_err(zmd->dev, "Recovery failed"); zmd 1076 drivers/md/dm-zoned-metadata.c zmd->sb_gen = sb_gen[0]; zmd 1077 drivers/md/dm-zoned-metadata.c zmd->mblk_primary = 0; zmd 1079 drivers/md/dm-zoned-metadata.c zmd->sb_gen = sb_gen[1]; zmd 1080 drivers/md/dm-zoned-metadata.c zmd->mblk_primary = 1; zmd 1083 drivers/md/dm-zoned-metadata.c dmz_dev_debug(zmd->dev, "Using super block %u (gen %llu)", zmd 1084 drivers/md/dm-zoned-metadata.c zmd->mblk_primary, zmd->sb_gen); zmd 1092 drivers/md/dm-zoned-metadata.c static int dmz_init_zone(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 1095 drivers/md/dm-zoned-metadata.c struct dmz_dev *dev = zmd->dev; zmd 1127 drivers/md/dm-zoned-metadata.c zmd->nr_useable_zones++; zmd 1129 drivers/md/dm-zoned-metadata.c zmd->nr_rnd_zones++; zmd 1130 drivers/md/dm-zoned-metadata.c if (!zmd->sb_zone) { zmd 1132 drivers/md/dm-zoned-metadata.c zmd->sb_zone = zone; zmd 1143 drivers/md/dm-zoned-metadata.c static void dmz_drop_zones(struct dmz_metadata *zmd) zmd 1145 drivers/md/dm-zoned-metadata.c kfree(zmd->zones); zmd 1146 drivers/md/dm-zoned-metadata.c zmd->zones = NULL; zmd 1159 drivers/md/dm-zoned-metadata.c static int dmz_init_zones(struct dmz_metadata *zmd) zmd 1161 drivers/md/dm-zoned-metadata.c struct dmz_dev *dev = zmd->dev; zmd 1169 drivers/md/dm-zoned-metadata.c zmd->zone_bitmap_size = dev->zone_nr_blocks >> 3; zmd 1170 drivers/md/dm-zoned-metadata.c zmd->zone_nr_bitmap_blocks = zmd 1171 drivers/md/dm-zoned-metadata.c max_t(sector_t, 1, zmd->zone_bitmap_size >> DMZ_BLOCK_SHIFT); zmd 1172 drivers/md/dm-zoned-metadata.c zmd->zone_bits_per_mblk = min_t(sector_t, dev->zone_nr_blocks, zmd 1176 drivers/md/dm-zoned-metadata.c zmd->zones = kcalloc(dev->nr_zones, sizeof(struct dm_zone), GFP_KERNEL); zmd 1177 drivers/md/dm-zoned-metadata.c if (!zmd->zones) zmd 1197 drivers/md/dm-zoned-metadata.c zone = zmd->zones; zmd 1212 drivers/md/dm-zoned-metadata.c ret = dmz_init_zone(zmd, zone, &blkz[i]); zmd 1228 drivers/md/dm-zoned-metadata.c dmz_drop_zones(zmd); zmd 1236 drivers/md/dm-zoned-metadata.c static int dmz_update_zone(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1250 drivers/md/dm-zoned-metadata.c ret = blkdev_report_zones(zmd->dev->bdev, dmz_start_sect(zmd, zone), zmd 1256 drivers/md/dm-zoned-metadata.c dmz_dev_err(zmd->dev, "Get zone %u report failed", zmd 1257 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone)); zmd 1258 drivers/md/dm-zoned-metadata.c dmz_check_bdev(zmd->dev); zmd 1281 drivers/md/dm-zoned-metadata.c static int dmz_handle_seq_write_err(struct dmz_metadata *zmd, zmd 1288 drivers/md/dm-zoned-metadata.c ret = dmz_update_zone(zmd, zone); zmd 1292 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "Processing zone %u write error (zone wp %u/%u)", zmd 1293 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone), zone->wp_block, wp); zmd 1296 drivers/md/dm-zoned-metadata.c dmz_invalidate_blocks(zmd, zone, zone->wp_block, zmd 1303 drivers/md/dm-zoned-metadata.c static struct dm_zone *dmz_get(struct dmz_metadata *zmd, unsigned int zone_id) zmd 1305 drivers/md/dm-zoned-metadata.c return &zmd->zones[zone_id]; zmd 1311 drivers/md/dm-zoned-metadata.c static int dmz_reset_zone(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1325 drivers/md/dm-zoned-metadata.c struct dmz_dev *dev = zmd->dev; zmd 1328 drivers/md/dm-zoned-metadata.c dmz_start_sect(zmd, zone), zmd 1332 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone), ret); zmd 1344 drivers/md/dm-zoned-metadata.c static void dmz_get_zone_weight(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 1349 drivers/md/dm-zoned-metadata.c static int dmz_load_mapping(struct dmz_metadata *zmd) zmd 1351 drivers/md/dm-zoned-metadata.c struct dmz_dev *dev = zmd->dev; zmd 1360 drivers/md/dm-zoned-metadata.c zmd->map_mblk = kcalloc(zmd->nr_map_blocks, zmd 1362 drivers/md/dm-zoned-metadata.c if (!zmd->map_mblk) zmd 1366 drivers/md/dm-zoned-metadata.c while (chunk < zmd->nr_chunks) { zmd 1369 drivers/md/dm-zoned-metadata.c dmap_mblk = dmz_get_mblock(zmd, i + 1); zmd 1372 drivers/md/dm-zoned-metadata.c zmd->map_mblk[i] = dmap_mblk; zmd 1389 drivers/md/dm-zoned-metadata.c dzone = dmz_get(zmd, dzone_id); zmd 1392 drivers/md/dm-zoned-metadata.c dmz_get_zone_weight(zmd, dzone); zmd 1395 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->map_rnd_list); zmd 1397 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->map_seq_list); zmd 1410 drivers/md/dm-zoned-metadata.c bzone = dmz_get(zmd, bzone_id); zmd 1422 drivers/md/dm-zoned-metadata.c dmz_get_zone_weight(zmd, bzone); zmd 1423 drivers/md/dm-zoned-metadata.c list_add_tail(&bzone->link, &zmd->map_rnd_list); zmd 1437 drivers/md/dm-zoned-metadata.c dzone = dmz_get(zmd, i); zmd 1442 drivers/md/dm-zoned-metadata.c zmd->nr_rnd++; zmd 1444 drivers/md/dm-zoned-metadata.c zmd->nr_seq++; zmd 1455 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->unmap_rnd_list); zmd 1456 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->unmap_nr_rnd); zmd 1457 drivers/md/dm-zoned-metadata.c } else if (atomic_read(&zmd->nr_reserved_seq_zones) < zmd->nr_reserved_seq) { zmd 1458 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->reserved_seq_zones_list); zmd 1459 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->nr_reserved_seq_zones); zmd 1460 drivers/md/dm-zoned-metadata.c zmd->nr_seq--; zmd 1462 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->unmap_seq_list); zmd 1463 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->unmap_nr_seq); zmd 1473 drivers/md/dm-zoned-metadata.c static void dmz_set_chunk_mapping(struct dmz_metadata *zmd, unsigned int chunk, zmd 1476 drivers/md/dm-zoned-metadata.c struct dmz_mblock *dmap_mblk = zmd->map_mblk[chunk >> DMZ_MAP_ENTRIES_SHIFT]; zmd 1482 drivers/md/dm-zoned-metadata.c dmz_dirty_mblock(zmd, dmap_mblk); zmd 1489 drivers/md/dm-zoned-metadata.c static void __dmz_lru_zone(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1497 drivers/md/dm-zoned-metadata.c list_add_tail(&zone->link, &zmd->map_seq_list); zmd 1500 drivers/md/dm-zoned-metadata.c list_add_tail(&zone->link, &zmd->map_rnd_list); zmd 1508 drivers/md/dm-zoned-metadata.c static void dmz_lru_zone(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1510 drivers/md/dm-zoned-metadata.c __dmz_lru_zone(zmd, zone); zmd 1512 drivers/md/dm-zoned-metadata.c __dmz_lru_zone(zmd, zone->bzone); zmd 1518 drivers/md/dm-zoned-metadata.c static void dmz_wait_for_free_zones(struct dmz_metadata *zmd) zmd 1522 drivers/md/dm-zoned-metadata.c prepare_to_wait(&zmd->free_wq, &wait, TASK_UNINTERRUPTIBLE); zmd 1523 drivers/md/dm-zoned-metadata.c dmz_unlock_map(zmd); zmd 1524 drivers/md/dm-zoned-metadata.c dmz_unlock_metadata(zmd); zmd 1528 drivers/md/dm-zoned-metadata.c dmz_lock_metadata(zmd); zmd 1529 drivers/md/dm-zoned-metadata.c dmz_lock_map(zmd); zmd 1530 drivers/md/dm-zoned-metadata.c finish_wait(&zmd->free_wq, &wait); zmd 1563 drivers/md/dm-zoned-metadata.c static void dmz_wait_for_reclaim(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1565 drivers/md/dm-zoned-metadata.c dmz_unlock_map(zmd); zmd 1566 drivers/md/dm-zoned-metadata.c dmz_unlock_metadata(zmd); zmd 1568 drivers/md/dm-zoned-metadata.c dmz_lock_metadata(zmd); zmd 1569 drivers/md/dm-zoned-metadata.c dmz_lock_map(zmd); zmd 1575 drivers/md/dm-zoned-metadata.c static struct dm_zone *dmz_get_rnd_zone_for_reclaim(struct dmz_metadata *zmd) zmd 1580 drivers/md/dm-zoned-metadata.c if (list_empty(&zmd->map_rnd_list)) zmd 1583 drivers/md/dm-zoned-metadata.c list_for_each_entry(zone, &zmd->map_rnd_list, link) { zmd 1598 drivers/md/dm-zoned-metadata.c static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd) zmd 1602 drivers/md/dm-zoned-metadata.c if (list_empty(&zmd->map_seq_list)) zmd 1605 drivers/md/dm-zoned-metadata.c list_for_each_entry(zone, &zmd->map_seq_list, link) { zmd 1618 drivers/md/dm-zoned-metadata.c struct dm_zone *dmz_get_zone_for_reclaim(struct dmz_metadata *zmd) zmd 1630 drivers/md/dm-zoned-metadata.c dmz_lock_map(zmd); zmd 1631 drivers/md/dm-zoned-metadata.c if (list_empty(&zmd->reserved_seq_zones_list)) zmd 1632 drivers/md/dm-zoned-metadata.c zone = dmz_get_seq_zone_for_reclaim(zmd); zmd 1634 drivers/md/dm-zoned-metadata.c zone = dmz_get_rnd_zone_for_reclaim(zmd); zmd 1635 drivers/md/dm-zoned-metadata.c dmz_unlock_map(zmd); zmd 1646 drivers/md/dm-zoned-metadata.c struct dm_zone *dmz_get_chunk_mapping(struct dmz_metadata *zmd, unsigned int chunk, int op) zmd 1648 drivers/md/dm-zoned-metadata.c struct dmz_mblock *dmap_mblk = zmd->map_mblk[chunk >> DMZ_MAP_ENTRIES_SHIFT]; zmd 1655 drivers/md/dm-zoned-metadata.c dmz_lock_map(zmd); zmd 1668 drivers/md/dm-zoned-metadata.c dzone = dmz_alloc_zone(zmd, DMZ_ALLOC_RND); zmd 1670 drivers/md/dm-zoned-metadata.c if (dmz_bdev_is_dying(zmd->dev)) { zmd 1674 drivers/md/dm-zoned-metadata.c dmz_wait_for_free_zones(zmd); zmd 1678 drivers/md/dm-zoned-metadata.c dmz_map_zone(zmd, dzone, chunk); zmd 1682 drivers/md/dm-zoned-metadata.c dzone = dmz_get(zmd, dzone_id); zmd 1690 drivers/md/dm-zoned-metadata.c ret = dmz_handle_seq_write_err(zmd, dzone); zmd 1705 drivers/md/dm-zoned-metadata.c dmz_wait_for_reclaim(zmd, dzone); zmd 1709 drivers/md/dm-zoned-metadata.c dmz_lru_zone(zmd, dzone); zmd 1711 drivers/md/dm-zoned-metadata.c dmz_unlock_map(zmd); zmd 1722 drivers/md/dm-zoned-metadata.c void dmz_put_chunk_mapping(struct dmz_metadata *zmd, struct dm_zone *dzone) zmd 1726 drivers/md/dm-zoned-metadata.c dmz_lock_map(zmd); zmd 1731 drivers/md/dm-zoned-metadata.c dmz_lru_zone(zmd, bzone); zmd 1734 drivers/md/dm-zoned-metadata.c dmz_unmap_zone(zmd, bzone); zmd 1735 drivers/md/dm-zoned-metadata.c dmz_free_zone(zmd, bzone); zmd 1743 drivers/md/dm-zoned-metadata.c dmz_lru_zone(zmd, dzone); zmd 1746 drivers/md/dm-zoned-metadata.c dmz_unmap_zone(zmd, dzone); zmd 1747 drivers/md/dm-zoned-metadata.c dmz_free_zone(zmd, dzone); zmd 1750 drivers/md/dm-zoned-metadata.c dmz_unlock_map(zmd); zmd 1757 drivers/md/dm-zoned-metadata.c struct dm_zone *dmz_get_chunk_buffer(struct dmz_metadata *zmd, zmd 1762 drivers/md/dm-zoned-metadata.c dmz_lock_map(zmd); zmd 1769 drivers/md/dm-zoned-metadata.c bzone = dmz_alloc_zone(zmd, DMZ_ALLOC_RND); zmd 1771 drivers/md/dm-zoned-metadata.c if (dmz_bdev_is_dying(zmd->dev)) { zmd 1775 drivers/md/dm-zoned-metadata.c dmz_wait_for_free_zones(zmd); zmd 1780 drivers/md/dm-zoned-metadata.c dmz_set_chunk_mapping(zmd, dzone->chunk, dmz_id(zmd, dzone), zmd 1781 drivers/md/dm-zoned-metadata.c dmz_id(zmd, bzone)); zmd 1787 drivers/md/dm-zoned-metadata.c list_add_tail(&bzone->link, &zmd->map_rnd_list); zmd 1789 drivers/md/dm-zoned-metadata.c dmz_unlock_map(zmd); zmd 1798 drivers/md/dm-zoned-metadata.c struct dm_zone *dmz_alloc_zone(struct dmz_metadata *zmd, unsigned long flags) zmd 1804 drivers/md/dm-zoned-metadata.c list = &zmd->unmap_rnd_list; zmd 1806 drivers/md/dm-zoned-metadata.c list = &zmd->unmap_seq_list; zmd 1814 drivers/md/dm-zoned-metadata.c list_empty(&zmd->reserved_seq_zones_list)) zmd 1817 drivers/md/dm-zoned-metadata.c zone = list_first_entry(&zmd->reserved_seq_zones_list, zmd 1820 drivers/md/dm-zoned-metadata.c atomic_dec(&zmd->nr_reserved_seq_zones); zmd 1828 drivers/md/dm-zoned-metadata.c atomic_dec(&zmd->unmap_nr_rnd); zmd 1830 drivers/md/dm-zoned-metadata.c atomic_dec(&zmd->unmap_nr_seq); zmd 1833 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "Zone %u is offline", dmz_id(zmd, zone)); zmd 1845 drivers/md/dm-zoned-metadata.c void dmz_free_zone(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1849 drivers/md/dm-zoned-metadata.c dmz_reset_zone(zmd, zone); zmd 1853 drivers/md/dm-zoned-metadata.c list_add_tail(&zone->link, &zmd->unmap_rnd_list); zmd 1854 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->unmap_nr_rnd); zmd 1855 drivers/md/dm-zoned-metadata.c } else if (atomic_read(&zmd->nr_reserved_seq_zones) < zmd 1856 drivers/md/dm-zoned-metadata.c zmd->nr_reserved_seq) { zmd 1857 drivers/md/dm-zoned-metadata.c list_add_tail(&zone->link, &zmd->reserved_seq_zones_list); zmd 1858 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->nr_reserved_seq_zones); zmd 1860 drivers/md/dm-zoned-metadata.c list_add_tail(&zone->link, &zmd->unmap_seq_list); zmd 1861 drivers/md/dm-zoned-metadata.c atomic_inc(&zmd->unmap_nr_seq); zmd 1864 drivers/md/dm-zoned-metadata.c wake_up_all(&zmd->free_wq); zmd 1871 drivers/md/dm-zoned-metadata.c void dmz_map_zone(struct dmz_metadata *zmd, struct dm_zone *dzone, zmd 1875 drivers/md/dm-zoned-metadata.c dmz_set_chunk_mapping(zmd, chunk, dmz_id(zmd, dzone), zmd 1879 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->map_rnd_list); zmd 1881 drivers/md/dm-zoned-metadata.c list_add_tail(&dzone->link, &zmd->map_seq_list); zmd 1888 drivers/md/dm-zoned-metadata.c void dmz_unmap_zone(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 1903 drivers/md/dm-zoned-metadata.c dzone_id = dmz_id(zmd, zone->bzone); zmd 1919 drivers/md/dm-zoned-metadata.c dmz_set_chunk_mapping(zmd, chunk, dzone_id, DMZ_MAP_UNMAPPED); zmd 1960 drivers/md/dm-zoned-metadata.c static struct dmz_mblock *dmz_get_bitmap(struct dmz_metadata *zmd, zmd 1964 drivers/md/dm-zoned-metadata.c sector_t bitmap_block = 1 + zmd->nr_map_blocks + zmd 1965 drivers/md/dm-zoned-metadata.c (sector_t)(dmz_id(zmd, zone) * zmd->zone_nr_bitmap_blocks) + zmd 1968 drivers/md/dm-zoned-metadata.c return dmz_get_mblock(zmd, bitmap_block); zmd 1974 drivers/md/dm-zoned-metadata.c int dmz_copy_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone, zmd 1981 drivers/md/dm-zoned-metadata.c while (chunk_block < zmd->dev->zone_nr_blocks) { zmd 1982 drivers/md/dm-zoned-metadata.c from_mblk = dmz_get_bitmap(zmd, from_zone, chunk_block); zmd 1985 drivers/md/dm-zoned-metadata.c to_mblk = dmz_get_bitmap(zmd, to_zone, chunk_block); zmd 1987 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, from_mblk); zmd 1992 drivers/md/dm-zoned-metadata.c dmz_dirty_mblock(zmd, to_mblk); zmd 1994 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, to_mblk); zmd 1995 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, from_mblk); zmd 1997 drivers/md/dm-zoned-metadata.c chunk_block += zmd->zone_bits_per_mblk; zmd 2009 drivers/md/dm-zoned-metadata.c int dmz_merge_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone, zmd 2016 drivers/md/dm-zoned-metadata.c while (chunk_block < zmd->dev->zone_nr_blocks) { zmd 2018 drivers/md/dm-zoned-metadata.c ret = dmz_first_valid_block(zmd, from_zone, &chunk_block); zmd 2023 drivers/md/dm-zoned-metadata.c ret = dmz_validate_blocks(zmd, to_zone, chunk_block, nr_blocks); zmd 2036 drivers/md/dm-zoned-metadata.c int dmz_validate_blocks(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 2040 drivers/md/dm-zoned-metadata.c unsigned int zone_nr_blocks = zmd->dev->zone_nr_blocks; zmd 2044 drivers/md/dm-zoned-metadata.c dmz_dev_debug(zmd->dev, "=> VALIDATE zone %u, block %llu, %u blocks", zmd 2045 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone), (unsigned long long)chunk_block, zmd 2052 drivers/md/dm-zoned-metadata.c mblk = dmz_get_bitmap(zmd, zone, chunk_block); zmd 2058 drivers/md/dm-zoned-metadata.c nr_bits = min(nr_blocks, zmd->zone_bits_per_mblk - bit); zmd 2062 drivers/md/dm-zoned-metadata.c dmz_dirty_mblock(zmd, mblk); zmd 2065 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, mblk); zmd 2074 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "Zone %u: weight %u should be <= %u", zmd 2075 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone), zone->weight, zmd 2117 drivers/md/dm-zoned-metadata.c int dmz_invalidate_blocks(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 2124 drivers/md/dm-zoned-metadata.c dmz_dev_debug(zmd->dev, "=> INVALIDATE zone %u, block %llu, %u blocks", zmd 2125 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone), (u64)chunk_block, nr_blocks); zmd 2127 drivers/md/dm-zoned-metadata.c WARN_ON(chunk_block + nr_blocks > zmd->dev->zone_nr_blocks); zmd 2131 drivers/md/dm-zoned-metadata.c mblk = dmz_get_bitmap(zmd, zone, chunk_block); zmd 2137 drivers/md/dm-zoned-metadata.c nr_bits = min(nr_blocks, zmd->zone_bits_per_mblk - bit); zmd 2142 drivers/md/dm-zoned-metadata.c dmz_dirty_mblock(zmd, mblk); zmd 2145 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, mblk); zmd 2154 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "Zone %u: weight %u should be >= %u", zmd 2155 drivers/md/dm-zoned-metadata.c dmz_id(zmd, zone), zone->weight, n); zmd 2165 drivers/md/dm-zoned-metadata.c static int dmz_test_block(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 2171 drivers/md/dm-zoned-metadata.c WARN_ON(chunk_block >= zmd->dev->zone_nr_blocks); zmd 2174 drivers/md/dm-zoned-metadata.c mblk = dmz_get_bitmap(zmd, zone, chunk_block); zmd 2182 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, mblk); zmd 2191 drivers/md/dm-zoned-metadata.c static int dmz_to_next_set_block(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 2197 drivers/md/dm-zoned-metadata.c unsigned int zone_bits = zmd->zone_bits_per_mblk; zmd 2201 drivers/md/dm-zoned-metadata.c WARN_ON(chunk_block + nr_blocks > zmd->dev->zone_nr_blocks); zmd 2205 drivers/md/dm-zoned-metadata.c mblk = dmz_get_bitmap(zmd, zone, chunk_block); zmd 2217 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, mblk); zmd 2234 drivers/md/dm-zoned-metadata.c int dmz_block_valid(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 2239 drivers/md/dm-zoned-metadata.c valid = dmz_test_block(zmd, zone, chunk_block); zmd 2244 drivers/md/dm-zoned-metadata.c return dmz_to_next_set_block(zmd, zone, chunk_block, zmd 2245 drivers/md/dm-zoned-metadata.c zmd->dev->zone_nr_blocks - chunk_block, 0); zmd 2254 drivers/md/dm-zoned-metadata.c int dmz_first_valid_block(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 2260 drivers/md/dm-zoned-metadata.c ret = dmz_to_next_set_block(zmd, zone, start_block, zmd 2261 drivers/md/dm-zoned-metadata.c zmd->dev->zone_nr_blocks - start_block, 1); zmd 2268 drivers/md/dm-zoned-metadata.c return dmz_to_next_set_block(zmd, zone, start_block, zmd 2269 drivers/md/dm-zoned-metadata.c zmd->dev->zone_nr_blocks - start_block, 0); zmd 2303 drivers/md/dm-zoned-metadata.c static void dmz_get_zone_weight(struct dmz_metadata *zmd, struct dm_zone *zone) zmd 2308 drivers/md/dm-zoned-metadata.c unsigned int nr_blocks = zmd->dev->zone_nr_blocks; zmd 2314 drivers/md/dm-zoned-metadata.c mblk = dmz_get_bitmap(zmd, zone, chunk_block); zmd 2323 drivers/md/dm-zoned-metadata.c nr_bits = min(nr_blocks, zmd->zone_bits_per_mblk - bit); zmd 2326 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, mblk); zmd 2338 drivers/md/dm-zoned-metadata.c static void dmz_cleanup_metadata(struct dmz_metadata *zmd) zmd 2345 drivers/md/dm-zoned-metadata.c if (zmd->map_mblk) { zmd 2346 drivers/md/dm-zoned-metadata.c for (i = 0; i < zmd->nr_map_blocks; i++) zmd 2347 drivers/md/dm-zoned-metadata.c dmz_release_mblock(zmd, zmd->map_mblk[i]); zmd 2348 drivers/md/dm-zoned-metadata.c kfree(zmd->map_mblk); zmd 2349 drivers/md/dm-zoned-metadata.c zmd->map_mblk = NULL; zmd 2354 drivers/md/dm-zoned-metadata.c if (zmd->sb[i].mblk) { zmd 2355 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, zmd->sb[i].mblk); zmd 2356 drivers/md/dm-zoned-metadata.c zmd->sb[i].mblk = NULL; zmd 2361 drivers/md/dm-zoned-metadata.c while (!list_empty(&zmd->mblk_dirty_list)) { zmd 2362 drivers/md/dm-zoned-metadata.c mblk = list_first_entry(&zmd->mblk_dirty_list, zmd 2364 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "mblock %llu still in dirty list (ref %u)", zmd 2367 drivers/md/dm-zoned-metadata.c rb_erase(&mblk->node, &zmd->mblk_rbtree); zmd 2368 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 2371 drivers/md/dm-zoned-metadata.c while (!list_empty(&zmd->mblk_lru_list)) { zmd 2372 drivers/md/dm-zoned-metadata.c mblk = list_first_entry(&zmd->mblk_lru_list, zmd 2375 drivers/md/dm-zoned-metadata.c rb_erase(&mblk->node, &zmd->mblk_rbtree); zmd 2376 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 2380 drivers/md/dm-zoned-metadata.c root = &zmd->mblk_rbtree; zmd 2382 drivers/md/dm-zoned-metadata.c dmz_dev_warn(zmd->dev, "mblock %llu ref %u still in rbtree", zmd 2385 drivers/md/dm-zoned-metadata.c dmz_free_mblock(zmd, mblk); zmd 2389 drivers/md/dm-zoned-metadata.c dmz_drop_zones(zmd); zmd 2391 drivers/md/dm-zoned-metadata.c mutex_destroy(&zmd->mblk_flush_lock); zmd 2392 drivers/md/dm-zoned-metadata.c mutex_destroy(&zmd->map_lock); zmd 2400 drivers/md/dm-zoned-metadata.c struct dmz_metadata *zmd; zmd 2405 drivers/md/dm-zoned-metadata.c zmd = kzalloc(sizeof(struct dmz_metadata), GFP_KERNEL); zmd 2406 drivers/md/dm-zoned-metadata.c if (!zmd) zmd 2409 drivers/md/dm-zoned-metadata.c zmd->dev = dev; zmd 2410 drivers/md/dm-zoned-metadata.c zmd->mblk_rbtree = RB_ROOT; zmd 2411 drivers/md/dm-zoned-metadata.c init_rwsem(&zmd->mblk_sem); zmd 2412 drivers/md/dm-zoned-metadata.c mutex_init(&zmd->mblk_flush_lock); zmd 2413 drivers/md/dm-zoned-metadata.c spin_lock_init(&zmd->mblk_lock); zmd 2414 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->mblk_lru_list); zmd 2415 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->mblk_dirty_list); zmd 2417 drivers/md/dm-zoned-metadata.c mutex_init(&zmd->map_lock); zmd 2418 drivers/md/dm-zoned-metadata.c atomic_set(&zmd->unmap_nr_rnd, 0); zmd 2419 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->unmap_rnd_list); zmd 2420 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->map_rnd_list); zmd 2422 drivers/md/dm-zoned-metadata.c atomic_set(&zmd->unmap_nr_seq, 0); zmd 2423 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->unmap_seq_list); zmd 2424 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->map_seq_list); zmd 2426 drivers/md/dm-zoned-metadata.c atomic_set(&zmd->nr_reserved_seq_zones, 0); zmd 2427 drivers/md/dm-zoned-metadata.c INIT_LIST_HEAD(&zmd->reserved_seq_zones_list); zmd 2429 drivers/md/dm-zoned-metadata.c init_waitqueue_head(&zmd->free_wq); zmd 2432 drivers/md/dm-zoned-metadata.c ret = dmz_init_zones(zmd); zmd 2437 drivers/md/dm-zoned-metadata.c ret = dmz_load_sb(zmd); zmd 2442 drivers/md/dm-zoned-metadata.c zid = dmz_id(zmd, zmd->sb_zone); zmd 2443 drivers/md/dm-zoned-metadata.c for (i = 0; i < zmd->nr_meta_zones << 1; i++) { zmd 2444 drivers/md/dm-zoned-metadata.c zone = dmz_get(zmd, zid + i); zmd 2451 drivers/md/dm-zoned-metadata.c ret = dmz_load_mapping(zmd); zmd 2461 drivers/md/dm-zoned-metadata.c zmd->min_nr_mblks = 2 + zmd->nr_map_blocks + zmd->zone_nr_bitmap_blocks * 16; zmd 2462 drivers/md/dm-zoned-metadata.c zmd->max_nr_mblks = zmd->min_nr_mblks + 512; zmd 2463 drivers/md/dm-zoned-metadata.c zmd->mblk_shrinker.count_objects = dmz_mblock_shrinker_count; zmd 2464 drivers/md/dm-zoned-metadata.c zmd->mblk_shrinker.scan_objects = dmz_mblock_shrinker_scan; zmd 2465 drivers/md/dm-zoned-metadata.c zmd->mblk_shrinker.seeks = DEFAULT_SEEKS; zmd 2468 drivers/md/dm-zoned-metadata.c ret = register_shrinker(&zmd->mblk_shrinker); zmd 2482 drivers/md/dm-zoned-metadata.c zmd->nr_meta_zones * 2); zmd 2484 drivers/md/dm-zoned-metadata.c zmd->nr_data_zones, zmd->nr_chunks); zmd 2486 drivers/md/dm-zoned-metadata.c zmd->nr_rnd, atomic_read(&zmd->unmap_nr_rnd)); zmd 2488 drivers/md/dm-zoned-metadata.c zmd->nr_seq, atomic_read(&zmd->unmap_nr_seq)); zmd 2490 drivers/md/dm-zoned-metadata.c zmd->nr_reserved_seq); zmd 2494 drivers/md/dm-zoned-metadata.c zmd->nr_meta_blocks, zmd->max_nr_mblks); zmd 2496 drivers/md/dm-zoned-metadata.c zmd->nr_map_blocks); zmd 2498 drivers/md/dm-zoned-metadata.c zmd->nr_bitmap_blocks); zmd 2500 drivers/md/dm-zoned-metadata.c *metadata = zmd; zmd 2504 drivers/md/dm-zoned-metadata.c dmz_cleanup_metadata(zmd); zmd 2505 drivers/md/dm-zoned-metadata.c kfree(zmd); zmd 2514 drivers/md/dm-zoned-metadata.c void dmz_dtr_metadata(struct dmz_metadata *zmd) zmd 2516 drivers/md/dm-zoned-metadata.c unregister_shrinker(&zmd->mblk_shrinker); zmd 2517 drivers/md/dm-zoned-metadata.c dmz_cleanup_metadata(zmd); zmd 2518 drivers/md/dm-zoned-metadata.c kfree(zmd); zmd 2524 drivers/md/dm-zoned-metadata.c int dmz_resume_metadata(struct dmz_metadata *zmd) zmd 2526 drivers/md/dm-zoned-metadata.c struct dmz_dev *dev = zmd->dev; zmd 2534 drivers/md/dm-zoned-metadata.c zone = dmz_get(zmd, i); zmd 2542 drivers/md/dm-zoned-metadata.c ret = dmz_update_zone(zmd, zone); zmd 2560 drivers/md/dm-zoned-metadata.c dmz_invalidate_blocks(zmd, zone, zone->wp_block, zmd 61 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 78 drivers/md/dm-zoned-reclaim.c dmz_start_sect(zmd, zone) + dmz_blk2sect(wp_block), zmd 83 drivers/md/dm-zoned-reclaim.c dmz_id(zmd, zone), (unsigned long long)wp_block, zmd 118 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 132 drivers/md/dm-zoned-reclaim.c src_zone_block = dmz_start_block(zmd, src_zone); zmd 133 drivers/md/dm-zoned-reclaim.c dst_zone_block = dmz_start_block(zmd, dst_zone); zmd 143 drivers/md/dm-zoned-reclaim.c ret = dmz_first_valid_block(zmd, src_zone, &block); zmd 194 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 199 drivers/md/dm-zoned-reclaim.c dzone->chunk, dmz_id(zmd, bzone), dmz_weight(bzone), zmd 200 drivers/md/dm-zoned-reclaim.c dmz_id(zmd, dzone), dmz_weight(dzone)); zmd 207 drivers/md/dm-zoned-reclaim.c dmz_lock_flush(zmd); zmd 210 drivers/md/dm-zoned-reclaim.c ret = dmz_merge_valid_blocks(zmd, bzone, dzone, chunk_block); zmd 213 drivers/md/dm-zoned-reclaim.c dmz_invalidate_blocks(zmd, bzone, 0, zrc->dev->zone_nr_blocks); zmd 214 drivers/md/dm-zoned-reclaim.c dmz_lock_map(zmd); zmd 215 drivers/md/dm-zoned-reclaim.c dmz_unmap_zone(zmd, bzone); zmd 217 drivers/md/dm-zoned-reclaim.c dmz_free_zone(zmd, bzone); zmd 218 drivers/md/dm-zoned-reclaim.c dmz_unlock_map(zmd); zmd 221 drivers/md/dm-zoned-reclaim.c dmz_unlock_flush(zmd); zmd 233 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 238 drivers/md/dm-zoned-reclaim.c chunk, dmz_id(zmd, dzone), dmz_weight(dzone), zmd 239 drivers/md/dm-zoned-reclaim.c dmz_id(zmd, bzone), dmz_weight(bzone)); zmd 246 drivers/md/dm-zoned-reclaim.c dmz_lock_flush(zmd); zmd 249 drivers/md/dm-zoned-reclaim.c ret = dmz_merge_valid_blocks(zmd, dzone, bzone, 0); zmd 255 drivers/md/dm-zoned-reclaim.c dmz_invalidate_blocks(zmd, dzone, 0, zrc->dev->zone_nr_blocks); zmd 256 drivers/md/dm-zoned-reclaim.c dmz_lock_map(zmd); zmd 257 drivers/md/dm-zoned-reclaim.c dmz_unmap_zone(zmd, bzone); zmd 258 drivers/md/dm-zoned-reclaim.c dmz_unmap_zone(zmd, dzone); zmd 260 drivers/md/dm-zoned-reclaim.c dmz_free_zone(zmd, dzone); zmd 261 drivers/md/dm-zoned-reclaim.c dmz_map_zone(zmd, bzone, chunk); zmd 262 drivers/md/dm-zoned-reclaim.c dmz_unlock_map(zmd); zmd 265 drivers/md/dm-zoned-reclaim.c dmz_unlock_flush(zmd); zmd 278 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 282 drivers/md/dm-zoned-reclaim.c dmz_lock_map(zmd); zmd 283 drivers/md/dm-zoned-reclaim.c szone = dmz_alloc_zone(zmd, DMZ_ALLOC_RECLAIM); zmd 284 drivers/md/dm-zoned-reclaim.c dmz_unlock_map(zmd); zmd 290 drivers/md/dm-zoned-reclaim.c chunk, dmz_id(zmd, dzone), dmz_weight(dzone), zmd 291 drivers/md/dm-zoned-reclaim.c dmz_id(zmd, szone)); zmd 296 drivers/md/dm-zoned-reclaim.c dmz_lock_flush(zmd); zmd 300 drivers/md/dm-zoned-reclaim.c ret = dmz_copy_valid_blocks(zmd, dzone, szone); zmd 304 drivers/md/dm-zoned-reclaim.c dmz_lock_map(zmd); zmd 305 drivers/md/dm-zoned-reclaim.c dmz_free_zone(zmd, szone); zmd 306 drivers/md/dm-zoned-reclaim.c dmz_unlock_map(zmd); zmd 309 drivers/md/dm-zoned-reclaim.c dmz_invalidate_blocks(zmd, dzone, 0, zrc->dev->zone_nr_blocks); zmd 310 drivers/md/dm-zoned-reclaim.c dmz_lock_map(zmd); zmd 311 drivers/md/dm-zoned-reclaim.c dmz_unmap_zone(zmd, dzone); zmd 313 drivers/md/dm-zoned-reclaim.c dmz_free_zone(zmd, dzone); zmd 314 drivers/md/dm-zoned-reclaim.c dmz_map_zone(zmd, szone, chunk); zmd 315 drivers/md/dm-zoned-reclaim.c dmz_unlock_map(zmd); zmd 318 drivers/md/dm-zoned-reclaim.c dmz_unlock_flush(zmd); zmd 328 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 330 drivers/md/dm-zoned-reclaim.c dmz_lock_flush(zmd); zmd 331 drivers/md/dm-zoned-reclaim.c dmz_lock_map(zmd); zmd 332 drivers/md/dm-zoned-reclaim.c dmz_unmap_zone(zmd, dzone); zmd 334 drivers/md/dm-zoned-reclaim.c dmz_free_zone(zmd, dzone); zmd 335 drivers/md/dm-zoned-reclaim.c dmz_unlock_map(zmd); zmd 336 drivers/md/dm-zoned-reclaim.c dmz_unlock_flush(zmd); zmd 344 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 351 drivers/md/dm-zoned-reclaim.c dzone = dmz_get_zone_for_reclaim(zmd); zmd 375 drivers/md/dm-zoned-reclaim.c ret = dmz_first_valid_block(zmd, bzone, &chunk_block); zmd 406 drivers/md/dm-zoned-reclaim.c dmz_id(zmd, rzone), ret); zmd 411 drivers/md/dm-zoned-reclaim.c dmz_id(zmd, rzone), jiffies_to_msecs(jiffies - start)); zmd 428 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 429 drivers/md/dm-zoned-reclaim.c unsigned int nr_rnd = dmz_nr_rnd_zones(zmd); zmd 430 drivers/md/dm-zoned-reclaim.c unsigned int nr_unmap_rnd = dmz_nr_unmap_rnd_zones(zmd); zmd 454 drivers/md/dm-zoned-reclaim.c struct dmz_metadata *zmd = zrc->metadata; zmd 473 drivers/md/dm-zoned-reclaim.c nr_rnd = dmz_nr_rnd_zones(zmd); zmd 474 drivers/md/dm-zoned-reclaim.c nr_unmap_rnd = dmz_nr_unmap_rnd_zones(zmd); zmd 503 drivers/md/dm-zoned-reclaim.c int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd, zmd 514 drivers/md/dm-zoned-reclaim.c zrc->metadata = zmd; zmd 244 drivers/md/dm-zoned-target.c struct dmz_metadata *zmd = dmz->metadata; zmd 260 drivers/md/dm-zoned-target.c ret = dmz_validate_blocks(zmd, zone, chunk_block, nr_blocks); zmd 262 drivers/md/dm-zoned-target.c ret = dmz_invalidate_blocks(zmd, bzone, chunk_block, nr_blocks); zmd 277 drivers/md/dm-zoned-target.c struct dmz_metadata *zmd = dmz->metadata; zmd 282 drivers/md/dm-zoned-target.c bzone = dmz_get_chunk_buffer(zmd, zone); zmd 298 drivers/md/dm-zoned-target.c ret = dmz_validate_blocks(zmd, bzone, chunk_block, nr_blocks); zmd 300 drivers/md/dm-zoned-target.c ret = dmz_invalidate_blocks(zmd, zone, chunk_block, nr_blocks); zmd 345 drivers/md/dm-zoned-target.c struct dmz_metadata *zmd = dmz->metadata; zmd 360 drivers/md/dm-zoned-target.c dmz_id(zmd, zone), zmd 368 drivers/md/dm-zoned-target.c ret = dmz_invalidate_blocks(zmd, zone, chunk_block, nr_blocks); zmd 370 drivers/md/dm-zoned-target.c ret = dmz_invalidate_blocks(zmd, zone->bzone, zmd 382 drivers/md/dm-zoned-target.c struct dmz_metadata *zmd = dmz->metadata; zmd 393 drivers/md/dm-zoned-target.c dmz_lock_metadata(zmd); zmd 405 drivers/md/dm-zoned-target.c zone = dmz_get_chunk_mapping(zmd, dmz_bio_chunk(dmz->dev, bio), zmd 440 drivers/md/dm-zoned-target.c dmz_put_chunk_mapping(zmd, zone); zmd 444 drivers/md/dm-zoned-target.c dmz_unlock_metadata(zmd); zmd 167 drivers/md/dm-zoned.h int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **zmd); zmd 168 drivers/md/dm-zoned.h void dmz_dtr_metadata(struct dmz_metadata *zmd); zmd 169 drivers/md/dm-zoned.h int dmz_resume_metadata(struct dmz_metadata *zmd); zmd 171 drivers/md/dm-zoned.h void dmz_lock_map(struct dmz_metadata *zmd); zmd 172 drivers/md/dm-zoned.h void dmz_unlock_map(struct dmz_metadata *zmd); zmd 173 drivers/md/dm-zoned.h void dmz_lock_metadata(struct dmz_metadata *zmd); zmd 174 drivers/md/dm-zoned.h void dmz_unlock_metadata(struct dmz_metadata *zmd); zmd 175 drivers/md/dm-zoned.h void dmz_lock_flush(struct dmz_metadata *zmd); zmd 176 drivers/md/dm-zoned.h void dmz_unlock_flush(struct dmz_metadata *zmd); zmd 177 drivers/md/dm-zoned.h int dmz_flush_metadata(struct dmz_metadata *zmd); zmd 179 drivers/md/dm-zoned.h unsigned int dmz_id(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 180 drivers/md/dm-zoned.h sector_t dmz_start_sect(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 181 drivers/md/dm-zoned.h sector_t dmz_start_block(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 182 drivers/md/dm-zoned.h unsigned int dmz_nr_chunks(struct dmz_metadata *zmd); zmd 187 drivers/md/dm-zoned.h struct dm_zone *dmz_alloc_zone(struct dmz_metadata *zmd, unsigned long flags); zmd 188 drivers/md/dm-zoned.h void dmz_free_zone(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 190 drivers/md/dm-zoned.h void dmz_map_zone(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 192 drivers/md/dm-zoned.h void dmz_unmap_zone(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 193 drivers/md/dm-zoned.h unsigned int dmz_nr_rnd_zones(struct dmz_metadata *zmd); zmd 194 drivers/md/dm-zoned.h unsigned int dmz_nr_unmap_rnd_zones(struct dmz_metadata *zmd); zmd 223 drivers/md/dm-zoned.h struct dm_zone *dmz_get_zone_for_reclaim(struct dmz_metadata *zmd); zmd 225 drivers/md/dm-zoned.h struct dm_zone *dmz_get_chunk_mapping(struct dmz_metadata *zmd, zmd 227 drivers/md/dm-zoned.h void dmz_put_chunk_mapping(struct dmz_metadata *zmd, struct dm_zone *zone); zmd 228 drivers/md/dm-zoned.h struct dm_zone *dmz_get_chunk_buffer(struct dmz_metadata *zmd, zmd 231 drivers/md/dm-zoned.h int dmz_validate_blocks(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 233 drivers/md/dm-zoned.h int dmz_invalidate_blocks(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 235 drivers/md/dm-zoned.h int dmz_block_valid(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 237 drivers/md/dm-zoned.h int dmz_first_valid_block(struct dmz_metadata *zmd, struct dm_zone *zone, zmd 239 drivers/md/dm-zoned.h int dmz_copy_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone, zmd 241 drivers/md/dm-zoned.h int dmz_merge_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone, zmd 247 drivers/md/dm-zoned.h int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd,