Print this page
NEX-9755 Race in libshare can cause zfs set sharenfs to fail
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/libshare/common/libshare_impl.h
+++ new/usr/src/lib/libshare/common/libshare_impl.h
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 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 * Copyright (c) 2016 by Delphix. All rights reserved.
26 26 */
27 27
28 28 /*
29 29 * basic declarations for implementation of the share management
30 30 * libraries.
31 31 */
32 32
33 33 #ifndef _LIBSHARE_IMPL_H
34 34 #define _LIBSHARE_IMPL_H
35 35
36 36 #include <libshare.h>
37 37 #include <libscf.h>
38 38 #include <scfutil.h>
39 39 #include <libzfs.h>
40 40 #include <sharefs/share.h>
41 41 #include <sharefs/sharetab.h>
42 42
43 43 #ifdef __cplusplus
44 44 extern "C" {
45 45 #endif
46 46
47 47 /* directory to find plugin modules in */
48 48 #define SA_LIB_DIR "/usr/lib/fs"
49 49
50 50 /* default group name for dfstab file */
51 51 #define SA_DEFAULT_FILE_GRP "sys"
52 52
53 53 typedef void *sa_phandle_t;
54 54
55 55 #define SA_PLUGIN_VERSION 1
56 56 struct sa_plugin_ops {
57 57 int sa_version; /* version number */
58 58 char *sa_protocol; /* protocol name */
59 59 int (*sa_init)();
60 60 void (*sa_fini)();
61 61 int (*sa_share)(sa_share_t); /* start sharing */
62 62 int (*sa_unshare)(sa_share_t, char *); /* stop sharing */
63 63 int (*sa_valid_prop)(sa_handle_t, sa_property_t,
64 64 sa_optionset_t); /* validate */
65 65 int (*sa_valid_space)(char *); /* is name valid optionspace? */
66 66 int (*sa_security_prop)(char *); /* property is security */
67 67 int (*sa_legacy_opts)(sa_group_t, char *); /* parse legacy opts */
68 68 char *(*sa_legacy_format)(sa_group_t, int);
69 69 int (*sa_set_proto_prop)(sa_property_t); /* set a property */
70 70 sa_protocol_properties_t (*sa_get_proto_set)(); /* get properties */
71 71 char *(*sa_get_proto_status)();
72 72 char *(*sa_space_alias)(char *);
73 73 int (*sa_update_legacy)(sa_share_t);
74 74 int (*sa_delete_legacy)(sa_share_t);
75 75 int (*sa_change_notify)(sa_share_t);
76 76 int (*sa_enable_resource)(sa_resource_t);
77 77 int (*sa_disable_resource)(sa_resource_t);
|
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
78 78 uint64_t (*sa_features)(void);
79 79 int (*sa_get_transient_shares)(sa_handle_t); /* add transients */
80 80 int (*sa_notify_resource)(sa_resource_t);
81 81 int (*sa_rename_resource)(sa_handle_t, sa_resource_t, char *);
82 82 int (*sa_run_command)(int, int, char **); /* proto specific */
83 83 int (*sa_command_help)();
84 84 int (*sa_delete_proto_section)(char *);
85 85 };
86 86
87 87 struct sa_proto_handle {
88 + int sa_ref_count;
88 89 int sa_num_proto;
89 90 char **sa_proto;
90 91 struct sa_plugin_ops **sa_ops;
91 92 };
92 93
93 94 typedef struct propertylist {
94 95 struct propertylist *pl_next;
95 96 int pl_type;
96 97 union propval {
97 98 sa_optionset_t pl_optionset;
98 99 sa_security_t pl_security;
99 100 void *pl_void;
100 101 } pl_value;
101 102 } property_list_t;
102 103
103 104 /* internal version of sa_handle_t */
104 105 typedef struct sa_handle_impl {
105 106 uint64_t flags;
106 107 scfutilhandle_t *scfhandle;
107 108 libzfs_handle_t *zfs_libhandle;
108 109 zfs_handle_t **zfs_list;
109 110 size_t zfs_list_count;
110 111 xmlNodePtr tree;
111 112 xmlDocPtr doc;
112 113 uint64_t tssharetab;
113 114 uint64_t tstrans;
114 115 int sa_service;
115 116 } *sa_handle_impl_t;
116 117
117 118 extern int sa_proto_share(char *, sa_share_t);
118 119 extern int sa_proto_unshare(sa_share_t, char *, char *);
119 120 extern int sa_proto_valid_prop(sa_handle_t, char *, sa_property_t,
120 121 sa_optionset_t);
121 122 extern int sa_proto_security_prop(char *, char *);
122 123 extern int sa_proto_legacy_opts(char *, sa_group_t, char *);
123 124 extern int sa_proto_share_resource(char *, sa_resource_t);
124 125 extern int sa_proto_unshare_resource(char *, sa_resource_t);
125 126
126 127 /* internal utility functions */
127 128 extern sa_optionset_t sa_get_derived_optionset(sa_group_t, char *, int);
128 129 extern void sa_free_derived_optionset(sa_optionset_t);
129 130 extern sa_optionset_t sa_get_all_security_types(void *, char *, int);
130 131 extern sa_security_t sa_get_derived_security(void *, char *, char *, int);
131 132 extern void sa_free_derived_security(sa_security_t);
132 133 extern sa_protocol_properties_t sa_create_protocol_properties(char *);
133 134 extern int sa_start_transaction(scfutilhandle_t *, char *);
134 135 extern int sa_end_transaction(scfutilhandle_t *, sa_handle_impl_t);
135 136 extern void sa_abort_transaction(scfutilhandle_t *);
136 137 extern int sa_commit_share(scfutilhandle_t *, sa_group_t, sa_share_t);
137 138 extern int sa_set_property(scfutilhandle_t *, char *, char *);
138 139 extern void sa_free_fstype(char *fstyp);
139 140 extern int sa_delete_share(scfutilhandle_t *, sa_group_t, sa_share_t);
140 141 extern int sa_delete_instance(scfutilhandle_t *, char *);
141 142 extern int sa_create_pgroup(scfutilhandle_t *, char *);
142 143 extern int sa_delete_pgroup(scfutilhandle_t *, char *);
143 144 extern void sa_fillshare(sa_share_t share, char *proto, struct share *sh);
144 145 extern void sa_emptyshare(struct share *sh);
145 146
146 147 /* ZFS functions */
147 148 extern int sa_get_one_zfs_share(sa_handle_t, char *, sa_init_selective_arg_t *,
148 149 char ***, size_t *);
149 150 extern int sa_get_zfs_shares(sa_handle_t, char *);
150 151 extern int sa_get_zfs_share_for_name(sa_handle_t, char *, const char *, char *);
151 152 extern int sa_zfs_update(sa_share_t);
152 153 extern int sa_share_zfs(sa_share_t, sa_resource_t, char *, share_t *,
153 154 void *, zfs_share_op_t);
154 155 extern int sa_sharetab_fill_zfs(sa_share_t share, struct share *sh,
155 156 char *proto);
156 157
157 158 /* plugin specific functions */
158 159 extern int proto_plugin_init();
159 160 extern void proto_plugin_fini();
160 161 extern int sa_proto_set_property(char *, sa_property_t);
161 162 extern int sa_proto_delete_legacy(char *, sa_share_t);
162 163 extern int sa_proto_update_legacy(char *, sa_share_t);
163 164 extern int sa_proto_rename_resource(sa_handle_t, char *,
164 165 sa_resource_t, char *);
165 166
166 167 #define PL_TYPE_PROPERTY 0
167 168 #define PL_TYPE_SECURITY 1
168 169
169 170 /* values only used by the internal dfstab/sharetab parser */
170 171 #define SA_SHARE_PARSER 0x1000
171 172
172 173 /* plugin handler only */
173 174 struct sa_proto_plugin {
174 175 struct sa_proto_plugin *plugin_next;
175 176 struct sa_plugin_ops *plugin_ops;
176 177 void *plugin_handle;
177 178 };
178 179
179 180 #define TSTAMP(tm) (uint64_t)(((uint64_t)tm.tv_sec << 32) | \
180 181 (tm.tv_nsec & 0xffffffff))
181 182
182 183
183 184 #ifdef __cplusplus
184 185 }
185 186 #endif
186 187
187 188 #endif /* _LIBSHARE_IMPL_H */
|
↓ open down ↓ |
90 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX