Fixed bugs(Issue 363)

1) Fixed Issue 363
   Fixed a bug which has below reason.
   Fuse does not wait finishing "release file descriptor" function
   called by fuse, and fuse runs(calls) next processing(commands).
   Then s3fs could not clear stats cache information for that file
   before calling next processing, and s3fs uses old stats cache
   information.
   So that, s3fs clears stats cache in release function at first.

   And found two bad codes(but these codes do not influence normal
   movement) in fdcache.cpp and fixed these.

   Issue 363: make check failing inconsistently



git-svn-id: http://s3fs.googlecode.com/svn/trunk@471 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
ggtakec@gmail.com 2013-08-22 09:36:16 +00:00
parent 07a8caa250
commit b3682f87d2
2 changed files with 12 additions and 6 deletions

View File

@ -515,7 +515,7 @@ void FdEntity::Clear(void)
AutoLock auto_lock(&fdent_lock); AutoLock auto_lock(&fdent_lock);
if(file){ if(file){
{ if(0 != cachepath.size()){
CacheFileStat cfstat(path.c_str()); CacheFileStat cfstat(path.c_str());
if(!pagelist.Serialize(cfstat, true)){ if(!pagelist.Serialize(cfstat, true)){
DPRN("failed to save cache stat file(%s).", path.c_str()); DPRN("failed to save cache stat file(%s).", path.c_str());
@ -543,7 +543,7 @@ void FdEntity::Close(void)
refcnt--; refcnt--;
} }
if(0 == refcnt){ if(0 == refcnt){
{ if(0 != cachepath.size()){
CacheFileStat cfstat(path.c_str()); CacheFileStat cfstat(path.c_str());
if(!pagelist.Serialize(cfstat, true)){ if(!pagelist.Serialize(cfstat, true)){
DPRN("failed to save cache stat file(%s).", path.c_str()); DPRN("failed to save cache stat file(%s).", path.c_str());

View File

@ -1960,6 +1960,16 @@ static int s3fs_release(const char* path, struct fuse_file_info* fi)
{ {
FPRN("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh)); FPRN("[path=%s][fd=%llu]", path, (unsigned long long)(fi->fh));
// [NOTICE]
// At first, we remove stats cache.
// Because fuse does not wait for responce from "release" function. :-(
// And fuse runs next command before this function returns.
// Thus we call deleting stats function ASSAP.
//
if((fi->flags & O_RDWR) || (fi->flags & O_WRONLY)){
StatCache::getStatCacheData()->DelStat(path);
}
FdEntity* ent; FdEntity* ent;
if(NULL == (ent = FdManager::get()->GetFdEntity(path))){ if(NULL == (ent = FdManager::get()->GetFdEntity(path))){
DPRN("could not find fd(file=%s)", path); DPRN("could not find fd(file=%s)", path);
@ -1976,10 +1986,6 @@ static int s3fs_release(const char* path, struct fuse_file_info* fi)
DPRNNN("Warning - file(%s),fd(%d) is still opened.", path, ent->GetFd()); DPRNNN("Warning - file(%s),fd(%d) is still opened.", path, ent->GetFd());
} }
} }
if((fi->flags & O_RDWR) || (fi->flags & O_WRONLY)){
StatCache::getStatCacheData()->DelStat(path);
}
return 0; return 0;
} }