diff options
Diffstat (limited to 'weed/storage')
| -rw-r--r-- | weed/storage/disk_location_ec.go | 8 | ||||
| -rw-r--r-- | weed/storage/erasure_coding/ec_volume.go | 7 | ||||
| -rw-r--r-- | weed/storage/store.go | 10 | ||||
| -rw-r--r-- | weed/storage/store_ec.go | 6 | ||||
| -rw-r--r-- | weed/storage/volume.go | 2 | ||||
| -rw-r--r-- | weed/storage/volume_vacuum.go | 3 |
6 files changed, 19 insertions, 17 deletions
diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go index 3f56d797b..5fa5316fd 100644 --- a/weed/storage/disk_location_ec.go +++ b/weed/storage/disk_location_ec.go @@ -2,10 +2,10 @@ package storage import ( "fmt" + "golang.org/x/exp/slices" "os" "path" "regexp" - "sort" "strconv" "github.com/chrislusf/seaweedfs/weed/storage/erasure_coding" @@ -128,11 +128,9 @@ func (l *DiskLocation) loadAllEcShards() (err error) { } dirEntries = append(dirEntries, indexDirEntries...) } - - sort.Slice(dirEntries, func(i, j int) bool { - return dirEntries[i].Name() < dirEntries[j].Name() + slices.SortFunc(dirEntries, func(a, b os.DirEntry) bool { + return a.Name() < b.Name() }) - var sameVolumeShards []string var prevVolumeId needle.VolumeId for _, fileInfo := range dirEntries { diff --git a/weed/storage/erasure_coding/ec_volume.go b/weed/storage/erasure_coding/ec_volume.go index f4cde310f..4dd07ec40 100644 --- a/weed/storage/erasure_coding/ec_volume.go +++ b/weed/storage/erasure_coding/ec_volume.go @@ -5,9 +5,9 @@ import ( "fmt" "github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/storage/volume_info" + "golang.org/x/exp/slices" "math" "os" - "sort" "sync" "time" @@ -82,9 +82,8 @@ func (ev *EcVolume) AddEcVolumeShard(ecVolumeShard *EcVolumeShard) bool { } } ev.Shards = append(ev.Shards, ecVolumeShard) - sort.Slice(ev.Shards, func(i, j int) bool { - return ev.Shards[i].VolumeId < ev.Shards[j].VolumeId || - ev.Shards[i].VolumeId == ev.Shards[j].VolumeId && ev.Shards[i].ShardId < ev.Shards[j].ShardId + slices.SortFunc(ev.Shards, func(a, b *EcVolumeShard) bool { + return a.VolumeId < b.VolumeId || a.VolumeId == b.VolumeId && a.ShardId < b.ShardId }) return true } diff --git a/weed/storage/store.go b/weed/storage/store.go index 30fe63b63..fa2897fbc 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -434,10 +434,13 @@ func (s *Store) UnmountVolume(i needle.VolumeId) error { } for _, location := range s.Locations { - if err := location.UnloadVolume(i); err == nil || err == ErrVolumeNotFound { + err := location.UnloadVolume(i) + if err == nil { glog.V(0).Infof("UnmountVolume %d", i) s.DeletedVolumesChan <- message return nil + } else if err == ErrVolumeNotFound { + continue } } @@ -458,10 +461,13 @@ func (s *Store) DeleteVolume(i needle.VolumeId) error { DiskType: string(v.location.DiskType), } for _, location := range s.Locations { - if err := location.DeleteVolume(i); err == nil || err == ErrVolumeNotFound { + err := location.DeleteVolume(i) + if err == nil { glog.V(0).Infof("DeleteVolume %d", i) s.DeletedVolumesChan <- message return nil + } else if err == ErrVolumeNotFound { + continue } else { glog.Errorf("DeleteVolume %d: %v", i, err) } diff --git a/weed/storage/store_ec.go b/weed/storage/store_ec.go index 70e1593a0..0c9de45aa 100644 --- a/weed/storage/store_ec.go +++ b/weed/storage/store_ec.go @@ -4,9 +4,9 @@ import ( "context" "fmt" "github.com/chrislusf/seaweedfs/weed/pb" + "golang.org/x/exp/slices" "io" "os" - "sort" "sync" "time" @@ -389,8 +389,8 @@ func (s *Store) EcVolumes() (ecVolumes []*erasure_coding.EcVolume) { } location.ecVolumesLock.RUnlock() } - sort.Slice(ecVolumes, func(i, j int) bool { - return ecVolumes[i].VolumeId > ecVolumes[j].VolumeId + slices.SortFunc(ecVolumes, func(a, b *erasure_coding.EcVolume) bool { + return a.VolumeId > b.VolumeId }) return ecVolumes } diff --git a/weed/storage/volume.go b/weed/storage/volume.go index 14bc5f22d..6d48fbc83 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -260,7 +260,7 @@ func (v *Volume) collectStatus() (maxFileKey types.NeedleId, datFileSize int64, defer v.dataFileAccessLock.RUnlock() glog.V(3).Infof("collectStatus volume %d", v.Id) - if v.nm == nil { + if v.nm == nil || v.DataBackend == nil { return } diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go index 06de181b5..7651420aa 100644 --- a/weed/storage/volume_vacuum.go +++ b/weed/storage/volume_vacuum.go @@ -438,8 +438,7 @@ func copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, datIdxName str } n := new(needle.Needle) - err := n.ReadData(srcDatBackend, offset.ToActualOffset(), size, version) - if err != nil { + if err := n.ReadData(srcDatBackend, offset.ToActualOffset(), size, version); err != nil { return fmt.Errorf("cannot hydrate needle from file: %s", err) } |
