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.
This commit is contained in:
Max Kellermann
2014-10-05 07:41:50 +02:00
parent fb90b64bac
commit b1a252a64d
5 changed files with 128 additions and 7 deletions

View File

@@ -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();