mirror of https://github.com/trapexit/mergerfs.git
Browse Source
Update the secondary group cache (#1492)
Update the secondary group cache (#1492)
* Use concurrent_flat_map to build a global cache rather than per thread. * Create global maintanence thread manager for clearing unused cache entries.pull/1493/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 338 additions and 242 deletions
-
3libfuse/Makefile
-
3libfuse/include/fuse.h
-
13libfuse/include/maintenance_thread.hpp
-
56libfuse/lib/fuse.cpp
-
16libfuse/lib/fuse_loop.cpp
-
65libfuse/lib/maintenance_thread.cpp
-
8mkdocs/docs/config/options.md
-
23mkdocs/docs/known_issues_bugs.md
-
4src/config.cpp
-
3src/config.hpp
-
65src/config_gidcache.cpp
-
25src/config_gidcache.hpp
-
2src/fuse_ioctl.cpp
-
229src/gidcache.cpp
-
41src/gidcache.hpp
-
8src/mergerfs.cpp
-
4src/ugid.cpp
@ -0,0 +1,13 @@ |
|||
#pragma once
|
|||
|
|||
#include <functional>
|
|||
#include <vector>
|
|||
|
|||
|
|||
class MaintenanceThread |
|||
{ |
|||
public: |
|||
static void setup(); |
|||
static void stop(); |
|||
static void push_job(const std::function<void(int)> &func); |
|||
}; |
@ -0,0 +1,65 @@ |
|||
#include "maintenance_thread.hpp"
|
|||
|
|||
#include "fmt/core.h"
|
|||
|
|||
#include <cassert>
|
|||
#include <mutex>
|
|||
#include <vector>
|
|||
|
|||
#include <pthread.h>
|
|||
#include <unistd.h>
|
|||
|
|||
|
|||
pthread_t g_thread; |
|||
std::vector<std::function<void(int)>> g_funcs; |
|||
std::mutex g_mutex; |
|||
|
|||
static |
|||
void* |
|||
_thread_loop(void *) |
|||
{ |
|||
int count; |
|||
|
|||
pthread_setname_np(pthread_self(),"fuse.maint"); |
|||
|
|||
count = 0; |
|||
while(true) |
|||
{ |
|||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL); |
|||
{ |
|||
std::lock_guard<std::mutex> lg(g_mutex); |
|||
for(auto &func : g_funcs) |
|||
func(count); |
|||
} |
|||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL); |
|||
|
|||
count++; |
|||
::sleep(60); |
|||
} |
|||
|
|||
return NULL; |
|||
} |
|||
|
|||
void |
|||
MaintenanceThread::setup() |
|||
{ |
|||
int rv; |
|||
|
|||
rv = pthread_create(&g_thread,NULL,_thread_loop,NULL); |
|||
assert((rv == 0) && "pthread_create failed"); |
|||
} |
|||
|
|||
void |
|||
MaintenanceThread::push_job(const std::function<void(int)> &func_) |
|||
{ |
|||
std::lock_guard<std::mutex> lg(g_mutex); |
|||
|
|||
g_funcs.emplace_back(func_); |
|||
} |
|||
|
|||
void |
|||
MaintenanceThread::stop() |
|||
{ |
|||
pthread_cancel(g_thread); |
|||
pthread_join(g_thread,NULL); |
|||
} |
@ -0,0 +1,65 @@ |
|||
#include "config_gidcache.hpp"
|
|||
|
|||
#include "gidcache.hpp"
|
|||
|
|||
#include "to_string.hpp"
|
|||
#include "from_string.hpp"
|
|||
|
|||
|
|||
GIDCacheExpireTimeout::GIDCacheExpireTimeout(const int i_) |
|||
{ |
|||
GIDCache::expire_timeout = i_; |
|||
} |
|||
|
|||
GIDCacheExpireTimeout::GIDCacheExpireTimeout(const std::string &s_) |
|||
{ |
|||
from_string(s_); |
|||
} |
|||
|
|||
std::string |
|||
GIDCacheExpireTimeout::to_string(void) const |
|||
{ |
|||
return str::to(GIDCache::expire_timeout); |
|||
} |
|||
|
|||
int |
|||
GIDCacheExpireTimeout::from_string(const std::string &s_) |
|||
{ |
|||
int rv; |
|||
|
|||
rv = str::from(s_,&GIDCache::expire_timeout); |
|||
if(rv < 0) |
|||
return rv; |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
|
|||
GIDCacheRemoveTimeout::GIDCacheRemoveTimeout(const int i_) |
|||
{ |
|||
GIDCache::remove_timeout = i_; |
|||
} |
|||
|
|||
|
|||
GIDCacheRemoveTimeout::GIDCacheRemoveTimeout(const std::string &s_) |
|||
{ |
|||
from_string(s_); |
|||
} |
|||
|
|||
std::string |
|||
GIDCacheRemoveTimeout::to_string(void) const |
|||
{ |
|||
return str::to(GIDCache::remove_timeout); |
|||
} |
|||
|
|||
int |
|||
GIDCacheRemoveTimeout::from_string(const std::string &s_) |
|||
{ |
|||
int rv; |
|||
|
|||
rv = str::from(s_,&GIDCache::remove_timeout); |
|||
if(rv < 0) |
|||
return rv; |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,25 @@ |
|||
#pragma once
|
|||
|
|||
#include "tofrom_string.hpp"
|
|||
|
|||
class GIDCacheExpireTimeout : public ToFromString |
|||
{ |
|||
public: |
|||
GIDCacheExpireTimeout(const int i = 60 * 60); |
|||
GIDCacheExpireTimeout(const std::string &); |
|||
|
|||
public: |
|||
std::string to_string(void) const final; |
|||
int from_string(const std::string &) final; |
|||
}; |
|||
|
|||
class GIDCacheRemoveTimeout : public ToFromString |
|||
{ |
|||
public: |
|||
GIDCacheRemoveTimeout(const int = 60 * 60 * 12); |
|||
GIDCacheRemoveTimeout(const std::string &); |
|||
|
|||
public: |
|||
std::string to_string(void) const final; |
|||
int from_string(const std::string &) final; |
|||
}; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue