From 6ba609eb667d9c2c88341377cf7c2ea163738191 Mon Sep 17 00:00:00 2001 From: "ggtakec@gmail.com" Date: Fri, 3 May 2013 13:33:49 +0000 Subject: [PATCH] Fixed a bug(max_stat_cache_size=0) 1) Fixes a bug When the option max_stat_cache_size=0 is specified, the s3fs fails getting the attributes. git-svn-id: http://s3fs.googlecode.com/svn/trunk@418 df820570-a93a-0410-bd06-b72b767a4274 --- src/s3fs.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/s3fs.cpp b/src/s3fs.cpp index bcebf37..ae5bdf7 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -389,7 +389,7 @@ static int get_object_attribute(const char *path, struct stat *pstbuf, headers_t } } } - +#ifdef ORG_CODE_BUG // add into stat cache if(!StatCache::getStatCacheData()->AddStat(strpath, (*pheader), forcedir)){ FGPRINT(" get_object_attribute: failed adding stat cache [path=%s]\n", strpath.c_str()); @@ -399,6 +399,28 @@ static int get_object_attribute(const char *path, struct stat *pstbuf, headers_t FGPRINT(" get_object_attribute: failed getting added stat cache [path=%s]\n", strpath.c_str()); return -ENOENT; } +#else + if(0 != StatCache::getStatCacheData()->GetCacheSize()){ + // add into stat cache + if(!StatCache::getStatCacheData()->AddStat(strpath, (*pheader), forcedir)){ + FGPRINT(" get_object_attribute: failed adding stat cache [path=%s]\n", strpath.c_str()); + return -ENOENT; + } + if(!StatCache::getStatCacheData()->GetStat(strpath, pstat, pheader, overcheck, pisforce)){ + // There is not in cache.(why?) -> retry to convert. + if(!convert_header_to_stat(strpath.c_str(), (*pheader), pstat, forcedir)){ + FGPRINT(" get_object_attribute: failed convert headers to stat[path=%s]\n", strpath.c_str()); + return -ENOENT; + } + } + }else{ + // cache size is Zero -> only convert. + if(!convert_header_to_stat(strpath.c_str(), (*pheader), pstat, forcedir)){ + FGPRINT(" get_object_attribute: failed convert headers to stat[path=%s]\n", strpath.c_str()); + return -ENOENT; + } + } +#endif return 0; }