Load IO error count for posix atomically (#4448)

* Load error count atomically in order to check for maximum allowed number of IO errors.

* Remove unused (previously atomic) network IO error count
master
Frank Wessels 8 years ago committed by Harshavardhana
parent a0e02f43e1
commit 0f0758aece
  1. 26
      cmd/posix.go
  2. 1
      cmd/storage-rpc-client.go

@ -251,7 +251,7 @@ func (s *posix) MakeVol(volume string) (err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return errFaultyDisk return errFaultyDisk
} }
@ -285,7 +285,7 @@ func (s *posix) ListVols() (volsInfo []VolInfo, err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return nil, errFaultyDisk return nil, errFaultyDisk
} }
@ -349,7 +349,7 @@ func (s *posix) StatVol(volume string) (volInfo VolInfo, err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return VolInfo{}, errFaultyDisk return VolInfo{}, errFaultyDisk
} }
@ -388,7 +388,7 @@ func (s *posix) DeleteVol(volume string) (err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return errFaultyDisk return errFaultyDisk
} }
@ -422,7 +422,7 @@ func (s *posix) ListDir(volume, dirPath string) (entries []string, err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return nil, errFaultyDisk return nil, errFaultyDisk
} }
@ -459,7 +459,7 @@ func (s *posix) ReadAll(volume, path string) (buf []byte, err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return nil, errFaultyDisk return nil, errFaultyDisk
} }
@ -544,7 +544,7 @@ func (s *posix) ReadFileWithVerify(volume, path string, offset int64, buf []byte
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return 0, errFaultyDisk return 0, errFaultyDisk
} }
@ -664,7 +664,7 @@ func (s *posix) createFile(volume, path string) (f *os.File, err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return nil, errFaultyDisk return nil, errFaultyDisk
} }
@ -737,7 +737,7 @@ func (s *posix) PrepareFile(volume, path string, fileSize int64) (err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return errFaultyDisk return errFaultyDisk
} }
@ -784,7 +784,7 @@ func (s *posix) AppendFile(volume, path string, buf []byte) (err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return errFaultyDisk return errFaultyDisk
} }
@ -815,7 +815,7 @@ func (s *posix) StatFile(volume, path string) (file FileInfo, err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return FileInfo{}, errFaultyDisk return FileInfo{}, errFaultyDisk
} }
@ -911,7 +911,7 @@ func (s *posix) DeleteFile(volume, path string) (err error) {
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return errFaultyDisk return errFaultyDisk
} }
@ -951,7 +951,7 @@ func (s *posix) RenameFile(srcVolume, srcPath, dstVolume, dstPath string) (err e
} }
}() }()
if s.ioErrCount > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return errFaultyDisk return errFaultyDisk
} }

@ -28,7 +28,6 @@ import (
) )
type networkStorage struct { type networkStorage struct {
networkIOErrCount int32 // ref: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
rpcClient *AuthRPCClient rpcClient *AuthRPCClient
} }

Loading…
Cancel
Save