Files
seaweedfs/seaweed-block/cmd/blockvolume/nvme_controller_id.go
T
Ping Qiu 6dd9dc33e2 docs: close iSCSI/NVMe protocol readiness plan (#44)
Close the current protocol-readiness plan and move active work to V2 parity and hardening.

The release gate now covers iSCSI ALUA/failover, NVMe ANA/multipath/failover, CSI protocol selection, and the iSCSI compatibility soak. Test layering is documented so default Go tests stay unit/component scoped, local subprocess tests are opt-in, and Linux lab coverage remains in runner-native TestOps suites.
2026-05-09 11:34:39 -07:00

42 lines
756 B
Go

package main
import (
"hash/fnv"
"strconv"
)
const maxNVMeControllerID uint32 = 0xffef
func nvmeControllerIDFromReplicaID(replicaID string) uint16 {
if n, ok := trailingDecimal(replicaID); ok {
if n == 0 {
return 1
}
if n > uint64(maxNVMeControllerID) {
n = uint64(maxNVMeControllerID)
}
return uint16(n)
}
h := fnv.New32a()
_, _ = h.Write([]byte(replicaID))
return uint16(h.Sum32()%maxNVMeControllerID + 1)
}
func trailingDecimal(s string) (uint64, bool) {
if s == "" {
return 0, false
}
start := len(s)
for start > 0 && s[start-1] >= '0' && s[start-1] <= '9' {
start--
}
if start == len(s) {
return 0, false
}
n, err := strconv.ParseUint(s[start:], 10, 64)
if err != nil {
return 0, false
}
return n, true
}