]>
Commit | Line | Data |
---|---|---|
75b07eca FG |
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 | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
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. | |
14 | ||
15 | Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
16 | Signed-off-by: loli10K <ezomori.nozomu@gmail.com> | |
17 | Closes #6924 | |
18 | Closes #6977 | |
19 | (cherry picked from commit 6c891ade8bee9c54484d5cf9b939582b7a9b7eeb) | |
20 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
21 | --- | |
22 | cmd/zdb/zdb.c | 8 ++-- | |
23 | .../cli_root/zpool_create/create-o_ashift.ksh | 47 ++++++++++------------ | |
24 | 2 files changed, 26 insertions(+), 29 deletions(-) | |
25 | ||
26 | diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c | |
27 | index 1097501e8..442685486 100644 | |
28 | --- a/cmd/zdb/zdb.c | |
29 | +++ b/cmd/zdb/zdb.c | |
30 | @@ -2716,10 +2716,6 @@ dump_label(const char *dev) | |
31 | exit(1); | |
32 | } | |
33 | ||
34 | - if (ioctl(fd, BLKFLSBUF) != 0) | |
35 | - (void) printf("failed to invalidate cache '%s' : %s\n", path, | |
36 | - strerror(errno)); | |
37 | - | |
38 | if (fstat64_blk(fd, &statbuf) != 0) { | |
39 | (void) printf("failed to stat '%s': %s\n", path, | |
40 | strerror(errno)); | |
41 | @@ -2727,6 +2723,10 @@ dump_label(const char *dev) | |
42 | exit(1); | |
43 | } | |
44 | ||
45 | + if (S_ISBLK(statbuf.st_mode) && ioctl(fd, BLKFLSBUF) != 0) | |
46 | + (void) printf("failed to invalidate cache '%s' : %s\n", path, | |
47 | + strerror(errno)); | |
48 | + | |
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" | |
57 | ||
58 | function cleanup | |
59 | { | |
60 | - poolexists $TESTPOOL && destroy_pool $TESTPOOL | |
61 | + destroy_pool $TESTPOOL | |
62 | log_must rm -f $disk | |
63 | } | |
64 | ||
65 | # | |
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 | |
68 | -# $1 pool name | |
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 | |
73 | +# illumos | |
74 | # | |
75 | -function txg_sync | |
76 | +function write_device_uberblocks # <device> <pool> | |
77 | { | |
78 | - typeset pool=$1 | |
79 | - typeset -i count=$2 | |
80 | - typeset -i i=0; | |
81 | + typeset device=$1 | |
82 | + typeset pool=$2 | |
83 | ||
84 | - while [ $i -lt $count ] | |
85 | + while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ] | |
86 | do | |
87 | - log_must sync_pool $pool true | |
88 | - ((i = i + 1)) | |
89 | + sync_pool $pool true | |
90 | done | |
91 | } | |
92 | ||
93 | # | |
94 | -# Verify device $1 labels contains $2 valid uberblocks in every label | |
95 | -# $1 device | |
96 | -# $2 uberblocks count | |
97 | +# Verify every label on <device> contains <count> (valid) uberblocks | |
98 | # | |
99 | -function verify_device_uberblocks | |
100 | +function verify_device_uberblocks # <device> <count> | |
101 | { | |
102 | typeset device=$1 | |
103 | typeset ubcount=$2 | |
104 | ||
105 | zdb -quuul $device | egrep '^(\s+)?Uberblock' | | |
106 | - egrep -v 'invalid$' | awk \ | |
107 | - -v ubcount=$ubcount '{ uberblocks[$0]++; } | |
108 | - END { for (i in uberblocks) { | |
109 | - count++; | |
110 | - if (uberblocks[i] != 4) { exit 1; } | |
111 | - } | |
112 | - if (count != ubcount) { exit 1; } }' | |
113 | + awk -v ubcount=$ubcount 'BEGIN { count=0 } { uberblocks[$0]++; } | |
114 | + END { | |
115 | + for (i in uberblocks) { | |
116 | + if (i ~ /invalid/) { continue; } | |
117 | + if (uberblocks[i] != 4) { exit 1; } | |
118 | + count++; | |
119 | + } | |
120 | + if (count != ubcount) { exit 1; } | |
121 | + }' | |
122 | ||
123 | return $? | |
124 | } | |
125 | @@ -110,8 +108,7 @@ do | |
126 | log_fail "Pool was created without setting ashift value to "\ | |
127 | "$ashift (current = $pprop)" | |
128 | fi | |
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]} | |
133 | if [[ $? -ne 0 ]] | |
134 | then | |
135 | -- | |
136 | 2.14.2 | |
137 |