path: root/sbin/mdconfig
diff options
authorBruce Evans <bde@FreeBSD.org>2018-12-21 08:15:31 +0000
committerBruce Evans <bde@FreeBSD.org>2018-12-21 08:15:31 +0000
commit9e5ed8593f6bf24929021e092e2de23e8ed9e7b8 (patch)
tree402402187f33b247002f645cf699e4459e2bf0b8 /sbin/mdconfig
parente6f6d8853ccca2130665d74deee83591cc1f5960 (diff)
implement not double-caching for reads from vnode-backed md devices. Use VOP_ADVISE() similarly instead of !IO_DIRECT unsimilarly for writes. Add a "cache" option to mdconfig to allow changing the default of not caching. This depends on a recent commit to fix VOP_ADVISE(). A previous version had optimizations for sequential i/o's (merge the i/o's and only uncache for discontiguous i/o's and for full blocks), but optimizations and knowledge of block boundaries belong in VOP_ADVISE(). Read-ahead should also be handled better, by supporting it in md and discarding it in VOP_ADVISE(). POSIX_FADV_DONTNEED is ignored by zfs, but so is IO_DIRECT. POSIX_FADV_DONTNEED works better than IO_DIRECT if it is not ignored, since it only discards from the buffer cache immediately, while IO_DIRECT also discards from the page cache immediately. IO_DIRECT was not used for writes since it was claimed to be too slow, but most of the slowness for writes is from doing them synchronously by default. Non-synchronous writes still deadlock in many cases. IO_DIRECT only has a special implementation for ffs reads with DIRECTIO configured. Otherwise, if it is not ignored than it uses the buffer and page caches normally except for discarding everything after each i/o, and then it has much the same overheads as POSIX_FADV_DONTNEED. The overheads for reading with ffs and DIRECTIO were similar in tests of md. Reviewed by: kib
Notes: svn path=/head/; revision=342297
Diffstat (limited to 'sbin/mdconfig')
2 files changed, 32 insertions, 2 deletions
diff --git a/sbin/mdconfig/mdconfig.8 b/sbin/mdconfig/mdconfig.8
index cf05d8f43efb..b91ffb3cb916 100644
--- a/sbin/mdconfig/mdconfig.8
+++ b/sbin/mdconfig/mdconfig.8
@@ -37,7 +37,7 @@
.\" $FreeBSD$
-.Dd August 28, 2017
+.Dd December 21, 2018
@@ -206,6 +206,32 @@ backed devices: avoid
for increased performance but
at the risk of deadlocking the entire kernel.
+.It Oo Cm no Oc Ns Cm cache
+.Cm vnode
+backed devices: enable/disable caching of data in system caches.
+The default is to not cache.
+Accesses via the device are converted to accesses via the vnode.
+The caching policy for the vnode is used initially.
+This is normally to cache.
+This caching policy is retained if the
+.Cm cache
+option is used.
+Otherwise, caching is limited
+by releasing data from caches soon after each access.
+The release has the same semantics as the
+feature of
+.Xr posix_fadvise 2 .
+The result is that with normal (non-zfs) caching,
+buffers are released from the buffer cache soon after they are constructed,
+but their data is kept in the page cache at lower priority.
+.Cm cache
+option tends to waste memory by giving unwanted double caching,
+but it saves time if there is memory to spare.
.It Oo Cm no Oc Ns Cm reserve
Allocate and reserve all needed storage from the start, rather than as needed.
.It Oo Cm no Oc Ns Cm cluster
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index f6f642c0a024..852909aa9032 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -88,7 +88,7 @@ usage(void)
" mdconfig -l [-v] [-n] [-f file] [-u unit]\n"
" mdconfig file\n");
fprintf(stderr, "\t\ttype = {malloc, vnode, swap}\n");
- fprintf(stderr, "\t\toption = {cluster, compress, force,\n");
+ fprintf(stderr, "\t\toption = {cache, cluster, compress, force,\n");
fprintf(stderr, "\t\t readonly, reserve, ro, verify}\n");
fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%db (B),\n");
fprintf(stderr, "\t\t %%dk (kB), %%dm (MB), %%dg (GB), \n");
@@ -178,6 +178,10 @@ main(int argc, char **argv)
mdio.md_options |= MD_ASYNC;
else if (!strcmp(optarg, "noasync"))
mdio.md_options &= ~MD_ASYNC;
+ else if (!strcmp(optarg, "cache"))
+ mdio.md_options |= MD_CACHE;
+ else if (!strcmp(optarg, "nocache"))
+ mdio.md_options &= ~MD_CACHE;
else if (!strcmp(optarg, "cluster"))
mdio.md_options |= MD_CLUSTER;
else if (!strcmp(optarg, "nocluster"))