diff --git a/lxd/storage_volumes.go b/lxd/storage_volumes.go index ee186047d196..2cf8b9c791c4 100644 --- a/lxd/storage_volumes.go +++ b/lxd/storage_volumes.go @@ -688,29 +688,21 @@ func storagePoolVolumesGet(d *Daemon, r *http.Request) response.Response { } if allPools { - poolNames, err := tx.GetStoragePoolNames(ctx) + dbVolumes, err = tx.GetStoragePoolVolumes(ctx, memberSpecific, filters...) if err != nil { - return fmt.Errorf("Failed to get storage volumes: %w", err) - } - - for _, pool := range poolNames { - poolID, err := tx.GetStoragePoolID(ctx, pool) - if err != nil { - return fmt.Errorf("Failed to get storage volumes: %w", err) - } - - poolVolumes, err := tx.GetStoragePoolVolumes(ctx, poolID, memberSpecific, filters...) - if err != nil { - return fmt.Errorf("Failed loading storage volumes: %w", err) - } - - dbVolumes = append(dbVolumes, poolVolumes...) + return fmt.Errorf("Failed loading storage volumes: %w", err) } return err } - dbVolumes, err = tx.GetStoragePoolVolumes(ctx, poolID, memberSpecific, filters...) + poolFilter := db.StorageVolumeFilter{ + PoolID: &poolID, + } + + filters = append(filters, poolFilter) + + dbVolumes, err = tx.GetStoragePoolVolumes(ctx, memberSpecific, filters...) if err != nil { return fmt.Errorf("Failed loading storage volumes: %w", err) }