Commit 18979819 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Mike Snitzer

dm zoned: add metadata pointer to struct dmz_dev

Add a metadata pointer within struct dmz_dev and use it as argument
for blkdev_report_zones() instead of the metadata itself.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 8f22272a
...@@ -1371,8 +1371,8 @@ static int dmz_load_sb(struct dmz_metadata *zmd) ...@@ -1371,8 +1371,8 @@ static int dmz_load_sb(struct dmz_metadata *zmd)
*/ */
static int dmz_init_zone(struct blk_zone *blkz, unsigned int num, void *data) static int dmz_init_zone(struct blk_zone *blkz, unsigned int num, void *data)
{ {
struct dmz_metadata *zmd = data; struct dmz_dev *dev = data;
struct dmz_dev *dev = zmd->nr_devs > 1 ? &zmd->dev[1] : &zmd->dev[0]; struct dmz_metadata *zmd = dev->metadata;
int idx = num + dev->zone_offset; int idx = num + dev->zone_offset;
struct dm_zone *zone; struct dm_zone *zone;
...@@ -1495,8 +1495,12 @@ static int dmz_init_zones(struct dmz_metadata *zmd) ...@@ -1495,8 +1495,12 @@ static int dmz_init_zones(struct dmz_metadata *zmd)
/* Allocate zone array */ /* Allocate zone array */
zmd->nr_zones = 0; zmd->nr_zones = 0;
for (i = 0; i < zmd->nr_devs; i++) for (i = 0; i < zmd->nr_devs; i++) {
zmd->nr_zones += zmd->dev[i].nr_zones; struct dmz_dev *dev = &zmd->dev[i];
dev->metadata = zmd;
zmd->nr_zones += dev->nr_zones;
}
if (!zmd->nr_zones) { if (!zmd->nr_zones) {
DMERR("(%s): No zones found", zmd->devname); DMERR("(%s): No zones found", zmd->devname);
...@@ -1531,7 +1535,7 @@ static int dmz_init_zones(struct dmz_metadata *zmd) ...@@ -1531,7 +1535,7 @@ static int dmz_init_zones(struct dmz_metadata *zmd)
* first randomly writable zone. * first randomly writable zone.
*/ */
ret = blkdev_report_zones(zoned_dev->bdev, 0, BLK_ALL_ZONES, ret = blkdev_report_zones(zoned_dev->bdev, 0, BLK_ALL_ZONES,
dmz_init_zone, zmd); dmz_init_zone, zoned_dev);
if (ret < 0) { if (ret < 0) {
DMDEBUG("(%s): Failed to report zones, error %d", DMDEBUG("(%s): Failed to report zones, error %d",
zmd->devname, ret); zmd->devname, ret);
......
...@@ -45,11 +45,15 @@ ...@@ -45,11 +45,15 @@
#define dmz_bio_block(bio) dmz_sect2blk((bio)->bi_iter.bi_sector) #define dmz_bio_block(bio) dmz_sect2blk((bio)->bi_iter.bi_sector)
#define dmz_bio_blocks(bio) dmz_sect2blk(bio_sectors(bio)) #define dmz_bio_blocks(bio) dmz_sect2blk(bio_sectors(bio))
struct dmz_metadata;
struct dmz_reclaim;
/* /*
* Zoned block device information. * Zoned block device information.
*/ */
struct dmz_dev { struct dmz_dev {
struct block_device *bdev; struct block_device *bdev;
struct dmz_metadata *metadata;
char name[BDEVNAME_SIZE]; char name[BDEVNAME_SIZE];
uuid_t uuid; uuid_t uuid;
...@@ -170,9 +174,6 @@ enum { ...@@ -170,9 +174,6 @@ enum {
#define dmz_dev_debug(dev, format, args...) \ #define dmz_dev_debug(dev, format, args...) \
DMDEBUG("(%s): " format, (dev)->name, ## args) DMDEBUG("(%s): " format, (dev)->name, ## args)
struct dmz_metadata;
struct dmz_reclaim;
/* /*
* Functions defined in dm-zoned-metadata.c * Functions defined in dm-zoned-metadata.c
*/ */
......
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