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