All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Damien LeMoal <damien.lemoal@wdc.com>, dm-devel@redhat.com
Subject: [PATCH 04/14] dm-zoned: add a 'reserved' zone flag
Date: Fri, 29 May 2020 19:38:57 +0200	[thread overview]
Message-ID: <20200529173907.40529-5-hare@suse.de> (raw)
In-Reply-To: <20200529173907.40529-1-hare@suse.de>

Instead of counting the number of reserved zones in dmz_free_zone()
we should mark the zone as 'reserved' during allocation and simplify
dmz_free_zone().

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/md/dm-zoned-metadata.c | 4 ++--
 drivers/md/dm-zoned.h          | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 043ed882970a..0982ab1758a6 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -1743,6 +1743,7 @@ static int dmz_load_mapping(struct dmz_metadata *zmd)
 			atomic_inc(&zmd->unmap_nr_rnd);
 		} else if (atomic_read(&zmd->nr_reserved_seq_zones) < zmd->nr_reserved_seq) {
 			list_add_tail(&dzone->link, &zmd->reserved_seq_zones_list);
+			set_bit(DMZ_RESERVED, &dzone->flags);
 			atomic_inc(&zmd->nr_reserved_seq_zones);
 			zmd->nr_seq--;
 		} else {
@@ -2168,8 +2169,7 @@ void dmz_free_zone(struct dmz_metadata *zmd, struct dm_zone *zone)
 	} else if (dmz_is_rnd(zone)) {
 		list_add_tail(&zone->link, &zmd->unmap_rnd_list);
 		atomic_inc(&zmd->unmap_nr_rnd);
-	} else if (atomic_read(&zmd->nr_reserved_seq_zones) <
-		   zmd->nr_reserved_seq) {
+	} else if (dmz_is_reserved(zone)) {
 		list_add_tail(&zone->link, &zmd->reserved_seq_zones_list);
 		atomic_inc(&zmd->nr_reserved_seq_zones);
 	} else {
diff --git a/drivers/md/dm-zoned.h b/drivers/md/dm-zoned.h
index 8083607b9535..3451b5a768b4 100644
--- a/drivers/md/dm-zoned.h
+++ b/drivers/md/dm-zoned.h
@@ -123,6 +123,7 @@ enum {
 	DMZ_META,
 	DMZ_DATA,
 	DMZ_BUF,
+	DMZ_RESERVED,
 
 	/* Zone internal state */
 	DMZ_RECLAIM,
@@ -140,6 +141,7 @@ enum {
 #define dmz_is_offline(z)	test_bit(DMZ_OFFLINE, &(z)->flags)
 #define dmz_is_readonly(z)	test_bit(DMZ_READ_ONLY, &(z)->flags)
 #define dmz_in_reclaim(z)	test_bit(DMZ_RECLAIM, &(z)->flags)
+#define dmz_is_reserved(z)	test_bit(DMZ_RESERVED, &(z)->flags)
 #define dmz_seq_write_err(z)	test_bit(DMZ_SEQ_WRITE_ERR, &(z)->flags)
 #define dmz_reclaim_should_terminate(z) \
 				test_bit(DMZ_RECLAIM_TERMINATE, &(z)->flags)
-- 
2.16.4

  parent reply	other threads:[~2020-05-29 17:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 17:38 [PATCHv3 00/14] dm-zoned: multiple drive support Hannes Reinecke
2020-05-29 17:38 ` [PATCH 01/14] dm-zoned: add debugging message for reading superblocks Hannes Reinecke
2020-05-29 17:38 ` [PATCH 02/14] dm-zoned: secondary superblock must reside on the same devices than primary superblock Hannes Reinecke
2020-05-29 17:38 ` [PATCH 03/14] dm-zoned: improve logging messages for reclaim Hannes Reinecke
2020-05-29 17:38 ` Hannes Reinecke [this message]
2020-05-29 17:38 ` [PATCH 05/14] dm-zoned: convert to xarray Hannes Reinecke
2020-05-29 17:38 ` [PATCH 06/14] dm-zoned: temporary superblock for tertiary devices Hannes Reinecke
2020-05-31  8:58   ` Damien Le Moal
2020-05-29 17:39 ` [PATCH 07/14] dm-zoned: add device pointer to struct dm_zone Hannes Reinecke
2020-05-29 17:39 ` [PATCH 08/14] dm-zoned: add metadata pointer to struct dmz_dev Hannes Reinecke
2020-05-29 17:39 ` [PATCH 09/14] dm-zoned: per-device reclaim Hannes Reinecke
2020-05-31  9:19   ` Damien Le Moal
2020-05-29 17:39 ` [PATCH 10/14] dm-zoned: move random and sequential zones into struct dmz_dev Hannes Reinecke
2020-05-31  9:06   ` Damien Le Moal
2020-05-29 17:39 ` [PATCH 11/14] dm-zoned: support arbitrary number of devices Hannes Reinecke
2020-05-31  9:10   ` Damien Le Moal
2020-05-31 13:06     ` Hannes Reinecke
2020-05-31 23:54       ` Damien Le Moal
2020-06-02  6:42         ` Hannes Reinecke
2020-05-29 17:39 ` [PATCH 12/14] dm-zoned: allocate zone by device index Hannes Reinecke
2020-05-31  9:12   ` Damien Le Moal
2020-05-29 17:39 ` [PATCH 13/14] dm-zoned: select reclaim zone based on " Hannes Reinecke
2020-05-29 17:39 ` [PATCH 14/14] dm-zoned: prefer full zones for reclaim Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200529173907.40529-5-hare@suse.de \
    --to=hare@suse.de \
    --cc=damien.lemoal@wdc.com \
    --cc=dm-devel@redhat.com \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.