1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: LOLi <loli10K@users.noreply.github.com>
3 Date: Tue, 19 Dec 2017 19:49:33 +0100
4 Subject: [PATCH] ZTS: Fix create-o_ashift test case
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The function that fills the uberblock ring buffer on every device label
10 has been reworked to avoid occasional failures caused by a race
11 condition that prevents 'zpool sync' from writing some uberblock
12 sequentially: this happens when the pool sync ioctl dispatch code calls
13 txg_wait_synced() while we're already waiting for a TXG to sync.
15 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
16 Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
19 (cherry picked from commit 6c891ade8bee9c54484d5cf9b939582b7a9b7eeb)
20 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
22 cmd/zdb/zdb.c | 8 ++--
23 .../cli_root/zpool_create/create-o_ashift.ksh | 47 ++++++++++------------
24 2 files changed, 26 insertions(+), 29 deletions(-)
26 diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
27 index 1097501e8..442685486 100644
30 @@ -2716,10 +2716,6 @@ dump_label(const char *dev)
34 - if (ioctl(fd, BLKFLSBUF) != 0)
35 - (void) printf("failed to invalidate cache '%s' : %s\n", path,
38 if (fstat64_blk(fd, &statbuf) != 0) {
39 (void) printf("failed to stat '%s': %s\n", path,
41 @@ -2727,6 +2723,10 @@ dump_label(const char *dev)
45 + if (S_ISBLK(statbuf.st_mode) && ioctl(fd, BLKFLSBUF) != 0)
46 + (void) printf("failed to invalidate cache '%s' : %s\n", path,
49 avl_create(&config_tree, cksum_record_compare,
50 sizeof (cksum_record_t), offsetof(cksum_record_t, link));
51 avl_create(&uberblock_tree, cksum_record_compare,
52 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh
53 index 6449c8a91..6a9c3e28c 100755
54 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh
55 +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh
56 @@ -44,47 +44,45 @@ verify_runnable "global"
60 - poolexists $TESTPOOL && destroy_pool $TESTPOOL
61 + destroy_pool $TESTPOOL
66 -# Commit the specified number of TXGs to the provided pool
67 -# We use 'zpool sync' here because we can't force it via sync(1) like on illumos
69 -# $2 number of txg syncs
70 +# Fill the uberblock ring in every <device> label: we do this by committing
71 +# TXGs to the provided <pool> until every slot contains a valid uberblock.
72 +# NOTE: We use 'zpool sync' here because we can't force it via sync(1) like on
76 +function write_device_uberblocks # <device> <pool>
84 - while [ $i -lt $count ]
85 + while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ]
87 - log_must sync_pool $pool true
89 + sync_pool $pool true
94 -# Verify device $1 labels contains $2 valid uberblocks in every label
96 -# $2 uberblocks count
97 +# Verify every label on <device> contains <count> (valid) uberblocks
99 -function verify_device_uberblocks
100 +function verify_device_uberblocks # <device> <count>
105 zdb -quuul $device | egrep '^(\s+)?Uberblock' |
106 - egrep -v 'invalid$' | awk \
107 - -v ubcount=$ubcount '{ uberblocks[$0]++; }
108 - END { for (i in uberblocks) {
110 - if (uberblocks[i] != 4) { exit 1; }
112 - if (count != ubcount) { exit 1; } }'
113 + awk -v ubcount=$ubcount 'BEGIN { count=0 } { uberblocks[$0]++; }
115 + for (i in uberblocks) {
116 + if (i ~ /invalid/) { continue; }
117 + if (uberblocks[i] != 4) { exit 1; }
120 + if (count != ubcount) { exit 1; }
125 @@ -110,8 +108,7 @@ do
126 log_fail "Pool was created without setting ashift value to "\
127 "$ashift (current = $pprop)"
129 - # force 128 txg sync to fill the uberblock ring
130 - txg_sync $TESTPOOL 128
131 + write_device_uberblocks $disk $TESTPOOL
132 verify_device_uberblocks $disk ${ubcount[$i]}