]>
Commit | Line | Data |
---|---|---|
75b07eca FG |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Chunwei Chen <david.chen@nutanix.com> | |
3 | Date: Thu, 1 Feb 2018 15:42:41 -0800 | |
4 | Subject: [PATCH] Fix racy assignment of zcb.zcb_haderrors | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | zcb_haderrors will be modified in zdb_blkptr_done, which is | |
10 | asynchronous. So we must move this assignment after zio_wait. | |
11 | ||
12 | Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
13 | Reviewed-by: loli10K <ezomori.nozomu@gmail.com> | |
14 | Signed-off-by: Chunwei Chen <david.chen@nutanix.com> | |
15 | Closes #7099 | |
16 | (cherry picked from commit c797f0898ec11669427e2fc481118bc2e2d8ef3f) | |
17 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
18 | --- | |
19 | cmd/zdb/zdb.c | 10 ++++++++-- | |
20 | 1 file changed, 8 insertions(+), 2 deletions(-) | |
21 | ||
22 | diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c | |
23 | index 442685486..0cc1656a8 100644 | |
24 | --- a/cmd/zdb/zdb.c | |
25 | +++ b/cmd/zdb/zdb.c | |
26 | @@ -3313,7 +3313,7 @@ dump_block_stats(spa_t *spa) | |
27 | uint64_t norm_alloc, norm_space, total_alloc, total_found; | |
28 | int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD; | |
29 | boolean_t leaks = B_FALSE; | |
30 | - int e, c; | |
31 | + int e, c, err; | |
32 | bp_embedded_type_t i; | |
33 | ||
34 | (void) printf("\nTraversing all blocks %s%s%s%s%s...\n\n", | |
35 | @@ -3354,7 +3354,7 @@ dump_block_stats(spa_t *spa) | |
36 | ||
37 | zcb.zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa)); | |
38 | zcb.zcb_start = zcb.zcb_lastprint = gethrtime(); | |
39 | - zcb.zcb_haderrors |= traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb); | |
40 | + err = traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb); | |
41 | ||
42 | /* | |
43 | * If we've traversed the data blocks then we need to wait for those | |
44 | @@ -3370,6 +3370,12 @@ dump_block_stats(spa_t *spa) | |
45 | } | |
46 | } | |
47 | ||
48 | + /* | |
49 | + * Done after zio_wait() since zcb_haderrors is modified in | |
50 | + * zdb_blkptr_done() | |
51 | + */ | |
52 | + zcb.zcb_haderrors |= err; | |
53 | + | |
54 | if (zcb.zcb_haderrors) { | |
55 | (void) printf("\nError counts:\n\n"); | |
56 | (void) printf("\t%5s %s\n", "errno", "count"); | |
57 | -- | |
58 | 2.14.2 | |
59 |