Commit 2234e732 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Mike Snitzer

dm zoned: introduce dmz_metadata_label() to format device name

Introduce dmz_metadata_label() to format the device-mapper device
name and use it instead of the device name of the underlying device.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: default avatarBob Liu <bob.liu@oracle.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 36820560
...@@ -134,6 +134,8 @@ struct dmz_sb { ...@@ -134,6 +134,8 @@ struct dmz_sb {
struct dmz_metadata { struct dmz_metadata {
struct dmz_dev *dev; struct dmz_dev *dev;
char devname[BDEVNAME_SIZE];
sector_t zone_bitmap_size; sector_t zone_bitmap_size;
unsigned int zone_nr_bitmap_blocks; unsigned int zone_nr_bitmap_blocks;
unsigned int zone_bits_per_mblk; unsigned int zone_bits_per_mblk;
...@@ -260,6 +262,11 @@ unsigned int dmz_nr_unmap_seq_zones(struct dmz_metadata *zmd) ...@@ -260,6 +262,11 @@ unsigned int dmz_nr_unmap_seq_zones(struct dmz_metadata *zmd)
return atomic_read(&zmd->unmap_nr_seq); return atomic_read(&zmd->unmap_nr_seq);
} }
const char *dmz_metadata_label(struct dmz_metadata *zmd)
{
return (const char *)zmd->devname;
}
/* /*
* Lock/unlock mapping table. * Lock/unlock mapping table.
* The map lock also protects all the zone lists. * The map lock also protects all the zone lists.
...@@ -2439,7 +2446,8 @@ static void dmz_cleanup_metadata(struct dmz_metadata *zmd) ...@@ -2439,7 +2446,8 @@ static void dmz_cleanup_metadata(struct dmz_metadata *zmd)
/* /*
* Initialize the zoned metadata. * Initialize the zoned metadata.
*/ */
int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **metadata) int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **metadata,
const char *devname)
{ {
struct dmz_metadata *zmd; struct dmz_metadata *zmd;
unsigned int i; unsigned int i;
...@@ -2450,6 +2458,7 @@ int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **metadata) ...@@ -2450,6 +2458,7 @@ int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **metadata)
if (!zmd) if (!zmd)
return -ENOMEM; return -ENOMEM;
strcpy(zmd->devname, devname);
zmd->dev = dev; zmd->dev = dev;
zmd->mblk_rbtree = RB_ROOT; zmd->mblk_rbtree = RB_ROOT;
init_rwsem(&zmd->mblk_sem); init_rwsem(&zmd->mblk_sem);
......
...@@ -480,15 +480,16 @@ static void dmz_reclaim_work(struct work_struct *work) ...@@ -480,15 +480,16 @@ static void dmz_reclaim_work(struct work_struct *work)
zrc->kc_throttle.throttle = min(75U, 100U - p_unmap_rnd / 2); zrc->kc_throttle.throttle = min(75U, 100U - p_unmap_rnd / 2);
} }
dmz_dev_debug(zrc->dev, DMDEBUG("(%s): Reclaim (%u): %s, %u%% free rnd zones (%u/%u)",
"Reclaim (%u): %s, %u%% free rnd zones (%u/%u)", dmz_metadata_label(zmd),
zrc->kc_throttle.throttle, zrc->kc_throttle.throttle,
(dmz_target_idle(zrc) ? "Idle" : "Busy"), (dmz_target_idle(zrc) ? "Idle" : "Busy"),
p_unmap_rnd, nr_unmap_rnd, nr_rnd); p_unmap_rnd, nr_unmap_rnd, nr_rnd);
ret = dmz_do_reclaim(zrc); ret = dmz_do_reclaim(zrc);
if (ret) { if (ret) {
dmz_dev_debug(zrc->dev, "Reclaim error %d\n", ret); DMDEBUG("(%s): Reclaim error %d\n",
dmz_metadata_label(zmd), ret);
if (!dmz_check_bdev(zrc->dev)) if (!dmz_check_bdev(zrc->dev))
return; return;
} }
...@@ -524,7 +525,7 @@ int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd, ...@@ -524,7 +525,7 @@ int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd,
/* Reclaim work */ /* Reclaim work */
INIT_DELAYED_WORK(&zrc->work, dmz_reclaim_work); INIT_DELAYED_WORK(&zrc->work, dmz_reclaim_work);
zrc->wq = alloc_ordered_workqueue("dmz_rwq_%s", WQ_MEM_RECLAIM, zrc->wq = alloc_ordered_workqueue("dmz_rwq_%s", WQ_MEM_RECLAIM,
dev->name); dmz_metadata_label(zmd));
if (!zrc->wq) { if (!zrc->wq) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
......
...@@ -178,11 +178,12 @@ static int dmz_handle_read(struct dmz_target *dmz, struct dm_zone *zone, ...@@ -178,11 +178,12 @@ static int dmz_handle_read(struct dmz_target *dmz, struct dm_zone *zone,
return 0; return 0;
} }
dmz_dev_debug(dmz->dev, "READ chunk %llu -> %s zone %u, block %llu, %u blocks", DMDEBUG("(%s): READ chunk %llu -> %s zone %u, block %llu, %u blocks",
(unsigned long long)dmz_bio_chunk(zmd, bio), dmz_metadata_label(zmd),
(dmz_is_rnd(zone) ? "RND" : "SEQ"), (unsigned long long)dmz_bio_chunk(zmd, bio),
zone->id, (dmz_is_rnd(zone) ? "RND" : "SEQ"),
(unsigned long long)chunk_block, nr_blocks); zone->id,
(unsigned long long)chunk_block, nr_blocks);
/* Check block validity to determine the read location */ /* Check block validity to determine the read location */
bzone = zone->bzone; bzone = zone->bzone;
...@@ -316,11 +317,12 @@ static int dmz_handle_write(struct dmz_target *dmz, struct dm_zone *zone, ...@@ -316,11 +317,12 @@ static int dmz_handle_write(struct dmz_target *dmz, struct dm_zone *zone,
if (!zone) if (!zone)
return -ENOSPC; return -ENOSPC;
dmz_dev_debug(dmz->dev, "WRITE chunk %llu -> %s zone %u, block %llu, %u blocks", DMDEBUG("(%s): WRITE chunk %llu -> %s zone %u, block %llu, %u blocks",
(unsigned long long)dmz_bio_chunk(zmd, bio), dmz_metadata_label(zmd),
(dmz_is_rnd(zone) ? "RND" : "SEQ"), (unsigned long long)dmz_bio_chunk(zmd, bio),
zone->id, (dmz_is_rnd(zone) ? "RND" : "SEQ"),
(unsigned long long)chunk_block, nr_blocks); zone->id,
(unsigned long long)chunk_block, nr_blocks);
if (dmz_is_rnd(zone) || chunk_block == zone->wp_block) { if (dmz_is_rnd(zone) || chunk_block == zone->wp_block) {
/* /*
...@@ -357,10 +359,11 @@ static int dmz_handle_discard(struct dmz_target *dmz, struct dm_zone *zone, ...@@ -357,10 +359,11 @@ static int dmz_handle_discard(struct dmz_target *dmz, struct dm_zone *zone,
if (dmz_is_readonly(zone)) if (dmz_is_readonly(zone))
return -EROFS; return -EROFS;
dmz_dev_debug(dmz->dev, "DISCARD chunk %llu -> zone %u, block %llu, %u blocks", DMDEBUG("(%s): DISCARD chunk %llu -> zone %u, block %llu, %u blocks",
(unsigned long long)dmz_bio_chunk(zmd, bio), dmz_metadata_label(dmz->metadata),
zone->id, (unsigned long long)dmz_bio_chunk(zmd, bio),
(unsigned long long)chunk_block, nr_blocks); zone->id,
(unsigned long long)chunk_block, nr_blocks);
/* /*
* Invalidate blocks in the data zone and its * Invalidate blocks in the data zone and its
...@@ -429,8 +432,8 @@ static void dmz_handle_bio(struct dmz_target *dmz, struct dm_chunk_work *cw, ...@@ -429,8 +432,8 @@ static void dmz_handle_bio(struct dmz_target *dmz, struct dm_chunk_work *cw,
ret = dmz_handle_discard(dmz, zone, bio); ret = dmz_handle_discard(dmz, zone, bio);
break; break;
default: default:
dmz_dev_err(dmz->dev, "Unsupported BIO operation 0x%x", DMERR("(%s): Unsupported BIO operation 0x%x",
bio_op(bio)); dmz_metadata_label(dmz->metadata), bio_op(bio));
ret = -EIO; ret = -EIO;
} }
...@@ -504,7 +507,8 @@ static void dmz_flush_work(struct work_struct *work) ...@@ -504,7 +507,8 @@ static void dmz_flush_work(struct work_struct *work)
/* Flush dirty metadata blocks */ /* Flush dirty metadata blocks */
ret = dmz_flush_metadata(dmz->metadata); ret = dmz_flush_metadata(dmz->metadata);
if (ret) if (ret)
dmz_dev_debug(dmz->dev, "Metadata flush failed, rc=%d\n", ret); DMDEBUG("(%s): Metadata flush failed, rc=%d\n",
dmz_metadata_label(dmz->metadata), ret);
/* Process queued flush requests */ /* Process queued flush requests */
while (1) { while (1) {
...@@ -631,11 +635,12 @@ static int dmz_map(struct dm_target *ti, struct bio *bio) ...@@ -631,11 +635,12 @@ static int dmz_map(struct dm_target *ti, struct bio *bio)
if (dmz_bdev_is_dying(dmz->dev)) if (dmz_bdev_is_dying(dmz->dev))
return DM_MAPIO_KILL; return DM_MAPIO_KILL;
dmz_dev_debug(dev, "BIO op %d sector %llu + %u => chunk %llu, block %llu, %u blocks", DMDEBUG("(%s): BIO op %d sector %llu + %u => chunk %llu, block %llu, %u blocks",
bio_op(bio), (unsigned long long)sector, nr_sectors, dmz_metadata_label(zmd),
(unsigned long long)dmz_bio_chunk(zmd, bio), bio_op(bio), (unsigned long long)sector, nr_sectors,
(unsigned long long)dmz_chunk_block(zmd, dmz_bio_block(bio)), (unsigned long long)dmz_bio_chunk(zmd, bio),
(unsigned int)dmz_bio_blocks(bio)); (unsigned long long)dmz_chunk_block(zmd, dmz_bio_block(bio)),
(unsigned int)dmz_bio_blocks(bio));
bio_set_dev(bio, dev->bdev); bio_set_dev(bio, dev->bdev);
...@@ -669,10 +674,10 @@ static int dmz_map(struct dm_target *ti, struct bio *bio) ...@@ -669,10 +674,10 @@ static int dmz_map(struct dm_target *ti, struct bio *bio)
/* Now ready to handle this BIO */ /* Now ready to handle this BIO */
ret = dmz_queue_chunk_work(dmz, bio); ret = dmz_queue_chunk_work(dmz, bio);
if (ret) { if (ret) {
dmz_dev_debug(dmz->dev, DMDEBUG("(%s): BIO op %d, can't process chunk %llu, err %i\n",
"BIO op %d, can't process chunk %llu, err %i\n", dmz_metadata_label(zmd),
bio_op(bio), (u64)dmz_bio_chunk(zmd, bio), bio_op(bio), (u64)dmz_bio_chunk(zmd, bio),
ret); ret);
return DM_MAPIO_REQUEUE; return DM_MAPIO_REQUEUE;
} }
...@@ -782,7 +787,8 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -782,7 +787,8 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
/* Initialize metadata */ /* Initialize metadata */
dev = dmz->dev; dev = dmz->dev;
ret = dmz_ctr_metadata(dev, &dmz->metadata); ret = dmz_ctr_metadata(dev, &dmz->metadata,
dm_table_device_name(ti->table));
if (ret) { if (ret) {
ti->error = "Metadata initialization failed"; ti->error = "Metadata initialization failed";
goto err_dev; goto err_dev;
...@@ -811,8 +817,9 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -811,8 +817,9 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
/* Chunk BIO work */ /* Chunk BIO work */
mutex_init(&dmz->chunk_lock); mutex_init(&dmz->chunk_lock);
INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_NOIO); INIT_RADIX_TREE(&dmz->chunk_rxtree, GFP_NOIO);
dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s", WQ_MEM_RECLAIM | WQ_UNBOUND, dmz->chunk_wq = alloc_workqueue("dmz_cwq_%s",
0, dev->name); WQ_MEM_RECLAIM | WQ_UNBOUND, 0,
dmz_metadata_label(dmz->metadata));
if (!dmz->chunk_wq) { if (!dmz->chunk_wq) {
ti->error = "Create chunk workqueue failed"; ti->error = "Create chunk workqueue failed";
ret = -ENOMEM; ret = -ENOMEM;
...@@ -824,7 +831,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -824,7 +831,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
bio_list_init(&dmz->flush_list); bio_list_init(&dmz->flush_list);
INIT_DELAYED_WORK(&dmz->flush_work, dmz_flush_work); INIT_DELAYED_WORK(&dmz->flush_work, dmz_flush_work);
dmz->flush_wq = alloc_ordered_workqueue("dmz_fwq_%s", WQ_MEM_RECLAIM, dmz->flush_wq = alloc_ordered_workqueue("dmz_fwq_%s", WQ_MEM_RECLAIM,
dev->name); dmz_metadata_label(dmz->metadata));
if (!dmz->flush_wq) { if (!dmz->flush_wq) {
ti->error = "Create flush workqueue failed"; ti->error = "Create flush workqueue failed";
ret = -ENOMEM; ret = -ENOMEM;
...@@ -839,9 +846,10 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -839,9 +846,10 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto err_fwq; goto err_fwq;
} }
dmz_dev_info(dev, "Target device: %llu 512-byte logical sectors (%llu blocks)", DMINFO("(%s): Target device: %llu 512-byte logical sectors (%llu blocks)",
(unsigned long long)ti->len, dmz_metadata_label(dmz->metadata),
(unsigned long long)dmz_sect2blk(ti->len)); (unsigned long long)ti->len,
(unsigned long long)dmz_sect2blk(ti->len));
return 0; return 0;
err_fwq: err_fwq:
......
...@@ -163,7 +163,8 @@ struct dmz_reclaim; ...@@ -163,7 +163,8 @@ struct dmz_reclaim;
/* /*
* Functions defined in dm-zoned-metadata.c * Functions defined in dm-zoned-metadata.c
*/ */
int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **zmd); int dmz_ctr_metadata(struct dmz_dev *dev, struct dmz_metadata **zmd,
const char *devname);
void dmz_dtr_metadata(struct dmz_metadata *zmd); void dmz_dtr_metadata(struct dmz_metadata *zmd);
int dmz_resume_metadata(struct dmz_metadata *zmd); int dmz_resume_metadata(struct dmz_metadata *zmd);
...@@ -174,6 +175,7 @@ void dmz_unlock_metadata(struct dmz_metadata *zmd); ...@@ -174,6 +175,7 @@ void dmz_unlock_metadata(struct dmz_metadata *zmd);
void dmz_lock_flush(struct dmz_metadata *zmd); void dmz_lock_flush(struct dmz_metadata *zmd);
void dmz_unlock_flush(struct dmz_metadata *zmd); void dmz_unlock_flush(struct dmz_metadata *zmd);
int dmz_flush_metadata(struct dmz_metadata *zmd); int dmz_flush_metadata(struct dmz_metadata *zmd);
const char *dmz_metadata_label(struct dmz_metadata *zmd);
sector_t dmz_start_sect(struct dmz_metadata *zmd, struct dm_zone *zone); sector_t dmz_start_sect(struct dmz_metadata *zmd, struct dm_zone *zone);
sector_t dmz_start_block(struct dmz_metadata *zmd, struct dm_zone *zone); sector_t dmz_start_block(struct dmz_metadata *zmd, struct dm_zone *zone);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment