diff --git a/go.mod b/go.mod index 97d8b22a..5ca63eda 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.22.0 toolchain go1.23.1 +replace github.com/longhorn/go-spdk-helper => github.com/shuo-wu/go-spdk-helper v0.0.0-20240927003316-38f51a815d5e + require ( github.com/0xPolygon/polygon-edge v1.3.3 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index 2696d7a4..7d6bc60b 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,6 @@ github.com/longhorn/backupstore v0.0.0-20240922062439-e33cb1230db9 h1:ua4PCfArX2 github.com/longhorn/backupstore v0.0.0-20240922062439-e33cb1230db9/go.mod h1:UTONYTgRryrw0RgDZbxwU+r1s4PeKQ+v0Z8Pb6jUWn4= github.com/longhorn/go-common-libs v0.0.0-20240921050101-797b589b669d h1:MXJlzyXLptspJEc1UC7ee2eBIYksTl0RT2bXUAXU+8Q= github.com/longhorn/go-common-libs v0.0.0-20240921050101-797b589b669d/go.mod h1:L8QlyY7cqL84FcxnJ8HK6DaQ1Ej9JiZtZ94OW5W+Yyw= -github.com/longhorn/go-spdk-helper v0.0.0-20240922062342-22115a91cbe9 h1:DVYw6dzssMcCOAQSqXLVJIQQiKdZD7lAKfnU2ZTf4Mo= -github.com/longhorn/go-spdk-helper v0.0.0-20240922062342-22115a91cbe9/go.mod h1:pKbJjuJN69T+qDaJIkR1NcpGqCzj/vGv1NTTDiaE5s0= github.com/longhorn/types v0.0.0-20240902072916-1bf23d310acb h1:8CoW5YYn+SC43o5zFR+wscOd3SgF6rQZjrkXOkJfZPM= github.com/longhorn/types v0.0.0-20240902072916-1bf23d310acb/go.mod h1:KlJuZB8NfHchWshYxYgV9pPIxBKC04Vq05G2TfgMf7w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -90,6 +88,8 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= +github.com/shuo-wu/go-spdk-helper v0.0.0-20240927003316-38f51a815d5e h1:VC65DWcZ1sEXpVDd1hqQbPm6RAOSgPjr1z4+k67P1ZU= +github.com/shuo-wu/go-spdk-helper v0.0.0-20240927003316-38f51a815d5e/go.mod h1:pKbJjuJN69T+qDaJIkR1NcpGqCzj/vGv1NTTDiaE5s0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/slok/goresilience v0.2.0 h1:dagdIiWlhTm7BK/r/LRKz+zvw0SCNk+nHf7obdsbzxQ= diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go index 4bba39c1..96e35202 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/client/basic.go @@ -250,6 +250,19 @@ func (c *Client) BdevLvolDelete(name string) (deleted bool, err error) { // // "timeout": Optional. 0 by default, meaning the method returns immediately whether the lvol bdev exists or not. func (c *Client) BdevLvolGet(name string, timeout uint64) (bdevLvolInfoList []spdktypes.BdevInfo, err error) { + return c.BdevLvolGetWithFilter(name, timeout, func(*spdktypes.BdevInfo) bool { return true }) +} + +// BdevLvolGetWithFilter gets information about some specific lvol bdevs. +// +// "name": Optional. UUID or alias of a logical volume (lvol) bdev. +// The alias of a lvol bdev is /. And the name of a lvol bdev is UUID. +// If this is not specified, the function will list all lvol bdevs. +// +// "timeout": Optional. 0 by default, meaning the method returns immediately whether the lvol bdev exists or not. +// +// "filter": Only the lvol bdevs that pass the filter will be returned. +func (c *Client) BdevLvolGetWithFilter(name string, timeout uint64, filter func(*spdktypes.BdevInfo) bool) (bdevLvolInfoList []spdktypes.BdevInfo, err error) { req := spdktypes.BdevGetBdevsRequest{ Name: name, Timeout: timeout, @@ -269,7 +282,9 @@ func (c *Client) BdevLvolGet(name string, timeout uint64) (bdevLvolInfoList []sp if spdktypes.GetBdevType(&b) != spdktypes.BdevTypeLvol { continue } - + if !filter(&b) { + continue + } b.DriverSpecific.Lvol.Xattrs = make(map[string]string) user_created, err := c.BdevLvolGetXattr(b.Name, UserCreated) if err == nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index ea92318e..e9afc0d6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -64,7 +64,7 @@ github.com/longhorn/go-common-libs/sync github.com/longhorn/go-common-libs/sys github.com/longhorn/go-common-libs/types github.com/longhorn/go-common-libs/utils -# github.com/longhorn/go-spdk-helper v0.0.0-20240922062342-22115a91cbe9 +# github.com/longhorn/go-spdk-helper v0.0.0-20240922062342-22115a91cbe9 => github.com/shuo-wu/go-spdk-helper v0.0.0-20240927003316-38f51a815d5e ## explicit; go 1.22.0 github.com/longhorn/go-spdk-helper/pkg/jsonrpc github.com/longhorn/go-spdk-helper/pkg/nvme @@ -304,3 +304,4 @@ k8s.io/utils/internal/third_party/forked/golang/net k8s.io/utils/io k8s.io/utils/keymutex k8s.io/utils/net +# github.com/longhorn/go-spdk-helper => github.com/shuo-wu/go-spdk-helper v0.0.0-20240927003316-38f51a815d5e