]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dm zoned: add a 'reserved' zone flag
authorHannes Reinecke <hare@suse.de>
Tue, 2 Jun 2020 11:09:45 +0000 (13:09 +0200)
committerMike Snitzer <snitzer@redhat.com>
Fri, 5 Jun 2020 18:59:46 +0000 (14:59 -0400)
Instead of counting the number of reserved zones in dmz_free_zone(),
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>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-zoned-metadata.c
drivers/md/dm-zoned.h

index 043ed882970a9f912de553a7ad4d0ccd5b78337d..0982ab1758a6511fae71ee063ac10491999e140d 100644 (file)
@@ -1743,6 +1743,7 @@ next:
                        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 {
index 8083607b95352c6229ebcfbbd71abe7903142120..3451b5a768b421b2f7d0318000de57371960cbae 100644 (file)
@@ -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)