diff --git a/lib/storage/storage.go b/lib/storage/storage.go index dcbc9b6f4..e1177f88c 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -596,10 +596,15 @@ func (s *Storage) startFreeDiskSpaceWatcher() { freeSpaceBytes := fs.MustGetFreeSpace(s.path) if freeSpaceBytes < freeDiskSpaceLimitBytes { // Switch the storage to readonly mode if there is no enough free space left at s.path + logger.Warnf("switching the storage at %s to read-only mode, since it has less than -storage.minFreeDiskSpaceBytes=%d of free space: %d bytes left", + s.path, freeDiskSpaceLimitBytes, freeSpaceBytes) atomic.StoreUint32(&s.isReadOnly, 1) return } - atomic.StoreUint32(&s.isReadOnly, 0) + if atomic.CompareAndSwapUint32(&s.isReadOnly, 1, 0) { + logger.Warnf("enabling writing to the storage at %s, since it has more than -storage.minFreeDiskSpaceBytes=%d of free space: %d bytes left", + s.path, freeDiskSpaceLimitBytes, freeSpaceBytes) + } } f() s.freeDiskSpaceWatcherWG.Add(1)