Print this page
NEX-4649 zpool create <name> special <disk> command hangs
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@gmail.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/common/zfs/zfs_comutil.c
+++ new/usr/src/common/zfs/zfs_comutil.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 24 */
25 25
26 26 /*
27 27 * This file is intended for functions that ought to be common between user
28 28 * land (libzfs) and the kernel. When many common routines need to be shared
29 29 * then a separate file should to be created.
30 30 */
31 31
32 32 #if defined(_KERNEL)
33 33 #include <sys/systm.h>
34 34 #else
35 35 #include <string.h>
|
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
36 36 #endif
37 37
38 38 #include <sys/types.h>
39 39 #include <sys/fs/zfs.h>
40 40 #include <sys/int_limits.h>
41 41 #include <sys/nvpair.h>
42 42 #include "zfs_comutil.h"
43 43
44 44 /*
45 45 * Are there allocatable vdevs?
46 + * Any pool must have at least one normal (metaslab) class vdev, which means:
47 + * at least one that is simultaneously non-slog and non-special
46 48 */
47 49 boolean_t
48 50 zfs_allocatable_devs(nvlist_t *nv)
49 51 {
50 - uint64_t is_log;
52 + uint64_t is_log, is_special;
51 53 uint_t c;
52 54 nvlist_t **child;
53 55 uint_t children;
54 56
55 57 if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
56 58 &child, &children) != 0) {
57 59 return (B_FALSE);
58 60 }
59 61 for (c = 0; c < children; c++) {
60 - is_log = 0;
62 + is_log = is_special = 0;
61 63 (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
62 64 &is_log);
63 - if (!is_log)
65 + (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_SPECIAL,
66 + &is_special);
67 + if (!is_log && !is_special)
64 68 return (B_TRUE);
65 69 }
66 70 return (B_FALSE);
67 71 }
68 72
69 73 void
70 74 zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
71 75 {
72 76 nvlist_t *policy;
73 77 nvpair_t *elem;
74 78 char *nm;
75 79
76 80 /* Defaults */
77 81 zrpp->zrp_request = ZPOOL_NO_REWIND;
78 82 zrpp->zrp_maxmeta = 0;
79 83 zrpp->zrp_maxdata = UINT64_MAX;
80 84 zrpp->zrp_txg = UINT64_MAX;
81 85
82 86 if (nvl == NULL)
83 87 return;
84 88
85 89 elem = NULL;
86 90 while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) {
87 91 nm = nvpair_name(elem);
88 92 if (strcmp(nm, ZPOOL_REWIND_POLICY) == 0) {
89 93 if (nvpair_value_nvlist(elem, &policy) == 0)
90 94 zpool_get_rewind_policy(policy, zrpp);
91 95 return;
92 96 } else if (strcmp(nm, ZPOOL_REWIND_REQUEST) == 0) {
93 97 if (nvpair_value_uint32(elem, &zrpp->zrp_request) == 0)
94 98 if (zrpp->zrp_request & ~ZPOOL_REWIND_POLICIES)
95 99 zrpp->zrp_request = ZPOOL_NO_REWIND;
96 100 } else if (strcmp(nm, ZPOOL_REWIND_REQUEST_TXG) == 0) {
97 101 (void) nvpair_value_uint64(elem, &zrpp->zrp_txg);
98 102 } else if (strcmp(nm, ZPOOL_REWIND_META_THRESH) == 0) {
99 103 (void) nvpair_value_uint64(elem, &zrpp->zrp_maxmeta);
100 104 } else if (strcmp(nm, ZPOOL_REWIND_DATA_THRESH) == 0) {
101 105 (void) nvpair_value_uint64(elem, &zrpp->zrp_maxdata);
102 106 }
103 107 }
104 108 if (zrpp->zrp_request == 0)
105 109 zrpp->zrp_request = ZPOOL_NO_REWIND;
106 110 }
107 111
108 112 typedef struct zfs_version_spa_map {
109 113 int version_zpl;
110 114 int version_spa;
111 115 } zfs_version_spa_map_t;
112 116
113 117 /*
114 118 * Keep this table in monotonically increasing version number order.
115 119 */
116 120 static zfs_version_spa_map_t zfs_version_table[] = {
117 121 {ZPL_VERSION_INITIAL, SPA_VERSION_INITIAL},
118 122 {ZPL_VERSION_DIRENT_TYPE, SPA_VERSION_INITIAL},
119 123 {ZPL_VERSION_FUID, SPA_VERSION_FUID},
120 124 {ZPL_VERSION_USERSPACE, SPA_VERSION_USERSPACE},
121 125 {ZPL_VERSION_SA, SPA_VERSION_SA},
122 126 {0, 0}
123 127 };
124 128
125 129 /*
126 130 * Return the max zpl version for a corresponding spa version
127 131 * -1 is returned if no mapping exists.
128 132 */
129 133 int
130 134 zfs_zpl_version_map(int spa_version)
131 135 {
132 136 int i;
133 137 int version = -1;
134 138
135 139 for (i = 0; zfs_version_table[i].version_spa; i++) {
136 140 if (spa_version >= zfs_version_table[i].version_spa)
137 141 version = zfs_version_table[i].version_zpl;
138 142 }
139 143
140 144 return (version);
141 145 }
142 146
143 147 /*
144 148 * Return the min spa version for a corresponding spa version
145 149 * -1 is returned if no mapping exists.
146 150 */
147 151 int
148 152 zfs_spa_version_map(int zpl_version)
149 153 {
150 154 int i;
151 155 int version = -1;
152 156
153 157 for (i = 0; zfs_version_table[i].version_zpl; i++) {
154 158 if (zfs_version_table[i].version_zpl >= zpl_version)
155 159 return (zfs_version_table[i].version_spa);
156 160 }
157 161
158 162 return (version);
159 163 }
160 164
161 165 /*
162 166 * This is the table of legacy internal event names; it should not be modified.
163 167 * The internal events are now stored in the history log as strings.
164 168 */
165 169 const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = {
166 170 "invalid event",
167 171 "pool create",
168 172 "vdev add",
169 173 "pool remove",
170 174 "pool destroy",
171 175 "pool export",
172 176 "pool import",
173 177 "vdev attach",
174 178 "vdev replace",
175 179 "vdev detach",
176 180 "vdev online",
177 181 "vdev offline",
178 182 "vdev upgrade",
179 183 "pool clear",
180 184 "pool scrub",
181 185 "pool property set",
182 186 "create",
183 187 "clone",
184 188 "destroy",
185 189 "destroy_begin_sync",
186 190 "inherit",
187 191 "property set",
188 192 "quota set",
189 193 "permission update",
190 194 "permission remove",
191 195 "permission who remove",
192 196 "promote",
193 197 "receive",
194 198 "rename",
195 199 "reservation set",
196 200 "replay_inc_sync",
197 201 "replay_full_sync",
198 202 "rollback",
199 203 "snapshot",
200 204 "filesystem version upgrade",
201 205 "refquota set",
202 206 "refreservation set",
203 207 "pool scrub done",
204 208 "user hold",
205 209 "user release",
206 210 "pool split",
207 211 };
|
↓ open down ↓ |
134 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX