dm writecache: have ssd writeback wait if the kcopyd workqueue is busy
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 15 Jun 2021 18:17:35 +0000 (14:17 -0400)
committerMike Snitzer <snitzer@redhat.com>
Tue, 15 Jun 2021 19:42:03 +0000 (15:42 -0400)
Make dm-writecache wait if the kcopyd workqueue is busy (as will
happen if waiting for page allocation or inside submit_bio).

This change improves performance of "mkfs.ext2" by approximately 20%
on one testbed.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-kcopyd.c
drivers/md/dm-writecache.c
include/linux/dm-kcopyd.h

index e50625ce74ec5df03433ce9422145159af591612..37b03ab7e5c9e6df7eadf762af8dbcadb260d114 100644 (file)
@@ -980,3 +980,9 @@ void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc)
        kfree(kc);
 }
 EXPORT_SYMBOL(dm_kcopyd_client_destroy);
+
+void dm_kcopyd_client_flush(struct dm_kcopyd_client *kc)
+{
+       flush_workqueue(kc->kcopyd_wq);
+}
+EXPORT_SYMBOL(dm_kcopyd_client_flush);
index 56179a21db0eaf5f975a49e79bdc186501def86c..28bb6890fcf438fae9d61f335fde665b6701222d 100644 (file)
@@ -1812,6 +1812,11 @@ static void writecache_writeback(struct work_struct *work)
        struct writeback_list wbl;
        unsigned long n_walked;
 
+       if (!WC_MODE_PMEM(wc)) {
+               /* Wait for any active kcopyd work on behalf of ssd writeback */
+               dm_kcopyd_client_flush(wc->dm_kcopyd);
+       }
+
        wc_lock(wc);
 restart:
        if (writecache_has_error(wc)) {
index e42de7750c884ec6f7c56e250db963bbc154d9f9..c1707ee5b540894c566017ed4abfc0a942f6f9b2 100644 (file)
@@ -51,6 +51,7 @@ MODULE_PARM_DESC(name, description)
 struct dm_kcopyd_client;
 struct dm_kcopyd_client *dm_kcopyd_client_create(struct dm_kcopyd_throttle *throttle);
 void dm_kcopyd_client_destroy(struct dm_kcopyd_client *kc);
+void dm_kcopyd_client_flush(struct dm_kcopyd_client *kc);
 
 /*
  * Submit a copy job to kcopyd.  This is built on top of the