nfs4: Allow customization of DirectoryCache expiration time
This commit is contained in:
@@ -78,7 +78,7 @@ DirectoryCacheSnapshot::~DirectoryCacheSnapshot()
|
||||
|
||||
DirectoryCache::DirectoryCache(Inode* inode, bool attr)
|
||||
:
|
||||
fRevalidated(false),
|
||||
fExpirationTime(inode->fFileSystem->GetConfiguration().fDirectoryCacheTime),
|
||||
fDirectoryCache(NULL),
|
||||
fInode(inode),
|
||||
fAttrDir(attr),
|
||||
@@ -100,7 +100,7 @@ void
|
||||
DirectoryCache::Reset()
|
||||
{
|
||||
Trash();
|
||||
fExpireTime = system_time() + kExpirationTime;
|
||||
fExpireTime = system_time() + fExpirationTime;
|
||||
fTrashed = false;
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ DirectoryCache::_LoadSnapshot(bool trash)
|
||||
newSnapshot->AcquireReference();
|
||||
|
||||
_SetSnapshot(newSnapshot);
|
||||
fExpireTime = system_time() + kExpirationTime;
|
||||
fExpireTime = system_time() + fExpirationTime;
|
||||
|
||||
fTrashed = false;
|
||||
|
||||
@@ -260,7 +260,7 @@ DirectoryCache::Revalidate()
|
||||
}
|
||||
|
||||
if (change == fChange) {
|
||||
fExpireTime = system_time() + kExpirationTime;
|
||||
fExpireTime = system_time() + fExpirationTime;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,7 @@ public:
|
||||
|
||||
inline Inode* GetInode();
|
||||
|
||||
static const bigtime_t kExpirationTime = 15000000;
|
||||
|
||||
bool fRevalidated;
|
||||
const bigtime_t fExpirationTime;
|
||||
protected:
|
||||
void NotifyChanges(DirectoryCacheSnapshot* oldSnapshot,
|
||||
DirectoryCacheSnapshot* newSnapshot);
|
||||
@@ -139,7 +137,7 @@ DirectoryCache::ValidateChangeInfo(uint64 change)
|
||||
if (fTrashed || change != fChange) {
|
||||
Trash();
|
||||
fChange = change;
|
||||
fExpireTime = system_time() + kExpirationTime;
|
||||
fExpireTime = system_time() + fExpirationTime;
|
||||
fTrashed = false;
|
||||
|
||||
return B_ERROR;
|
||||
@@ -152,7 +150,7 @@ DirectoryCache::ValidateChangeInfo(uint64 change)
|
||||
inline void
|
||||
DirectoryCache::SetChangeInfo(uint64 change)
|
||||
{
|
||||
fExpireTime = system_time() + kExpirationTime;
|
||||
fExpireTime = system_time() + fExpirationTime;
|
||||
fChange = change;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ struct MountConfiguration {
|
||||
|
||||
bool fEmulateNamedAttrs;
|
||||
bool fCacheMetadata;
|
||||
|
||||
bigtime_t fDirectoryCacheTime;
|
||||
};
|
||||
|
||||
class FileSystem : public DoublyLinkedListLinkImpl<FileSystem> {
|
||||
|
||||
@@ -71,6 +71,8 @@ CreateNFS4Server(RPC::Server* serv)
|
||||
// noxattr-emu - do not emulate named attributes (default)
|
||||
// port=X - connect to port X (default: 2049)
|
||||
// proto=X - user transport protocol X (default: tcp)
|
||||
// dirtime=X - attempt revalidate directory cache not more often than each X
|
||||
// seconds
|
||||
static status_t
|
||||
ParseArguments(const char* _args, AddressResolver** address, char** _path,
|
||||
MountConfiguration* conf)
|
||||
@@ -107,6 +109,7 @@ ParseArguments(const char* _args, AddressResolver** address, char** _path,
|
||||
conf->fRequestTimeout = sSecToBigTime(60);
|
||||
conf->fEmulateNamedAttrs = false;
|
||||
conf->fCacheMetadata = true;
|
||||
conf->fDirectoryCacheTime = sSecToBigTime(5);
|
||||
|
||||
char* optionsEnd = NULL;
|
||||
if (options != NULL)
|
||||
@@ -133,6 +136,9 @@ ParseArguments(const char* _args, AddressResolver** address, char** _path,
|
||||
} else if (strncmp(options, "proto=", 6) == 0) {
|
||||
options += strlen("proto=");
|
||||
(*address)->ForceProtocol(options);
|
||||
} else if (strncmp(options, "dirtime=", 8) == 0) {
|
||||
options += strlen("dirtime=");
|
||||
conf->fDirectoryCacheTime = sSecToBigTime(atoi(options));
|
||||
}
|
||||
|
||||
options = optionsEnd;
|
||||
|
||||
Reference in New Issue
Block a user