[dm-devel] [PATCH] dm-writecache: use early kcopyd callback

Mikulas Patocka mpatocka at redhat.com
Wed May 26 16:15:50 UTC 2021


Hi

You can add this to the kernel that will be used for testing writecache.

Another suggestion is to try to use the dm table argument "writeback_jobs" 
- for example:
dmsetup create wc --table "0 `blockdev --getsize /dev/vdb` writecache s /dev/vdb /dev/vdc 4096 2 writeback_jobs 65536"

It limits the number of work that is submitted to kcopyd and it may 
improve latency.

Mikulas


Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c
+++ linux-2.6/drivers/md/dm-writecache.c
@@ -1538,14 +1538,15 @@ static void writecache_copy_endio(int re
 {
 	struct copy_struct *c = ptr;
 	struct dm_writecache *wc = c->wc;
+	unsigned long flags;
 
 	c->error = likely(!(read_err | write_err)) ? 0 : -EIO;
 
-	raw_spin_lock_irq(&wc->endio_list_lock);
+	raw_spin_lock_irqsave(&wc->endio_list_lock, flags);
 	if (unlikely(list_empty(&wc->endio_list)))
 		wake_up_process(wc->endio_thread);
 	list_add_tail(&c->endio_entry, &wc->endio_list);
-	raw_spin_unlock_irq(&wc->endio_list_lock);
+	raw_spin_unlock_irqrestore(&wc->endio_list_lock, flags);
 }
 
 static void __writecache_endio_pmem(struct dm_writecache *wc, struct list_head *list)
@@ -1799,7 +1800,7 @@ static void __writecache_writeback_ssd(s
 			from.count = to.count = wc->data_device_sectors - to.sector;
 		}
 
-		dm_kcopyd_copy(wc->dm_kcopyd, &from, 1, &to, 0, writecache_copy_endio, c);
+		dm_kcopyd_copy(wc->dm_kcopyd, &from, 1, &to, BIT(DM_KCOPYD_EARLY_CALLBACK), writecache_copy_endio, c);
 
 		__writeback_throttle(wc, wbl);
 	}




More information about the dm-devel mailing list