projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '15430-fts-operator-removal' into main. Closes #15430
[arvados.git]
/
services
/
keepstore
/
volume.go
diff --git
a/services/keepstore/volume.go
b/services/keepstore/volume.go
index 9bfc6ca3e5191d2953ceac75f915a07cab19c69f..3f7c9cb79b4b24b71c3c441e49235fd657d77e69 100644
(file)
--- a/
services/keepstore/volume.go
+++ b/
services/keepstore/volume.go
@@
-344,11
+344,11
@@
func makeRRVolumeManager(logger logrus.FieldLogger, cluster *arvados.Cluster, my
vm.writables = append(vm.writables, mnt)
}
}
vm.writables = append(vm.writables, mnt)
}
}
- // pri(
i
): return highest priority of any storage class
- // offered by
vm.readables[i]
- pri := func(
i i
nt) int {
+ // pri(
mnt
): return highest priority of any storage class
+ // offered by
mnt
+ pri := func(
mnt *VolumeMou
nt) int {
any, best := false, 0
any, best := false, 0
- for class := range
vm.readables[i]
.KeepMount.StorageClasses {
+ for class := range
mnt
.KeepMount.StorageClasses {
if p := cluster.StorageClasses[class].Priority; !any || best < p {
best = p
any = true
if p := cluster.StorageClasses[class].Priority; !any || best < p {
best = p
any = true
@@
-356,14
+356,20
@@
func makeRRVolumeManager(logger logrus.FieldLogger, cluster *arvados.Cluster, my
}
return best
}
}
return best
}
- //
sort vm.readables,
first by highest priority of any offered
+ //
less(a,b): sort
first by highest priority of any offered
// storage class (highest->lowest), then by volume UUID
// storage class (highest->lowest), then by volume UUID
-
sort.Slice(vm.readables, func(i, j i
nt) bool {
- if p
i, pj := pri(i), pri(j); pi != pj
{
- return p
i > pj
+
less := func(a, b *VolumeMou
nt) bool {
+ if p
a, pb := pri(a), pri(b); pa != pb
{
+ return p
a > pb
} else {
} else {
- return
vm.readables[i].KeepMount.UUID < vm.readables[j]
.KeepMount.UUID
+ return
a.KeepMount.UUID < b
.KeepMount.UUID
}
}
+ }
+ sort.Slice(vm.readables, func(i, j int) bool {
+ return less(vm.readables[i], vm.readables[j])
+ })
+ sort.Slice(vm.writables, func(i, j int) bool {
+ return less(vm.writables[i], vm.writables[j])
})
return vm, nil
}
})
return vm, nil
}
@@
-384,18
+390,22
@@
func (vm *RRVolumeManager) AllReadable() []*VolumeMount {
return vm.readables
}
return vm.readables
}
-// AllWritable returns an array of all writable volumes
+// AllWritable returns writable volumes, sorted by priority/uuid. Used
+// by CompareAndTouch to ensure higher-priority volumes are checked
+// first.
func (vm *RRVolumeManager) AllWritable() []*VolumeMount {
return vm.writables
}
func (vm *RRVolumeManager) AllWritable() []*VolumeMount {
return vm.writables
}
-// NextWritable returns the next writable
-func (vm *RRVolumeManager) NextWritable() *VolumeMount {
+// NextWritable returns writable volumes, rotated by vm.counter so
+// each volume gets a turn to be first. Used by PutBlock to distribute
+// new data across available volumes.
+func (vm *RRVolumeManager) NextWritable() []*VolumeMount {
if len(vm.writables) == 0 {
return nil
}
if len(vm.writables) == 0 {
return nil
}
-
i := atomic.AddUint32(&vm.counter, 1
)
- return
vm.writables[i%uint32(len(vm.writables))]
+
offset := (int(atomic.AddUint32(&vm.counter, 1)) - 1) % len(vm.writables
)
+ return
append(append([]*VolumeMount(nil), vm.writables[offset:]...), vm.writables[:offset]...)
}
// VolumeStats returns an ioStats for the given volume.
}
// VolumeStats returns an ioStats for the given volume.