mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-23 05:48:26 +00:00
Committing patch contributed by Ben LeMasurier to cache directory attributes. Details and tests on Issue 150.
git-svn-id: http://s3fs.googlecode.com/svn/trunk@309 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
0a233011a5
commit
fd2a6c120a
23
src/s3fs.cpp
23
src/s3fs.cpp
@ -2029,7 +2029,6 @@ static int s3fs_getattr(const char *path, struct stat *stbuf) {
|
||||
stat_cache_t::iterator iter = stat_cache.find(path);
|
||||
if (iter != stat_cache.end()) {
|
||||
*stbuf = (*iter).second;
|
||||
stat_cache.erase(path);
|
||||
pthread_mutex_unlock( &stat_cache_lock );
|
||||
return 0;
|
||||
}
|
||||
@ -2107,6 +2106,11 @@ static int s3fs_getattr(const char *path, struct stat *stbuf) {
|
||||
}
|
||||
destroy_curl_handle(curl);
|
||||
|
||||
// update stat cache
|
||||
pthread_mutex_lock(&stat_cache_lock);
|
||||
stat_cache[path] = *stbuf;
|
||||
pthread_mutex_unlock(&stat_cache_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2476,6 +2480,7 @@ static int s3fs_rmdir(const char *path) {
|
||||
return -ENOTEMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
// delete the directory
|
||||
string resource = urlEncode(service_path + bucket + path);
|
||||
string url = host + resource;
|
||||
@ -2510,6 +2515,9 @@ static int s3fs_rmdir(const char *path) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// delete cache entry
|
||||
delete_stat_cache_entry(path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2674,11 +2682,9 @@ static int rename_directory( const char *from, const char *to) {
|
||||
string Key;
|
||||
bool is_dir;
|
||||
|
||||
|
||||
body.text = (char *)malloc(1);
|
||||
body.size = 0;
|
||||
|
||||
|
||||
// create the head/tail of the linked list
|
||||
from_path.assign(from);
|
||||
to_path.assign(to);
|
||||
@ -2925,9 +2931,6 @@ static int rename_directory( const char *from, const char *to) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int s3fs_rename(const char *from, const char *to) {
|
||||
if(foreground)
|
||||
cout << "rename[from=" << from << "][to=" << to << "]" << endl;
|
||||
@ -2960,6 +2963,8 @@ static int s3fs_rename(const char *from, const char *to) {
|
||||
result = rename_object(from, to);
|
||||
}
|
||||
|
||||
delete_stat_cache_entry(from);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -3465,6 +3470,12 @@ static int s3fs_readdir(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void delete_stat_cache_entry(const char *path) {
|
||||
pthread_mutex_lock(&stat_cache_lock);
|
||||
stat_cache.erase(stat_cache.find(path));
|
||||
pthread_mutex_unlock(&stat_cache_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenSSL locking function.
|
||||
*
|
||||
|
@ -84,6 +84,8 @@ static struct fuse_operations s3fs_oper;
|
||||
string urlEncode(const string &s);
|
||||
string lookupMimeType(string);
|
||||
|
||||
static void delete_stat_cache_entry(const char *path);
|
||||
|
||||
static int s3fs_getattr(const char *path, struct stat *stbuf);
|
||||
static int s3fs_readlink(const char *path, char *buf, size_t size);
|
||||
static int s3fs_mknod(const char* path, mode_t mode, dev_t rdev);
|
||||
|
Loading…
x
Reference in New Issue
Block a user