From d8fb6615218173f32622878d720799a08fec32c9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 26 Apr 2022 02:11:26 +0100 Subject: Combine daemon settings with client settings, pass MessageMaxSize to OpenFiles --- netfs/fuse/fuseApp.cpp | 8 ++++++++ netfs/fuse/fuseApp.h | 2 ++ netfs/fuse/fuseFiles.cpp | 7 ++++--- netfs/fuse/fuseFiles.h | 3 ++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/netfs/fuse/fuseApp.cpp b/netfs/fuse/fuseApp.cpp index ffb46e5..29a142d 100644 --- a/netfs/fuse/fuseApp.cpp +++ b/netfs/fuse/fuseApp.cpp @@ -85,6 +85,7 @@ NetFS::FuseApp::init(struct fuse_conn_info *, struct fuse_config *) } BOOST_ASSERT(fcr); converter.mapper = fcr->Mapper; + combinedSettings.MessageSizeMax = ic->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024); return this; } @@ -172,6 +173,12 @@ NetFS::FuseApp::connectSession() } } +NetFS::Settings +NetFS::FuseApp::combineSettings(const Settings & daemon, const Settings & client) +{ + return NetFS::Settings {std::min(daemon.MessageSizeMax.value_or(1024), client.MessageSizeMax.value_or(1024))}; +} + void NetFS::FuseApp::connectToService() { @@ -186,6 +193,7 @@ NetFS::FuseApp::connectToService() throw std::runtime_error("Invalid service proxy: " + proxyAddr); } daemonSettings = service->getSettings(); + combinedSettings = combineSettings(*daemonSettings, clientSettings); } } diff --git a/netfs/fuse/fuseApp.h b/netfs/fuse/fuseApp.h index 8feb58a..006effd 100644 --- a/netfs/fuse/fuseApp.h +++ b/netfs/fuse/fuseApp.h @@ -82,6 +82,7 @@ namespace NetFS { static NetFS::Client::ResourcePtr configureFromFile(const std::filesystem::path &, const std::string &); static NetFS::Client::ResourcePtr configureFromUri(const std::string &); + static Settings combineSettings(const Settings & daemon, const Settings & client); protected: template void setProxy(FuseHandleTypeId & fh, const Params &...); @@ -103,6 +104,7 @@ namespace NetFS { NetFS::ServicePrxPtr service; Glacier2::SessionPrxPtr session; NetFS::SettingsPtr daemonSettings; + NetFS::Settings clientSettings, combinedSettings; bool sessionOpened {false}; std::string mountPoint; diff --git a/netfs/fuse/fuseFiles.cpp b/netfs/fuse/fuseFiles.cpp index 03cb394..5e155f2 100644 --- a/netfs/fuse/fuseFiles.cpp +++ b/netfs/fuse/fuseFiles.cpp @@ -9,7 +9,8 @@ namespace NetFS { FuseApp::OpenFile::WriteState::WriteState() : future(promise.get_future().share()) { } - FuseApp::OpenFile::OpenFile(FilePrxPtr r, std::string p, int f) : remote(std::move(r)), path(std::move(p)), flags(f) + FuseApp::OpenFile::OpenFile(FilePrxPtr r, std::string p, int f, Ice::Int mms) : + remote(std::move(r)), path(std::move(p)), flags(f), messageMaxSize(mms) { } @@ -56,7 +57,7 @@ namespace NetFS { { try { auto remote = volume->open(reqEnv(), p, fi->flags); - setProxy(fi->fh, remote, p, fi->flags); + setProxy(fi->fh, remote, p, fi->flags, combinedSettings.MessageSizeMax.value_or(1024)); return 0; } catch (SystemError & e) { @@ -69,7 +70,7 @@ namespace NetFS { { try { auto remote = volume->create(reqEnv(), p, fi->flags, safe {m}); - setProxy(fi->fh, remote, p, fi->flags); + setProxy(fi->fh, remote, p, fi->flags, combinedSettings.MessageSizeMax.value_or(1024)); return 0; } catch (SystemError & e) { diff --git a/netfs/fuse/fuseFiles.h b/netfs/fuse/fuseFiles.h index 46dff07..7ddf799 100644 --- a/netfs/fuse/fuseFiles.h +++ b/netfs/fuse/fuseFiles.h @@ -6,7 +6,7 @@ namespace NetFS { class FuseApp::OpenFile { public: - OpenFile(FilePrxPtr remote, std::string path, int flags); + OpenFile(FilePrxPtr remote, std::string path, int flags, Ice::Int messageMaxSize); void flush(); void wait() const; @@ -14,6 +14,7 @@ namespace NetFS { FilePrxPtr remote; const std::string path; const int flags; + const Ice::Int messageMaxSize; class WriteState { public: WriteState(); -- cgit v1.2.3