Skip to content

Commit

Permalink
Fix aio option when volume cache parameter is specified
Browse files Browse the repository at this point in the history
Signed-off-by: Daichi Sakaue <daichi-sakaue@cybozu.co.jp>
  • Loading branch information
yokaze committed Jul 21, 2020
1 parent be63dbd commit 80f8cdf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
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

0 comments on commit 80f8cdf

Please sign in to comment.