Skip to content

Commit 611c3e1

Browse files
Mikulas Patockasnitm
authored andcommitted
dm writecache: add optional "metadata_only" parameter
Add a "metadata_only" parameter that when present: only metadata is promoted to the cache. This option improves performance for heavier REQ_META workloads (e.g. device-mapper-test-suite's "git clone and checkout" benchmark improves from 341s to 312s). Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent cd039af commit 611c3e1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Documentation/admin-guide/device-mapper/writecache.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ Constructor parameters:
6868
specifies the maximum age of a block in milliseconds. If
6969
a block is stored in the cache for too long, it will be
7070
written to the underlying device and cleaned up.
71+
metadata_only
72+
only metadata is promoted to the cache. This option
73+
improves performance for heavier REQ_META workloads.
7174

7275
Status:
7376
1. error indicator - 0 if there was no error, otherwise error number

drivers/md/dm-writecache.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ struct dm_writecache {
171171
bool flush_on_suspend:1;
172172
bool cleaner:1;
173173
bool cleaner_set:1;
174+
bool metadata_only:1;
174175

175176
unsigned high_wm_percent_value;
176177
unsigned low_wm_percent_value;
@@ -1301,7 +1302,7 @@ static int writecache_map(struct dm_target *ti, struct bio *bio)
13011302
writecache_flush(wc);
13021303
if (writecache_has_error(wc))
13031304
goto unlock_error;
1304-
if (unlikely(wc->cleaner))
1305+
if (unlikely(wc->cleaner) || unlikely(wc->metadata_only))
13051306
goto unlock_remap_origin;
13061307
goto unlock_submit;
13071308
} else {
@@ -1380,7 +1381,8 @@ static int writecache_map(struct dm_target *ti, struct bio *bio)
13801381
}
13811382
found_entry = true;
13821383
} else {
1383-
if (unlikely(wc->cleaner))
1384+
if (unlikely(wc->cleaner) ||
1385+
(wc->metadata_only && !(bio->bi_opf & REQ_META)))
13841386
goto direct_write;
13851387
}
13861388
e = writecache_pop_from_freelist(wc, (sector_t)-1);
@@ -2094,7 +2096,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
20942096
struct wc_memory_superblock s;
20952097

20962098
static struct dm_arg _args[] = {
2097-
{0, 16, "Invalid number of feature args"},
2099+
{0, 17, "Invalid number of feature args"},
20982100
};
20992101

21002102
as.argc = argc;
@@ -2321,6 +2323,8 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
23212323
wc->writeback_fua = false;
23222324
wc->writeback_fua_set = true;
23232325
} else goto invalid_optional;
2326+
} else if (!strcasecmp(string, "metadata_only")) {
2327+
wc->metadata_only = true;
23242328
} else {
23252329
invalid_optional:
23262330
r = -EINVAL;
@@ -2544,6 +2548,8 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
25442548
extra_args++;
25452549
if (wc->writeback_fua_set)
25462550
extra_args++;
2551+
if (wc->metadata_only)
2552+
extra_args++;
25472553

25482554
DMEMIT("%u", extra_args);
25492555
if (wc->start_sector_set)
@@ -2564,13 +2570,15 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
25642570
DMEMIT(" cleaner");
25652571
if (wc->writeback_fua_set)
25662572
DMEMIT(" %sfua", wc->writeback_fua ? "" : "no");
2573+
if (wc->metadata_only)
2574+
DMEMIT(" metadata_only");
25672575
break;
25682576
}
25692577
}
25702578

25712579
static struct target_type writecache_target = {
25722580
.name = "writecache",
2573-
.version = {1, 4, 0},
2581+
.version = {1, 5, 0},
25742582
.module = THIS_MODULE,
25752583
.ctr = writecache_ctr,
25762584
.dtr = writecache_dtr,

0 commit comments

Comments
 (0)