Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@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 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
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 + * Copyright (c) 2012 by Delphix. All rights reserved.
23 24 */
24 25
25 26 /*
26 27 * This file is intended for functions that ought to be common between user
27 28 * land (libzfs) and the kernel. When many common routines need to be shared
28 29 * then a separate file should to be created.
29 30 */
30 31
31 32 #if defined(_KERNEL)
32 33 #include <sys/systm.h>
33 34 #else
34 35 #include <string.h>
35 36 #endif
36 37
37 38 #include <sys/types.h>
38 39 #include <sys/fs/zfs.h>
39 40 #include <sys/int_limits.h>
40 41 #include <sys/nvpair.h>
41 42 #include "zfs_comutil.h"
42 43
43 44 /*
44 45 * Are there allocatable vdevs?
45 46 */
46 47 boolean_t
47 48 zfs_allocatable_devs(nvlist_t *nv)
48 49 {
49 50 uint64_t is_log;
50 51 uint_t c;
51 52 nvlist_t **child;
52 53 uint_t children;
53 54
54 55 if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
55 56 &child, &children) != 0) {
56 57 return (B_FALSE);
57 58 }
58 59 for (c = 0; c < children; c++) {
59 60 is_log = 0;
60 61 (void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
61 62 &is_log);
62 63 if (!is_log)
63 64 return (B_TRUE);
64 65 }
65 66 return (B_FALSE);
66 67 }
67 68
68 69 void
69 70 zpool_get_rewind_policy(nvlist_t *nvl, zpool_rewind_policy_t *zrpp)
70 71 {
71 72 nvlist_t *policy;
72 73 nvpair_t *elem;
73 74 char *nm;
74 75
75 76 /* Defaults */
76 77 zrpp->zrp_request = ZPOOL_NO_REWIND;
77 78 zrpp->zrp_maxmeta = 0;
78 79 zrpp->zrp_maxdata = UINT64_MAX;
79 80 zrpp->zrp_txg = UINT64_MAX;
80 81
81 82 if (nvl == NULL)
82 83 return;
83 84
84 85 elem = NULL;
85 86 while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) {
86 87 nm = nvpair_name(elem);
87 88 if (strcmp(nm, ZPOOL_REWIND_POLICY) == 0) {
88 89 if (nvpair_value_nvlist(elem, &policy) == 0)
89 90 zpool_get_rewind_policy(policy, zrpp);
90 91 return;
91 92 } else if (strcmp(nm, ZPOOL_REWIND_REQUEST) == 0) {
92 93 if (nvpair_value_uint32(elem, &zrpp->zrp_request) == 0)
93 94 if (zrpp->zrp_request & ~ZPOOL_REWIND_POLICIES)
94 95 zrpp->zrp_request = ZPOOL_NO_REWIND;
95 96 } else if (strcmp(nm, ZPOOL_REWIND_REQUEST_TXG) == 0) {
96 97 (void) nvpair_value_uint64(elem, &zrpp->zrp_txg);
97 98 } else if (strcmp(nm, ZPOOL_REWIND_META_THRESH) == 0) {
98 99 (void) nvpair_value_uint64(elem, &zrpp->zrp_maxmeta);
99 100 } else if (strcmp(nm, ZPOOL_REWIND_DATA_THRESH) == 0) {
100 101 (void) nvpair_value_uint64(elem, &zrpp->zrp_maxdata);
101 102 }
102 103 }
103 104 if (zrpp->zrp_request == 0)
104 105 zrpp->zrp_request = ZPOOL_NO_REWIND;
105 106 }
106 107
107 108 typedef struct zfs_version_spa_map {
108 109 int version_zpl;
109 110 int version_spa;
110 111 } zfs_version_spa_map_t;
111 112
112 113 /*
113 114 * Keep this table in monotonically increasing version number order.
114 115 */
115 116 static zfs_version_spa_map_t zfs_version_table[] = {
116 117 {ZPL_VERSION_INITIAL, SPA_VERSION_INITIAL},
117 118 {ZPL_VERSION_DIRENT_TYPE, SPA_VERSION_INITIAL},
118 119 {ZPL_VERSION_FUID, SPA_VERSION_FUID},
119 120 {ZPL_VERSION_USERSPACE, SPA_VERSION_USERSPACE},
120 121 {ZPL_VERSION_SA, SPA_VERSION_SA},
121 122 {0, 0}
122 123 };
123 124
124 125 /*
125 126 * Return the max zpl version for a corresponding spa version
126 127 * -1 is returned if no mapping exists.
127 128 */
128 129 int
129 130 zfs_zpl_version_map(int spa_version)
130 131 {
131 132 int i;
132 133 int version = -1;
133 134
134 135 for (i = 0; zfs_version_table[i].version_spa; i++) {
135 136 if (spa_version >= zfs_version_table[i].version_spa)
136 137 version = zfs_version_table[i].version_zpl;
137 138 }
138 139
139 140 return (version);
140 141 }
141 142
142 143 /*
143 144 * Return the min spa version for a corresponding spa version
144 145 * -1 is returned if no mapping exists.
145 146 */
146 147 int
147 148 zfs_spa_version_map(int zpl_version)
148 149 {
149 150 int i;
↓ open down ↓ |
117 lines elided |
↑ open up ↑ |
150 151 int version = -1;
151 152
152 153 for (i = 0; zfs_version_table[i].version_zpl; i++) {
153 154 if (zfs_version_table[i].version_zpl >= zpl_version)
154 155 return (zfs_version_table[i].version_spa);
155 156 }
156 157
157 158 return (version);
158 159 }
159 160
160 -const char *zfs_history_event_names[LOG_END] = {
161 +/*
162 + * This is the table of legacy internal event names; it should not be modified.
163 + * The internal events are now stored in the history log as strings.
164 + */
165 +const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = {
161 166 "invalid event",
162 167 "pool create",
163 168 "vdev add",
164 169 "pool remove",
165 170 "pool destroy",
166 171 "pool export",
167 172 "pool import",
168 173 "vdev attach",
169 174 "vdev replace",
170 175 "vdev detach",
171 176 "vdev online",
172 177 "vdev offline",
173 178 "vdev upgrade",
174 179 "pool clear",
175 180 "pool scrub",
176 181 "pool property set",
177 182 "create",
178 183 "clone",
179 184 "destroy",
180 185 "destroy_begin_sync",
181 186 "inherit",
182 187 "property set",
183 188 "quota set",
184 189 "permission update",
185 190 "permission remove",
186 191 "permission who remove",
187 192 "promote",
188 193 "receive",
189 194 "rename",
190 195 "reservation set",
191 196 "replay_inc_sync",
192 197 "replay_full_sync",
193 198 "rollback",
194 199 "snapshot",
195 200 "filesystem version upgrade",
196 201 "refquota set",
197 202 "refreservation set",
198 203 "pool scrub done",
199 204 "user hold",
200 205 "user release",
201 206 "pool split",
202 207 };
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX