nfs4: Fix bugs when metadata cache is disabled

This commit is contained in:
Pawel Dziepak
2012-08-17 01:28:48 +02:00
parent da950cb2ef
commit 8568341ae6
3 changed files with 12 additions and 8 deletions
@@ -430,8 +430,9 @@ Inode::Access(int mode)
int acc = 0;
uint32 allowed;
bool cache = fFileSystem->GetConfiguration().fCacheMetadata;
status_t result = fMetaCache.GetAccess(geteuid(), &allowed);
if (result != B_OK) {
if (result != B_OK || !cache) {
result = NFS4Inode::Access(&allowed);
if (result != B_OK)
return result;
@@ -463,6 +464,10 @@ Inode::Stat(struct stat* st, OpenAttrCookie* attr)
if (attr != NULL)
return GetStat(st, attr);
bool cache = fFileSystem->GetConfiguration().fCacheMetadata;
if (!cache)
return GetStat(st, NULL);
status_t result = fMetaCache.GetStat(st);
if (result != B_OK) {
struct stat temp;
@@ -35,8 +35,7 @@ status_t
MetadataCache::GetStat(struct stat* st)
{
MutexLocker _(fLock);
bool cache = fInode->GetFileSystem()->GetConfiguration().fCacheMetadata;
if (fForceValid || (cache && fExpire > time(NULL))) {
if (fForceValid || fExpire > time(NULL)) {
// Do not touch other members of struct stat
st->st_size = fStatCache.st_size;
st->st_mode = fStatCache.st_mode;
@@ -112,8 +111,6 @@ MetadataCache::SetAccess(uid_t uid, uint32 allowed)
entry.fExpire = time(NULL) + kExpirationTime;
entry.fForceValid = fForceValid;
bool cache = fInode->GetFileSystem()->GetConfiguration().fCacheMetadata;
if (fForceValid || cache)
fAccessCache.Insert(uid, entry);
}
@@ -69,6 +69,7 @@ inline void
MetadataCache::InvalidateStat()
{
MutexLocker _(fLock);
if (!fForceValid)
fExpire = 0;
}
@@ -77,6 +78,7 @@ inline void
MetadataCache::InvalidateAccess()
{
MutexLocker _(fLock);
if (!fForceValid)
fAccessCache.MakeEmpty();
}