From 294a754c9ef4970d5f3283bdf172f4b9a1671602 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 27 Oct 2023 00:35:06 +0300 Subject: [PATCH] Allow write-back by default in NBD & NFS --- src/nbd_proxy.cpp | 8 ++++++++ src/nfs_proxy.cpp | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/nbd_proxy.cpp b/src/nbd_proxy.cpp index c87592ca..c2d45c97 100644 --- a/src/nbd_proxy.cpp +++ b/src/nbd_proxy.cpp @@ -216,6 +216,14 @@ public: { nbd_timeout = cfg["nbd_timeout"].uint64_value(); } + if (cfg["client_writeback_allowed"].is_null()) + { + // NBD is always aware of fsync, so we allow write-back cache + // by default if it's enabled + auto obj = cfg.object_items(); + obj["client_writeback_allowed"] = true; + cfg = obj; + } // Create client ringloop = new ring_loop_t(512); epmgr = new epoll_manager_t(ringloop); diff --git a/src/nfs_proxy.cpp b/src/nfs_proxy.cpp index 04a64291..b0167844 100644 --- a/src/nfs_proxy.cpp +++ b/src/nfs_proxy.cpp @@ -65,8 +65,9 @@ json11::Json::object nfs_proxy_t::parse_args(int narg, const char *args[]) " --pool use as default pool for new files (images)\n" " --foreground 1 stay in foreground, do not daemonize\n" "\n" - "NFS proxy is stateless if you use immediate_commit=all in your cluster, so\n" - "you can freely use multiple NFS proxies with L3 load balancing in this case.\n" + "NFS proxy is stateless if you use immediate_commit=all in your cluster and if\n" + "you do not use client_enable_writeback=true, so you can freely use multiple\n" + "NFS proxies with L3 load balancing in this case.\n" "\n" "Example start and mount commands for a custom NFS port:\n" " %s --etcd_address 192.168.5.10:2379 --portmap 0 --port 2050 --pool testpool\n" @@ -114,6 +115,14 @@ void nfs_proxy_t::run(json11::Json cfg) if (name_prefix.size()) name_prefix += "/"; } + if (cfg["client_writeback_allowed"].is_null()) + { + // NFS is always aware of fsync, so we allow write-back cache + // by default if it's enabled + auto obj = cfg.object_items(); + obj["client_writeback_allowed"] = true; + cfg = obj; + } // Create client ringloop = new ring_loop_t(512); epmgr = new epoll_manager_t(ringloop);