mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-10 23:00:57 +00:00
Merge pull request #1108 from gaul/lock/diskspace
Always hold lock when accessing free_disk_space
This commit is contained in:
commit
3d70e8966f
@ -1994,8 +1994,15 @@ bool FdManager::CheckCacheDirExist()
|
||||
return true;
|
||||
}
|
||||
|
||||
off_t FdManager::GetEnsureFreeDiskSpace()
|
||||
{
|
||||
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||
return FdManager::free_disk_space;
|
||||
}
|
||||
|
||||
off_t FdManager::SetEnsureFreeDiskSpace(off_t size)
|
||||
{
|
||||
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||
off_t old = FdManager::free_disk_space;
|
||||
FdManager::free_disk_space = size;
|
||||
return old;
|
||||
@ -2350,8 +2357,8 @@ void FdManager::CleanupCacheDirInternal(const std::string &path)
|
||||
|
||||
bool FdManager::ReserveDiskSpace(off_t size)
|
||||
{
|
||||
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||
if(IsSafeDiskSpace(NULL, size)){
|
||||
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||
free_disk_space += size;
|
||||
return true;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ class FdManager
|
||||
static bool SetCheckCacheDirExist(bool is_check);
|
||||
static bool CheckCacheDirExist(void);
|
||||
|
||||
static off_t GetEnsureFreeDiskSpace(void) { return FdManager::free_disk_space; }
|
||||
static off_t GetEnsureFreeDiskSpace();
|
||||
static off_t SetEnsureFreeDiskSpace(off_t size);
|
||||
static bool IsSafeDiskSpace(const char* path, off_t size);
|
||||
static void FreeReservedDiskSpace(off_t size);
|
||||
|
Loading…
Reference in New Issue
Block a user