From 6e3701141bbfc4b10ea599889fc7fd058ff436a0 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 14 Feb 2018 12:52:04 -0600 Subject: [PATCH] [testing] use smaller filesize on 4KB pagesize systems Use a smaller filesize on systems that have a default 4KB pagesize. This is because mkfs.btrfs uses the default system pagesize as blocksize when creating a device, so if the pagesize is larger, then the file needs to be larger as well. This larger filesize is needed specifically for systems where 64KB is default, such as ppc64le. Signed-off-by: Christopher Jones --- snapshots/btrfs/btrfs_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/snapshots/btrfs/btrfs_test.go b/snapshots/btrfs/btrfs_test.go index 3ab1927d0..99e5e0726 100644 --- a/snapshots/btrfs/btrfs_test.go +++ b/snapshots/btrfs/btrfs_test.go @@ -29,7 +29,14 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snap return func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) { - deviceName, cleanupDevice, err := testutil.NewLoopback(650 << 20) // 650 MB + loopbackSize := int64(100 << 20) // 100 MB + // mkfs.btrfs creates a fs which has a blocksize equal to the system default pagesize. If that pagesize + // is > 4KB, mounting the fs will fail unless we increase the size of the file used by mkfs.btrfs + if os.Getpagesize() > 4096 { + loopbackSize = int64(650 << 20) // 650 MB + } + deviceName, cleanupDevice, err := testutil.NewLoopback(loopbackSize) + if err != nil { return nil, nil, err }