dm zoned: terminate reclaim on congestion
authorHannes Reinecke <hare@suse.de>
Tue, 19 May 2020 08:14:23 +0000 (10:14 +0200)
committerMike Snitzer <snitzer@redhat.com>
Wed, 20 May 2020 21:09:52 +0000 (17:09 -0400)
When dmz_get_chunk_mapping() selects a zone which is under reclaim
we should terminate the reclaim copy process. Since we're changing
the zone itself, reclaim needs to run afterwards again anyway.

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-reclaim.c
drivers/md/dm-zoned.h

index b5fd67eff04623730414532fca75f813a28e2de6..db0dc2b5d44dcc00dc9c35e40dc5b61fe1de7412 100644 (file)
@@ -1851,7 +1851,9 @@ static void dmz_wait_for_reclaim(struct dmz_metadata *zmd, struct dm_zone *zone)
 {
        dmz_unlock_map(zmd);
        dmz_unlock_metadata(zmd);
+       set_bit(DMZ_RECLAIM_TERMINATE, &zone->flags);
        wait_on_bit_timeout(&zone->flags, DMZ_RECLAIM, TASK_UNINTERRUPTIBLE, HZ);
+       clear_bit(DMZ_RECLAIM_TERMINATE, &zone->flags);
        dmz_lock_metadata(zmd);
        dmz_lock_map(zmd);
 }
index d62f6890b92cd797b6a8941bf326f1b55ed8725c..571bc1d41baba65c467bb98efb9cdf00f426229e 100644 (file)
@@ -143,6 +143,9 @@ static int dmz_reclaim_copy(struct dmz_reclaim *zrc,
                if (dst_dev->flags & DMZ_BDEV_DYING)
                        return -EIO;
 
+               if (dmz_reclaim_should_terminate(src_zone))
+                       return -EINTR;
+
                /* Get a valid region from the source zone */
                ret = dmz_first_valid_block(zmd, src_zone, &block);
                if (ret <= 0)
@@ -515,7 +518,7 @@ static void dmz_reclaim_work(struct work_struct *work)
                dmz_nr_rnd_zones(zmd));
 
        ret = dmz_do_reclaim(zrc);
-       if (ret) {
+       if (ret && ret != -EINTR) {
                DMDEBUG("(%s): Reclaim error %d",
                        dmz_metadata_label(zmd), ret);
                if (!dmz_check_dev(zmd))
@@ -615,4 +618,3 @@ void dmz_schedule_reclaim(struct dmz_reclaim *zrc)
        if (dmz_should_reclaim(zrc, p_unmap))
                mod_delayed_work(zrc->wq, &zrc->work, 0);
 }
-
index 288054dd7cf421804b7ceaf3d5d1813a52efffca..8083607b95352c6229ebcfbbd71abe7903142120 100644 (file)
@@ -127,6 +127,7 @@ enum {
        /* Zone internal state */
        DMZ_RECLAIM,
        DMZ_SEQ_WRITE_ERR,
+       DMZ_RECLAIM_TERMINATE,
 };
 
 /*
@@ -140,6 +141,8 @@ enum {
 #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_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)
 
 #define dmz_is_meta(z)         test_bit(DMZ_META, &(z)->flags)
 #define dmz_is_buf(z)          test_bit(DMZ_BUF, &(z)->flags)