Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aio option when volume cache parameter is specified #115

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mtest/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ volumes:
name: raw-raw
size: 5G
format: raw
- kind: raw
name: raw-writeback
size: 5G
cache: writeback
- kind: @KIND_LV@
name: lv
size: 5G
Expand Down
11 changes: 8 additions & 3 deletions mtest/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ func TestVolume() {
Expect(err).To(Succeed())
})

By("writing to vde (raw volume, qcow2 format, cache=writeback)", func() {
_, _, err := execAt(node1, "sudo", "dd", "if=/dev/zero", "of=/dev/vde", "bs=1M", "count=1")
Expect(err).To(Succeed())
})

if vg != "" {
By("writing to vde (lv volume)", func() {
_, _, err := execAt(node1, "sudo", "dd", "if=/dev/zero", "of=/dev/vde", "bs=1M", "count=1")
By("writing to vdf (lv volume)", func() {
_, _, err := execAt(node1, "sudo", "dd", "if=/dev/zero", "of=/dev/vdf", "bs=1M", "count=1")
Expect(err).To(Succeed())
})
} else {
By("skipping test for vde (lv volume)")
By("skipping test for vdf (lv volume)")
}

By("terminating placemat", func() {
Expand Down
13 changes: 10 additions & 3 deletions node_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ const (
nodeVolumeFormatRaw = "raw"
)

func selectAIOforCache(cache string) string {
if cache == nodeVolumeCacheNone {
return "native"
}
return "threads"
}

type baseVolume struct {
name string
cache string
Expand All @@ -62,7 +69,7 @@ func volumePath(dataDir, name string) string {
func (v baseVolume) qemuArgs(p string) []string {
return []string{
"-drive",
fmt.Sprintf("if=virtio,cache=%s,aio=native,file=%s", v.cache, p),
fmt.Sprintf("if=virtio,cache=%s,aio=%s,file=%s", v.cache, selectAIOforCache(v.cache), p),
}
}

Expand Down Expand Up @@ -250,7 +257,7 @@ func (v *rawVolume) Create(ctx context.Context, dataDir string) ([]string, error
func (v *rawVolume) qemuArgs(p string) []string {
return []string{
"-drive",
fmt.Sprintf("if=virtio,cache=%s,aio=native,format=%s,file=%s", v.cache, v.format, p),
fmt.Sprintf("if=virtio,cache=%s,aio=%s,format=%s,file=%s", v.cache, selectAIOforCache(v.cache), v.format, p),
}
}

Expand Down Expand Up @@ -311,7 +318,7 @@ func (v *lvVolume) Create(ctx context.Context, dataDir string) ([]string, error)
func (v *lvVolume) qemuArgs(p string) []string {
return []string{
"-drive",
fmt.Sprintf("if=virtio,cache=%s,aio=native,format=raw,file=%s", v.cache, p),
fmt.Sprintf("if=virtio,cache=%s,aio=%s,format=raw,file=%s", v.cache, selectAIOforCache(v.cache), p),
}
}

Expand Down