nfs4: Fix bugs when metadata cache is disabled
This commit is contained in:
@@ -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,9 +111,7 @@ 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);
|
||||
fAccessCache.Insert(uid, entry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,8 @@ inline void
|
||||
MetadataCache::InvalidateStat()
|
||||
{
|
||||
MutexLocker _(fLock);
|
||||
fExpire = 0;
|
||||
if (!fForceValid)
|
||||
fExpire = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +78,8 @@ inline void
|
||||
MetadataCache::InvalidateAccess()
|
||||
{
|
||||
MutexLocker _(fLock);
|
||||
fAccessCache.MakeEmpty();
|
||||
if (!fForceValid)
|
||||
fAccessCache.MakeEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user