mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-09-21 05:49:02 +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;
|
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)
|
off_t FdManager::SetEnsureFreeDiskSpace(off_t size)
|
||||||
{
|
{
|
||||||
|
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||||
off_t old = FdManager::free_disk_space;
|
off_t old = FdManager::free_disk_space;
|
||||||
FdManager::free_disk_space = size;
|
FdManager::free_disk_space = size;
|
||||||
return old;
|
return old;
|
||||||
@ -2350,8 +2357,8 @@ void FdManager::CleanupCacheDirInternal(const std::string &path)
|
|||||||
|
|
||||||
bool FdManager::ReserveDiskSpace(off_t size)
|
bool FdManager::ReserveDiskSpace(off_t size)
|
||||||
{
|
{
|
||||||
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
|
||||||
if(IsSafeDiskSpace(NULL, size)){
|
if(IsSafeDiskSpace(NULL, size)){
|
||||||
|
AutoLock auto_lock(&FdManager::reserved_diskspace_lock);
|
||||||
free_disk_space += size;
|
free_disk_space += size;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ class FdManager
|
|||||||
static bool SetCheckCacheDirExist(bool is_check);
|
static bool SetCheckCacheDirExist(bool is_check);
|
||||||
static bool CheckCacheDirExist(void);
|
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 off_t SetEnsureFreeDiskSpace(off_t size);
|
||||||
static bool IsSafeDiskSpace(const char* path, off_t size);
|
static bool IsSafeDiskSpace(const char* path, off_t size);
|
||||||
static void FreeReservedDiskSpace(off_t size);
|
static void FreeReservedDiskSpace(off_t size);
|
||||||
|
Loading…
Reference in New Issue
Block a user