aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-12 21:12:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-12 21:12:08 -0400
commit4597fcff07044d89c646d0c5d8b42cd976d966a1 (patch)
treeace9a18c624e6ede7229d495aa5bad393daded92
parenta205f0c974db78c6a1a8ce31cd4c0b45ac45ea40 (diff)
parent48debafe4f2feabcc99f8e2659e80557e3ca6b39 (diff)
Merge tag 'for-4.18/dm-changes-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper updates from Mike Snitzer: - Adjust various DM structure members to improve alignment relative to 4.18 block's mempool_t and bioset changes. - Add DM writecache target that offers writeback caching to persistent memory or SSD. - Small DM core error message change to give context for why a DM table type transition wasn't allowed. * tag 'for-4.18/dm-changes-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm: add writecache target dm: adjust structure members to improve alignment dm: report which conflicting type caused error during table_load()
-rw-r--r--Documentation/device-mapper/writecache.txt68
-rw-r--r--drivers/md/Kconfig11
-rw-r--r--drivers/md/Makefile1
-rw-r--r--drivers/md/dm-bio-prison-v1.c2
-rw-r--r--drivers/md/dm-bio-prison-v2.c2
-rw-r--r--drivers/md/dm-cache-target.c61
-rw-r--r--drivers/md/dm-core.h38
-rw-r--r--drivers/md/dm-crypt.c26
-rw-r--r--drivers/md/dm-ioctl.c3
-rw-r--r--drivers/md/dm-kcopyd.c3
-rw-r--r--drivers/md/dm-region-hash.c13
-rw-r--r--drivers/md/dm-thin.c5
-rw-r--r--drivers/md/dm-writecache.c2305
-rw-r--r--drivers/md/dm-zoned-target.c2
14 files changed, 2466 insertions, 74 deletions
diff --git a/Documentation/device-mapper/writecache.txt b/Documentation/device-mapper/writecache.txt
new file mode 100644
index 000000000000..4424fa2c67d7
--- /dev/null
+++ b/Documentation/device-mapper/writecache.txt
@@ -0,0 +1,68 @@
1The writecache target caches writes on persistent memory or on SSD. It
2doesn't cache reads because reads are supposed to be cached in page cache
3in normal RAM.
4
5When the device is constructed, the first sector should be zeroed or the
6first sector should contain valid superblock from previous invocation.
7
8Constructor parameters:
91. type of the cache device - "p" or "s"
10 p - persistent memory
11 s - SSD
122. the underlying device that will be cached
133. the cache device
144. block size (4096 is recommended; the maximum block size is the page
15 size)
165. the number of optional parameters (the parameters with an argument
17 count as two)
18 high_watermark n (default: 50)
19 start writeback when the number of used blocks reach this
20 watermark
21 low_watermark x (default: 45)
22 stop writeback when the number of used blocks drops below
23 this watermark
24 writeback_jobs n (default: unlimited)
25 limit the number of blocks that are in flight during
26 writeback. Setting this value reduces writeback
27 throughput, but it may improve latency of read requests
28 autocommit_blocks n (default: 64 for pmem, 65536 for ssd)
29 when the application writes this amount of blocks without
30 issuing the FLUSH request, the blocks are automatically
31 commited
32 autocommit_time ms (default: 1000)
33 autocommit time in milliseconds. The data is automatically
34 commited if this time passes and no FLUSH request is
35 received
36 fua (by default on)
37 applicable only to persistent memory - use the FUA flag
38 when writing data from persistent memory back to the
39 underlying device
40 nofua
41 applicable only to persistent memory - don't use the FUA
42 flag when writing back data and send the FLUSH request
43 afterwards
44 - some underlying devices perform better with fua, some
45 with nofua. The user should test it
46
47Status:
481. error indicator - 0 if there was no error, otherwise error number
492. the number of blocks
503. the number of free blocks
514. the number of blocks under writeback
52
53Messages:
54 flush
55 flush the cache device. The message returns successfully
56 if the cache device was flushed without an error
57 flush_on_suspend
58 flush the cache device on next suspend. Use this message
59 when you are going to remove the cache device. The proper
60 sequence for removing the cache device is:
61 1. send the "flush_on_suspend" message
62 2. load an inactive table with a linear target that maps
63 to the underlying device
64 3. suspend the device
65 4. ask for status and verify that there are no errors
66 5. resume the device, so that it will use the linear
67 target
68 6. the cache device is now inactive and it can be deleted
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index edff083f7c4e..8b8c123cae66 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -334,6 +334,17 @@ config DM_CACHE_SMQ
334 of less memory utilization, improved performance and increased 334 of less memory utilization, improved performance and increased
335 adaptability in the face of changing workloads. 335 adaptability in the face of changing workloads.
336 336
337config DM_WRITECACHE
338 tristate "Writecache target"
339 depends on BLK_DEV_DM
340 ---help---
341 The writecache target caches writes on persistent memory or SSD.
342 It is intended for databases or other programs that need extremely
343 low commit latency.
344
345 The writecache target doesn't cache reads because reads are supposed
346 to be cached in standard RAM.
347
337config DM_ERA 348config DM_ERA
338 tristate "Era target (EXPERIMENTAL)" 349 tristate "Era target (EXPERIMENTAL)"
339 depends on BLK_DEV_DM 350 depends on BLK_DEV_DM
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index 63255f3ebd97..822f4e8753bc 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_DM_ERA) += dm-era.o
67obj-$(CONFIG_DM_LOG_WRITES) += dm-log-writes.o 67obj-$(CONFIG_DM_LOG_WRITES) += dm-log-writes.o
68obj-$(CONFIG_DM_INTEGRITY) += dm-integrity.o 68obj-$(CONFIG_DM_INTEGRITY) += dm-integrity.o
69obj-$(CONFIG_DM_ZONED) += dm-zoned.o 69obj-$(CONFIG_DM_ZONED) += dm-zoned.o
70obj-$(CONFIG_DM_WRITECACHE) += dm-writecache.o
70 71
71ifeq ($(CONFIG_DM_UEVENT),y) 72ifeq ($(CONFIG_DM_UEVENT),y)
72dm-mod-objs += dm-uevent.o 73dm-mod-objs += dm-uevent.o
diff --git a/drivers/md/dm-bio-prison-v1.c b/drivers/md/dm-bio-prison-v1.c
index e794e3662fdd..b5389890bbc3 100644
--- a/drivers/md/dm-bio-prison-v1.c
+++ b/drivers/md/dm-bio-prison-v1.c
@@ -19,8 +19,8 @@
19 19
20struct dm_bio_prison { 20struct dm_bio_prison {
21 spinlock_t lock; 21 spinlock_t lock;
22 mempool_t cell_pool;
23 struct rb_root cells; 22 struct rb_root cells;
23 mempool_t cell_pool;
24}; 24};
25 25
26static struct kmem_cache *_cell_cache; 26static struct kmem_cache *_cell_cache;
diff --git a/drivers/md/dm-bio-prison-v2.c b/drivers/md/dm-bio-prison-v2.c
index f866bc97b032..b092cdc8e1ae 100644
--- a/drivers/md/dm-bio-prison-v2.c
+++ b/drivers/md/dm-bio-prison-v2.c
@@ -21,8 +21,8 @@ struct dm_bio_prison_v2 {
21 struct workqueue_struct *wq; 21 struct workqueue_struct *wq;
22 22
23 spinlock_t lock; 23 spinlock_t lock;
24 mempool_t cell_pool;
25 struct rb_root cells; 24 struct rb_root cells;
25 mempool_t cell_pool;
26}; 26};
27 27
28static struct kmem_cache *_cell_cache; 28static struct kmem_cache *_cell_cache;
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 001c71248246..ce14a3d1f609 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -371,7 +371,13 @@ struct cache_stats {
371 371
372struct cache { 372struct cache {
373 struct dm_target *ti; 373 struct dm_target *ti;
374 struct dm_target_callbacks callbacks; 374 spinlock_t lock;
375
376 /*
377 * Fields for converting from sectors to blocks.
378 */
379 int sectors_per_block_shift;
380 sector_t sectors_per_block;
375 381
376 struct dm_cache_metadata *cmd; 382 struct dm_cache_metadata *cmd;
377 383
@@ -402,13 +408,11 @@ struct cache {
402 dm_cblock_t cache_size; 408 dm_cblock_t cache_size;
403 409
404 /* 410 /*
405 * Fields for converting from sectors to blocks. 411 * Invalidation fields.
406 */ 412 */
407 sector_t sectors_per_block; 413 spinlock_t invalidation_lock;
408 int sectors_per_block_shift; 414 struct list_head invalidation_requests;
409 415
410 spinlock_t lock;
411 struct bio_list deferred_bios;
412 sector_t migration_threshold; 416 sector_t migration_threshold;
413 wait_queue_head_t migration_wait; 417 wait_queue_head_t migration_wait;
414 atomic_t nr_allocated_migrations; 418 atomic_t nr_allocated_migrations;
@@ -419,13 +423,11 @@ struct cache {
419 */ 423 */
420 atomic_t nr_io_migrations; 424 atomic_t nr_io_migrations;
421 425
426 struct bio_list deferred_bios;