nfs4: Fix bugs when metadata cache is disabled
This commit is contained in:
@@ -430,8 +430,9 @@ Inode::Access(int mode)
|
|||||||
int acc = 0;
|
int acc = 0;
|
||||||
|
|
||||||
uint32 allowed;
|
uint32 allowed;
|
||||||
|
bool cache = fFileSystem->GetConfiguration().fCacheMetadata;
|
||||||
status_t result = fMetaCache.GetAccess(geteuid(), &allowed);
|
status_t result = fMetaCache.GetAccess(geteuid(), &allowed);
|
||||||
if (result != B_OK) {
|
if (result != B_OK || !cache) {
|
||||||
result = NFS4Inode::Access(&allowed);
|
result = NFS4Inode::Access(&allowed);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
@@ -463,6 +464,10 @@ Inode::Stat(struct stat* st, OpenAttrCookie* attr)
|
|||||||
if (attr != NULL)
|
if (attr != NULL)
|
||||||
return GetStat(st, attr);
|
return GetStat(st, attr);
|
||||||
|
|
||||||
|
bool cache = fFileSystem->GetConfiguration().fCacheMetadata;
|
||||||
|
if (!cache)
|
||||||
|
return GetStat(st, NULL);
|
||||||
|
|
||||||
status_t result = fMetaCache.GetStat(st);
|
status_t result = fMetaCache.GetStat(st);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
struct stat temp;
|
struct stat temp;
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ status_t
|
|||||||
MetadataCache::GetStat(struct stat* st)
|
MetadataCache::GetStat(struct stat* st)
|
||||||
{
|
{
|
||||||
MutexLocker _(fLock);
|
MutexLocker _(fLock);
|
||||||
bool cache = fInode->GetFileSystem()->GetConfiguration().fCacheMetadata;
|
if (fForceValid || fExpire > time(NULL)) {
|
||||||
if (fForceValid || (cache && fExpire > time(NULL))) {
|
|
||||||
// Do not touch other members of struct stat
|
// Do not touch other members of struct stat
|
||||||
st->st_size = fStatCache.st_size;
|
st->st_size = fStatCache.st_size;
|
||||||
st->st_mode = fStatCache.st_mode;
|
st->st_mode = fStatCache.st_mode;
|
||||||
@@ -112,8 +111,6 @@ MetadataCache::SetAccess(uid_t uid, uint32 allowed)
|
|||||||
entry.fExpire = time(NULL) + kExpirationTime;
|
entry.fExpire = time(NULL) + kExpirationTime;
|
||||||
entry.fForceValid = fForceValid;
|
entry.fForceValid = fForceValid;
|
||||||
|
|
||||||
bool cache = fInode->GetFileSystem()->GetConfiguration().fCacheMetadata;
|
|
||||||
if (fForceValid || cache)
|
|
||||||
fAccessCache.Insert(uid, entry);
|
fAccessCache.Insert(uid, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ inline void
|
|||||||
MetadataCache::InvalidateStat()
|
MetadataCache::InvalidateStat()
|
||||||
{
|
{
|
||||||
MutexLocker _(fLock);
|
MutexLocker _(fLock);
|
||||||
|
if (!fForceValid)
|
||||||
fExpire = 0;
|
fExpire = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ inline void
|
|||||||
MetadataCache::InvalidateAccess()
|
MetadataCache::InvalidateAccess()
|
||||||
{
|
{
|
||||||
MutexLocker _(fLock);
|
MutexLocker _(fLock);
|
||||||
|
if (!fForceValid)
|
||||||
fAccessCache.MakeEmpty();
|
fAccessCache.MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user