Skip to content

Commit

Permalink
disk: support different drivers
Browse files Browse the repository at this point in the history
Longhorn 7672

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Mar 27, 2024
1 parent 22b71b7 commit b486190
Show file tree
Hide file tree
Showing 12 changed files with 745 additions and 105 deletions.
1 change: 1 addition & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func ProtoEngineToEngine(e *spdkrpc.Engine) *Engine {

type DiskInfo struct {
ID string
Name string
UUID string
Path string
Type string
Expand Down
25 changes: 15 additions & 10 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func (c *SPDKClient) ReplicaRestoreStatus(replicaName string) (*spdkrpc.ReplicaR

// DiskCreate creates a disk with the given name and path.
// diskUUID is optional, if not provided, it indicates the disk is newly added.
func (c *SPDKClient) DiskCreate(diskName, diskUUID, diskPath string, blockSize int64) (*spdkrpc.Disk, error) {
func (c *SPDKClient) DiskCreate(diskName, diskUUID, diskPath, diskDriver string, blockSize int64) (*spdkrpc.Disk, error) {
if diskName == "" || diskPath == "" {
return nil, fmt.Errorf("failed to create disk: missing required parameters")
}
Expand All @@ -695,14 +695,15 @@ func (c *SPDKClient) DiskCreate(diskName, diskUUID, diskPath string, blockSize i
defer cancel()

return client.DiskCreate(ctx, &spdkrpc.DiskCreateRequest{
DiskName: diskName,
DiskUuid: diskUUID,
DiskPath: diskPath,
BlockSize: blockSize,
DiskName: diskName,
DiskUuid: diskUUID,
DiskPath: diskPath,
BlockSize: blockSize,
DiskDriver: diskDriver,
})
}

func (c *SPDKClient) DiskGet(diskName string) (*spdkrpc.Disk, error) {
func (c *SPDKClient) DiskGet(diskName, diskPath, diskDriver string) (*spdkrpc.Disk, error) {
if diskName == "" {
return nil, fmt.Errorf("failed to get disk info: missing required parameter")
}
Expand All @@ -712,11 +713,13 @@ func (c *SPDKClient) DiskGet(diskName string) (*spdkrpc.Disk, error) {
defer cancel()

return client.DiskGet(ctx, &spdkrpc.DiskGetRequest{
DiskName: diskName,
DiskName: diskName,
DiskPath: diskPath,
DiskDriver: diskDriver,
})
}

func (c *SPDKClient) DiskDelete(diskName, diskUUID string) error {
func (c *SPDKClient) DiskDelete(diskName, diskUUID, diskPath, diskDriver string) error {
if diskName == "" || diskUUID == "" {
return fmt.Errorf("failed to delete disk: missing required parameters")
}
Expand All @@ -726,8 +729,10 @@ func (c *SPDKClient) DiskDelete(diskName, diskUUID string) error {
defer cancel()

_, err := client.DiskDelete(ctx, &spdkrpc.DiskDeleteRequest{
DiskName: diskName,
DiskUuid: diskUUID,
DiskName: diskName,
DiskUuid: diskUUID,
DiskPath: diskPath,
DiskDriver: diskDriver,
})
return err
}
Expand Down
Loading

0 comments on commit b486190

Please sign in to comment.