diff --git a/lib/storage/storage.go b/lib/storage/storage.go
index 5c4ebfd71e..2e48db3d66 100644
--- a/lib/storage/storage.go
+++ b/lib/storage/storage.go
@@ -648,13 +648,12 @@ func (s *Storage) startFreeDiskSpaceWatcher() {
 	f := func() {
 		freeSpaceBytes := fs.MustGetFreeSpace(s.path)
 		if freeSpaceBytes < freeDiskSpaceLimitBytes {
-			if atomic.LoadUint32(&s.isReadOnly) == 0 {
+			// Switch the storage to readonly mode if there is no enough free space left at s.path
+			if atomic.CompareAndSwapUint32(&s.isReadOnly, 0, 1) {
 				// log notification only on state change
 				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)
 			}
-			// Switch the storage to readonly mode if there is no enough free space left at s.path
-			atomic.StoreUint32(&s.isReadOnly, 1)
 			return
 		}
 		if atomic.CompareAndSwapUint32(&s.isReadOnly, 1, 0) {