From b1a252a64d39d17618d2d00ac341684b6f290ef6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 5 Oct 2014 07:41:50 +0200 Subject: lib/nfs/Base: kludge to reduce number of NFS mounts Creating a NfsStorage sets its own export_name as the "base". Now NfsFileReader can use this information to derive the export_name to be mounted, instead of guessing. This solves the "too many connection" problem on the NFS server while updating the database. --- src/lib/nfs/FileReader.cxx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/lib/nfs/FileReader.cxx') diff --git a/src/lib/nfs/FileReader.cxx b/src/lib/nfs/FileReader.cxx index d2be46f8e..4837e1f0e 100644 --- a/src/lib/nfs/FileReader.cxx +++ b/src/lib/nfs/FileReader.cxx @@ -20,6 +20,7 @@ #include "config.h" #include "FileReader.hxx" #include "Glue.hxx" +#include "Base.hxx" #include "Connection.hxx" #include "Domain.hxx" #include "event/Call.hxx" @@ -100,14 +101,23 @@ NfsFileReader::Open(const char *uri, Error &error) server = std::string(uri, slash); uri = slash; - slash = strrchr(uri + 1, '/'); - if (slash == nullptr || slash[1] == 0) { - error.Set(nfs_domain, "Malformed nfs:// URI"); - return false; - } - export_name = std::string(uri, slash); - path = slash; + const char *new_path = nfs_check_base(server.c_str(), uri); + if (new_path != nullptr) { + export_name = std::string(uri, new_path); + if (*new_path == 0) + new_path = "/"; + path = new_path; + } else { + slash = strrchr(uri + 1, '/'); + if (slash == nullptr || slash[1] == 0) { + error.Set(nfs_domain, "Malformed nfs:// URI"); + return false; + } + + export_name = std::string(uri, slash); + path = slash; + } state = State::DEFER; DeferredMonitor::Schedule(); -- cgit v1.2.3