Commit 6c805f77 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Mike Snitzer

dm zoned: remove 'dev' argument from reclaim

Use the dmz_zone_to_dev() mapping function to remove the
'dev' argument from reclaim.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarBob Liu <bob.liu@oracle.com>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent d0e21ce4
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
struct dmz_reclaim { struct dmz_reclaim {
struct dmz_metadata *metadata; struct dmz_metadata *metadata;
struct dmz_dev *dev;
struct delayed_work work; struct delayed_work work;
struct workqueue_struct *wq; struct workqueue_struct *wq;
...@@ -59,6 +58,7 @@ static int dmz_reclaim_align_wp(struct dmz_reclaim *zrc, struct dm_zone *zone, ...@@ -59,6 +58,7 @@ static int dmz_reclaim_align_wp(struct dmz_reclaim *zrc, struct dm_zone *zone,
sector_t block) sector_t block)
{ {
struct dmz_metadata *zmd = zrc->metadata; struct dmz_metadata *zmd = zrc->metadata;
struct dmz_dev *dev = dmz_zone_to_dev(zmd, zone);
sector_t wp_block = zone->wp_block; sector_t wp_block = zone->wp_block;
unsigned int nr_blocks; unsigned int nr_blocks;
int ret; int ret;
...@@ -74,15 +74,15 @@ static int dmz_reclaim_align_wp(struct dmz_reclaim *zrc, struct dm_zone *zone, ...@@ -74,15 +74,15 @@ static int dmz_reclaim_align_wp(struct dmz_reclaim *zrc, struct dm_zone *zone,
* pointer and the requested position. * pointer and the requested position.
*/ */
nr_blocks = block - wp_block; nr_blocks = block - wp_block;
ret = blkdev_issue_zeroout(zrc->dev->bdev, ret = blkdev_issue_zeroout(dev->bdev,
dmz_start_sect(zmd, zone) + dmz_blk2sect(wp_block), dmz_start_sect(zmd, zone) + dmz_blk2sect(wp_block),
dmz_blk2sect(nr_blocks), GFP_NOIO, 0); dmz_blk2sect(nr_blocks), GFP_NOIO, 0);
if (ret) { if (ret) {
dmz_dev_err(zrc->dev, dmz_dev_err(dev,
"Align zone %u wp %llu to %llu (wp+%u) blocks failed %d", "Align zone %u wp %llu to %llu (wp+%u) blocks failed %d",
zone->id, (unsigned long long)wp_block, zone->id, (unsigned long long)wp_block,
(unsigned long long)block, nr_blocks, ret); (unsigned long long)block, nr_blocks, ret);
dmz_check_bdev(zrc->dev); dmz_check_bdev(dev);
return ret; return ret;
} }
...@@ -116,7 +116,7 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc, ...@@ -116,7 +116,7 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc,
struct dm_zone *src_zone, struct dm_zone *dst_zone) struct dm_zone *src_zone, struct dm_zone *dst_zone)
{ {
struct dmz_metadata *zmd = zrc->metadata; struct dmz_metadata *zmd = zrc->metadata;
struct dmz_dev *dev = zrc->dev; struct dmz_dev *src_dev, *dst_dev;
struct dm_io_region src, dst; struct dm_io_region src, dst;
sector_t block = 0, end_block; sector_t block = 0, end_block;
sector_t nr_blocks; sector_t nr_blocks;
...@@ -130,13 +130,17 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc, ...@@ -130,13 +130,17 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc,
else else
end_block = dmz_zone_nr_blocks(zmd); end_block = dmz_zone_nr_blocks(zmd);
src_zone_block = dmz_start_block(zmd, src_zone); src_zone_block = dmz_start_block(zmd, src_zone);
src_dev = dmz_zone_to_dev(zmd, src_zone);
dst_zone_block = dmz_start_block(zmd, dst_zone); dst_zone_block = dmz_start_block(zmd, dst_zone);
dst_dev = dmz_zone_to_dev(zmd, dst_zone);
if (dmz_is_seq(dst_zone)) if (dmz_is_seq(dst_zone))
set_bit(DM_KCOPYD_WRITE_SEQ, &flags); set_bit(DM_KCOPYD_WRITE_SEQ, &flags);
while (block < end_block) { while (block < end_block) {
if (dev->flags & DMZ_BDEV_DYING) if (src_dev->flags & DMZ_BDEV_DYING)
return -EIO;
if (dst_dev->flags & DMZ_BDEV_DYING)
return -EIO; return -EIO;
/* Get a valid region from the source zone */ /* Get a valid region from the source zone */
...@@ -156,11 +160,11 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc, ...@@ -156,11 +160,11 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc,
return ret; return ret;
} }
src.bdev = dev->bdev; src.bdev = src_dev->bdev;
src.sector = dmz_blk2sect(src_zone_block + block); src.sector = dmz_blk2sect(src_zone_block + block);
src.count = dmz_blk2sect(nr_blocks); src.count = dmz_blk2sect(nr_blocks);
dst.bdev = dev->bdev; dst.bdev = dst_dev->bdev;
dst.sector = dmz_blk2sect(dst_zone_block + block); dst.sector = dmz_blk2sect(dst_zone_block + block);
dst.count = src.count; dst.count = src.count;
...@@ -194,8 +198,8 @@ static int dmz_reclaim_buf(struct dmz_reclaim *zrc, struct dm_zone *dzone) ...@@ -194,8 +198,8 @@ static int dmz_reclaim_buf(struct dmz_reclaim *zrc, struct dm_zone *dzone)
struct dmz_metadata *zmd = zrc->metadata; struct dmz_metadata *zmd = zrc->metadata;
int ret; int ret;
dmz_dev_debug(zrc->dev, DMDEBUG("(%s): Chunk %u, move buf zone %u (weight %u) to data zone %u (weight %u)",
"Chunk %u, move buf zone %u (weight %u) to data zone %u (weight %u)", dmz_metadata_label(zmd),
dzone->chunk, bzone->id, dmz_weight(bzone), dzone->chunk, bzone->id, dmz_weight(bzone),
dzone->id, dmz_weight(dzone)); dzone->id, dmz_weight(dzone));
...@@ -233,8 +237,8 @@ static int dmz_reclaim_seq_data(struct dmz_reclaim *zrc, struct dm_zone *dzone) ...@@ -233,8 +237,8 @@ static int dmz_reclaim_seq_data(struct dmz_reclaim *zrc, struct dm_zone *dzone)
struct dmz_metadata *zmd = zrc->metadata; struct dmz_metadata *zmd = zrc->metadata;
int ret = 0; int ret = 0;
dmz_dev_debug(zrc->dev, DMDEBUG("(%s): Chunk %u, move data zone %u (weight %u) to buf zone %u (weight %u)",
"Chunk %u, move data zone %u (weight %u) to buf zone %u (weight %u)", dmz_metadata_label(zmd),
chunk, dzone->id, dmz_weight(dzone), chunk, dzone->id, dmz_weight(dzone),
bzone->id, dmz_weight(bzone)); bzone->id, dmz_weight(bzone));
...@@ -285,8 +289,8 @@ static int dmz_reclaim_rnd_data(struct dmz_reclaim *zrc, struct dm_zone *dzone) ...@@ -285,8 +289,8 @@ static int dmz_reclaim_rnd_data(struct dmz_reclaim *zrc, struct dm_zone *dzone)
if (!szone) if (!szone)
return -ENOSPC; return -ENOSPC;
dmz_dev_debug(zrc->dev, DMDEBUG("(%s): Chunk %u, move rnd zone %u (weight %u) to seq zone %u",
"Chunk %u, move rnd zone %u (weight %u) to seq zone %u", dmz_metadata_label(zmd),
chunk, dzone->id, dmz_weight(dzone), szone->id); chunk, dzone->id, dmz_weight(dzone), szone->id);
/* Flush the random data zone into the sequential zone */ /* Flush the random data zone into the sequential zone */
...@@ -352,7 +356,6 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc) ...@@ -352,7 +356,6 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)
return PTR_ERR(dzone); return PTR_ERR(dzone);
start = jiffies; start = jiffies;
if (dmz_is_rnd(dzone)) { if (dmz_is_rnd(dzone)) {
if (!dmz_weight(dzone)) { if (!dmz_weight(dzone)) {
/* Empty zone */ /* Empty zone */
...@@ -400,13 +403,13 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc) ...@@ -400,13 +403,13 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)
ret = dmz_flush_metadata(zrc->metadata); ret = dmz_flush_metadata(zrc->metadata);
if (ret) { if (ret) {
dmz_dev_debug(zrc->dev, DMDEBUG("(%s): Metadata flush for zone %u failed, err %d\n",
"Metadata flush for zone %u failed, err %d\n", dmz_metadata_label(zmd), rzone->id, ret);
rzone->id, ret);
return ret; return ret;
} }
dmz_dev_debug(zrc->dev, "Reclaimed zone %u in %u ms", DMDEBUG("(%s): Reclaimed zone %u in %u ms",
dmz_metadata_label(zmd),
rzone->id, jiffies_to_msecs(jiffies - start)); rzone->id, jiffies_to_msecs(jiffies - start));
return 0; return 0;
} }
...@@ -500,7 +503,7 @@ static void dmz_reclaim_work(struct work_struct *work) ...@@ -500,7 +503,7 @@ static void dmz_reclaim_work(struct work_struct *work)
/* /*
* Initialize reclaim. * Initialize reclaim.
*/ */
int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd, int dmz_ctr_reclaim(struct dmz_metadata *zmd,
struct dmz_reclaim **reclaim) struct dmz_reclaim **reclaim)
{ {
struct dmz_reclaim *zrc; struct dmz_reclaim *zrc;
...@@ -510,7 +513,6 @@ int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd, ...@@ -510,7 +513,6 @@ int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd,
if (!zrc) if (!zrc)
return -ENOMEM; return -ENOMEM;
zrc->dev = dev;
zrc->metadata = zmd; zrc->metadata = zmd;
zrc->atime = jiffies; zrc->atime = jiffies;
......
...@@ -840,7 +840,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -840,7 +840,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
mod_delayed_work(dmz->flush_wq, &dmz->flush_work, DMZ_FLUSH_PERIOD); mod_delayed_work(dmz->flush_wq, &dmz->flush_work, DMZ_FLUSH_PERIOD);
/* Initialize reclaim */ /* Initialize reclaim */
ret = dmz_ctr_reclaim(dev, dmz->metadata, &dmz->reclaim); ret = dmz_ctr_reclaim(dmz->metadata, &dmz->reclaim);
if (ret) { if (ret) {
ti->error = "Zone reclaim initialization failed"; ti->error = "Zone reclaim initialization failed";
goto err_fwq; goto err_fwq;
......
...@@ -180,6 +180,7 @@ const char *dmz_metadata_label(struct dmz_metadata *zmd); ...@@ -180,6 +180,7 @@ 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);
unsigned int dmz_nr_chunks(struct dmz_metadata *zmd); unsigned int dmz_nr_chunks(struct dmz_metadata *zmd);
struct dmz_dev *dmz_zone_to_dev(struct dmz_metadata *zmd, struct dm_zone *zone);
bool dmz_check_dev(struct dmz_metadata *zmd); bool dmz_check_dev(struct dmz_metadata *zmd);
bool dmz_dev_is_dying(struct dmz_metadata *zmd); bool dmz_dev_is_dying(struct dmz_metadata *zmd);
...@@ -254,8 +255,7 @@ int dmz_merge_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone, ...@@ -254,8 +255,7 @@ int dmz_merge_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone,
/* /*
* Functions defined in dm-zoned-reclaim.c * Functions defined in dm-zoned-reclaim.c
*/ */
int dmz_ctr_reclaim(struct dmz_dev *dev, struct dmz_metadata *zmd, int dmz_ctr_reclaim(struct dmz_metadata *zmd, struct dmz_reclaim **zrc);
struct dmz_reclaim **zrc);
void dmz_dtr_reclaim(struct dmz_reclaim *zrc); void dmz_dtr_reclaim(struct dmz_reclaim *zrc);
void dmz_suspend_reclaim(struct dmz_reclaim *zrc); void dmz_suspend_reclaim(struct dmz_reclaim *zrc);
void dmz_resume_reclaim(struct dmz_reclaim *zrc); void dmz_resume_reclaim(struct dmz_reclaim *zrc);
......
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