mirror of
https://github.com/minio/minio.git
synced 2025-02-28 13:59:15 -05:00
Fix disk info race (#11984)
Protect updated members in xlStorage. ``` WARNING: DATA RACE Write at 0x00c004b4ee78 by goroutine 1491: github.com/minio/minio/cmd.(*xlStorage).GetDiskID() d:/minio/minio/cmd/xl-storage.go:590 +0x1078 github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).checkDiskStale() d:/minio/minio/cmd/xl-storage-disk-id-check.go:195 +0x84 github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).StatVol() d:/minio/minio/cmd/xl-storage-disk-id-check.go:284 +0x16a github.com/minio/minio/cmd.erasureObjects.getBucketInfo.func1() d:/minio/minio/cmd/erasure-bucket.go:100 +0x1a5 github.com/minio/minio/pkg/sync/errgroup.(*Group).Go.func1() d:/minio/minio/pkg/sync/errgroup/errgroup.go:122 +0xd7 Previous read at 0x00c004b4ee78 by goroutine 1087: github.com/minio/minio/cmd.(*xlStorage).CheckFile.func1() d:/minio/minio/cmd/xl-storage.go:1699 +0x384 github.com/minio/minio/cmd.(*xlStorage).CheckFile() d:/minio/minio/cmd/xl-storage.go:1726 +0x13c github.com/minio/minio/cmd.(*xlStorageDiskIDCheck).CheckFile() d:/minio/minio/cmd/xl-storage-disk-id-check.go:446 +0x23b github.com/minio/minio/cmd.erasureObjects.parentDirIsObject.func1() d:/minio/minio/cmd/erasure-common.go:173 +0x194 github.com/minio/minio/pkg/sync/errgroup.(*Group).Go.func1() d:/minio/minio/pkg/sync/errgroup/errgroup.go:122 +0xd7 ```
This commit is contained in:
parent
f687ba53bc
commit
98c792bbeb
@ -347,6 +347,8 @@ func (s *xlStorage) IsLocal() bool {
|
|||||||
|
|
||||||
// Retrieve location indexes.
|
// Retrieve location indexes.
|
||||||
func (s *xlStorage) GetDiskLoc() (poolIdx, setIdx, diskIdx int) {
|
func (s *xlStorage) GetDiskLoc() (poolIdx, setIdx, diskIdx int) {
|
||||||
|
s.RLock()
|
||||||
|
defer s.RUnlock()
|
||||||
// If unset, see if we can locate it.
|
// If unset, see if we can locate it.
|
||||||
if s.poolIndex < 0 || s.setIndex < 0 || s.diskIndex < 0 {
|
if s.poolIndex < 0 || s.setIndex < 0 || s.diskIndex < 0 {
|
||||||
return getXLDiskLoc(s.diskID)
|
return getXLDiskLoc(s.diskID)
|
||||||
@ -1615,6 +1617,9 @@ func (s *xlStorage) CheckFile(ctx context.Context, volume string, path string) e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
s.RLock()
|
||||||
|
formatLegacy := s.formatLegacy
|
||||||
|
s.RUnlock()
|
||||||
|
|
||||||
var checkFile func(p string) error
|
var checkFile func(p string) error
|
||||||
checkFile = func(p string) error {
|
checkFile = func(p string) error {
|
||||||
@ -1626,10 +1631,10 @@ func (s *xlStorage) CheckFile(ctx context.Context, volume string, path string) e
|
|||||||
if err := checkPathLength(filePath); err != nil {
|
if err := checkPathLength(filePath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
st, _ := Lstat(filePath)
|
st, _ := Lstat(filePath)
|
||||||
if st == nil {
|
if st == nil {
|
||||||
if !s.formatLegacy {
|
|
||||||
|
if !formatLegacy {
|
||||||
return errPathNotFound
|
return errPathNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1880,10 +1885,13 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath, dataDir,
|
|||||||
legacyPreserved = true
|
legacyPreserved = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
s.RLock()
|
||||||
|
formatLegacy := s.formatLegacy
|
||||||
|
s.RUnlock()
|
||||||
// It is possible that some drives may not have `xl.meta` file
|
// It is possible that some drives may not have `xl.meta` file
|
||||||
// in such scenarios verify if atleast `part.1` files exist
|
// in such scenarios verify if atleast `part.1` files exist
|
||||||
// to verify for legacy version.
|
// to verify for legacy version.
|
||||||
if s.formatLegacy {
|
if formatLegacy {
|
||||||
// We only need this code if we are moving
|
// We only need this code if we are moving
|
||||||
// from `xl.json` to `xl.meta`, we can avoid
|
// from `xl.json` to `xl.meta`, we can avoid
|
||||||
// one extra readdir operation here for all
|
// one extra readdir operation here for all
|
||||||
|
Loading…
x
Reference in New Issue
Block a user