File: | xlators/cluster/dht/src/dht-common.c |
Location: | line 1366, column 13 |
Description: | Access to field 'ia_type' results in a dereference of a null pointer (loaded from variable 'inode') |
1 | /* | |||
2 | Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | ||||
12 | #ifndef _CONFIG_H | |||
13 | #define _CONFIG_H | |||
14 | #include "config.h" | |||
15 | #endif | |||
16 | ||||
17 | /* TODO: add NS locking */ | |||
18 | ||||
19 | #include "glusterfs.h" | |||
20 | #include "xlator.h" | |||
21 | #include "libxlator.h" | |||
22 | #include "dht-common.h" | |||
23 | #include "defaults.h" | |||
24 | #include "byte-order.h" | |||
25 | ||||
26 | #include <sys/time.h> | |||
27 | #include <libgen.h> | |||
28 | ||||
29 | int | |||
30 | dht_aggregate (dict_t *this, char *key, data_t *value, void *data) | |||
31 | { | |||
32 | dict_t *dst = NULL((void*)0); | |||
33 | int64_t *ptr = 0, *size = NULL((void*)0); | |||
34 | int32_t ret = -1; | |||
35 | data_t *dict_data = NULL((void*)0); | |||
36 | ||||
37 | dst = data; | |||
38 | ||||
39 | if (strcmp (key, GF_XATTR_QUOTA_SIZE_KEY"trusted.glusterfs.quota.size") == 0) { | |||
40 | ret = dict_get_bin (dst, key, (void **)&size); | |||
41 | if (ret < 0) { | |||
42 | size = GF_CALLOC (1, sizeof (int64_t),__gf_calloc (1, sizeof (int64_t), gf_common_mt_char) | |||
43 | gf_common_mt_char)__gf_calloc (1, sizeof (int64_t), gf_common_mt_char); | |||
44 | if (size == NULL((void*)0)) { | |||
45 | gf_log ("dht", GF_LOG_WARNING,do { do { if (0) printf ("memory allocation failed"); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 46, GF_LOG_WARNING , "memory allocation failed"); } while (0) | |||
46 | "memory allocation failed")do { do { if (0) printf ("memory allocation failed"); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 46, GF_LOG_WARNING , "memory allocation failed"); } while (0); | |||
47 | return -1; | |||
48 | } | |||
49 | ret = dict_set_bin (dst, key, size, sizeof (int64_t)); | |||
50 | if (ret < 0) { | |||
51 | gf_log ("dht", GF_LOG_WARNING,do { do { if (0) printf ("dht aggregate dict set failed"); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 52, GF_LOG_WARNING , "dht aggregate dict set failed"); } while (0) | |||
52 | "dht aggregate dict set failed")do { do { if (0) printf ("dht aggregate dict set failed"); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 52, GF_LOG_WARNING , "dht aggregate dict set failed"); } while (0); | |||
53 | GF_FREE (size)__gf_free (size); | |||
54 | return -1; | |||
55 | } | |||
56 | } | |||
57 | ||||
58 | ptr = data_to_bin (value); | |||
59 | if (ptr == NULL((void*)0)) { | |||
60 | gf_log ("dht", GF_LOG_WARNING, "data to bin failed")do { do { if (0) printf ("data to bin failed"); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 60, GF_LOG_WARNING, "data to bin failed" ); } while (0); | |||
61 | return -1; | |||
62 | } | |||
63 | ||||
64 | *size = hton64 (ntoh64hton64 (*size) + ntoh64hton64 (*ptr)); | |||
65 | } else { | |||
66 | /* compare user xattrs only */ | |||
67 | if (!strncmp (key, "user.", strlen ("user."))) { | |||
68 | ret = dict_lookup (dst, key, &dict_data); | |||
69 | if (!ret && dict_data && value) { | |||
70 | ret = is_data_equal (dict_data, value); | |||
71 | if (!ret) | |||
72 | gf_log ("dht", GF_LOG_DEBUG,do { do { if (0) printf ("xattr mismatch for %s", key); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 73, GF_LOG_DEBUG , "xattr mismatch for %s", key); } while (0) | |||
73 | "xattr mismatch for %s", key)do { do { if (0) printf ("xattr mismatch for %s", key); } while (0); _gf_log ("dht", "dht-common.c", __FUNCTION__, 73, GF_LOG_DEBUG , "xattr mismatch for %s", key); } while (0); | |||
74 | } | |||
75 | } | |||
76 | ret = dict_set (dst, key, value); | |||
77 | if (ret) | |||
78 | gf_log ("dht", GF_LOG_WARNING, "xattr dict set failed")do { do { if (0) printf ("xattr dict set failed"); } while (0 ); _gf_log ("dht", "dht-common.c", __FUNCTION__, 78, GF_LOG_WARNING , "xattr dict set failed"); } while (0); | |||
79 | } | |||
80 | ||||
81 | return 0; | |||
82 | } | |||
83 | ||||
84 | ||||
85 | void | |||
86 | dht_aggregate_xattr (dict_t *dst, dict_t *src) | |||
87 | { | |||
88 | if ((dst == NULL((void*)0)) || (src == NULL((void*)0))) { | |||
89 | goto out; | |||
90 | } | |||
91 | ||||
92 | dict_foreach (src, dht_aggregate, dst); | |||
93 | out: | |||
94 | return; | |||
95 | } | |||
96 | ||||
97 | /* TODO: | |||
98 | - use volumename in xattr instead of "dht" | |||
99 | - use NS locks | |||
100 | - handle all cases in self heal layout reconstruction | |||
101 | - complete linkfile selfheal | |||
102 | */ | |||
103 | ||||
104 | ||||
105 | int | |||
106 | dht_lookup_selfheal_cbk (call_frame_t *frame, void *cookie, | |||
107 | xlator_t *this, | |||
108 | int op_ret, int op_errno, dict_t *xdata) | |||
109 | { | |||
110 | dht_local_t *local = NULL((void*)0); | |||
111 | dht_layout_t *layout = NULL((void*)0); | |||
112 | int ret = -1; | |||
113 | ||||
114 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 114, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
115 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 115, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
116 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 116, GF_LOG_ERROR, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
117 | ||||
118 | local = frame->local; | |||
119 | ret = op_ret; | |||
120 | ||||
121 | FRAME_SU_UNDO (frame, dht_local_t)do { dht_local_t *__local = (frame)->local; frame->root ->uid = __local->uid; frame->root->gid = __local-> gid; } while (0);; | |||
122 | ||||
123 | if (ret == 0) { | |||
124 | layout = local->selfheal.layout; | |||
125 | ret = dht_layout_set (this, local->inode, layout); | |||
126 | } | |||
127 | ||||
128 | if (local->loc.parent) { | |||
129 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
130 | &local->postparent, 1); | |||
131 | } | |||
132 | ||||
133 | DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local-> stbuf)->ia_type == IA_IFREG) && ((&local->stbuf )->ia_prot.sticky == 1) && ((&local->stbuf) ->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot .sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } } while (0); | |||
134 | ||||
135 | DHT_STACK_UNWIND (lookup, frame, ret, local->op_errno, local->inode,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 136, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, ret, local->op_errno, local->inode, &local ->stbuf, local->xattr, &local->postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
136 | &local->stbuf, local->xattr, &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 136, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, ret, local->op_errno, local->inode, &local ->stbuf, local->xattr, &local->postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
137 | ||||
138 | out: | |||
139 | return ret; | |||
140 | } | |||
141 | ||||
142 | ||||
143 | int | |||
144 | dht_discover_complete (xlator_t *this, call_frame_t *discover_frame) | |||
145 | { | |||
146 | dht_local_t *local = NULL((void*)0); | |||
147 | call_frame_t *main_frame = NULL((void*)0); | |||
148 | int op_errno = 0; | |||
149 | int ret = -1; | |||
150 | dht_layout_t *layout = NULL((void*)0); | |||
151 | ||||
152 | local = discover_frame->local; | |||
153 | layout = local->layout; | |||
154 | ||||
155 | LOCK(&discover_frame->lock)pthread_spin_lock (&discover_frame->lock); | |||
156 | { | |||
157 | main_frame = local->main_frame; | |||
158 | local->main_frame = NULL((void*)0); | |||
159 | } | |||
160 | UNLOCK(&discover_frame->lock)pthread_spin_unlock (&discover_frame->lock); | |||
161 | ||||
162 | if (!main_frame) | |||
163 | return 0; | |||
164 | ||||
165 | if (local->file_count && local->dir_count) { | |||
166 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 170, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
167 | "path %s exists as a file on one subvolume "do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 170, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
168 | "and directory on another. "do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 170, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
169 | "Please fix it manually",do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 170, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
170 | local->loc.path)do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 170, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); | |||
171 | op_errno = EIO5; | |||
172 | goto out; | |||
173 | } | |||
174 | ||||
175 | if (local->cached_subvol) { | |||
176 | ret = dht_layout_preset (this, local->cached_subvol, | |||
177 | local->inode); | |||
178 | if (ret < 0) { | |||
179 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set layout for subvolume %s" , local->cached_subvol ? local->cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 181, GF_LOG_WARNING, "failed to set layout for subvolume %s" , local->cached_subvol ? local->cached_subvol->name : "<nil>"); } while (0) | |||
180 | "failed to set layout for subvolume %s",do { do { if (0) printf ("failed to set layout for subvolume %s" , local->cached_subvol ? local->cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 181, GF_LOG_WARNING, "failed to set layout for subvolume %s" , local->cached_subvol ? local->cached_subvol->name : "<nil>"); } while (0) | |||
181 | local->cached_subvol ? local->cached_subvol->name : "<nil>")do { do { if (0) printf ("failed to set layout for subvolume %s" , local->cached_subvol ? local->cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 181, GF_LOG_WARNING, "failed to set layout for subvolume %s" , local->cached_subvol ? local->cached_subvol->name : "<nil>"); } while (0); | |||
182 | op_errno = EINVAL22; | |||
183 | goto out; | |||
184 | } | |||
185 | } else { | |||
186 | ret = dht_layout_normalize (this, &local->loc, layout); | |||
187 | if ((ret < 0) || ((ret > 0) && (local->op_ret != 0))) { | |||
188 | /* either the layout is incorrect or the directory is | |||
189 | * not found even in one subvolume. | |||
190 | */ | |||
191 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local->loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 195, GF_LOG_DEBUG, "normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local-> loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0 ); } while (0) | |||
192 | "normalizing failed on %s "do { do { if (0) printf ("normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local->loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 195, GF_LOG_DEBUG, "normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local-> loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0 ); } while (0) | |||
193 | "(overlaps/holes present: %s, "do { do { if (0) printf ("normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local->loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 195, GF_LOG_DEBUG, "normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local-> loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0 ); } while (0) | |||
194 | "ENOENT errors: %d)", local->loc.path,do { do { if (0) printf ("normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local->loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 195, GF_LOG_DEBUG, "normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local-> loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0 ); } while (0) | |||
195 | (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0)do { do { if (0) printf ("normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local->loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 195, GF_LOG_DEBUG, "normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local-> loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0 ); } while (0); | |||
196 | op_errno = EINVAL22; | |||
197 | goto out; | |||
198 | } | |||
199 | ||||
200 | dht_layout_set (this, local->inode, layout); | |||
201 | } | |||
202 | ||||
203 | DHT_STACK_UNWIND (lookup, main_frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (main_frame) { __xl = main_frame->this; __local = main_frame->local; main_frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "dht-common.c", __FUNCTION__, 205, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )main_frame-> ret; _parent = main_frame->parent; pthread_spin_lock (& main_frame->root->stack_lock); { _parent->ref_count-- ; } pthread_spin_unlock (&main_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; main_frame->complete = _gf_true; main_frame ->unwind_from = __FUNCTION__; if (main_frame->this-> ctx->measure_latency) gf_latency_end (main_frame); fn (_parent , main_frame->cookie, _parent->this, local->op_ret, local ->op_errno, local->inode, &local->stbuf, local-> xattr, &local->postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
204 | local->inode, &local->stbuf, local->xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (main_frame) { __xl = main_frame->this; __local = main_frame->local; main_frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "dht-common.c", __FUNCTION__, 205, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )main_frame-> ret; _parent = main_frame->parent; pthread_spin_lock (& main_frame->root->stack_lock); { _parent->ref_count-- ; } pthread_spin_unlock (&main_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; main_frame->complete = _gf_true; main_frame ->unwind_from = __FUNCTION__; if (main_frame->this-> ctx->measure_latency) gf_latency_end (main_frame); fn (_parent , main_frame->cookie, _parent->this, local->op_ret, local ->op_errno, local->inode, &local->stbuf, local-> xattr, &local->postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
205 | &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (main_frame) { __xl = main_frame->this; __local = main_frame->local; main_frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "dht-common.c", __FUNCTION__, 205, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )main_frame-> ret; _parent = main_frame->parent; pthread_spin_lock (& main_frame->root->stack_lock); { _parent->ref_count-- ; } pthread_spin_unlock (&main_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; main_frame->complete = _gf_true; main_frame ->unwind_from = __FUNCTION__; if (main_frame->this-> ctx->measure_latency) gf_latency_end (main_frame); fn (_parent , main_frame->cookie, _parent->this, local->op_ret, local ->op_errno, local->inode, &local->stbuf, local-> xattr, &local->postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
206 | return 0; | |||
207 | out: | |||
208 | DHT_STACK_UNWIND (lookup, main_frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (main_frame) { __xl = main_frame->this; __local = main_frame->local; main_frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "dht-common.c", __FUNCTION__, 209, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )main_frame-> ret; _parent = main_frame->parent; pthread_spin_lock (& main_frame->root->stack_lock); { _parent->ref_count-- ; } pthread_spin_unlock (&main_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; main_frame->complete = _gf_true; main_frame ->unwind_from = __FUNCTION__; if (main_frame->this-> ctx->measure_latency) gf_latency_end (main_frame); fn (_parent , main_frame->cookie, _parent->this, -1, op_errno, ((void *)0), ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
209 | NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (main_frame) { __xl = main_frame->this; __local = main_frame->local; main_frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!main_frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "dht-common.c", __FUNCTION__, 209, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )main_frame-> ret; _parent = main_frame->parent; pthread_spin_lock (& main_frame->root->stack_lock); { _parent->ref_count-- ; } pthread_spin_unlock (&main_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; main_frame->complete = _gf_true; main_frame ->unwind_from = __FUNCTION__; if (main_frame->this-> ctx->measure_latency) gf_latency_end (main_frame); fn (_parent , main_frame->cookie, _parent->this, -1, op_errno, ((void *)0), ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
210 | ||||
211 | return ret; | |||
212 | } | |||
213 | ||||
214 | ||||
215 | int | |||
216 | dht_discover_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
217 | int op_ret, int op_errno, | |||
218 | inode_t *inode, struct iatt *stbuf, dict_t *xattr, | |||
219 | struct iatt *postparent) | |||
220 | { | |||
221 | dht_local_t *local = NULL((void*)0); | |||
222 | int this_call_cnt = 0; | |||
223 | call_frame_t *prev = NULL((void*)0); | |||
224 | dht_layout_t *layout = NULL((void*)0); | |||
225 | int ret = -1; | |||
226 | int is_dir = 0; | |||
227 | int is_linkfile = 0; | |||
228 | int attempt_unwind = 0; | |||
229 | dht_conf_t *conf = 0; | |||
230 | ||||
231 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 231, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
232 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 232, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
233 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 233, GF_LOG_ERROR, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
234 | GF_VALIDATE_OR_GOTO ("dht", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 234, GF_LOG_ERROR, "invalid argument: " "this->private") ; } while (0); goto out; } } while (0); | |||
235 | GF_VALIDATE_OR_GOTO ("dht", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 235, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | |||
236 | ||||
237 | local = frame->local; | |||
238 | prev = cookie; | |||
239 | conf = this->private; | |||
240 | ||||
241 | layout = local->layout; | |||
242 | ||||
243 | /* Check if the gfid is different for file from other node */ | |||
244 | if (!op_ret && uuid_compare (local->gfid, stbuf->ia_gfid)) { | |||
245 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid different on %s", local-> loc.path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 247, GF_LOG_WARNING, "%s: gfid different on %s", local->loc.path, prev->this ->name); } while (0) | |||
246 | "%s: gfid different on %s",do { do { if (0) printf ("%s: gfid different on %s", local-> loc.path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 247, GF_LOG_WARNING, "%s: gfid different on %s", local->loc.path, prev->this ->name); } while (0) | |||
247 | local->loc.path, prev->this->name)do { do { if (0) printf ("%s: gfid different on %s", local-> loc.path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 247, GF_LOG_WARNING, "%s: gfid different on %s", local->loc.path, prev->this ->name); } while (0); | |||
248 | } | |||
249 | ||||
250 | ||||
251 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
252 | { | |||
253 | /* TODO: assert equal mode on stbuf->st_mode and | |||
254 | local->stbuf->st_mode | |||
255 | ||||
256 | else mkdir/chmod/chown and fix | |||
257 | */ | |||
258 | ret = dht_layout_merge (this, layout, prev->this, | |||
259 | op_ret, op_errno, xattr); | |||
260 | if (ret) | |||
261 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to merge layouts", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 262, GF_LOG_WARNING, "%s: failed to merge layouts" , local->loc.path); } while (0) | |||
262 | "%s: failed to merge layouts", local->loc.path)do { do { if (0) printf ("%s: failed to merge layouts", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 262, GF_LOG_WARNING, "%s: failed to merge layouts" , local->loc.path); } while (0); | |||
263 | ||||
264 | if (op_ret == -1) { | |||
265 | local->op_errno = op_errno; | |||
266 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 269, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0) | |||
267 | "lookup of %s on %s returned error (%s)",do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 269, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0) | |||
268 | local->loc.path, prev->this->name,do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 269, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0) | |||
269 | strerror (op_errno))do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 269, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); | |||
270 | ||||
271 | goto unlock; | |||
272 | } | |||
273 | ||||
274 | is_linkfile = check_is_linkfile (inode, stbuf, xattr,( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)) | |||
275 | conf->link_xattr_name)( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)); | |||
276 | is_dir = check_is_dir (inode, stbuf, xattr)((stbuf->ia_type == IA_IFDIR)); | |||
277 | ||||
278 | if (is_dir) { | |||
279 | local->dir_count ++; | |||
280 | } else { | |||
281 | local->file_count ++; | |||
282 | ||||
283 | if (!is_linkfile) { | |||
284 | /* real file */ | |||
285 | local->cached_subvol = prev->this; | |||
286 | attempt_unwind = 1; | |||
287 | } else { | |||
288 | goto unlock; | |||
289 | } | |||
290 | } | |||
291 | ||||
292 | local->op_ret = 0; | |||
293 | ||||
294 | if (local->xattr == NULL((void*)0)) { | |||
295 | local->xattr = dict_ref (xattr); | |||
296 | } else { | |||
297 | dht_aggregate_xattr (local->xattr, xattr); | |||
298 | } | |||
299 | ||||
300 | if (local->inode == NULL((void*)0)) | |||
301 | local->inode = inode_ref (inode); | |||
302 | ||||
303 | dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); | |||
304 | dht_iatt_merge (this, &local->postparent, postparent, | |||
305 | prev->this); | |||
306 | } | |||
307 | unlock: | |||
308 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
309 | out: | |||
310 | this_call_cnt = dht_frame_return (frame); | |||
311 | ||||
312 | if (is_last_call (this_call_cnt)(this_call_cnt == 0) || attempt_unwind) { | |||
313 | dht_discover_complete (this, frame); | |||
314 | } | |||
315 | ||||
316 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
317 | DHT_STACK_DESTROY (frame)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); __xl = frame->this; __local = frame->local; frame ->local = ((void*)0); STACK_DESTROY (frame->root); dht_local_wipe (__xl, __local); } while (0); | |||
318 | ||||
319 | return 0; | |||
320 | } | |||
321 | ||||
322 | ||||
323 | int | |||
324 | dht_discover (call_frame_t *frame, xlator_t *this, loc_t *loc) | |||
325 | { | |||
326 | int ret; | |||
327 | dht_local_t *local = NULL((void*)0); | |||
328 | dht_conf_t *conf = NULL((void*)0); | |||
329 | int call_cnt = 0; | |||
330 | int op_errno = EINVAL22; | |||
331 | int i = 0; | |||
332 | call_frame_t *discover_frame = NULL((void*)0); | |||
333 | ||||
334 | conf = this->private; | |||
335 | local = frame->local; | |||
336 | ||||
337 | ret = dict_set_uint32 (local->xattr_req, conf->xattr_name, 4 * 4); | |||
338 | if (ret) | |||
339 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to set '%s' key", loc-> path, conf->xattr_name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 341, GF_LOG_WARNING, "%s: failed to set '%s' key" , loc->path, conf->xattr_name); } while (0) | |||
340 | "%s: failed to set '%s' key",do { do { if (0) printf ("%s: failed to set '%s' key", loc-> path, conf->xattr_name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 341, GF_LOG_WARNING, "%s: failed to set '%s' key" , loc->path, conf->xattr_name); } while (0) | |||
341 | loc->path, conf->xattr_name)do { do { if (0) printf ("%s: failed to set '%s' key", loc-> path, conf->xattr_name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 341, GF_LOG_WARNING, "%s: failed to set '%s' key" , loc->path, conf->xattr_name); } while (0); | |||
342 | ||||
343 | ret = dict_set_uint32 (local->xattr_req, conf->link_xattr_name, 256); | |||
344 | if (ret) | |||
345 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to set '%s' key", loc-> path, conf->link_xattr_name); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 347, GF_LOG_WARNING, "%s: failed to set '%s' key" , loc->path, conf->link_xattr_name); } while (0) | |||
346 | "%s: failed to set '%s' key",do { do { if (0) printf ("%s: failed to set '%s' key", loc-> path, conf->link_xattr_name); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 347, GF_LOG_WARNING, "%s: failed to set '%s' key" , loc->path, conf->link_xattr_name); } while (0) | |||
347 | loc->path, conf->link_xattr_name)do { do { if (0) printf ("%s: failed to set '%s' key", loc-> path, conf->link_xattr_name); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 347, GF_LOG_WARNING, "%s: failed to set '%s' key" , loc->path, conf->link_xattr_name); } while (0); | |||
348 | ||||
349 | call_cnt = conf->subvolume_cnt; | |||
350 | local->call_cnt = call_cnt; | |||
351 | ||||
352 | local->layout = dht_layout_new (this, conf->subvolume_cnt); | |||
353 | ||||
354 | if (!local->layout) { | |||
355 | op_errno = ENOMEM12; | |||
356 | goto err; | |||
357 | } | |||
358 | ||||
359 | uuid_copy (local->gfid, loc->gfid); | |||
360 | ||||
361 | discover_frame = copy_frame (frame); | |||
362 | if (!discover_frame) { | |||
363 | op_errno = ENOMEM12; | |||
364 | goto err; | |||
365 | } | |||
366 | ||||
367 | discover_frame->local = local; | |||
368 | frame->local = NULL((void*)0); | |||
369 | local->main_frame = frame; | |||
370 | ||||
371 | for (i = 0; i < call_cnt; i++) { | |||
372 | STACK_WIND (discover_frame, dht_discover_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (discover_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 375, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( conf->subvolumes[i]->fops->lookup_cbk) tmp_cbk = dht_discover_cbk ; _new->root = discover_frame->root; _new->this = conf ->subvolumes[i]; _new->ret = (ret_fn_t) tmp_cbk; _new-> parent = discover_frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "conf->subvolumes[i]->fops->lookup" ; _new->unwind_to = "dht_discover_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&discover_frame ->root->stack_lock); { _new->next = discover_frame-> root->frames.next; _new->prev = &discover_frame-> root->frames; if (discover_frame->root->frames.next) discover_frame->root->frames.next->prev = _new; discover_frame ->root->frames.next = _new; discover_frame->ref_count ++; } pthread_spin_unlock (&discover_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (discover_frame->this-> ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes [i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
373 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (discover_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 375, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( conf->subvolumes[i]->fops->lookup_cbk) tmp_cbk = dht_discover_cbk ; _new->root = discover_frame->root; _new->this = conf ->subvolumes[i]; _new->ret = (ret_fn_t) tmp_cbk; _new-> parent = discover_frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "conf->subvolumes[i]->fops->lookup" ; _new->unwind_to = "dht_discover_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&discover_frame ->root->stack_lock); { _new->next = discover_frame-> root->frames.next; _new->prev = &discover_frame-> root->frames; if (discover_frame->root->frames.next) discover_frame->root->frames.next->prev = _new; discover_frame ->root->frames.next = _new; discover_frame->ref_count ++; } pthread_spin_unlock (&discover_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (discover_frame->this-> ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes [i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
374 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (discover_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 375, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( conf->subvolumes[i]->fops->lookup_cbk) tmp_cbk = dht_discover_cbk ; _new->root = discover_frame->root; _new->this = conf ->subvolumes[i]; _new->ret = (ret_fn_t) tmp_cbk; _new-> parent = discover_frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "conf->subvolumes[i]->fops->lookup" ; _new->unwind_to = "dht_discover_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&discover_frame ->root->stack_lock); { _new->next = discover_frame-> root->frames.next; _new->prev = &discover_frame-> root->frames; if (discover_frame->root->frames.next) discover_frame->root->frames.next->prev = _new; discover_frame ->root->frames.next = _new; discover_frame->ref_count ++; } pthread_spin_unlock (&discover_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (discover_frame->this-> ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes [i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
375 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (discover_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 375, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( conf->subvolumes[i]->fops->lookup_cbk) tmp_cbk = dht_discover_cbk ; _new->root = discover_frame->root; _new->this = conf ->subvolumes[i]; _new->ret = (ret_fn_t) tmp_cbk; _new-> parent = discover_frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "conf->subvolumes[i]->fops->lookup" ; _new->unwind_to = "dht_discover_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&discover_frame ->root->stack_lock); { _new->next = discover_frame-> root->frames.next; _new->prev = &discover_frame-> root->frames; if (discover_frame->root->frames.next) discover_frame->root->frames.next->prev = _new; discover_frame ->root->frames.next = _new; discover_frame->ref_count ++; } pthread_spin_unlock (&discover_frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (discover_frame->this-> ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes [i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
376 | } | |||
377 | ||||
378 | return 0; | |||
379 | ||||
380 | err: | |||
381 | DHT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 382, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
382 | NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 382, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
383 | ||||
384 | return 0; | |||
385 | } | |||
386 | ||||
387 | ||||
388 | int | |||
389 | dht_lookup_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
390 | int op_ret, int op_errno, | |||
391 | inode_t *inode, struct iatt *stbuf, dict_t *xattr, | |||
392 | struct iatt *postparent) | |||
393 | { | |||
394 | dht_local_t *local = NULL((void*)0); | |||
395 | int this_call_cnt = 0; | |||
396 | call_frame_t *prev = NULL((void*)0); | |||
397 | dht_layout_t *layout = NULL((void*)0); | |||
398 | int ret = -1; | |||
399 | int is_dir = 0; | |||
400 | ||||
401 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 401, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
402 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 402, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
403 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 403, GF_LOG_ERROR, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
404 | GF_VALIDATE_OR_GOTO ("dht", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 404, GF_LOG_ERROR, "invalid argument: " "this->private") ; } while (0); goto out; } } while (0); | |||
405 | GF_VALIDATE_OR_GOTO ("dht", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 405, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | |||
406 | ||||
407 | local = frame->local; | |||
408 | prev = cookie; | |||
409 | ||||
410 | layout = local->layout; | |||
411 | ||||
412 | if (!op_ret && uuid_is_null (local->gfid)) | |||
413 | memcpy (local->gfid, stbuf->ia_gfid, 16); | |||
414 | ||||
415 | /* Check if the gfid is different for file from other node */ | |||
416 | if (!op_ret && uuid_compare (local->gfid, stbuf->ia_gfid)) { | |||
417 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid different on %s", local-> loc.path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 419, GF_LOG_WARNING, "%s: gfid different on %s", local->loc.path, prev->this ->name); } while (0) | |||
418 | "%s: gfid different on %s",do { do { if (0) printf ("%s: gfid different on %s", local-> loc.path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 419, GF_LOG_WARNING, "%s: gfid different on %s", local->loc.path, prev->this ->name); } while (0) | |||
419 | local->loc.path, prev->this->name)do { do { if (0) printf ("%s: gfid different on %s", local-> loc.path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 419, GF_LOG_WARNING, "%s: gfid different on %s", local->loc.path, prev->this ->name); } while (0); | |||
420 | } | |||
421 | ||||
422 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
423 | { | |||
424 | /* TODO: assert equal mode on stbuf->st_mode and | |||
425 | local->stbuf->st_mode | |||
426 | ||||
427 | else mkdir/chmod/chown and fix | |||
428 | */ | |||
429 | ret = dht_layout_merge (this, layout, prev->this, | |||
430 | op_ret, op_errno, xattr); | |||
431 | ||||
432 | if (op_ret == -1) { | |||
433 | local->op_errno = ENOENT2; | |||
434 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 437, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0) | |||
435 | "lookup of %s on %s returned error (%s)",do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 437, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0) | |||
436 | local->loc.path, prev->this->name,do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 437, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0) | |||
437 | strerror (op_errno))do { do { if (0) printf ("lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 437, GF_LOG_DEBUG, "lookup of %s on %s returned error (%s)" , local->loc.path, prev->this->name, strerror (op_errno )); } while (0); | |||
438 | ||||
439 | goto unlock; | |||
440 | } | |||
441 | ||||
442 | is_dir = check_is_dir (inode, stbuf, xattr)((stbuf->ia_type == IA_IFDIR)); | |||
443 | if (!is_dir) { | |||
444 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 447, GF_LOG_DEBUG, "lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0) | |||
445 | "lookup of %s on %s returned non dir 0%o",do { do { if (0) printf ("lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 447, GF_LOG_DEBUG, "lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0) | |||
446 | local->loc.path, prev->this->name,do { do { if (0) printf ("lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 447, GF_LOG_DEBUG, "lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0) | |||
447 | stbuf->ia_type)do { do { if (0) printf ("lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 447, GF_LOG_DEBUG, "lookup of %s on %s returned non dir 0%o" , local->loc.path, prev->this->name, stbuf->ia_type ); } while (0); | |||
448 | local->need_selfheal = 1; | |||
449 | goto unlock; | |||
450 | } | |||
451 | ||||
452 | local->op_ret = 0; | |||
453 | if (local->xattr == NULL((void*)0)) { | |||
454 | local->xattr = dict_ref (xattr); | |||
455 | } else { | |||
456 | dht_aggregate_xattr (local->xattr, xattr); | |||
457 | } | |||
458 | ||||
459 | if (local->inode == NULL((void*)0)) | |||
460 | local->inode = inode_ref (inode); | |||
461 | ||||
462 | dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); | |||
463 | dht_iatt_merge (this, &local->postparent, postparent, | |||
464 | prev->this); | |||
465 | } | |||
466 | unlock: | |||
467 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
468 | ||||
469 | ||||
470 | this_call_cnt = dht_frame_return (frame); | |||
471 | ||||
472 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
473 | if (local->need_selfheal) { | |||
474 | local->need_selfheal = 0; | |||
475 | dht_lookup_everywhere (frame, this, &local->loc); | |||
476 | return 0; | |||
477 | } | |||
478 | ||||
479 | if (local->op_ret == 0) { | |||
480 | ret = dht_layout_normalize (this, &local->loc, layout); | |||
481 | ||||
482 | if (ret != 0) { | |||
483 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("fixing assignment on %s", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 485, GF_LOG_DEBUG, "fixing assignment on %s", local->loc.path); } while (0) | |||
484 | "fixing assignment on %s",do { do { if (0) printf ("fixing assignment on %s", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 485, GF_LOG_DEBUG, "fixing assignment on %s", local->loc.path); } while (0) | |||
485 | local->loc.path)do { do { if (0) printf ("fixing assignment on %s", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 485, GF_LOG_DEBUG, "fixing assignment on %s", local->loc.path); } while (0); | |||
486 | goto selfheal; | |||
487 | } | |||
488 | ||||
489 | dht_layout_set (this, local->inode, layout); | |||
490 | } | |||
491 | ||||
492 | if (local->loc.parent) { | |||
493 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
494 | &local->postparent, 1); | |||
495 | } | |||
496 | ||||
497 | DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local-> stbuf)->ia_type == IA_IFREG) && ((&local->stbuf )->ia_prot.sticky == 1) && ((&local->stbuf) ->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot .sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } } while (0); | |||
498 | DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 500, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
499 | local->inode, &local->stbuf, local->xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 500, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
500 | &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 500, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
501 | } | |||
502 | ||||
503 | return 0; | |||
504 | ||||
505 | selfheal: | |||
506 | FRAME_SU_DO (frame, dht_local_t)do { dht_local_t *__local = (frame)->local; __local->uid = frame->root->uid; __local->gid = frame->root-> gid; frame->root->uid = 0; frame->root->gid = 0; } while (0);; | |||
507 | uuid_copy (local->loc.gfid, local->gfid); | |||
508 | ret = dht_selfheal_directory (frame, dht_lookup_selfheal_cbk, | |||
509 | &local->loc, layout); | |||
510 | out: | |||
511 | return ret; | |||
512 | } | |||
513 | ||||
514 | int | |||
515 | dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
516 | int op_ret, int op_errno, | |||
517 | inode_t *inode, struct iatt *stbuf, dict_t *xattr, | |||
518 | struct iatt *postparent) | |||
519 | { | |||
520 | dht_local_t *local = NULL((void*)0); | |||
521 | int this_call_cnt = 0; | |||
522 | call_frame_t *prev = NULL((void*)0); | |||
523 | dht_layout_t *layout = NULL((void*)0); | |||
524 | dht_conf_t *conf = NULL((void*)0); | |||
525 | int ret = -1; | |||
526 | int is_dir = 0; | |||
527 | int is_linkfile = 0; | |||
528 | call_frame_t *copy = NULL((void*)0); | |||
529 | dht_local_t *copy_local = NULL((void*)0); | |||
530 | ||||
531 | GF_VALIDATE_OR_GOTO ("dht", frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 531, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto err; } } while (0); | |||
532 | GF_VALIDATE_OR_GOTO ("dht", this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 532, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto err; } } while (0); | |||
533 | GF_VALIDATE_OR_GOTO ("dht", frame->local, err)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 533, GF_LOG_ERROR, "invalid argument: " "frame->local"); } while (0); goto err; } } while (0); | |||
534 | GF_VALIDATE_OR_GOTO ("dht", cookie, err)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 534, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto err; } } while (0); | |||
535 | ||||
536 | local = frame->local; | |||
537 | prev = cookie; | |||
538 | conf = this->private; | |||
539 | if (!conf) | |||
540 | goto out; | |||
541 | ||||
542 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
543 | { | |||
544 | if (op_ret == -1) { | |||
545 | local->op_errno = op_errno; | |||
546 | ||||
547 | if ((op_errno != ENOTCONN107) | |||
548 | && (op_errno != ENOENT2) | |||
549 | && (op_errno != ESTALE116)) { | |||
550 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("subvolume %s for %s returned -1 (%s)" , prev->this->name, local->loc.path, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 553, GF_LOG_INFO, "subvolume %s for %s returned -1 (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
551 | "subvolume %s for %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s for %s returned -1 (%s)" , prev->this->name, local->loc.path, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 553, GF_LOG_INFO, "subvolume %s for %s returned -1 (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
552 | prev->this->name, local->loc.path,do { do { if (0) printf ("subvolume %s for %s returned -1 (%s)" , prev->this->name, local->loc.path, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 553, GF_LOG_INFO, "subvolume %s for %s returned -1 (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
553 | strerror (op_errno))do { do { if (0) printf ("subvolume %s for %s returned -1 (%s)" , prev->this->name, local->loc.path, strerror (op_errno )); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 553, GF_LOG_INFO, "subvolume %s for %s returned -1 (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); | |||
554 | } | |||
555 | if (op_errno == ESTALE116) { | |||
556 | /* propagate the ESTALE to parent. | |||
557 | * setting local->return_estale would send | |||
558 | * ESTALE to parent. */ | |||
559 | local->return_estale = 1; | |||
560 | } | |||
561 | ||||
562 | /* if it is ENOENT, we may have to do a | |||
563 | * 'lookup_everywhere()' to make sure | |||
564 | * the file is not migrated */ | |||
565 | if (op_errno == ENOENT2) { | |||
566 | if (IA_ISREG (local->loc.inode->ia_type)(local->loc.inode->ia_type == IA_IFREG)) { | |||
567 | local->need_lookup_everywhere = 1; | |||
568 | } | |||
569 | } | |||
570 | goto unlock; | |||
571 | } | |||
572 | ||||
573 | if (stbuf->ia_type != local->inode->ia_type) { | |||
574 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 577, GF_LOG_INFO, "mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0) | |||
575 | "mismatching filetypes 0%o v/s 0%o for %s",do { do { if (0) printf ("mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 577, GF_LOG_INFO, "mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0) | |||
576 | (stbuf->ia_type), (local->inode->ia_type),do { do { if (0) printf ("mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 577, GF_LOG_INFO, "mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0) | |||
577 | local->loc.path)do { do { if (0) printf ("mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 577, GF_LOG_INFO, "mismatching filetypes 0%o v/s 0%o for %s" , (stbuf->ia_type), (local->inode->ia_type), local-> loc.path); } while (0); | |||
578 | ||||
579 | local->op_ret = -1; | |||
580 | local->op_errno = EINVAL22; | |||
581 | ||||
582 | goto unlock; | |||
583 | } | |||
584 | ||||
585 | layout = local->layout; | |||
586 | ||||
587 | is_dir = check_is_dir (inode, stbuf, xattr)((stbuf->ia_type == IA_IFDIR)); | |||
588 | is_linkfile = check_is_linkfile (inode, stbuf, xattr,( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)) | |||
589 | conf->link_xattr_name)( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)); | |||
590 | ||||
591 | if (is_linkfile) { | |||
592 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("linkfile found in revalidate for %s" , local->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 594, GF_LOG_INFO, "linkfile found in revalidate for %s" , local->loc.path); } while (0) | |||
593 | "linkfile found in revalidate for %s",do { do { if (0) printf ("linkfile found in revalidate for %s" , local->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 594, GF_LOG_INFO, "linkfile found in revalidate for %s" , local->loc.path); } while (0) | |||
594 | local->loc.path)do { do { if (0) printf ("linkfile found in revalidate for %s" , local->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 594, GF_LOG_INFO, "linkfile found in revalidate for %s" , local->loc.path); } while (0); | |||
595 | local->return_estale = 1; | |||
596 | ||||
597 | goto unlock; | |||
598 | } | |||
599 | ||||
600 | if (is_dir) { | |||
601 | ret = dht_dir_has_layout (xattr, conf->xattr_name); | |||
602 | if (ret >= 0) { | |||
603 | if (is_greater_time(local->stbuf.ia_ctime,(((local->stbuf.ia_ctime) < (stbuf->ia_ctime)) || (( (local->stbuf.ia_ctime) == (stbuf->ia_ctime)) && ((local->stbuf.ia_ctime_nsec) < (stbuf->ia_ctime_nsec )))) | |||
604 | local->stbuf.ia_ctime_nsec,(((local->stbuf.ia_ctime) < (stbuf->ia_ctime)) || (( (local->stbuf.ia_ctime) == (stbuf->ia_ctime)) && ((local->stbuf.ia_ctime_nsec) < (stbuf->ia_ctime_nsec )))) | |||
605 | stbuf->ia_ctime,(((local->stbuf.ia_ctime) < (stbuf->ia_ctime)) || (( (local->stbuf.ia_ctime) == (stbuf->ia_ctime)) && ((local->stbuf.ia_ctime_nsec) < (stbuf->ia_ctime_nsec )))) | |||
606 | stbuf->ia_ctime_nsec)(((local->stbuf.ia_ctime) < (stbuf->ia_ctime)) || (( (local->stbuf.ia_ctime) == (stbuf->ia_ctime)) && ((local->stbuf.ia_ctime_nsec) < (stbuf->ia_ctime_nsec ))))) { | |||
607 | local->prebuf.ia_gid = stbuf->ia_gid; | |||
608 | local->prebuf.ia_uid = stbuf->ia_uid; | |||
609 | } | |||
610 | } | |||
611 | if (local->stbuf.ia_type != IA_INVAL) | |||
612 | { | |||
613 | if ((local->stbuf.ia_gid != stbuf->ia_gid) || | |||
614 | (local->stbuf.ia_uid != stbuf->ia_uid)) { | |||
615 | local->need_selfheal = 1; | |||
616 | } | |||
617 | } | |||
618 | ret = dht_layout_dir_mismatch (this, layout, | |||
619 | prev->this, &local->loc, | |||
620 | xattr); | |||
621 | if (ret != 0) { | |||
622 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("mismatching layouts for %s", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 624, GF_LOG_INFO, "mismatching layouts for %s" , local->loc.path); } while (0) | |||
623 | "mismatching layouts for %s",do { do { if (0) printf ("mismatching layouts for %s", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 624, GF_LOG_INFO, "mismatching layouts for %s" , local->loc.path); } while (0) | |||
624 | local->loc.path)do { do { if (0) printf ("mismatching layouts for %s", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 624, GF_LOG_INFO, "mismatching layouts for %s" , local->loc.path); } while (0); | |||
625 | ||||
626 | local->layout_mismatch = 1; | |||
627 | ||||
628 | goto unlock; | |||
629 | } | |||
630 | } | |||
631 | ||||
632 | dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); | |||
633 | dht_iatt_merge (this, &local->postparent, postparent, | |||
634 | prev->this); | |||
635 | ||||
636 | local->op_ret = 0; | |||
637 | ||||
638 | if (!local->xattr) { | |||
639 | local->xattr = dict_ref (xattr); | |||
640 | } else if (is_dir) { | |||
641 | dht_aggregate_xattr (local->xattr, xattr); | |||
642 | } | |||
643 | } | |||
644 | unlock: | |||
645 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
646 | out: | |||
647 | this_call_cnt = dht_frame_return (frame); | |||
648 | ||||
649 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
650 | if (!IA_ISDIR (local->stbuf.ia_type)(local->stbuf.ia_type == IA_IFDIR) | |||
651 | && (local->hashed_subvol != local->cached_subvol) | |||
652 | && (local->stbuf.ia_nlink == 1) | |||
653 | && (conf && conf->unhashed_sticky_bit)) { | |||
654 | local->stbuf.ia_prot.sticky = 1; | |||
655 | } | |||
656 | if (local->need_selfheal) { | |||
657 | local->need_selfheal = 0; | |||
658 | uuid_copy (local->gfid, local->stbuf.ia_gfid); | |||
659 | local->stbuf.ia_gid = local->prebuf.ia_gid; | |||
660 | local->stbuf.ia_uid = local->prebuf.ia_uid; | |||
661 | copy = create_frame (this, this->ctx->pool); | |||
662 | if (copy) { | |||
663 | copy_local = dht_local_init (copy, &local->loc, | |||
664 | NULL((void*)0), 0); | |||
665 | if (!copy_local) | |||
666 | goto cont; | |||
667 | copy_local->stbuf = local->stbuf; | |||
668 | copy->local = copy_local; | |||
669 | FRAME_SU_DO (copy, dht_local_t)do { dht_local_t *__local = (copy)->local; __local->uid = copy->root->uid; __local->gid = copy->root-> gid; copy->root->uid = 0; copy->root->gid = 0; } while (0);; | |||
670 | ret = synctask_new (this->ctx->env, | |||
671 | dht_dir_attr_heal, | |||
672 | dht_dir_attr_heal_done, | |||
673 | copy, copy); | |||
674 | } | |||
675 | } | |||
676 | cont: | |||
677 | if (local->layout_mismatch) { | |||
678 | /* Found layout mismatch in the directory, need to | |||
679 | fix this in the inode context */ | |||
680 | dht_layout_unref (this, local->layout); | |||
681 | local->layout = NULL((void*)0); | |||
682 | dht_lookup_directory (frame, this, &local->loc); | |||
683 | return 0; | |||
684 | } | |||
685 | ||||
686 | if (local->need_lookup_everywhere) { | |||
687 | /* As the current layout gave ENOENT error, we would | |||
688 | need a new layout */ | |||
689 | dht_layout_unref (this, local->layout); | |||
690 | local->layout = NULL((void*)0); | |||
691 | ||||
692 | /* We know that current cached subvol is no more | |||
693 | valid, get the new one */ | |||
694 | local->cached_subvol = NULL((void*)0); | |||
695 | dht_lookup_everywhere (frame, this, &local->loc); | |||
696 | return 0; | |||
697 | } | |||
698 | if (local->return_estale) { | |||
699 | local->op_ret = -1; | |||
700 | local->op_errno = ESTALE116; | |||
701 | } | |||
702 | ||||
703 | if (local->loc.parent) { | |||
704 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
705 | &local->postparent, 1); | |||
706 | } | |||
707 | ||||
708 | DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local-> stbuf)->ia_type == IA_IFREG) && ((&local->stbuf )->ia_prot.sticky == 1) && ((&local->stbuf) ->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot .sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } } while (0); | |||
709 | DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 711, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
710 | local->inode, &local->stbuf, local->xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 711, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
711 | &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 711, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
712 | } | |||
713 | ||||
714 | err: | |||
715 | return ret; | |||
716 | } | |||
717 | ||||
718 | ||||
719 | int | |||
720 | dht_lookup_linkfile_create_cbk (call_frame_t *frame, void *cookie, | |||
721 | xlator_t *this, | |||
722 | int32_t op_ret, int32_t op_errno, | |||
723 | inode_t *inode, struct iatt *stbuf, | |||
724 | struct iatt *preparent, struct iatt *postparent, | |||
725 | dict_t *xdata) | |||
726 | { | |||
727 | dht_local_t *local = NULL((void*)0); | |||
728 | xlator_t *cached_subvol = NULL((void*)0); | |||
729 | dht_conf_t *conf = NULL((void*)0); | |||
730 | int ret = -1; | |||
731 | ||||
732 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 732, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
733 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 733, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
734 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 734, GF_LOG_ERROR, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
735 | GF_VALIDATE_OR_GOTO ("dht", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 735, GF_LOG_ERROR, "invalid argument: " "this->private") ; } while (0); goto out; } } while (0); | |||
736 | GF_VALIDATE_OR_GOTO ("dht", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 736, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | |||
737 | ||||
738 | local = frame->local; | |||
739 | cached_subvol = local->cached_subvol; | |||
740 | conf = this->private; | |||
741 | ||||
742 | ret = dht_layout_preset (this, local->cached_subvol, inode); | |||
743 | if (ret < 0) { | |||
744 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to set layout for subvolume %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 746 , GF_LOG_DEBUG, "failed to set layout for subvolume %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0) | |||
745 | "failed to set layout for subvolume %s",do { do { if (0) printf ("failed to set layout for subvolume %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 746 , GF_LOG_DEBUG, "failed to set layout for subvolume %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0) | |||
746 | cached_subvol ? cached_subvol->name : "<nil>")do { do { if (0) printf ("failed to set layout for subvolume %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 746 , GF_LOG_DEBUG, "failed to set layout for subvolume %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0); | |||
747 | local->op_ret = -1; | |||
748 | local->op_errno = EINVAL22; | |||
749 | goto unwind; | |||
750 | } | |||
751 | ||||
752 | local->op_ret = 0; | |||
753 | if ((local->stbuf.ia_nlink == 1) | |||
754 | && (conf && conf->unhashed_sticky_bit)) { | |||
755 | local->stbuf.ia_prot.sticky = 1; | |||
756 | } | |||
757 | ||||
758 | if (local->loc.parent) { | |||
759 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
760 | postparent, 1); | |||
761 | } | |||
762 | ||||
763 | unwind: | |||
764 | if (local->linked == _gf_true) | |||
765 | dht_linkfile_attr_heal (frame, this); | |||
766 | ||||
767 | DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local-> stbuf)->ia_type == IA_IFREG) && ((&local->stbuf )->ia_prot.sticky == 1) && ((&local->stbuf) ->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot .sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } } while (0); | |||
768 | DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 770, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
769 | local->inode, &local->stbuf, local->xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 770, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
770 | &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 770, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
771 | out: | |||
772 | return ret; | |||
773 | } | |||
774 | ||||
775 | ||||
776 | int | |||
777 | dht_lookup_everywhere_done (call_frame_t *frame, xlator_t *this) | |||
778 | { | |||
779 | int ret = 0; | |||
780 | dht_local_t *local = NULL((void*)0); | |||
781 | xlator_t *hashed_subvol = NULL((void*)0); | |||
782 | xlator_t *cached_subvol = NULL((void*)0); | |||
783 | dht_layout_t *layout = NULL((void*)0); | |||
784 | ||||
785 | local = frame->local; | |||
786 | hashed_subvol = local->hashed_subvol; | |||
787 | cached_subvol = local->cached_subvol; | |||
788 | ||||
789 | if (local->file_count && local->dir_count) { | |||
790 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 794, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
791 | "path %s exists as a file on one subvolume "do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 794, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
792 | "and directory on another. "do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 794, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
793 | "Please fix it manually",do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 794, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0) | |||
794 | local->loc.path)do { do { if (0) printf ("path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 794, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local ->loc.path); } while (0); | |||
795 | DHT_STACK_UNWIND (lookup, frame, -1, EIO, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 796, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 5, ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
796 | NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 796, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 5, ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
797 | return 0; | |||
798 | } | |||
799 | ||||
800 | if (local->dir_count) { | |||
801 | dht_lookup_directory (frame, this, &local->loc); | |||
802 | return 0; | |||
803 | } | |||
804 | ||||
805 | if (!cached_subvol) { | |||
806 | DHT_STACK_UNWIND (lookup, frame, -1, ENOENT, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 807, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 2, ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
807 | NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 807, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 2, ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
808 | return 0; | |||
809 | } | |||
810 | ||||
811 | if (local->need_lookup_everywhere) { | |||
812 | if (uuid_compare (local->gfid, local->inode->gfid)) { | |||
813 | /* GFID different, return error */ | |||
814 | DHT_STACK_UNWIND (lookup, frame, -1, ENOENT, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 815, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 2, ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
815 | NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 815, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 2, ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
816 | return 0; | |||
817 | } | |||
818 | local->op_ret = 0; | |||
819 | local->op_errno = 0; | |||
820 | layout = dht_layout_for_subvol (this, cached_subvol); | |||
821 | if (!layout) { | |||
822 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 826, GF_LOG_INFO, "%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
823 | "%s: no pre-set layout for subvolume %s",do { do { if (0) printf ("%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 826, GF_LOG_INFO, "%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
824 | local->loc.path, (cached_subvol ?do { do { if (0) printf ("%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 826, GF_LOG_INFO, "%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
825 | cached_subvol->name :do { do { if (0) printf ("%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 826, GF_LOG_INFO, "%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
826 | "<nil>"))do { do { if (0) printf ("%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 826, GF_LOG_INFO, "%s: no pre-set layout for subvolume %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); | |||
827 | } | |||
828 | ||||
829 | ret = dht_layout_set (this, local->inode, layout); | |||
830 | if (ret < 0) { | |||
831 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 835, GF_LOG_INFO, "%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
832 | "%s: failed to set layout for subvol %s",do { do { if (0) printf ("%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 835, GF_LOG_INFO, "%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
833 | local->loc.path, (cached_subvol ?do { do { if (0) printf ("%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 835, GF_LOG_INFO, "%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
834 | cached_subvol->name :do { do { if (0) printf ("%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 835, GF_LOG_INFO, "%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0) | |||
835 | "<nil>"))do { do { if (0) printf ("%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 835, GF_LOG_INFO, "%s: failed to set layout for subvol %s" , local->loc.path, (cached_subvol ? cached_subvol->name : "<nil>")); } while (0); | |||
836 | } | |||
837 | ||||
838 | if (local->loc.parent) { | |||
839 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
840 | &local->postparent, 1); | |||
841 | } | |||
842 | ||||
843 | DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local-> stbuf)->ia_type == IA_IFREG) && ((&local->stbuf )->ia_prot.sticky == 1) && ((&local->stbuf) ->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot .sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } } while (0); | |||
844 | DHT_STACK_UNWIND (lookup, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 847, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
845 | local->op_errno, local->inode,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 847, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
846 | &local->stbuf, local->xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 847, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
847 | &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 847, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
848 | return 0; | |||
849 | } | |||
850 | ||||
851 | if (!hashed_subvol) { | |||
852 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 855, GF_LOG_INFO, "cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0) | |||
853 | "cannot create linkfile file for %s on %s: "do { do { if (0) printf ("cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 855, GF_LOG_INFO, "cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0) | |||
854 | "hashed subvolume cannot be found.",do { do { if (0) printf ("cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 855, GF_LOG_INFO, "cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0) | |||
855 | local->loc.path, cached_subvol->name)do { do { if (0) printf ("cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 855, GF_LOG_INFO, "cannot create linkfile file for %s on %s: " "hashed subvolume cannot be found.", local->loc.path, cached_subvol ->name); } while (0); | |||
856 | ||||
857 | local->op_ret = 0; | |||
858 | local->op_errno = 0; | |||
859 | ||||
860 | ret = dht_layout_preset (frame->this, cached_subvol, | |||
861 | local->inode); | |||
862 | if (ret < 0) { | |||
863 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("failed to set layout for subvol %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 866 , GF_LOG_INFO, "failed to set layout for subvol %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0) | |||
864 | "failed to set layout for subvol %s",do { do { if (0) printf ("failed to set layout for subvol %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 866 , GF_LOG_INFO, "failed to set layout for subvol %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0) | |||
865 | cached_subvol ? cached_subvol->name :do { do { if (0) printf ("failed to set layout for subvol %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 866 , GF_LOG_INFO, "failed to set layout for subvol %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0) | |||
866 | "<nil>")do { do { if (0) printf ("failed to set layout for subvol %s" , cached_subvol ? cached_subvol->name : "<nil>"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 866 , GF_LOG_INFO, "failed to set layout for subvol %s", cached_subvol ? cached_subvol->name : "<nil>"); } while (0); | |||
867 | local->op_ret = -1; | |||
868 | local->op_errno = EINVAL22; | |||
869 | } | |||
870 | ||||
871 | if (local->loc.parent) { | |||
872 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
873 | &local->postparent, 1); | |||
874 | } | |||
875 | ||||
876 | DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local-> stbuf)->ia_type == IA_IFREG) && ((&local->stbuf )->ia_prot.sticky == 1) && ((&local->stbuf) ->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot .sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } } while (0); | |||
877 | DHT_STACK_UNWIND (lookup, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 880, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
878 | local->op_errno, local->inode,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 880, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
879 | &local->stbuf, local->xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 880, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
880 | &local->postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 880, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->inode , &local->stbuf, local->xattr, &local->postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
881 | return 0; | |||
882 | } | |||
883 | ||||
884 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 887, GF_LOG_DEBUG, "linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0) | |||
885 | "linking file %s existing on %s to %s (hash)",do { do { if (0) printf ("linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 887, GF_LOG_DEBUG, "linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0) | |||
886 | local->loc.path, cached_subvol->name,do { do { if (0) printf ("linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 887, GF_LOG_DEBUG, "linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0) | |||
887 | hashed_subvol->name)do { do { if (0) printf ("linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 887, GF_LOG_DEBUG, "linking file %s existing on %s to %s (hash)" , local->loc.path, cached_subvol->name, hashed_subvol-> name); } while (0); | |||
888 | ||||
889 | ret = dht_linkfile_create (frame, | |||
890 | dht_lookup_linkfile_create_cbk, this, | |||
891 | cached_subvol, hashed_subvol, &local->loc); | |||
892 | ||||
893 | return ret; | |||
894 | } | |||
895 | ||||
896 | ||||
897 | int | |||
898 | dht_lookup_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
899 | int op_ret, int op_errno, | |||
900 | struct iatt *preparent, struct iatt *postparent, | |||
901 | dict_t *xdata) | |||
902 | { | |||
903 | int this_call_cnt = 0; | |||
904 | ||||
905 | this_call_cnt = dht_frame_return (frame); | |||
906 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
907 | dht_lookup_everywhere_done (frame, this); | |||
908 | } | |||
909 | ||||
910 | return 0; | |||
911 | } | |||
912 | ||||
913 | ||||
914 | int | |||
915 | dht_lookup_everywhere_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
916 | int32_t op_ret, int32_t op_errno, | |||
917 | inode_t *inode, struct iatt *buf, dict_t *xattr, | |||
918 | struct iatt *postparent) | |||
919 | { | |||
920 | dht_local_t *local = NULL((void*)0); | |||
921 | int this_call_cnt = 0; | |||
922 | call_frame_t *prev = NULL((void*)0); | |||
923 | int is_linkfile = 0; | |||
924 | int is_dir = 0; | |||
925 | xlator_t *subvol = NULL((void*)0); | |||
926 | loc_t *loc = NULL((void*)0); | |||
927 | xlator_t *link_subvol = NULL((void*)0); | |||
928 | int ret = -1; | |||
929 | int32_t fd_count = 0; | |||
930 | dht_conf_t *conf = NULL((void*)0); | |||
931 | ||||
932 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 932, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
933 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 933, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
934 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 934, GF_LOG_ERROR, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
935 | GF_VALIDATE_OR_GOTO ("dht", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 935, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | |||
936 | GF_VALIDATE_OR_GOTO ("dht", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 936, GF_LOG_ERROR, "invalid argument: " "this->private") ; } while (0); goto out; } } while (0); | |||
937 | ||||
938 | local = frame->local; | |||
939 | loc = &local->loc; | |||
940 | conf = this->private; | |||
941 | ||||
942 | prev = cookie; | |||
943 | subvol = prev->this; | |||
944 | ||||
945 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
946 | { | |||
947 | if (op_ret == -1) { | |||
948 | if (op_errno != ENOENT2) | |||
949 | local->op_errno = op_errno; | |||
950 | goto unlock; | |||
951 | } | |||
952 | ||||
953 | if (uuid_is_null (local->gfid)) | |||
954 | uuid_copy (local->gfid, buf->ia_gfid); | |||
955 | ||||
956 | if (uuid_compare (local->gfid, buf->ia_gfid)) { | |||
957 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid differs on subvolume %s", loc ->path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 959, GF_LOG_WARNING, "%s: gfid differs on subvolume %s", loc->path, prev->this ->name); } while (0) | |||
958 | "%s: gfid differs on subvolume %s",do { do { if (0) printf ("%s: gfid differs on subvolume %s", loc ->path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 959, GF_LOG_WARNING, "%s: gfid differs on subvolume %s", loc->path, prev->this ->name); } while (0) | |||
959 | loc->path, prev->this->name)do { do { if (0) printf ("%s: gfid differs on subvolume %s", loc ->path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 959, GF_LOG_WARNING, "%s: gfid differs on subvolume %s", loc->path, prev->this ->name); } while (0); | |||
960 | } | |||
961 | ||||
962 | is_linkfile = check_is_linkfile (inode, buf, xattr,( ((st_mode_from_ia ((buf)->ia_prot, (buf)->ia_type) & ~0170000) == (01000)) && dict_get (xattr, conf->link_xattr_name )) | |||
963 | conf->link_xattr_name)( ((st_mode_from_ia ((buf)->ia_prot, (buf)->ia_type) & ~0170000) == (01000)) && dict_get (xattr, conf->link_xattr_name )); | |||
964 | is_dir = check_is_dir (inode, buf, xattr)((buf->ia_type == IA_IFDIR)); | |||
965 | ||||
966 | if (is_linkfile) { | |||
967 | link_subvol = dht_linkfile_subvol (this, inode, buf, | |||
968 | xattr); | |||
969 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 972, GF_LOG_DEBUG, "found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0) | |||
970 | "found on %s linkfile %s (-> %s)",do { do { if (0) printf ("found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 972, GF_LOG_DEBUG, "found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0) | |||
971 | subvol->name, loc->path,do { do { if (0) printf ("found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 972, GF_LOG_DEBUG, "found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0) | |||
972 | link_subvol ? link_subvol->name : "''")do { do { if (0) printf ("found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 972, GF_LOG_DEBUG, "found on %s linkfile %s (-> %s)" , subvol->name, loc->path, link_subvol ? link_subvol-> name : "''"); } while (0); | |||
973 | goto unlock; | |||
974 | } | |||
975 | ||||
976 | /* non linkfile GFID takes precedence */ | |||
977 | uuid_copy (local->gfid, buf->ia_gfid); | |||
978 | ||||
979 | if (is_dir) { | |||
980 | local->dir_count++; | |||
981 | ||||
982 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("found on %s directory %s", subvol-> name, loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 984, GF_LOG_DEBUG, "found on %s directory %s" , subvol->name, loc->path); } while (0) | |||
983 | "found on %s directory %s",do { do { if (0) printf ("found on %s directory %s", subvol-> name, loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 984, GF_LOG_DEBUG, "found on %s directory %s" , subvol->name, loc->path); } while (0) | |||
984 | subvol->name, loc->path)do { do { if (0) printf ("found on %s directory %s", subvol-> name, loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 984, GF_LOG_DEBUG, "found on %s directory %s" , subvol->name, loc->path); } while (0); | |||
985 | } else { | |||
986 | local->file_count++; | |||
987 | ||||
988 | if (!local->cached_subvol) { | |||
989 | /* found one file */ | |||
990 | dht_iatt_merge (this, &local->stbuf, buf, | |||
991 | subvol); | |||
992 | local->xattr = dict_ref (xattr); | |||
993 | local->cached_subvol = subvol; | |||
994 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("found on %s file %s", subvol->name , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 996, GF_LOG_DEBUG, "found on %s file %s", subvol ->name, loc->path); } while (0) | |||
995 | "found on %s file %s",do { do { if (0) printf ("found on %s file %s", subvol->name , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 996, GF_LOG_DEBUG, "found on %s file %s", subvol ->name, loc->path); } while (0) | |||
996 | subvol->name, loc->path)do { do { if (0) printf ("found on %s file %s", subvol->name , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 996, GF_LOG_DEBUG, "found on %s file %s", subvol ->name, loc->path); } while (0); | |||
997 | ||||
998 | dht_iatt_merge (this, &local->postparent, | |||
999 | postparent, subvol); | |||
1000 | } else { | |||
1001 | /* This is where we need 'rename' both entries logic */ | |||
1002 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1007, GF_LOG_WARNING, "multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0) | |||
1003 | "multiple subvolumes (%s and %s) have "do { do { if (0) printf ("multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1007, GF_LOG_WARNING, "multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0) | |||
1004 | "file %s (preferably rename the file "do { do { if (0) printf ("multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1007, GF_LOG_WARNING, "multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0) | |||
1005 | "in the backend, and do a fresh lookup)",do { do { if (0) printf ("multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1007, GF_LOG_WARNING, "multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0) | |||
1006 | local->cached_subvol->name,do { do { if (0) printf ("multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1007, GF_LOG_WARNING, "multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0) | |||
1007 | subvol->name, local->loc.path)do { do { if (0) printf ("multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1007, GF_LOG_WARNING, "multiple subvolumes (%s and %s) have " "file %s (preferably rename the file " "in the backend, and do a fresh lookup)" , local->cached_subvol->name, subvol->name, local-> loc.path); } while (0); | |||
1008 | } | |||
1009 | } | |||
1010 | } | |||
1011 | unlock: | |||
1012 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
1013 | ||||
1014 | if (is_linkfile) { | |||
1015 | ret = dict_get_int32 (xattr, GLUSTERFS_OPEN_FD_COUNT"glusterfs.open-fd-count", &fd_count); | |||
1016 | /* Delete the linkfile only if there are no open fds on it. | |||
1017 | if there is a open-fd, it may be in migration */ | |||
1018 | if (!ret && (fd_count == 0)) { | |||
1019 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("deleting stale linkfile %s on %s", loc ->path, subvol->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1021, GF_LOG_INFO, "deleting stale linkfile %s on %s" , loc->path, subvol->name); } while (0) | |||
1020 | "deleting stale linkfile %s on %s",do { do { if (0) printf ("deleting stale linkfile %s on %s", loc ->path, subvol->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1021, GF_LOG_INFO, "deleting stale linkfile %s on %s" , loc->path, subvol->name); } while (0) | |||
1021 | loc->path, subvol->name)do { do { if (0) printf ("deleting stale linkfile %s on %s", loc ->path, subvol->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1021, GF_LOG_INFO, "deleting stale linkfile %s on %s" , loc->path, subvol->name); } while (0); | |||
1022 | STACK_WIND (frame, dht_lookup_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1023, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->unlink_cbk) tmp_cbk = dht_lookup_unlink_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->unlink" ; _new->unwind_to = "dht_lookup_unlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->unlink); subvol-> fops->unlink (_new, subvol, loc, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1023 | subvol, subvol->fops->unlink, loc, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1023, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->unlink_cbk) tmp_cbk = dht_lookup_unlink_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->unlink" ; _new->unwind_to = "dht_lookup_unlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->unlink); subvol-> fops->unlink (_new, subvol, loc, 0, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1024 | return 0; | |||
1025 | } | |||
1026 | } | |||
1027 | ||||
1028 | this_call_cnt = dht_frame_return (frame); | |||
1029 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
1030 | dht_lookup_everywhere_done (frame, this); | |||
1031 | } | |||
1032 | ||||
1033 | out: | |||
1034 | return ret; | |||
1035 | } | |||
1036 | ||||
1037 | ||||
1038 | int | |||
1039 | dht_lookup_everywhere (call_frame_t *frame, xlator_t *this, loc_t *loc) | |||
1040 | { | |||
1041 | dht_conf_t *conf = NULL((void*)0); | |||
1042 | dht_local_t *local = NULL((void*)0); | |||
1043 | int i = 0; | |||
1044 | int call_cnt = 0; | |||
1045 | ||||
1046 | GF_VALIDATE_OR_GOTO ("dht", frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1046, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto err; } } while (0); | |||
1047 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1047, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
1048 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1048, GF_LOG_ERROR, "invalid argument: " "frame->local") ; } while (0); goto out; } } while (0); | |||
1049 | GF_VALIDATE_OR_GOTO ("dht", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1049, GF_LOG_ERROR, "invalid argument: " "this->private" ); } while (0); goto out; } } while (0); | |||
1050 | GF_VALIDATE_OR_GOTO ("dht", loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1050, GF_LOG_ERROR, "invalid argument: " "loc"); } while (0); goto out; } } while (0); | |||
1051 | ||||
1052 | conf = this->private; | |||
1053 | local = frame->local; | |||
1054 | ||||
1055 | call_cnt = conf->subvolume_cnt; | |||
1056 | local->call_cnt = call_cnt; | |||
1057 | ||||
1058 | if (!local->inode) | |||
1059 | local->inode = inode_ref (loc->inode); | |||
1060 | ||||
1061 | for (i = 0; i < call_cnt; i++) { | |||
1062 | STACK_WIND (frame, dht_lookup_everywhere_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1065, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_everywhere_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_everywhere_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1063 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1065, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_everywhere_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_everywhere_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1064 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1065, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_everywhere_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_everywhere_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1065 | loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1065, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_everywhere_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_everywhere_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1066 | } | |||
1067 | ||||
1068 | return 0; | |||
1069 | out: | |||
1070 | DHT_STACK_UNWIND (lookup, frame, -1, EINVAL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1070, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 22, ((void*)0), ((void*)0), ((void*)0), ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) ; dht_local_wipe (__xl, __local); } while (0); | |||
1071 | err: | |||
1072 | return -1; | |||
1073 | } | |||
1074 | ||||
1075 | ||||
1076 | int | |||
1077 | dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie, | |||
1078 | xlator_t *this, int op_ret, int op_errno, | |||
1079 | inode_t *inode, struct iatt *stbuf, dict_t *xattr, | |||
1080 | struct iatt *postparent) | |||
1081 | { | |||
1082 | call_frame_t *prev = NULL((void*)0); | |||
1083 | dht_local_t *local = NULL((void*)0); | |||
1084 | xlator_t *subvol = NULL((void*)0); | |||
1085 | loc_t *loc = NULL((void*)0); | |||
1086 | dht_conf_t *conf = NULL((void*)0); | |||
1087 | int ret = 0; | |||
1088 | ||||
1089 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1089, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
1090 | GF_VALIDATE_OR_GOTO ("dht", this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1090, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); | |||
1091 | GF_VALIDATE_OR_GOTO ("dht", frame->local, unwind)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1091, GF_LOG_ERROR, "invalid argument: " "frame->local") ; } while (0); goto unwind; } } while (0); | |||
1092 | GF_VALIDATE_OR_GOTO ("dht", this->private, unwind)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1092, GF_LOG_ERROR, "invalid argument: " "this->private" ); } while (0); goto unwind; } } while (0); | |||
1093 | GF_VALIDATE_OR_GOTO ("dht", cookie, unwind)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1093, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto unwind; } } while (0); | |||
1094 | ||||
1095 | prev = cookie; | |||
1096 | subvol = prev->this; | |||
1097 | conf = this->private; | |||
1098 | local = frame->local; | |||
1099 | loc = &local->loc; | |||
1100 | ||||
1101 | if (op_ret == -1) { | |||
1102 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("lookup of %s on %s (following linkfile) failed (%s)" , local->loc.path, subvol->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 1104, GF_LOG_INFO, "lookup of %s on %s (following linkfile) failed (%s)" , local->loc.path, subvol->name, strerror (op_errno)); } while (0) | |||
1103 | "lookup of %s on %s (following linkfile) failed (%s)",do { do { if (0) printf ("lookup of %s on %s (following linkfile) failed (%s)" , local->loc.path, subvol->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 1104, GF_LOG_INFO, "lookup of %s on %s (following linkfile) failed (%s)" , local->loc.path, subvol->name, strerror (op_errno)); } while (0) | |||
1104 | local->loc.path, subvol->name, strerror (op_errno))do { do { if (0) printf ("lookup of %s on %s (following linkfile) failed (%s)" , local->loc.path, subvol->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 1104, GF_LOG_INFO, "lookup of %s on %s (following linkfile) failed (%s)" , local->loc.path, subvol->name, strerror (op_errno)); } while (0); | |||
1105 | ||||
1106 | /* If cached subvol returned ENOTCONN, do not do | |||
1107 | lookup_everywhere. We need to make sure linkfile does not get | |||
1108 | removed, which can take away the namespace, and subvol is | |||
1109 | anyways down. */ | |||
1110 | ||||
1111 | if (op_errno != ENOTCONN107) | |||
1112 | goto err; | |||
1113 | else | |||
1114 | goto unwind; | |||
1115 | } | |||
1116 | ||||
1117 | if (check_is_dir (inode, stbuf, xattr)((stbuf->ia_type == IA_IFDIR))) { | |||
1118 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("lookup of %s on %s (following linkfile) reached dir" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1120, GF_LOG_INFO , "lookup of %s on %s (following linkfile) reached dir", local ->loc.path, subvol->name); } while (0) | |||
1119 | "lookup of %s on %s (following linkfile) reached dir",do { do { if (0) printf ("lookup of %s on %s (following linkfile) reached dir" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1120, GF_LOG_INFO , "lookup of %s on %s (following linkfile) reached dir", local ->loc.path, subvol->name); } while (0) | |||
1120 | local->loc.path, subvol->name)do { do { if (0) printf ("lookup of %s on %s (following linkfile) reached dir" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1120, GF_LOG_INFO , "lookup of %s on %s (following linkfile) reached dir", local ->loc.path, subvol->name); } while (0); | |||
1121 | goto err; | |||
1122 | } | |||
1123 | ||||
1124 | if (check_is_linkfile (inode, stbuf, xattr, conf->link_xattr_name)( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name))) { | |||
1125 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("lookup of %s on %s (following linkfile) reached link" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1127, GF_LOG_INFO , "lookup of %s on %s (following linkfile) reached link", local ->loc.path, subvol->name); } while (0) | |||
1126 | "lookup of %s on %s (following linkfile) reached link",do { do { if (0) printf ("lookup of %s on %s (following linkfile) reached link" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1127, GF_LOG_INFO , "lookup of %s on %s (following linkfile) reached link", local ->loc.path, subvol->name); } while (0) | |||
1127 | local->loc.path, subvol->name)do { do { if (0) printf ("lookup of %s on %s (following linkfile) reached link" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1127, GF_LOG_INFO , "lookup of %s on %s (following linkfile) reached link", local ->loc.path, subvol->name); } while (0); | |||
1128 | goto err; | |||
1129 | } | |||
1130 | ||||
1131 | if (uuid_compare (local->gfid, stbuf->ia_gfid)) { | |||
1132 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid different on data file on %s" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1134, GF_LOG_WARNING , "%s: gfid different on data file on %s", local->loc.path , subvol->name); } while (0) | |||
1133 | "%s: gfid different on data file on %s",do { do { if (0) printf ("%s: gfid different on data file on %s" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1134, GF_LOG_WARNING , "%s: gfid different on data file on %s", local->loc.path , subvol->name); } while (0) | |||
1134 | local->loc.path, subvol->name)do { do { if (0) printf ("%s: gfid different on data file on %s" , local->loc.path, subvol->name); } while (0); _gf_log ( this->name, "dht-common.c", __FUNCTION__, 1134, GF_LOG_WARNING , "%s: gfid different on data file on %s", local->loc.path , subvol->name); } while (0); | |||
1135 | goto err; | |||
1136 | } | |||
1137 | ||||
1138 | if ((stbuf->ia_nlink == 1) | |||
1139 | && (conf && conf->unhashed_sticky_bit)) { | |||
1140 | stbuf->ia_prot.sticky = 1; | |||
1141 | } | |||
1142 | ||||
1143 | ret = dht_layout_preset (this, prev->this, inode); | |||
1144 | if (ret < 0) { | |||
1145 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("failed to set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1147, GF_LOG_INFO, "failed to set layout for subvolume %s" , prev->this->name); } while (0) | |||
1146 | "failed to set layout for subvolume %s",do { do { if (0) printf ("failed to set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1147, GF_LOG_INFO, "failed to set layout for subvolume %s" , prev->this->name); } while (0) | |||
1147 | prev->this->name)do { do { if (0) printf ("failed to set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1147, GF_LOG_INFO, "failed to set layout for subvolume %s" , prev->this->name); } while (0); | |||
1148 | op_ret = -1; | |||
1149 | op_errno = EINVAL22; | |||
1150 | } | |||
1151 | ||||
1152 | if (local->loc.parent) { | |||
1153 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
1154 | postparent, 1); | |||
1155 | } | |||
1156 | ||||
1157 | unwind: | |||
1158 | DHT_STRIP_PHASE1_FLAGS (stbuf)do { if ((stbuf) && ( ((stbuf)->ia_type == IA_IFREG ) && ((stbuf)->ia_prot.sticky == 1) && ((stbuf )->ia_prot.sgid == 1))) { (stbuf)->ia_prot.sticky = 0; ( stbuf)->ia_prot.sgid = 0; } } while (0); | |||
1159 | DHT_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf, xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1160, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, xattr, postparent) ; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1160 | postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1160, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, xattr, postparent) ; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1161 | ||||
1162 | return 0; | |||
1163 | ||||
1164 | err: | |||
1165 | dht_lookup_everywhere (frame, this, loc); | |||
1166 | out: | |||
1167 | return 0; | |||
1168 | } | |||
1169 | ||||
1170 | ||||
1171 | int | |||
1172 | dht_lookup_directory (call_frame_t *frame, xlator_t *this, loc_t *loc) | |||
1173 | { | |||
1174 | int call_cnt = 0; | |||
1175 | int i = 0; | |||
1176 | dht_conf_t *conf = NULL((void*)0); | |||
1177 | dht_local_t *local = NULL((void*)0); | |||
1178 | int ret = 0; | |||
1179 | ||||
1180 | GF_VALIDATE_OR_GOTO ("dht", frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1180, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto out; } } while (0); | |||
1181 | GF_VALIDATE_OR_GOTO ("dht", this, unwind)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1181, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto unwind; } } while (0); | |||
1182 | GF_VALIDATE_OR_GOTO ("dht", frame->local, unwind)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1182, GF_LOG_ERROR, "invalid argument: " "frame->local") ; } while (0); goto unwind; } } while (0); | |||
1183 | GF_VALIDATE_OR_GOTO ("dht", this->private, unwind)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1183, GF_LOG_ERROR, "invalid argument: " "this->private" ); } while (0); goto unwind; } } while (0); | |||
1184 | GF_VALIDATE_OR_GOTO ("dht", loc, unwind)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1184, GF_LOG_ERROR, "invalid argument: " "loc"); } while (0); goto unwind; } } while (0); | |||
1185 | ||||
1186 | conf = this->private; | |||
1187 | local = frame->local; | |||
1188 | ||||
1189 | call_cnt = conf->subvolume_cnt; | |||
1190 | local->call_cnt = call_cnt; | |||
1191 | ||||
1192 | local->layout = dht_layout_new (this, conf->subvolume_cnt); | |||
1193 | if (!local->layout) { | |||
1194 | goto unwind; | |||
1195 | } | |||
1196 | ||||
1197 | if (local->xattr != NULL((void*)0)) { | |||
1198 | dict_unref (local->xattr); | |||
1199 | local->xattr = NULL((void*)0); | |||
1200 | } | |||
1201 | ||||
1202 | if (!uuid_is_null (local->gfid)) { | |||
1203 | ret = dict_set_static_bin (local->xattr_req, "gfid-req", | |||
1204 | local->gfid, 16); | |||
1205 | if (ret) | |||
1206 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to set gfid", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1207, GF_LOG_WARNING, "%s: failed to set gfid" , local->loc.path); } while (0) | |||
1207 | "%s: failed to set gfid", local->loc.path)do { do { if (0) printf ("%s: failed to set gfid", local-> loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1207, GF_LOG_WARNING, "%s: failed to set gfid" , local->loc.path); } while (0); | |||
1208 | } | |||
1209 | ||||
1210 | for (i = 0; i < call_cnt; i++) { | |||
1211 | STACK_WIND (frame, dht_lookup_dir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1214, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1212 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1214, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1213 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1214, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1214 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1214, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1215 | } | |||
1216 | return 0; | |||
1217 | unwind: | |||
1218 | DHT_STACK_UNWIND (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1218, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, 12, ((void*)0), ((void*)0), ((void*)0), ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) ; dht_local_wipe (__xl, __local); } while (0); | |||
1219 | out: | |||
1220 | return 0; | |||
1221 | ||||
1222 | } | |||
1223 | ||||
1224 | ||||
1225 | int | |||
1226 | dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1227 | int op_ret, int op_errno, | |||
1228 | inode_t *inode, struct iatt *stbuf, dict_t *xattr, | |||
1229 | struct iatt *postparent) | |||
1230 | { | |||
1231 | char is_linkfile = 0; | |||
1232 | char is_dir = 0; | |||
1233 | xlator_t *subvol = NULL((void*)0); | |||
1234 | dht_conf_t *conf = NULL((void*)0); | |||
1235 | dht_local_t *local = NULL((void*)0); | |||
1236 | loc_t *loc = NULL((void*)0); | |||
1237 | call_frame_t *prev = NULL((void*)0); | |||
1238 | int ret = 0; | |||
1239 | dht_layout_t *parent_layout = NULL((void*)0); | |||
1240 | ||||
1241 | GF_VALIDATE_OR_GOTO ("dht", frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1241, GF_LOG_ERROR, "invalid argument: " "frame"); } while (0); goto err; } } while (0); | |||
1242 | GF_VALIDATE_OR_GOTO ("dht", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1242, GF_LOG_ERROR, "invalid argument: " "this"); } while (0); goto out; } } while (0); | |||
1243 | GF_VALIDATE_OR_GOTO ("dht", frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1243, GF_LOG_ERROR, "invalid argument: " "frame->local") ; } while (0); goto out; } } while (0); | |||
1244 | GF_VALIDATE_OR_GOTO ("dht", cookie, out)do { if (!cookie) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "cookie"); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__, 1244, GF_LOG_ERROR, "invalid argument: " "cookie"); } while (0); goto out; } } while (0); | |||
1245 | GF_VALIDATE_OR_GOTO ("dht", this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ("dht", "dht-common.c", __FUNCTION__ , 1245, GF_LOG_ERROR, "invalid argument: " "this->private" ); } while (0); goto out; } } while (0); | |||
1246 | ||||
1247 | conf = this->private; | |||
1248 | ||||
1249 | prev = cookie; | |||
1250 | local = frame->local; | |||
1251 | loc = &local->loc; | |||
1252 | ||||
1253 | /* This is required for handling stale linkfile deletion, | |||
1254 | * or any more call which happens from this 'loc'. | |||
1255 | */ | |||
1256 | if (!op_ret && uuid_is_null (local->gfid)) | |||
1257 | memcpy (local->gfid, stbuf->ia_gfid, 16); | |||
1258 | ||||
1259 | if (ENTRY_MISSING (op_ret, op_errno)(op_ret == -1 && op_errno == 2)) { | |||
1260 | gf_log (this->name, GF_LOG_TRACE, "Entry %s missing on subvol"do { do { if (0) printf ("Entry %s missing on subvol" " %s", loc ->path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 1261, GF_LOG_TRACE, "Entry %s missing on subvol" " %s", loc->path, prev->this->name); } while (0) | |||
1261 | " %s", loc->path, prev->this->name)do { do { if (0) printf ("Entry %s missing on subvol" " %s", loc ->path, prev->this->name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 1261, GF_LOG_TRACE, "Entry %s missing on subvol" " %s", loc->path, prev->this->name); } while (0); | |||
1262 | if (conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_ON1) { | |||
1263 | local->op_errno = ENOENT2; | |||
1264 | dht_lookup_everywhere (frame, this, loc); | |||
1265 | return 0; | |||
1266 | } | |||
1267 | if ((conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_AUTO2) && | |||
1268 | (loc->parent)) { | |||
1269 | ret = dht_inode_ctx_layout_get (loc->parent, this, | |||
1270 | &parent_layout); | |||
1271 | if (ret || !parent_layout) | |||
1272 | goto out; | |||
1273 | if (parent_layout->search_unhashed) { | |||
1274 | local->op_errno = ENOENT2; | |||
1275 | dht_lookup_everywhere (frame, this, loc); | |||
1276 | return 0; | |||
1277 | } | |||
1278 | } | |||
1279 | } | |||
1280 | ||||
1281 | if (op_ret == 0) { | |||
1282 | is_dir = check_is_dir (inode, stbuf, xattr)((stbuf->ia_type == IA_IFDIR)); | |||
1283 | if (is_dir) { | |||
1284 | local->inode = inode_ref (inode); | |||
1285 | local->xattr = dict_ref (xattr); | |||
1286 | } | |||
1287 | } | |||
1288 | ||||
1289 | if (is_dir || (op_ret == -1 && op_errno == ENOTCONN107)) { | |||
1290 | dht_lookup_directory (frame, this, &local->loc); | |||
1291 | return 0; | |||
1292 | } | |||
1293 | ||||
1294 | if (op_ret == -1) { | |||
1295 | gf_log (this->name, GF_LOG_DEBUG, "Lookup of %s for subvolume"do { do { if (0) printf ("Lookup of %s for subvolume" " %s failed with error %s" , loc->path, prev->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 1297, GF_LOG_DEBUG, "Lookup of %s for subvolume" " %s failed with error %s" , loc->path, prev->this->name, strerror (op_errno)); } while (0) | |||
1296 | " %s failed with error %s", loc->path, prev->this->name,do { do { if (0) printf ("Lookup of %s for subvolume" " %s failed with error %s" , loc->path, prev->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 1297, GF_LOG_DEBUG, "Lookup of %s for subvolume" " %s failed with error %s" , loc->path, prev->this->name, strerror (op_errno)); } while (0) | |||
1297 | strerror (op_errno))do { do { if (0) printf ("Lookup of %s for subvolume" " %s failed with error %s" , loc->path, prev->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 1297, GF_LOG_DEBUG, "Lookup of %s for subvolume" " %s failed with error %s" , loc->path, prev->this->name, strerror (op_errno)); } while (0); | |||
1298 | goto out; | |||
1299 | } | |||
1300 | ||||
1301 | is_linkfile = check_is_linkfile (inode, stbuf, xattr,( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)) | |||
1302 | conf->link_xattr_name)( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name)); | |||
1303 | ||||
1304 | if (!is_linkfile) { | |||
1305 | /* non-directory and not a linkfile */ | |||
1306 | ||||
1307 | ret = dht_layout_preset (this, prev->this, inode); | |||
1308 | if (ret < 0) { | |||
1309 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("could not set pre-set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1311, GF_LOG_INFO, "could not set pre-set layout for subvolume %s" , prev->this->name); } while (0) | |||
1310 | "could not set pre-set layout for subvolume %s",do { do { if (0) printf ("could not set pre-set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1311, GF_LOG_INFO, "could not set pre-set layout for subvolume %s" , prev->this->name); } while (0) | |||
1311 | prev->this->name)do { do { if (0) printf ("could not set pre-set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 1311, GF_LOG_INFO, "could not set pre-set layout for subvolume %s" , prev->this->name); } while (0); | |||
1312 | op_ret = -1; | |||
1313 | op_errno = EINVAL22; | |||
1314 | goto out; | |||
1315 | } | |||
1316 | goto out; | |||
1317 | } | |||
1318 | ||||
1319 | subvol = dht_linkfile_subvol (this, inode, stbuf, xattr); | |||
1320 | if (!subvol) { | |||
1321 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("linkfile not having link subvolume. path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1323, GF_LOG_DEBUG, "linkfile not having link subvolume. path=%s" , loc->path); } while (0) | |||
1322 | "linkfile not having link subvolume. path=%s",do { do { if (0) printf ("linkfile not having link subvolume. path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1323, GF_LOG_DEBUG, "linkfile not having link subvolume. path=%s" , loc->path); } while (0) | |||
1323 | loc->path)do { do { if (0) printf ("linkfile not having link subvolume. path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1323, GF_LOG_DEBUG, "linkfile not having link subvolume. path=%s" , loc->path); } while (0); | |||
1324 | dht_lookup_everywhere (frame, this, loc); | |||
1325 | return 0; | |||
1326 | } | |||
1327 | ||||
1328 | STACK_WIND (frame, dht_lookup_linkfile_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1330, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_lookup_linkfile_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup"; _new->unwind_to = "dht_lookup_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->lookup); subvol->fops->lookup (_new, subvol, & local->loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1329 | subvol, subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1330, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_lookup_linkfile_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup"; _new->unwind_to = "dht_lookup_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->lookup); subvol->fops->lookup (_new, subvol, & local->loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1330 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1330, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_lookup_linkfile_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup"; _new->unwind_to = "dht_lookup_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->lookup); subvol->fops->lookup (_new, subvol, & local->loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1331 | ||||
1332 | return 0; | |||
1333 | ||||
1334 | out: | |||
1335 | /* | |||
1336 | * FIXME: postparent->ia_size and postparent->st_blocks do not have | |||
1337 | * correct values. since, postparent corresponds to a directory these | |||
1338 | * two members should have values equal to sum of corresponding values | |||
1339 | * from each of the subvolume. See dht_iatt_merge for reference. | |||
1340 | */ | |||
1341 | ||||
1342 | if (!op_ret && local->loc.parent) { | |||
1343 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
1344 | postparent, 1); | |||
1345 | } | |||
1346 | ||||
1347 | DHT_STRIP_PHASE1_FLAGS (stbuf)do { if ((stbuf) && ( ((stbuf)->ia_type == IA_IFREG ) && ((stbuf)->ia_prot.sticky == 1) && ((stbuf )->ia_prot.sgid == 1))) { (stbuf)->ia_prot.sticky = 0; ( stbuf)->ia_prot.sgid = 0; } } while (0); | |||
1348 | DHT_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf, xattr,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1349, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, xattr, postparent) ; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1349 | postparent)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1349, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, xattr, postparent) ; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1350 | err: | |||
1351 | return 0; | |||
1352 | } | |||
1353 | ||||
1354 | /* For directories, check if acl xattrs have been requested (by the acl xlator), | |||
1355 | * if not, request for them. These xattrs are needed for dht dir self-heal to | |||
1356 | * perform proper self-healing of dirs | |||
1357 | */ | |||
1358 | void | |||
1359 | dht_check_and_set_acl_xattr_req (inode_t *inode, dict_t *xattr_req) | |||
1360 | { | |||
1361 | int ret = 0; | |||
1362 | ||||
1363 | GF_ASSERT (inode)do { if (!(inode)) { do { do { if (0) printf ("Assertion failed: " "inode"); } while (0); _gf_log_callingfn ("", "dht-common.c" , __FUNCTION__, 1363, GF_LOG_ERROR, "Assertion failed: " "inode" ); } while (0); } } while (0); | |||
1364 | GF_ASSERT (xattr_req)do { if (!(xattr_req)) { do { do { if (0) printf ("Assertion failed: " "xattr_req"); } while (0); _gf_log_callingfn ("", "dht-common.c" , __FUNCTION__, 1364, GF_LOG_ERROR, "Assertion failed: " "xattr_req" ); } while (0); } } while (0); | |||
1365 | ||||
1366 | if (inode->ia_type != IA_IFDIR) | |||
| ||||
1367 | return; | |||
1368 | ||||
1369 | if (!dict_get (xattr_req, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access")) { | |||
1370 | ret = dict_set_int8 (xattr_req, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access", 0); | |||
1371 | if (ret) | |||
1372 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "dht-common.c", __FUNCTION__, 1374, GF_LOG_WARNING, "failed to set key %s" , "system.posix_acl_access"); } while (0) | |||
1373 | "failed to set key %s",do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "dht-common.c", __FUNCTION__, 1374, GF_LOG_WARNING, "failed to set key %s" , "system.posix_acl_access"); } while (0) | |||
1374 | POSIX_ACL_ACCESS_XATTR)do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "dht-common.c", __FUNCTION__, 1374, GF_LOG_WARNING, "failed to set key %s" , "system.posix_acl_access"); } while (0); | |||
1375 | } | |||
1376 | ||||
1377 | if (!dict_get (xattr_req, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default")) { | |||
1378 | ret = dict_set_int8 (xattr_req, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default", 0); | |||
1379 | if (ret) | |||
1380 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "dht-common.c", __FUNCTION__, 1382, GF_LOG_WARNING, "failed to set key %s" , "system.posix_acl_default"); } while (0) | |||
1381 | "failed to set key %s",do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "dht-common.c", __FUNCTION__, 1382, GF_LOG_WARNING, "failed to set key %s" , "system.posix_acl_default"); } while (0) | |||
1382 | POSIX_ACL_DEFAULT_XATTR)do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log ((*__glusterfs_this_location())->name , "dht-common.c", __FUNCTION__, 1382, GF_LOG_WARNING, "failed to set key %s" , "system.posix_acl_default"); } while (0); | |||
1383 | } | |||
1384 | ||||
1385 | return; | |||
1386 | } | |||
1387 | ||||
1388 | int | |||
1389 | dht_lookup (call_frame_t *frame, xlator_t *this, | |||
1390 | loc_t *loc, dict_t *xattr_req) | |||
1391 | { | |||
1392 | xlator_t *subvol = NULL((void*)0); | |||
1393 | xlator_t *hashed_subvol = NULL((void*)0); | |||
1394 | dht_local_t *local = NULL((void*)0); | |||
1395 | dht_conf_t *conf = NULL((void*)0); | |||
1396 | int ret = -1; | |||
1397 | int op_errno = -1; | |||
1398 | dht_layout_t *layout = NULL((void*)0); | |||
1399 | int i = 0; | |||
1400 | int call_cnt = 0; | |||
1401 | loc_t new_loc = {0,}; | |||
1402 | ||||
1403 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 1403, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
1404 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 1404, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
1405 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 1405, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
1406 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 1406, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
1407 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 1407, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
1408 | ||||
1409 | conf = this->private; | |||
1410 | if (!conf) | |||
| ||||
1411 | goto err; | |||
1412 | ||||
1413 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_LOOKUP); | |||
1414 | if (!local) { | |||
1415 | op_errno = ENOMEM12; | |||
1416 | goto err; | |||
1417 | } | |||
1418 | ||||
1419 | ret = dht_filter_loc_subvol_key (this, loc, &new_loc, | |||
1420 | &hashed_subvol); | |||
1421 | if (ret) { | |||
1422 | loc_wipe (&local->loc); | |||
1423 | ret = loc_dup (&new_loc, &local->loc)loc_copy(&local->loc, &new_loc); | |||
1424 | ||||
1425 | /* we no more need 'new_loc' entries */ | |||
1426 | loc_wipe (&new_loc); | |||
1427 | ||||
1428 | /* check if loc_dup() is successful */ | |||
1429 | if (ret == -1) { | |||
1430 | op_errno = errno(*__errno_location ()); | |||
1431 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("copying location failed for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1433, GF_LOG_DEBUG, "copying location failed for path=%s" , loc->path); } while (0) | |||
1432 | "copying location failed for path=%s",do { do { if (0) printf ("copying location failed for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1433, GF_LOG_DEBUG, "copying location failed for path=%s" , loc->path); } while (0) | |||
1433 | loc->path)do { do { if (0) printf ("copying location failed for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1433, GF_LOG_DEBUG, "copying location failed for path=%s" , loc->path); } while (0); | |||
1434 | goto err; | |||
1435 | } | |||
1436 | } | |||
1437 | ||||
1438 | if (xattr_req) { | |||
1439 | local->xattr_req = dict_ref (xattr_req); | |||
1440 | } else { | |||
1441 | local->xattr_req = dict_new (); | |||
1442 | } | |||
1443 | ||||
1444 | if (uuid_is_null (loc->pargfid) && !uuid_is_null (loc->gfid) && | |||
1445 | !__is_root_gfid (loc->inode->gfid)) { | |||
1446 | local->cached_subvol = NULL((void*)0); | |||
1447 | dht_discover (frame, this, loc); | |||
1448 | return 0; | |||
1449 | } | |||
1450 | ||||
1451 | if (!hashed_subvol) | |||
1452 | hashed_subvol = dht_subvol_get_hashed (this, loc); | |||
1453 | local->hashed_subvol = hashed_subvol; | |||
1454 | ||||
1455 | if (is_revalidate (loc)(dht_inode_ctx_layout_get (loc->inode, this, ((void*)0)) == 0)) { | |||
1456 | layout = local->layout; | |||
1457 | if (!layout) { | |||
1458 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("revalidate without cache. path=%s", loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1460, GF_LOG_DEBUG, "revalidate without cache. path=%s" , loc->path); } while (0) | |||
1459 | "revalidate without cache. path=%s",do { do { if (0) printf ("revalidate without cache. path=%s", loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1460, GF_LOG_DEBUG, "revalidate without cache. path=%s" , loc->path); } while (0) | |||
1460 | loc->path)do { do { if (0) printf ("revalidate without cache. path=%s", loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1460, GF_LOG_DEBUG, "revalidate without cache. path=%s" , loc->path); } while (0); | |||
1461 | op_errno = EINVAL22; | |||
1462 | goto err; | |||
1463 | } | |||
1464 | ||||
1465 | if (layout->gen && (layout->gen < conf->gen)) { | |||
1466 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("incomplete layout failure for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1468, GF_LOG_TRACE, "incomplete layout failure for path=%s" , loc->path); } while (0) | |||
1467 | "incomplete layout failure for path=%s",do { do { if (0) printf ("incomplete layout failure for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1468, GF_LOG_TRACE, "incomplete layout failure for path=%s" , loc->path); } while (0) | |||
1468 | loc->path)do { do { if (0) printf ("incomplete layout failure for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1468, GF_LOG_TRACE, "incomplete layout failure for path=%s" , loc->path); } while (0); | |||
1469 | ||||
1470 | dht_layout_unref (this, local->layout); | |||
1471 | local->layout = NULL((void*)0); | |||
1472 | local->cached_subvol = NULL((void*)0); | |||
1473 | goto do_fresh_lookup; | |||
1474 | } | |||
1475 | ||||
1476 | local->inode = inode_ref (loc->inode); | |||
1477 | ||||
1478 | /* NOTE: we don't require 'trusted.glusterfs.dht.linkto' attribute, | |||
1479 | * revalidates directly go to the cached-subvolume. | |||
1480 | */ | |||
1481 | ret = dict_set_uint32 (local->xattr_req, | |||
1482 | conf->xattr_name, 4 * 4); | |||
1483 | ||||
1484 | if (IA_ISDIR (local->inode->ia_type)(local->inode->ia_type == IA_IFDIR)) { | |||
1485 | local->call_cnt = call_cnt = conf->subvolume_cnt; | |||
1486 | for (i = 0; i < call_cnt; i++) { | |||
1487 | STACK_WIND (frame, dht_revalidate_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1490, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1488 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1490, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1489 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1490, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1490 | loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1490, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], loc, local->xattr_req ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1491 | } | |||
1492 | return 0; | |||
1493 | } | |||
1494 | ||||
1495 | call_cnt = local->call_cnt = layout->cnt; | |||
1496 | ||||
1497 | /* need it for self-healing linkfiles which is | |||
1498 | 'in-migration' state */ | |||
1499 | ret = dict_set_uint32 (local->xattr_req, | |||
1500 | GLUSTERFS_OPEN_FD_COUNT"glusterfs.open-fd-count", 4); | |||
1501 | ||||
1502 | /* need it for dir self-heal */ | |||
1503 | dht_check_and_set_acl_xattr_req (loc->inode, local->xattr_req); | |||
1504 | ||||
1505 | for (i = 0; i < call_cnt; i++) { | |||
1506 | subvol = layout->list[i].xlator; | |||
1507 | ||||
1508 | STACK_WIND (frame, dht_revalidate_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1510, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup" ; _new->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->lookup); subvol-> fops->lookup (_new, subvol, &local->loc, local-> xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1509 | subvol, subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1510, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup" ; _new->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->lookup); subvol-> fops->lookup (_new, subvol, &local->loc, local-> xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1510 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1510, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->lookup_cbk) tmp_cbk = dht_revalidate_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->lookup" ; _new->unwind_to = "dht_revalidate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->lookup); subvol-> fops->lookup (_new, subvol, &local->loc, local-> xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1511 | ||||
1512 | } | |||
1513 | } else { | |||
1514 | do_fresh_lookup: | |||
1515 | /* TODO: remove the hard-coding */ | |||
1516 | ret = dict_set_uint32 (local->xattr_req, | |||
1517 | conf->xattr_name, 4 * 4); | |||
1518 | ||||
1519 | ret = dict_set_uint32 (local->xattr_req, | |||
1520 | conf->link_xattr_name, 256); | |||
1521 | ||||
1522 | /* need it for self-healing linkfiles which is | |||
1523 | 'in-migration' state */ | |||
1524 | ret = dict_set_uint32 (local->xattr_req, | |||
1525 | GLUSTERFS_OPEN_FD_COUNT"glusterfs.open-fd-count", 4); | |||
1526 | ||||
1527 | /* need it for dir self-heal */ | |||
1528 | dht_check_and_set_acl_xattr_req (loc->inode, local->xattr_req); | |||
1529 | ||||
1530 | if (!hashed_subvol) { | |||
1531 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1534, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0) | |||
1532 | "no subvolume in layout for path=%s, "do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1534, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0) | |||
1533 | "checking on all the subvols to see if "do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1534, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0) | |||
1534 | "it is a directory", loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1534, GF_LOG_DEBUG, "no subvolume in layout for path=%s, " "checking on all the subvols to see if " "it is a directory" , loc->path); } while (0); | |||
1535 | call_cnt = conf->subvolume_cnt; | |||
1536 | local->call_cnt = call_cnt; | |||
1537 | ||||
1538 | local->layout = dht_layout_new (this, | |||
1539 | conf->subvolume_cnt); | |||
1540 | if (!local->layout) { | |||
1541 | op_errno = ENOMEM12; | |||
1542 | goto err; | |||
1543 | } | |||
1544 | ||||
1545 | for (i = 0; i < call_cnt; i++) { | |||
1546 | STACK_WIND (frame, dht_lookup_dir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1549, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1547 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1549, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1548 | conf->subvolumes[i]->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1549, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1549 | &local->loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1549, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->lookup_cbk) tmp_cbk = dht_lookup_dir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->lookup"; _new ->unwind_to = "dht_lookup_dir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->lookup); conf->subvolumes[i]->fops-> lookup (_new, conf->subvolumes[i], &local->loc, local ->xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1550 | } | |||
1551 | return 0; | |||
1552 | } | |||
1553 | ||||
1554 | STACK_WIND (frame, dht_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1556, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1555 | hashed_subvol, hashed_subvol->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1556, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1556 | loc, local->xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1556, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->lookup_cbk) tmp_cbk = dht_lookup_cbk; _new-> root = frame->root; _new->this = hashed_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->lookup"; _new->unwind_to = "dht_lookup_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->lookup); hashed_subvol->fops-> lookup (_new, hashed_subvol, loc, local->xattr_req); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1557 | } | |||
1558 | ||||
1559 | return 0; | |||
1560 | ||||
1561 | err: | |||
1562 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
1563 | DHT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1564, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1564 | NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1564, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1565 | return 0; | |||
1566 | } | |||
1567 | ||||
1568 | ||||
1569 | int | |||
1570 | dht_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1571 | int op_ret, int op_errno, struct iatt *preparent, | |||
1572 | struct iatt *postparent, dict_t *xdata) | |||
1573 | { | |||
1574 | dht_local_t *local = NULL((void*)0); | |||
1575 | call_frame_t *prev = NULL((void*)0); | |||
1576 | ||||
1577 | local = frame->local; | |||
1578 | prev = cookie; | |||
1579 | ||||
1580 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
1581 | { | |||
1582 | if (op_ret == -1) { | |||
1583 | local->op_ret = -1; | |||
1584 | local->op_errno = op_errno; | |||
1585 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1587, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1586 | "subvolume %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1587, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1587 | prev->this->name, strerror (op_errno))do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1587, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
1588 | goto unlock; | |||
1589 | } | |||
1590 | ||||
1591 | local->op_ret = 0; | |||
1592 | ||||
1593 | local->postparent = *postparent; | |||
1594 | local->preparent = *preparent; | |||
1595 | ||||
1596 | if (local->loc.parent) { | |||
1597 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
1598 | &local->preparent, 0); | |||
1599 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
1600 | &local->postparent, 1); | |||
1601 | } | |||
1602 | } | |||
1603 | unlock: | |||
1604 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
1605 | ||||
1606 | DHT_STACK_UNWIND (unlink, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1607, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1607 | &local->preparent, &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1607, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1608 | ||||
1609 | return 0; | |||
1610 | } | |||
1611 | ||||
1612 | ||||
1613 | int | |||
1614 | dht_unlink_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1615 | int op_ret, int op_errno, struct iatt *preparent, | |||
1616 | struct iatt *postparent, dict_t *xdata) | |||
1617 | { | |||
1618 | dht_local_t *local = NULL((void*)0); | |||
1619 | call_frame_t *prev = NULL((void*)0); | |||
1620 | ||||
1621 | xlator_t *cached_subvol = NULL((void*)0); | |||
1622 | ||||
1623 | local = frame->local; | |||
1624 | prev = cookie; | |||
1625 | ||||
1626 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
1627 | { | |||
1628 | if (op_ret == -1) { | |||
1629 | local->op_errno = op_errno; | |||
1630 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1632, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1631 | "subvolume %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1632, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1632 | prev->this->name, strerror (op_errno))do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1632, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
1633 | goto unlock; | |||
1634 | } | |||
1635 | ||||
1636 | local->op_ret = 0; | |||
1637 | } | |||
1638 | unlock: | |||
1639 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
1640 | ||||
1641 | if (op_ret == -1) | |||
1642 | goto err; | |||
1643 | ||||
1644 | cached_subvol = dht_subvol_get_cached (this, local->loc.inode); | |||
1645 | if (!cached_subvol) { | |||
1646 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1648, GF_LOG_DEBUG, "no cached subvolume for path=%s" , local->loc.path); } while (0) | |||
1647 | "no cached subvolume for path=%s",do { do { if (0) printf ("no cached subvolume for path=%s", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1648, GF_LOG_DEBUG, "no cached subvolume for path=%s" , local->loc.path); } while (0) | |||
1648 | local->loc.path)do { do { if (0) printf ("no cached subvolume for path=%s", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1648, GF_LOG_DEBUG, "no cached subvolume for path=%s" , local->loc.path); } while (0); | |||
1649 | local->op_errno = EINVAL22; | |||
1650 | goto err; | |||
1651 | } | |||
1652 | ||||
1653 | STACK_WIND (frame, dht_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1655, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, &local->loc, local->flags , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1654 | cached_subvol, cached_subvol->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1655, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, &local->loc, local->flags , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1655 | &local->loc, local->flags, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 1655, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, &local->loc, local->flags , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1656 | ||||
1657 | return 0; | |||
1658 | ||||
1659 | err: | |||
1660 | DHT_STACK_UNWIND (unlink, frame, -1, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1661, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, local->op_errno, ((void*)0), ((void*)0), (( void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1661 | NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1661, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, local->op_errno, ((void*)0), ((void*)0), (( void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1662 | return 0; | |||
1663 | } | |||
1664 | ||||
1665 | static int | |||
1666 | dht_ufo_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1667 | int op_ret, int op_errno, dict_t *xdata) | |||
1668 | { | |||
1669 | dht_local_t *local = NULL((void*)0); | |||
1670 | int this_call_cnt = 0; | |||
1671 | call_frame_t *prev = NULL((void*)0); | |||
1672 | ||||
1673 | local = frame->local; | |||
1674 | prev = cookie; | |||
1675 | ||||
1676 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
1677 | { | |||
1678 | if (op_ret == -1) { | |||
1679 | local->op_ret = -1; | |||
1680 | local->op_errno = op_errno; | |||
1681 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1683, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1682 | "subvolume %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1683, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1683 | prev->this->name, strerror (op_errno))do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1683, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
1684 | goto unlock; | |||
1685 | } | |||
1686 | } | |||
1687 | unlock: | |||
1688 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
1689 | ||||
1690 | this_call_cnt = dht_frame_return (frame); | |||
1691 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
1692 | DHT_STACK_UNWIND (setxattr, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1693, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1693 | local->op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1693, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1694 | } | |||
1695 | ||||
1696 | return 0; | |||
1697 | } | |||
1698 | ||||
1699 | ||||
1700 | int | |||
1701 | dht_err_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1702 | int op_ret, int op_errno, dict_t *xdata) | |||
1703 | { | |||
1704 | dht_local_t *local = NULL((void*)0); | |||
1705 | int this_call_cnt = 0; | |||
1706 | call_frame_t *prev = NULL((void*)0); | |||
1707 | ||||
1708 | local = frame->local; | |||
1709 | prev = cookie; | |||
1710 | ||||
1711 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
1712 | { | |||
1713 | if (op_ret == -1) { | |||
1714 | local->op_errno = op_errno; | |||
1715 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1717, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1716 | "subvolume %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1717, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1717 | prev->this->name, strerror (op_errno))do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1717, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
1718 | goto unlock; | |||
1719 | } | |||
1720 | ||||
1721 | local->op_ret = 0; | |||
1722 | } | |||
1723 | unlock: | |||
1724 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
1725 | ||||
1726 | this_call_cnt = dht_frame_return (frame); | |||
1727 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
1728 | DHT_STACK_UNWIND (setxattr, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1729, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1729 | local->op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1729, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1730 | } | |||
1731 | ||||
1732 | return 0; | |||
1733 | } | |||
1734 | ||||
1735 | static void | |||
1736 | fill_layout_info (dht_layout_t *layout, char *buf) | |||
1737 | { | |||
1738 | int i = 0; | |||
1739 | char tmp_buf[128] = {0,}; | |||
1740 | ||||
1741 | for (i = 0; i < layout->cnt; i++) { | |||
1742 | snprintf (tmp_buf, 128, "(%s %u %u)", | |||
1743 | layout->list[i].xlator->name, | |||
1744 | layout->list[i].start, | |||
1745 | layout->list[i].stop); | |||
1746 | if (i) | |||
1747 | strcat (buf, " "); | |||
1748 | strcat (buf, tmp_buf); | |||
1749 | } | |||
1750 | } | |||
1751 | ||||
1752 | void | |||
1753 | dht_fill_pathinfo_xattr (xlator_t *this, dht_local_t *local, | |||
1754 | char *xattr_buf, int32_t alloc_len, | |||
1755 | int flag, char *layout_buf) | |||
1756 | { | |||
1757 | if (flag && local->xattr_val) | |||
1758 | snprintf (xattr_buf, alloc_len, | |||
1759 | "((<"DHT_PATHINFO_HEADER"DISTRIBUTE:""%s> %s) (%s-layout %s))", | |||
1760 | this->name, local->xattr_val, this->name, | |||
1761 | layout_buf); | |||
1762 | else if (local->xattr_val) | |||
1763 | snprintf (xattr_buf, alloc_len, | |||
1764 | "(<"DHT_PATHINFO_HEADER"DISTRIBUTE:""%s> %s)", | |||
1765 | this->name, local->xattr_val); | |||
1766 | else if (flag) | |||
1767 | snprintf (xattr_buf, alloc_len, "(%s-layout %s)", | |||
1768 | this->name, layout_buf); | |||
1769 | } | |||
1770 | ||||
1771 | int | |||
1772 | dht_vgetxattr_alloc_and_fill (dht_local_t *local, dict_t *xattr, xlator_t *this, | |||
1773 | int op_errno) | |||
1774 | { | |||
1775 | int ret = -1; | |||
1776 | char *value = NULL((void*)0); | |||
1777 | int32_t plen = 0; | |||
1778 | ||||
1779 | ret = dict_get_str (xattr, local->xsel, &value); | |||
1780 | if (ret) { | |||
1781 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Subvolume %s returned -1 (%s)", this ->name, strerror (op_errno)); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 1783, GF_LOG_ERROR, "Subvolume %s returned -1 (%s)" , this->name, strerror (op_errno)); } while (0) | |||
1782 | "Subvolume %s returned -1 (%s)", this->name,do { do { if (0) printf ("Subvolume %s returned -1 (%s)", this ->name, strerror (op_errno)); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 1783, GF_LOG_ERROR, "Subvolume %s returned -1 (%s)" , this->name, strerror (op_errno)); } while (0) | |||
1783 | strerror (op_errno))do { do { if (0) printf ("Subvolume %s returned -1 (%s)", this ->name, strerror (op_errno)); } while (0); _gf_log (this-> name, "dht-common.c", __FUNCTION__, 1783, GF_LOG_ERROR, "Subvolume %s returned -1 (%s)" , this->name, strerror (op_errno)); } while (0); | |||
1784 | local->op_ret = -1; | |||
1785 | local->op_errno = op_errno; | |||
1786 | goto out; | |||
1787 | } | |||
1788 | ||||
1789 | local->alloc_len += strlen(value); | |||
1790 | ||||
1791 | if (!local->xattr_val) { | |||
1792 | local->alloc_len += (strlen (DHT_PATHINFO_HEADER"DISTRIBUTE:") + 10); | |||
1793 | local->xattr_val = GF_CALLOC (local->alloc_len, sizeof (char),__gf_calloc (local->alloc_len, sizeof (char), gf_common_mt_char ) | |||
1794 | gf_common_mt_char)__gf_calloc (local->alloc_len, sizeof (char), gf_common_mt_char ); | |||
1795 | if (!local->xattr_val) { | |||
1796 | ret = -1; | |||
1797 | goto out; | |||
1798 | } | |||
1799 | } | |||
1800 | ||||
1801 | if (local->xattr_val) { | |||
1802 | plen = strlen (local->xattr_val); | |||
1803 | if (plen) { | |||
1804 | /* extra byte(s) for \0 to be safe */ | |||
1805 | local->alloc_len += (plen + 2); | |||
1806 | local->xattr_val = GF_REALLOC (local->xattr_val,__gf_realloc (local->xattr_val, local->alloc_len) | |||
1807 | local->alloc_len)__gf_realloc (local->xattr_val, local->alloc_len); | |||
1808 | if (!local->xattr_val) { | |||
1809 | ret = -1; | |||
1810 | goto out; | |||
1811 | } | |||
1812 | } | |||
1813 | ||||
1814 | (void) strcat (local->xattr_val, value); | |||
1815 | local->op_ret = 0; | |||
1816 | } | |||
1817 | ||||
1818 | ret = 0; | |||
1819 | ||||
1820 | out: | |||
1821 | return ret; | |||
1822 | } | |||
1823 | ||||
1824 | int | |||
1825 | dht_vgetxattr_fill_and_set (dht_local_t *local, dict_t **dict, xlator_t *this, | |||
1826 | gf_boolean_t flag) | |||
1827 | { | |||
1828 | int ret = -1; | |||
1829 | char *xattr_buf = NULL((void*)0); | |||
1830 | char layout_buf[8192] = {0,}; | |||
1831 | ||||
1832 | if (flag) | |||
1833 | fill_layout_info (local->layout, layout_buf); | |||
1834 | ||||
1835 | *dict = dict_new (); | |||
1836 | if (!*dict) | |||
1837 | goto out; | |||
1838 | ||||
1839 | /* we would need max this many bytes to create xattr string | |||
1840 | * extra 40 bytes is just an estimated amount of additional | |||
1841 | * space required as we include translator name and some | |||
1842 | * spaces, brackets etc. when forming the pathinfo string. | |||
1843 | * | |||
1844 | * For node-uuid we just don't have all the pretty formatting, | |||
1845 | * but since this is a generic routine for pathinfo & node-uuid | |||
1846 | * we dont have conditional space allocation and try to be | |||
1847 | * generic | |||
1848 | */ | |||
1849 | local->alloc_len += (2 * strlen (this->name)) | |||
1850 | + strlen (layout_buf) | |||
1851 | + 40; | |||
1852 | xattr_buf = GF_CALLOC (local->alloc_len, sizeof (char),__gf_calloc (local->alloc_len, sizeof (char), gf_common_mt_char ) | |||
1853 | gf_common_mt_char)__gf_calloc (local->alloc_len, sizeof (char), gf_common_mt_char ); | |||
1854 | if (!xattr_buf) | |||
1855 | goto out; | |||
1856 | ||||
1857 | if (XATTR_IS_PATHINFO (local->xsel)(strncmp (local->xsel, "trusted.glusterfs.pathinfo", strlen ("trusted.glusterfs.pathinfo")) == 0)) { | |||
1858 | (void) dht_fill_pathinfo_xattr (this, local, xattr_buf, | |||
1859 | local->alloc_len, flag, | |||
1860 | layout_buf); | |||
1861 | } else if (XATTR_IS_NODE_UUID (local->xsel)(strncmp (local->xsel, "trusted.glusterfs.node-uuid", strlen ("trusted.glusterfs.node-uuid")) == 0)) { | |||
1862 | (void) snprintf (xattr_buf, local->alloc_len, "%s", | |||
1863 | local->xattr_val); | |||
1864 | } else { | |||
1865 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Unknown local->xsel (%s)", local ->xsel); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1866, GF_LOG_WARNING, "Unknown local->xsel (%s)" , local->xsel); } while (0) | |||
1866 | "Unknown local->xsel (%s)", local->xsel)do { do { if (0) printf ("Unknown local->xsel (%s)", local ->xsel); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1866, GF_LOG_WARNING, "Unknown local->xsel (%s)" , local->xsel); } while (0); | |||
1867 | goto out; | |||
1868 | } | |||
1869 | ||||
1870 | ret = dict_set_dynstr (*dict, local->xsel, xattr_buf); | |||
1871 | GF_FREE (local->xattr_val)__gf_free (local->xattr_val); | |||
1872 | ||||
1873 | out: | |||
1874 | return ret; | |||
1875 | } | |||
1876 | ||||
1877 | int | |||
1878 | dht_vgetxattr_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1879 | int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) | |||
1880 | { | |||
1881 | int ret = 0; | |||
1882 | dht_local_t *local = NULL((void*)0); | |||
1883 | int this_call_cnt = 0; | |||
1884 | dict_t *dict = NULL((void*)0); | |||
1885 | ||||
1886 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 1886, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||
1887 | VALIDATE_OR_GOTO (frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 1887, GF_LOG_WARNING, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
1888 | ||||
1889 | local = frame->local; | |||
1890 | ||||
1891 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
1892 | { | |||
1893 | this_call_cnt = --local->call_cnt; | |||
1894 | if (op_ret < 0) { | |||
1895 | if (op_errno != ENOTCONN107) { | |||
1896 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("getxattr err (%s) for dir", strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1898, GF_LOG_ERROR, "getxattr err (%s) for dir" , strerror (op_errno)); } while (0) | |||
1897 | "getxattr err (%s) for dir",do { do { if (0) printf ("getxattr err (%s) for dir", strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1898, GF_LOG_ERROR, "getxattr err (%s) for dir" , strerror (op_errno)); } while (0) | |||
1898 | strerror (op_errno))do { do { if (0) printf ("getxattr err (%s) for dir", strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 1898, GF_LOG_ERROR, "getxattr err (%s) for dir" , strerror (op_errno)); } while (0); | |||
1899 | local->op_ret = -1; | |||
1900 | local->op_errno = op_errno; | |||
1901 | } | |||
1902 | ||||
1903 | goto unlock; | |||
1904 | } | |||
1905 | ||||
1906 | ret = dht_vgetxattr_alloc_and_fill (local, xattr, this, | |||
1907 | op_errno); | |||
1908 | if (ret) | |||
1909 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("alloc or fill failure"); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1910 , GF_LOG_ERROR, "alloc or fill failure"); } while (0) | |||
1910 | "alloc or fill failure")do { do { if (0) printf ("alloc or fill failure"); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1910 , GF_LOG_ERROR, "alloc or fill failure"); } while (0); | |||
1911 | } | |||
1912 | unlock: | |||
1913 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
1914 | ||||
1915 | if (!is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
1916 | goto out; | |||
1917 | ||||
1918 | /* -- last call: do patch ups -- */ | |||
1919 | ||||
1920 | if (local->op_ret == -1) { | |||
1921 | goto unwind; | |||
1922 | } | |||
1923 | ||||
1924 | ret = dht_vgetxattr_fill_and_set (local, &dict, this, _gf_true); | |||
1925 | if (ret) | |||
1926 | goto unwind; | |||
1927 | ||||
1928 | DHT_STACK_UNWIND (getxattr, frame, 0, 0, dict, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1928, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, 0, 0, dict, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1929 | goto cleanup; | |||
1930 | ||||
1931 | unwind: | |||
1932 | DHT_STACK_UNWIND (getxattr, frame, -1, local->op_errno, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1932, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, local->op_errno, ((void*)0), ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1933 | cleanup: | |||
1934 | if (dict) | |||
1935 | dict_unref (dict); | |||
1936 | out: | |||
1937 | return 0; | |||
1938 | } | |||
1939 | ||||
1940 | int | |||
1941 | dht_vgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1942 | int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) | |||
1943 | { | |||
1944 | dht_local_t *local = NULL((void*)0); | |||
1945 | int ret = 0; | |||
1946 | dict_t *dict = NULL((void*)0); | |||
1947 | call_frame_t *prev = NULL((void*)0); | |||
1948 | gf_boolean_t flag = _gf_true; | |||
1949 | ||||
1950 | local = frame->local; | |||
1951 | prev = cookie; | |||
1952 | ||||
1953 | if (op_ret < 0) { | |||
1954 | local->op_ret = -1; | |||
1955 | local->op_errno = op_errno; | |||
1956 | gf_log (this->name, GF_LOG_ERROR, "Subvolume %s returned -1 "do { do { if (0) printf ("Subvolume %s returned -1 " "(%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1957, GF_LOG_ERROR , "Subvolume %s returned -1 " "(%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
1957 | "(%s)", prev->this->name, strerror (op_errno))do { do { if (0) printf ("Subvolume %s returned -1 " "(%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1957, GF_LOG_ERROR , "Subvolume %s returned -1 " "(%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
1958 | goto unwind; | |||
1959 | } | |||
1960 | ||||
1961 | ret = dht_vgetxattr_alloc_and_fill (local, xattr, this, | |||
1962 | op_errno); | |||
1963 | if (ret) { | |||
1964 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("alloc or fill failure"); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1965 , GF_LOG_ERROR, "alloc or fill failure"); } while (0) | |||
1965 | "alloc or fill failure")do { do { if (0) printf ("alloc or fill failure"); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 1965 , GF_LOG_ERROR, "alloc or fill failure"); } while (0); | |||
1966 | goto unwind; | |||
1967 | } | |||
1968 | ||||
1969 | flag = (local->layout->cnt > 1) ? _gf_true : _gf_false; | |||
1970 | ||||
1971 | ret = dht_vgetxattr_fill_and_set (local, &dict, this, flag); | |||
1972 | if (ret) | |||
1973 | goto unwind; | |||
1974 | ||||
1975 | DHT_STACK_UNWIND (getxattr, frame, 0, 0, dict, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1975, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, 0, 0, dict, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1976 | goto cleanup; | |||
1977 | ||||
1978 | unwind: | |||
1979 | DHT_STACK_UNWIND (getxattr, frame, -1, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1980, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, local->op_errno, ((void*)0), ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
1980 | NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 1980, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, local->op_errno, ((void*)0), ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
1981 | cleanup: | |||
1982 | if (dict) | |||
1983 | dict_unref (dict); | |||
1984 | ||||
1985 | return 0; | |||
1986 | } | |||
1987 | ||||
1988 | int | |||
1989 | dht_linkinfo_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1990 | int op_ret, int op_errno, dict_t *xattr, | |||
1991 | dict_t *xdata) | |||
1992 | { | |||
1993 | int ret = 0; | |||
1994 | char *value = NULL((void*)0); | |||
1995 | ||||
1996 | if (op_ret != -1) { | |||
1997 | ret = dict_get_str (xattr, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo", &value); | |||
1998 | if (!ret) { | |||
1999 | ret = dict_set_str (xattr, GF_XATTR_LINKINFO_KEY"trusted.distribute.linkinfo", value); | |||
2000 | if (!ret) | |||
2001 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("failed to set linkinfo"); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2002 , GF_LOG_TRACE, "failed to set linkinfo"); } while (0) | |||
2002 | "failed to set linkinfo")do { do { if (0) printf ("failed to set linkinfo"); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2002 , GF_LOG_TRACE, "failed to set linkinfo"); } while (0); | |||
2003 | } | |||
2004 | } | |||
2005 | ||||
2006 | DHT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, xattr, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2006, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, xattr, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2007 | ||||
2008 | return 0; | |||
2009 | } | |||
2010 | ||||
2011 | int | |||
2012 | dht_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
2013 | int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) | |||
2014 | { | |||
2015 | int this_call_cnt = 0; | |||
2016 | dht_local_t *local = NULL((void*)0); | |||
2017 | dht_conf_t *conf = NULL((void*)0); | |||
2018 | ||||
2019 | VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2019, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto out; } } while (0); | |||
2020 | VALIDATE_OR_GOTO (frame->local, out)do { if (!frame->local) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "frame->local"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2020, GF_LOG_WARNING, "invalid argument: " "frame->local"); } while (0); goto out; } } while (0); | |||
2021 | VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2021, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto out; } } while (0); | |||
2022 | ||||
2023 | conf = this->private; | |||
2024 | local = frame->local; | |||
2025 | ||||
2026 | this_call_cnt = dht_frame_return (frame); | |||
2027 | ||||
2028 | if (!xattr || (op_ret == -1)) | |||
2029 | goto out; | |||
2030 | ||||
2031 | if (dict_get (xattr, conf->xattr_name)) { | |||
2032 | dict_del (xattr, conf->xattr_name); | |||
2033 | } | |||
2034 | local->op_ret = 0; | |||
2035 | ||||
2036 | if (!local->xattr) { | |||
2037 | local->xattr = dict_copy_with_ref (xattr, NULL((void*)0)); | |||
2038 | } else { | |||
2039 | /* first aggregate everything into xattr and then copy into | |||
2040 | * local->xattr. This is required as we want to have | |||
2041 | * 'local->xattr' as the proper final dictionary passed above | |||
2042 | * distribute xlator. | |||
2043 | */ | |||
2044 | dht_aggregate_xattr (xattr, local->xattr); | |||
2045 | local->xattr = dict_copy (xattr, local->xattr); | |||
2046 | } | |||
2047 | out: | |||
2048 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
2049 | DHT_STACK_UNWIND (getxattr, frame, local->op_ret, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2050, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, op_errno, local->xattr, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) ; dht_local_wipe (__xl, __local); } while (0) | |||
2050 | local->xattr, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2050, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, op_errno, local->xattr, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) ; dht_local_wipe (__xl, __local); } while (0); | |||
2051 | } | |||
2052 | return 0; | |||
2053 | } | |||
2054 | ||||
2055 | int32_t | |||
2056 | dht_getxattr_unwind (call_frame_t *frame, | |||
2057 | int op_ret, int op_errno, dict_t *dict, dict_t *xdata) | |||
2058 | { | |||
2059 | DHT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2059, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, dict, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2060 | return 0; | |||
2061 | } | |||
2062 | ||||
2063 | ||||
2064 | int | |||
2065 | dht_getxattr (call_frame_t *frame, xlator_t *this, | |||
2066 | loc_t *loc, const char *key, dict_t *xdata) | |||
2067 | #define DHT_IS_DIR(layout) (layout->cnt > 1) | |||
2068 | { | |||
2069 | ||||
2070 | xlator_t *subvol = NULL((void*)0); | |||
2071 | xlator_t *hashed_subvol = NULL((void*)0); | |||
2072 | xlator_t *cached_subvol = NULL((void*)0); | |||
2073 | dht_conf_t *conf = NULL((void*)0); | |||
2074 | dht_local_t *local = NULL((void*)0); | |||
2075 | dht_layout_t *layout = NULL((void*)0); | |||
2076 | xlator_t **sub_volumes = NULL((void*)0); | |||
2077 | int op_errno = -1; | |||
2078 | int i = 0; | |||
2079 | int cnt = 0; | |||
2080 | ||||
2081 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2081, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2082 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2082, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2083 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2083, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
2084 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2084, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
2085 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2085, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
2086 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2086, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2087 | ||||
2088 | conf = this->private; | |||
2089 | ||||
2090 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_GETXATTR); | |||
2091 | if (!local) { | |||
2092 | op_errno = ENOMEM12; | |||
2093 | ||||
2094 | goto err; | |||
2095 | } | |||
2096 | ||||
2097 | layout = local->layout; | |||
2098 | if (!layout) { | |||
2099 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("layout is NULL"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2100, GF_LOG_ERROR , "layout is NULL"); } while (0) | |||
2100 | "layout is NULL")do { do { if (0) printf ("layout is NULL"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2100, GF_LOG_ERROR , "layout is NULL"); } while (0); | |||
2101 | op_errno = ENOENT2; | |||
2102 | goto err; | |||
2103 | } | |||
2104 | ||||
2105 | if (key) { | |||
2106 | local->key = gf_strdup (key); | |||
2107 | if (!local->key) { | |||
2108 | op_errno = ENOMEM12; | |||
2109 | goto err; | |||
2110 | } | |||
2111 | } | |||
2112 | ||||
2113 | /* for file use cached subvolume (obviously!): see if {} | |||
2114 | * below | |||
2115 | * for directory: | |||
2116 | * wind to all subvolumes and exclude subvolumes which | |||
2117 | * return ENOTCONN (in callback) | |||
2118 | * | |||
2119 | * NOTE: Don't trust inode here, as that may not be valid | |||
2120 | * (until inode_link() happens) | |||
2121 | */ | |||
2122 | if (key && (strcmp (key, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo") == 0) | |||
2123 | && DHT_IS_DIR(layout)) { | |||
2124 | (void) strncpy (local->xsel, key, 256); | |||
2125 | cnt = local->call_cnt = layout->cnt; | |||
2126 | for (i = 0; i < cnt; i++) { | |||
2127 | subvol = layout->list[i].xlator; | |||
2128 | STACK_WIND (frame, dht_vgetxattr_dir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2130, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->getxattr_cbk) tmp_cbk = dht_vgetxattr_dir_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->getxattr"; _new->unwind_to = "dht_vgetxattr_dir_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->getxattr); subvol->fops->getxattr (_new, subvol , loc, key, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2129 | subvol, subvol->fops->getxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2130, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->getxattr_cbk) tmp_cbk = dht_vgetxattr_dir_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->getxattr"; _new->unwind_to = "dht_vgetxattr_dir_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->getxattr); subvol->fops->getxattr (_new, subvol , loc, key, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2130 | loc, key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2130, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->getxattr_cbk) tmp_cbk = dht_vgetxattr_dir_cbk; _new-> root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->getxattr"; _new->unwind_to = "dht_vgetxattr_dir_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = subvol; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, subvol-> fops->getxattr); subvol->fops->getxattr (_new, subvol , loc, key, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
2131 | } | |||
2132 | return 0; | |||
2133 | } | |||
2134 | ||||
2135 | /* node-uuid or pathinfo for files */ | |||
2136 | if (key && ((strcmp (key, GF_XATTR_NODE_UUID_KEY"trusted.glusterfs.node-uuid") == 0) | |||
2137 | || (strcmp (key, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo") == 0))) { | |||
2138 | cached_subvol = local->cached_subvol; | |||
2139 | (void) strncpy (local->xsel, key, 256); | |||
2140 | ||||
2141 | local->call_cnt = 1; | |||
2142 | STACK_WIND (frame, dht_vgetxattr_cbk, cached_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2143, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->getxattr_cbk) tmp_cbk = dht_vgetxattr_cbk; _new ->root = frame->root; _new->this = cached_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->getxattr"; _new->unwind_to = "dht_vgetxattr_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&frame->root->stack_lock); { _new ->next = frame->root->frames.next; _new->prev = & frame->root->frames; if (frame->root->frames.next ) frame->root->frames.next->prev = _new; frame->root ->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->getxattr); cached_subvol->fops ->getxattr (_new, cached_subvol, loc, key, ((void*)0)); (* __glusterfs_this_location()) = old_THIS; } while (0) | |||
2143 | cached_subvol->fops->getxattr, loc, key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2143, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->getxattr_cbk) tmp_cbk = dht_vgetxattr_cbk; _new ->root = frame->root; _new->this = cached_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->getxattr"; _new->unwind_to = "dht_vgetxattr_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&frame->root->stack_lock); { _new ->next = frame->root->frames.next; _new->prev = & frame->root->frames; if (frame->root->frames.next ) frame->root->frames.next->prev = _new; frame->root ->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->getxattr); cached_subvol->fops ->getxattr (_new, cached_subvol, loc, key, ((void*)0)); (* __glusterfs_this_location()) = old_THIS; } while (0); | |||
2144 | ||||
2145 | return 0; | |||
2146 | } | |||
2147 | ||||
2148 | if (key && (strcmp (key, GF_XATTR_LINKINFO_KEY"trusted.distribute.linkinfo") == 0)) { | |||
2149 | hashed_subvol = dht_subvol_get_hashed (this, loc); | |||
2150 | if (!hashed_subvol) { | |||
2151 | gf_log (this->name, GF_LOG_ERROR, "Failed to get"do { do { if (0) printf ("Failed to get" "hashed subvol for %s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2152, GF_LOG_ERROR, "Failed to get" "hashed subvol for %s" , loc->path); } while (0) | |||
2152 | "hashed subvol for %s", loc->path)do { do { if (0) printf ("Failed to get" "hashed subvol for %s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2152, GF_LOG_ERROR, "Failed to get" "hashed subvol for %s" , loc->path); } while (0); | |||
2153 | op_errno = EINVAL22; | |||
2154 | goto err; | |||
2155 | } | |||
2156 | ||||
2157 | cached_subvol = dht_subvol_get_cached (this, loc->inode); | |||
2158 | if (!cached_subvol) { | |||
2159 | gf_log (this->name, GF_LOG_ERROR, "Failed to get"do { do { if (0) printf ("Failed to get" "cached subvol for %s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2160, GF_LOG_ERROR, "Failed to get" "cached subvol for %s" , loc->path); } while (0) | |||
2160 | "cached subvol for %s", loc->path)do { do { if (0) printf ("Failed to get" "cached subvol for %s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2160, GF_LOG_ERROR, "Failed to get" "cached subvol for %s" , loc->path); } while (0); | |||
2161 | op_errno = EINVAL22; | |||
2162 | goto err; | |||
2163 | } | |||
2164 | ||||
2165 | if (hashed_subvol == cached_subvol) { | |||
2166 | op_errno = ENODATA61; | |||
2167 | goto err; | |||
2168 | } | |||
2169 | if (hashed_subvol) { | |||
2170 | STACK_WIND (frame, dht_linkinfo_getxattr_cbk, hashed_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2172, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->getxattr_cbk) tmp_cbk = dht_linkinfo_getxattr_cbk ; _new->root = frame->root; _new->this = hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "hashed_subvol->fops->getxattr"; _new-> unwind_to = "dht_linkinfo_getxattr_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = hashed_subvol; if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, hashed_subvol->fops->getxattr ); hashed_subvol->fops->getxattr (_new, hashed_subvol, loc , "trusted.glusterfs.pathinfo", ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2171 | hashed_subvol->fops->getxattr, loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2172, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->getxattr_cbk) tmp_cbk = dht_linkinfo_getxattr_cbk ; _new->root = frame->root; _new->this = hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "hashed_subvol->fops->getxattr"; _new-> unwind_to = "dht_linkinfo_getxattr_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = hashed_subvol; if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, hashed_subvol->fops->getxattr ); hashed_subvol->fops->getxattr (_new, hashed_subvol, loc , "trusted.glusterfs.pathinfo", ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2172 | GF_XATTR_PATHINFO_KEY, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2172, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->getxattr_cbk) tmp_cbk = dht_linkinfo_getxattr_cbk ; _new->root = frame->root; _new->this = hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "hashed_subvol->fops->getxattr"; _new-> unwind_to = "dht_linkinfo_getxattr_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = hashed_subvol; if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, hashed_subvol->fops->getxattr ); hashed_subvol->fops->getxattr (_new, hashed_subvol, loc , "trusted.glusterfs.pathinfo", ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
2173 | return 0; | |||
2174 | } | |||
2175 | op_errno = ENODATA61; | |||
2176 | goto err; | |||
2177 | } | |||
2178 | ||||
2179 | if (key && (!strcmp (GF_XATTR_MARKER_KEY"trusted.glusterfs" "." "volume-mark", key)) | |||
2180 | && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) { | |||
2181 | if (DHT_IS_DIR(layout)) { | |||
2182 | cnt = layout->cnt; | |||
2183 | } else { | |||
2184 | cnt = 1; | |||
2185 | } | |||
2186 | ||||
2187 | sub_volumes = alloca ( cnt * sizeof (xlator_t *))__builtin_alloca (cnt * sizeof (xlator_t *)); | |||
2188 | for (i = 0; i < cnt; i++) | |||
2189 | *(sub_volumes + i) = layout->list[i].xlator; | |||
2190 | ||||
2191 | if (cluster_getmarkerattr (frame, this, loc, key, | |||
2192 | local, dht_getxattr_unwind, | |||
2193 | sub_volumes, cnt, | |||
2194 | MARKER_UUID_TYPE1, conf->vol_uuid)) { | |||
2195 | op_errno = EINVAL22; | |||
2196 | goto err; | |||
2197 | } | |||
2198 | ||||
2199 | return 0; | |||
2200 | } | |||
2201 | ||||
2202 | if (key && *conf->vol_uuid) { | |||
2203 | if ((match_uuid_local (key, conf->vol_uuid) == 0) && | |||
2204 | (GF_CLIENT_PID_GSYNCD == frame->root->pid)) { | |||
2205 | if (DHT_IS_DIR(layout)) { | |||
2206 | cnt = layout->cnt; | |||
2207 | } else { | |||
2208 | cnt = 1; | |||
2209 | } | |||
2210 | sub_volumes = alloca ( cnt * sizeof (xlator_t *))__builtin_alloca (cnt * sizeof (xlator_t *)); | |||
2211 | for (i = 0; i < cnt; i++) | |||
2212 | sub_volumes[i] = layout->list[i].xlator; | |||
2213 | ||||
2214 | if (cluster_getmarkerattr (frame, this, loc, key, | |||
2215 | local, dht_getxattr_unwind, | |||
2216 | sub_volumes, cnt, | |||
2217 | MARKER_XTIME_TYPE2, | |||
2218 | conf->vol_uuid)) { | |||
2219 | op_errno = EINVAL22; | |||
2220 | goto err; | |||
2221 | } | |||
2222 | ||||
2223 | return 0; | |||
2224 | } | |||
2225 | } | |||
2226 | ||||
2227 | if (DHT_IS_DIR(layout)) { | |||
2228 | cnt = local->call_cnt = layout->cnt; | |||
2229 | } else { | |||
2230 | cnt = local->call_cnt = 1; | |||
2231 | } | |||
2232 | ||||
2233 | for (i = 0; i < cnt; i++) { | |||
2234 | subvol = layout->list[i].xlator; | |||
2235 | STACK_WIND (frame, dht_getxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2237, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->getxattr_cbk) tmp_cbk = dht_getxattr_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->getxattr" ; _new->unwind_to = "dht_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->getxattr); subvol ->fops->getxattr (_new, subvol, loc, key, ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0) | |||
2236 | subvol, subvol->fops->getxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2237, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->getxattr_cbk) tmp_cbk = dht_getxattr_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->getxattr" ; _new->unwind_to = "dht_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->getxattr); subvol ->fops->getxattr (_new, subvol, loc, key, ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0) | |||
2237 | loc, key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2237, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->getxattr_cbk) tmp_cbk = dht_getxattr_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->getxattr" ; _new->unwind_to = "dht_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->getxattr); subvol ->fops->getxattr (_new, subvol, loc, key, ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0); | |||
2238 | } | |||
2239 | return 0; | |||
2240 | ||||
2241 | err: | |||
2242 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2243 | DHT_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2243, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2244 | ||||
2245 | return 0; | |||
2246 | } | |||
2247 | #undef DHT_IS_DIR | |||
2248 | ||||
2249 | int | |||
2250 | dht_fgetxattr (call_frame_t *frame, xlator_t *this, | |||
2251 | fd_t *fd, const char *key, dict_t *xdata) | |||
2252 | { | |||
2253 | xlator_t *subvol = NULL((void*)0); | |||
2254 | dht_local_t *local = NULL((void*)0); | |||
2255 | dht_layout_t *layout = NULL((void*)0); | |||
2256 | int op_errno = -1; | |||
2257 | int i = 0; | |||
2258 | int cnt = 0; | |||
2259 | ||||
2260 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2260, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2261 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2261, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2262 | VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2262, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto err; } } while (0); | |||
2263 | VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2263, GF_LOG_WARNING, "invalid argument: " "fd->inode"); } while (0); goto err; } } while (0); | |||
2264 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2264, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2265 | ||||
2266 | local = dht_local_init (frame, NULL((void*)0), fd, GF_FOP_FGETXATTR); | |||
2267 | if (!local) { | |||
2268 | op_errno = ENOMEM12; | |||
2269 | ||||
2270 | goto err; | |||
2271 | } | |||
2272 | ||||
2273 | layout = local->layout; | |||
2274 | if (!layout) { | |||
2275 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("layout is NULL"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2276, GF_LOG_ERROR , "layout is NULL"); } while (0) | |||
2276 | "layout is NULL")do { do { if (0) printf ("layout is NULL"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2276, GF_LOG_ERROR , "layout is NULL"); } while (0); | |||
2277 | op_errno = ENOENT2; | |||
2278 | goto err; | |||
2279 | } | |||
2280 | ||||
2281 | if (key) { | |||
2282 | local->key = gf_strdup (key); | |||
2283 | if (!local->key) { | |||
2284 | op_errno = ENOMEM12; | |||
2285 | goto err; | |||
2286 | } | |||
2287 | } | |||
2288 | ||||
2289 | if ((fd->inode->ia_type == IA_IFDIR) | |||
2290 | && (strncmp (key, GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo", | |||
2291 | strlen (GF_XATTR_LOCKINFO_KEY"trusted.glusterfs.lockinfo") != 0))) { | |||
2292 | cnt = local->call_cnt = layout->cnt; | |||
2293 | } else { | |||
2294 | cnt = local->call_cnt = 1; | |||
2295 | } | |||
2296 | ||||
2297 | for (i = 0; i < cnt; i++) { | |||
2298 | subvol = layout->list[i].xlator; | |||
2299 | STACK_WIND (frame, dht_getxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2301, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fgetxattr_cbk) tmp_cbk = dht_getxattr_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fgetxattr" ; _new->unwind_to = "dht_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fgetxattr); subvol ->fops->fgetxattr (_new, subvol, fd, key, ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0) | |||
2300 | subvol, subvol->fops->fgetxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2301, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fgetxattr_cbk) tmp_cbk = dht_getxattr_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fgetxattr" ; _new->unwind_to = "dht_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fgetxattr); subvol ->fops->fgetxattr (_new, subvol, fd, key, ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0) | |||
2301 | fd, key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2301, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fgetxattr_cbk) tmp_cbk = dht_getxattr_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fgetxattr" ; _new->unwind_to = "dht_getxattr_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fgetxattr); subvol ->fops->fgetxattr (_new, subvol, fd, key, ((void*)0)); ( *__glusterfs_this_location()) = old_THIS; } while (0); | |||
2302 | } | |||
2303 | return 0; | |||
2304 | ||||
2305 | err: | |||
2306 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2307 | DHT_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fgetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2307, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fgetxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2308 | ||||
2309 | return 0; | |||
2310 | } | |||
2311 | ||||
2312 | int | |||
2313 | dht_fsetxattr (call_frame_t *frame, xlator_t *this, | |||
2314 | fd_t *fd, dict_t *xattr, int flags, dict_t *xdata) | |||
2315 | { | |||
2316 | xlator_t *subvol = NULL((void*)0); | |||
2317 | dht_local_t *local = NULL((void*)0); | |||
2318 | int op_errno = EINVAL22; | |||
2319 | dht_conf_t *conf = NULL((void*)0); | |||
2320 | ||||
2321 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2321, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2322 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2322, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2323 | VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2323, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto err; } } while (0); | |||
2324 | VALIDATE_OR_GOTO (fd->inode, err)do { if (!fd->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2324, GF_LOG_WARNING, "invalid argument: " "fd->inode"); } while (0); goto err; } } while (0); | |||
2325 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2325, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2326 | ||||
2327 | conf = this->private; | |||
2328 | ||||
2329 | GF_IF_INTERNAL_XATTR_GOTO (conf->wild_xattr_name, xattr,do { if (!xattr) { do { do { if (0) printf ("setxattr dict is null" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2330, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto err; } if (dict_foreach_fnmatch (xattr, conf->wild_xattr_name , dict_null_foreach_fn, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf ("attempt to set internal" " xattr: %s: %s" , conf->wild_xattr_name, strerror (op_errno)); } while (0) ; _gf_log (this->name, "dht-common.c", __FUNCTION__, 2330, GF_LOG_ERROR, "attempt to set internal" " xattr: %s: %s", conf ->wild_xattr_name, strerror (op_errno)); } while (0); goto err; } } while (0) | |||
2330 | op_errno, err)do { if (!xattr) { do { do { if (0) printf ("setxattr dict is null" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2330, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto err; } if (dict_foreach_fnmatch (xattr, conf->wild_xattr_name , dict_null_foreach_fn, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf ("attempt to set internal" " xattr: %s: %s" , conf->wild_xattr_name, strerror (op_errno)); } while (0) ; _gf_log (this->name, "dht-common.c", __FUNCTION__, 2330, GF_LOG_ERROR, "attempt to set internal" " xattr: %s: %s", conf ->wild_xattr_name, strerror (op_errno)); } while (0); goto err; } } while (0); | |||
2331 | ||||
2332 | local = dht_local_init (frame, NULL((void*)0), fd, GF_FOP_FSETXATTR); | |||
2333 | if (!local) { | |||
2334 | op_errno = ENOMEM12; | |||
2335 | goto err; | |||
2336 | } | |||
2337 | ||||
2338 | subvol = local->cached_subvol; | |||
2339 | if (!subvol) { | |||
2340 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for fd=%p", fd) ; } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2341, GF_LOG_DEBUG, "no cached subvolume for fd=%p", fd); } while (0) | |||
2341 | "no cached subvolume for fd=%p", fd)do { do { if (0) printf ("no cached subvolume for fd=%p", fd) ; } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2341, GF_LOG_DEBUG, "no cached subvolume for fd=%p", fd); } while (0); | |||
2342 | op_errno = EINVAL22; | |||
2343 | goto err; | |||
2344 | } | |||
2345 | ||||
2346 | local->call_cnt = 1; | |||
2347 | ||||
2348 | STACK_WIND (frame, dht_err_cbk, subvol, subvol->fops->fsetxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2349, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fsetxattr_cbk) tmp_cbk = dht_err_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fsetxattr" ; _new->unwind_to = "dht_err_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fsetxattr); subvol ->fops->fsetxattr (_new, subvol, fd, xattr, flags, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2349 | fd, xattr, flags, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2349, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fsetxattr_cbk) tmp_cbk = dht_err_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fsetxattr" ; _new->unwind_to = "dht_err_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fsetxattr); subvol ->fops->fsetxattr (_new, subvol, fd, xattr, flags, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2350 | ||||
2351 | return 0; | |||
2352 | ||||
2353 | err: | |||
2354 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2355 | DHT_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fsetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2355, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fsetxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2356 | ||||
2357 | return 0; | |||
2358 | } | |||
2359 | ||||
2360 | ||||
2361 | static int | |||
2362 | dht_common_setxattr_cbk (call_frame_t *frame, void *cookie, | |||
2363 | xlator_t *this, int32_t op_ret, int32_t op_errno, | |||
2364 | dict_t *xdata) | |||
2365 | { | |||
2366 | DHT_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2366, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2367 | ||||
2368 | return 0; | |||
2369 | } | |||
2370 | ||||
2371 | int | |||
2372 | dht_checking_pathinfo_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
2373 | int op_ret, int op_errno, dict_t *xattr, | |||
2374 | dict_t *xdata) | |||
2375 | { | |||
2376 | int i = -1; | |||
2377 | int ret = -1; | |||
2378 | char *value = NULL((void*)0); | |||
2379 | dht_local_t *local = NULL((void*)0); | |||
2380 | dht_conf_t *conf = NULL((void*)0); | |||
2381 | call_frame_t *prev = NULL((void*)0); | |||
2382 | int this_call_cnt = 0; | |||
2383 | ||||
2384 | local = frame->local; | |||
2385 | prev = cookie; | |||
2386 | conf = this->private; | |||
2387 | ||||
2388 | if (op_ret == -1) | |||
2389 | goto out; | |||
2390 | ||||
2391 | ||||
2392 | ret = dict_get_str (xattr, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo", &value); | |||
2393 | if (ret) | |||
2394 | goto out; | |||
2395 | ||||
2396 | if (!strcmp (value, local->key)) { | |||
2397 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
2398 | if (conf->subvolumes[i] == prev->this) | |||
2399 | conf->decommissioned_bricks[i] = prev->this; | |||
2400 | } | |||
2401 | } | |||
2402 | ||||
2403 | out: | |||
2404 | this_call_cnt = dht_frame_return (frame); | |||
2405 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
2406 | DHT_STACK_UNWIND (setxattr, frame, local->op_ret, ENOTSUP, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2406, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, 95, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2407 | } | |||
2408 | return 0; | |||
2409 | ||||
2410 | } | |||
2411 | ||||
2412 | int | |||
2413 | dht_setxattr (call_frame_t *frame, xlator_t *this, | |||
2414 | loc_t *loc, dict_t *xattr, int flags, dict_t *xdata) | |||
2415 | { | |||
2416 | xlator_t *subvol = NULL((void*)0); | |||
2417 | dht_local_t *local = NULL((void*)0); | |||
2418 | dht_conf_t *conf = NULL((void*)0); | |||
2419 | dht_layout_t *layout = NULL((void*)0); | |||
2420 | int i = 0; | |||
2421 | int op_errno = EINVAL22; | |||
2422 | int ret = -1; | |||
2423 | data_t *tmp = NULL((void*)0); | |||
2424 | uint32_t dir_spread = 0; | |||
2425 | char value[4096] = {0,}; | |||
2426 | gf_dht_migrate_data_type_t forced_rebalance = GF_DHT_MIGRATE_DATA; | |||
2427 | int call_cnt = 0; | |||
2428 | ||||
2429 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2429, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2430 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2430, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2431 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2431, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
2432 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2432, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
2433 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2433, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
2434 | ||||
2435 | conf = this->private; | |||
2436 | ||||
2437 | GF_IF_INTERNAL_XATTR_GOTO (conf->wild_xattr_name, xattr,do { if (!xattr) { do { do { if (0) printf ("setxattr dict is null" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2438, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto err; } if (dict_foreach_fnmatch (xattr, conf->wild_xattr_name , dict_null_foreach_fn, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf ("attempt to set internal" " xattr: %s: %s" , conf->wild_xattr_name, strerror (op_errno)); } while (0) ; _gf_log (this->name, "dht-common.c", __FUNCTION__, 2438, GF_LOG_ERROR, "attempt to set internal" " xattr: %s: %s", conf ->wild_xattr_name, strerror (op_errno)); } while (0); goto err; } } while (0) | |||
2438 | op_errno, err)do { if (!xattr) { do { do { if (0) printf ("setxattr dict is null" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2438, GF_LOG_ERROR, "setxattr dict is null"); } while (0); goto err; } if (dict_foreach_fnmatch (xattr, conf->wild_xattr_name , dict_null_foreach_fn, ((void*)0)) > 0) { op_errno = 1; do { do { if (0) printf ("attempt to set internal" " xattr: %s: %s" , conf->wild_xattr_name, strerror (op_errno)); } while (0) ; _gf_log (this->name, "dht-common.c", __FUNCTION__, 2438, GF_LOG_ERROR, "attempt to set internal" " xattr: %s: %s", conf ->wild_xattr_name, strerror (op_errno)); } while (0); goto err; } } while (0); | |||
2439 | ||||
2440 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_SETXATTR); | |||
2441 | if (!local) { | |||
2442 | op_errno = ENOMEM12; | |||
2443 | goto err; | |||
2444 | } | |||
2445 | ||||
2446 | subvol = local->cached_subvol; | |||
2447 | if (!subvol) { | |||
2448 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2449, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0) | |||
2449 | "no cached subvolume for path=%s", loc->path)do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2449, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0); | |||
2450 | op_errno = EINVAL22; | |||
2451 | goto err; | |||
2452 | } | |||
2453 | ||||
2454 | layout = local->layout; | |||
2455 | if (!layout) { | |||
2456 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no layout for path=%s", loc->path ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2457, GF_LOG_DEBUG, "no layout for path=%s", loc->path); } while (0) | |||
2457 | "no layout for path=%s", loc->path)do { do { if (0) printf ("no layout for path=%s", loc->path ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2457, GF_LOG_DEBUG, "no layout for path=%s", loc->path); } while (0); | |||
2458 | op_errno = EINVAL22; | |||
2459 | goto err; | |||
2460 | } | |||
2461 | ||||
2462 | local->call_cnt = call_cnt = layout->cnt; | |||
2463 | ||||
2464 | /* This key is sent by Unified File and Object storage | |||
2465 | * to test xattr support in backend. | |||
2466 | */ | |||
2467 | tmp = dict_get (xattr, "user.ufo-test"); | |||
2468 | if (tmp) { | |||
2469 | if (IA_ISREG (loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG)) { | |||
2470 | op_errno = ENOTSUP95; | |||
2471 | goto err; | |||
2472 | } | |||
2473 | local->op_ret = 0; | |||
2474 | for (i = 0; i < call_cnt; i++) { | |||
2475 | STACK_WIND (frame, dht_ufo_xattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2478, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_ufo_xattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_ufo_xattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2476 | layout->list[i].xlator,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2478, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_ufo_xattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_ufo_xattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2477 | layout->list[i].xlator->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2478, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_ufo_xattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_ufo_xattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2478 | loc, xattr, flags, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2478, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_ufo_xattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_ufo_xattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2479 | } | |||
2480 | return 0; | |||
2481 | } | |||
2482 | ||||
2483 | tmp = dict_get (xattr, "distribute.migrate-data"); | |||
2484 | if (tmp) { | |||
2485 | if (IA_ISDIR (loc->inode->ia_type)(loc->inode->ia_type == IA_IFDIR)) { | |||
2486 | op_errno = ENOTSUP95; | |||
2487 | goto err; | |||
2488 | } | |||
2489 | ||||
2490 | /* TODO: need to interpret the 'value' for more meaning | |||
2491 | (ie, 'target' subvolume given there, etc) */ | |||
2492 | memcpy (value, tmp->data, tmp->len); | |||
2493 | if (strcmp (value, "force") == 0) | |||
2494 | forced_rebalance = | |||
2495 | GF_DHT_MIGRATE_DATA_EVEN_IF_LINK_EXISTS; | |||
2496 | ||||
2497 | if (conf->decommission_in_progress) | |||
2498 | forced_rebalance = GF_DHT_MIGRATE_HARDLINK; | |||
2499 | ||||
2500 | local->rebalance.target_node = dht_subvol_get_hashed (this, loc); | |||
2501 | if (!local->rebalance.target_node) { | |||
2502 | gf_log (this->name, GF_LOG_ERROR, "Failed to get "do { do { if (0) printf ("Failed to get " "hashed subvol for %s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2503, GF_LOG_ERROR, "Failed to get " "hashed subvol for %s" , loc->path); } while (0) | |||
2503 | "hashed subvol for %s", loc->path)do { do { if (0) printf ("Failed to get " "hashed subvol for %s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2503, GF_LOG_ERROR, "Failed to get " "hashed subvol for %s" , loc->path); } while (0); | |||
2504 | op_errno = EINVAL22; | |||
2505 | goto err; | |||
2506 | } | |||
2507 | ||||
2508 | local->rebalance.from_subvol = local->cached_subvol; | |||
2509 | ||||
2510 | if (local->rebalance.target_node == local->rebalance.from_subvol) { | |||
2511 | op_errno = EEXIST17; | |||
2512 | goto err; | |||
2513 | } | |||
2514 | if (local->rebalance.target_node) { | |||
2515 | local->flags = forced_rebalance; | |||
2516 | ||||
2517 | ret = dht_start_rebalance_task (this, frame); | |||
2518 | if (!ret) | |||
2519 | return 0; | |||
2520 | ||||
2521 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s: failed to create a new synctask" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2523, GF_LOG_ERROR, "%s: failed to create a new synctask" , loc->path); } while (0) | |||
2522 | "%s: failed to create a new synctask",do { do { if (0) printf ("%s: failed to create a new synctask" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2523, GF_LOG_ERROR, "%s: failed to create a new synctask" , loc->path); } while (0) | |||
2523 | loc->path)do { do { if (0) printf ("%s: failed to create a new synctask" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2523, GF_LOG_ERROR, "%s: failed to create a new synctask" , loc->path); } while (0); | |||
2524 | } | |||
2525 | op_errno = EINVAL22; | |||
2526 | goto err; | |||
2527 | ||||
2528 | } | |||
2529 | ||||
2530 | tmp = dict_get (xattr, "decommission-brick"); | |||
2531 | if (tmp) { | |||
2532 | /* This operation should happen only on '/' */ | |||
2533 | if (!__is_root_gfid (loc->inode->gfid)) { | |||
2534 | op_errno = ENOTSUP95; | |||
2535 | goto err; | |||
2536 | } | |||
2537 | ||||
2538 | memcpy (value, tmp->data, ((tmp->len < 4095) ? tmp->len : 4095)); | |||
2539 | local->key = gf_strdup (value); | |||
2540 | local->call_cnt = conf->subvolume_cnt; | |||
2541 | ||||
2542 | for (i = 0 ; i < conf->subvolume_cnt; i++) { | |||
2543 | /* Get the pathinfo, and then compare */ | |||
2544 | STACK_WIND (frame, dht_checking_pathinfo_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2547, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->getxattr_cbk) tmp_cbk = dht_checking_pathinfo_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->getxattr" ; _new->unwind_to = "dht_checking_pathinfo_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->getxattr); conf->subvolumes[i]->fops-> getxattr (_new, conf->subvolumes[i], loc, "trusted.glusterfs.pathinfo" , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2545 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2547, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->getxattr_cbk) tmp_cbk = dht_checking_pathinfo_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->getxattr" ; _new->unwind_to = "dht_checking_pathinfo_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->getxattr); conf->subvolumes[i]->fops-> getxattr (_new, conf->subvolumes[i], loc, "trusted.glusterfs.pathinfo" , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2546 | conf->subvolumes[i]->fops->getxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2547, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->getxattr_cbk) tmp_cbk = dht_checking_pathinfo_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->getxattr" ; _new->unwind_to = "dht_checking_pathinfo_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->getxattr); conf->subvolumes[i]->fops-> getxattr (_new, conf->subvolumes[i], loc, "trusted.glusterfs.pathinfo" , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2547 | loc, GF_XATTR_PATHINFO_KEY, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2547, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->getxattr_cbk) tmp_cbk = dht_checking_pathinfo_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->getxattr" ; _new->unwind_to = "dht_checking_pathinfo_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->getxattr); conf->subvolumes[i]->fops-> getxattr (_new, conf->subvolumes[i], loc, "trusted.glusterfs.pathinfo" , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2548 | } | |||
2549 | return 0; | |||
2550 | } | |||
2551 | ||||
2552 | tmp = dict_get (xattr, GF_XATTR_FIX_LAYOUT_KEY"distribute.fix.layout"); | |||
2553 | if (tmp) { | |||
2554 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("fixing the layout of %s", loc->path ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2555, GF_LOG_INFO, "fixing the layout of %s", loc->path) ; } while (0) | |||
2555 | "fixing the layout of %s", loc->path)do { do { if (0) printf ("fixing the layout of %s", loc->path ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2555, GF_LOG_INFO, "fixing the layout of %s", loc->path) ; } while (0); | |||
2556 | ||||
2557 | ret = dht_fix_directory_layout (frame, dht_common_setxattr_cbk, | |||
2558 | layout); | |||
2559 | if (ret) { | |||
2560 | op_errno = ENOTCONN107; | |||
2561 | goto err; | |||
2562 | } | |||
2563 | return ret; | |||
2564 | } | |||
2565 | ||||
2566 | tmp = dict_get (xattr, "distribute.directory-spread-count"); | |||
2567 | if (tmp) { | |||
2568 | /* Setxattr value is packed as 'binary', not string */ | |||
2569 | memcpy (value, tmp->data, ((tmp->len < 4095)?tmp->len:4095)); | |||
2570 | ret = gf_string2uint32 (value, &dir_spread); | |||
2571 | if (!ret && ((dir_spread <= conf->subvolume_cnt) && | |||
2572 | (dir_spread > 0))) { | |||
2573 | layout->spread_cnt = dir_spread; | |||
2574 | ||||
2575 | ret = dht_fix_directory_layout (frame, | |||
2576 | dht_common_setxattr_cbk, | |||
2577 | layout); | |||
2578 | if (ret) { | |||
2579 | op_errno = ENOTCONN107; | |||
2580 | goto err; | |||
2581 | } | |||
2582 | return ret; | |||
2583 | } | |||
2584 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("wrong 'directory-spread-count' value (%s)" , value); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2585, GF_LOG_ERROR, "wrong 'directory-spread-count' value (%s)" , value); } while (0) | |||
2585 | "wrong 'directory-spread-count' value (%s)", value)do { do { if (0) printf ("wrong 'directory-spread-count' value (%s)" , value); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2585, GF_LOG_ERROR, "wrong 'directory-spread-count' value (%s)" , value); } while (0); | |||
2586 | op_errno = ENOTSUP95; | |||
2587 | goto err; | |||
2588 | } | |||
2589 | ||||
2590 | for (i = 0; i < call_cnt; i++) { | |||
2591 | STACK_WIND (frame, dht_err_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2594, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_err_cbk; _new ->root = frame->root; _new->this = layout->list[i ].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_err_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2592 | layout->list[i].xlator,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2594, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_err_cbk; _new ->root = frame->root; _new->this = layout->list[i ].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_err_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2593 | layout->list[i].xlator->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2594, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_err_cbk; _new ->root = frame->root; _new->this = layout->list[i ].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_err_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
2594 | loc, xattr, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2594, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->setxattr_cbk) tmp_cbk = dht_err_cbk; _new ->root = frame->root; _new->this = layout->list[i ].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->setxattr" ; _new->unwind_to = "dht_err_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->setxattr); layout->list[i].xlator->fops-> setxattr (_new, layout->list[i].xlator, loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); | |||
2595 | } | |||
2596 | ||||
2597 | return 0; | |||
2598 | ||||
2599 | err: | |||
2600 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2601 | DHT_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2601, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2602 | ||||
2603 | return 0; | |||
2604 | } | |||
2605 | ||||
2606 | ||||
2607 | int | |||
2608 | dht_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
2609 | int op_ret, int op_errno, dict_t *xdata) | |||
2610 | { | |||
2611 | dht_local_t *local = NULL((void*)0); | |||
2612 | int this_call_cnt = 0; | |||
2613 | call_frame_t *prev = NULL((void*)0); | |||
2614 | ||||
2615 | local = frame->local; | |||
2616 | prev = cookie; | |||
2617 | ||||
2618 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
2619 | { | |||
2620 | if (op_ret == -1) { | |||
2621 | local->op_errno = op_errno; | |||
2622 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2624, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
2623 | "subvolume %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2624, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
2624 | prev->this->name, strerror (op_errno))do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2624, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
2625 | goto unlock; | |||
2626 | } | |||
2627 | ||||
2628 | local->op_ret = 0; | |||
2629 | } | |||
2630 | unlock: | |||
2631 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
2632 | ||||
2633 | this_call_cnt = dht_frame_return (frame); | |||
2634 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
2635 | DHT_STACK_UNWIND (removexattr, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_removexattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2636, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_removexattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
2636 | local->op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_removexattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2636, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_removexattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2637 | } | |||
2638 | ||||
2639 | return 0; | |||
2640 | } | |||
2641 | ||||
2642 | ||||
2643 | int | |||
2644 | dht_removexattr (call_frame_t *frame, xlator_t *this, | |||
2645 | loc_t *loc, const char *key, dict_t *xdata) | |||
2646 | { | |||
2647 | xlator_t *subvol = NULL((void*)0); | |||
2648 | int op_errno = -1; | |||
2649 | dht_local_t *local = NULL((void*)0); | |||
2650 | dht_layout_t *layout = NULL((void*)0); | |||
2651 | int call_cnt = 0; | |||
2652 | dht_conf_t *conf = NULL((void*)0); | |||
2653 | ||||
2654 | int i; | |||
2655 | ||||
2656 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2656, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2657 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2657, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2658 | ||||
2659 | conf = this->private; | |||
2660 | ||||
2661 | GF_IF_NATIVE_XATTR_GOTO (conf->wild_xattr_name, key, op_errno, err)do { if (!key) { do { do { if (0) printf ("no key for removexattr" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2661, GF_LOG_ERROR, "no key for removexattr"); } while (0); goto err; } if (!fnmatch (conf->wild_xattr_name, key, 0)) { op_errno = 1; do { do { if (0) printf ("attempt to remove internal " "xattr: %s: %s", key, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2661, GF_LOG_ERROR , "attempt to remove internal " "xattr: %s: %s", key, strerror (op_errno)); } while (0); goto err; } } while (0); | |||
2662 | ||||
2663 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2663, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2664 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2664, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
2665 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2665, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
2666 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2666, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
2667 | ||||
2668 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_REMOVEXATTR); | |||
2669 | if (!local) { | |||
2670 | op_errno = ENOMEM12; | |||
2671 | goto err; | |||
2672 | } | |||
2673 | ||||
2674 | subvol = local->cached_subvol; | |||
2675 | if (!subvol) { | |||
2676 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2677, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0) | |||
2677 | "no cached subvolume for path=%s", loc->path)do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2677, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0); | |||
2678 | op_errno = EINVAL22; | |||
2679 | goto err; | |||
2680 | } | |||
2681 | ||||
2682 | layout = local->layout; | |||
2683 | if (!local->layout) { | |||
2684 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no layout for path=%s", loc->path ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2685, GF_LOG_DEBUG, "no layout for path=%s", loc->path); } while (0) | |||
2685 | "no layout for path=%s", loc->path)do { do { if (0) printf ("no layout for path=%s", loc->path ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2685, GF_LOG_DEBUG, "no layout for path=%s", loc->path); } while (0); | |||
2686 | op_errno = EINVAL22; | |||
2687 | goto err; | |||
2688 | } | |||
2689 | ||||
2690 | local->call_cnt = call_cnt = layout->cnt; | |||
2691 | local->key = gf_strdup (key); | |||
2692 | ||||
2693 | for (i = 0; i < call_cnt; i++) { | |||
2694 | STACK_WIND (frame, dht_removexattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2697, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->removexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->removexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->removexattr); layout->list[i].xlator->fops ->removexattr (_new, layout->list[i].xlator, loc, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2695 | layout->list[i].xlator,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2697, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->removexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->removexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->removexattr); layout->list[i].xlator->fops ->removexattr (_new, layout->list[i].xlator, loc, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2696 | layout->list[i].xlator->fops->removexattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2697, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->removexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->removexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->removexattr); layout->list[i].xlator->fops ->removexattr (_new, layout->list[i].xlator, loc, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2697 | loc, key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2697, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->removexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->removexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->removexattr); layout->list[i].xlator->fops ->removexattr (_new, layout->list[i].xlator, loc, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2698 | } | |||
2699 | ||||
2700 | return 0; | |||
2701 | ||||
2702 | err: | |||
2703 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2704 | DHT_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_removexattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2704, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_removexattr_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2705 | ||||
2706 | return 0; | |||
2707 | } | |||
2708 | ||||
2709 | int | |||
2710 | dht_fremovexattr (call_frame_t *frame, xlator_t *this, | |||
2711 | fd_t *fd, const char *key, dict_t *xdata) | |||
2712 | { | |||
2713 | xlator_t *subvol = NULL((void*)0); | |||
2714 | int op_errno = -1; | |||
2715 | dht_local_t *local = NULL((void*)0); | |||
2716 | dht_layout_t *layout = NULL((void*)0); | |||
2717 | int call_cnt = 0; | |||
2718 | dht_conf_t *conf = 0; | |||
2719 | ||||
2720 | int i; | |||
2721 | ||||
2722 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2722, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2723 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2723, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2724 | ||||
2725 | conf = this->private; | |||
2726 | ||||
2727 | GF_IF_NATIVE_XATTR_GOTO (conf->wild_xattr_name, key, op_errno, err)do { if (!key) { do { do { if (0) printf ("no key for removexattr" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 2727, GF_LOG_ERROR, "no key for removexattr"); } while (0); goto err; } if (!fnmatch (conf->wild_xattr_name, key, 0)) { op_errno = 1; do { do { if (0) printf ("attempt to remove internal " "xattr: %s: %s", key, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2727, GF_LOG_ERROR , "attempt to remove internal " "xattr: %s: %s", key, strerror (op_errno)); } while (0); goto err; } } while (0); | |||
2728 | ||||
2729 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2729, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2730 | ||||
2731 | local = dht_local_init (frame, NULL((void*)0), fd, GF_FOP_FREMOVEXATTR); | |||
2732 | if (!local) { | |||
2733 | op_errno = ENOMEM12; | |||
2734 | goto err; | |||
2735 | } | |||
2736 | ||||
2737 | subvol = local->cached_subvol; | |||
2738 | if (!subvol) { | |||
2739 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for inode=%s", uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 2741, GF_LOG_DEBUG, "no cached subvolume for inode=%s" , uuid_utoa (fd->inode->gfid)); } while (0) | |||
2740 | "no cached subvolume for inode=%s",do { do { if (0) printf ("no cached subvolume for inode=%s", uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 2741, GF_LOG_DEBUG, "no cached subvolume for inode=%s" , uuid_utoa (fd->inode->gfid)); } while (0) | |||
2741 | uuid_utoa (fd->inode->gfid))do { do { if (0) printf ("no cached subvolume for inode=%s", uuid_utoa (fd->inode->gfid)); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 2741, GF_LOG_DEBUG, "no cached subvolume for inode=%s" , uuid_utoa (fd->inode->gfid)); } while (0); | |||
2742 | op_errno = EINVAL22; | |||
2743 | goto err; | |||
2744 | } | |||
2745 | ||||
2746 | layout = local->layout; | |||
2747 | if (!local->layout) { | |||
2748 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no layout for inode=%s", uuid_utoa ( fd->inode->gfid)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2749, GF_LOG_DEBUG, "no layout for inode=%s" , uuid_utoa (fd->inode->gfid)); } while (0) | |||
2749 | "no layout for inode=%s", uuid_utoa (fd->inode->gfid))do { do { if (0) printf ("no layout for inode=%s", uuid_utoa ( fd->inode->gfid)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2749, GF_LOG_DEBUG, "no layout for inode=%s" , uuid_utoa (fd->inode->gfid)); } while (0); | |||
2750 | op_errno = EINVAL22; | |||
2751 | goto err; | |||
2752 | } | |||
2753 | ||||
2754 | local->call_cnt = call_cnt = layout->cnt; | |||
2755 | local->key = gf_strdup (key); | |||
2756 | ||||
2757 | for (i = 0; i < call_cnt; i++) { | |||
2758 | STACK_WIND (frame, dht_removexattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2761, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->fremovexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->fremovexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->fremovexattr); layout->list[i].xlator->fops ->fremovexattr (_new, layout->list[i].xlator, fd, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2759 | layout->list[i].xlator,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2761, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->fremovexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->fremovexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->fremovexattr); layout->list[i].xlator->fops ->fremovexattr (_new, layout->list[i].xlator, fd, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2760 | layout->list[i].xlator->fops->fremovexattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2761, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->fremovexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->fremovexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->fremovexattr); layout->list[i].xlator->fops ->fremovexattr (_new, layout->list[i].xlator, fd, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2761 | fd, key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2761, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( layout->list [i].xlator->fops->fremovexattr_cbk) tmp_cbk = dht_removexattr_cbk ; _new->root = frame->root; _new->this = layout-> list[i].xlator; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "layout->list[i].xlator->fops->fremovexattr" ; _new->unwind_to = "dht_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = layout->list[i].xlator; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, layout->list[i].xlator ->fops->fremovexattr); layout->list[i].xlator->fops ->fremovexattr (_new, layout->list[i].xlator, fd, key, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2762 | } | |||
2763 | ||||
2764 | return 0; | |||
2765 | ||||
2766 | err: | |||
2767 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2768 | DHT_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fremovexattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2768, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fremovexattr_cbk_t )frame->ret; _parent = frame-> parent; pthread_spin_lock (&frame->root->stack_lock ); { _parent->ref_count--; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2769 | ||||
2770 | return 0; | |||
2771 | } | |||
2772 | ||||
2773 | ||||
2774 | int | |||
2775 | dht_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
2776 | int op_ret, int op_errno, fd_t *fd, dict_t *xdata) | |||
2777 | { | |||
2778 | dht_local_t *local = NULL((void*)0); | |||
2779 | int this_call_cnt = 0; | |||
2780 | call_frame_t *prev = NULL((void*)0); | |||
2781 | ||||
2782 | local = frame->local; | |||
2783 | prev = cookie; | |||
2784 | ||||
2785 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
2786 | { | |||
2787 | if (op_ret == -1) { | |||
2788 | local->op_errno = op_errno; | |||
2789 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2791, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
2790 | "subvolume %s returned -1 (%s)",do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2791, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0) | |||
2791 | prev->this->name, strerror (op_errno))do { do { if (0) printf ("subvolume %s returned -1 (%s)", prev ->this->name, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 2791, GF_LOG_DEBUG , "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); } while (0); | |||
2792 | goto unlock; | |||
2793 | } | |||
2794 | ||||
2795 | local->op_ret = 0; | |||
2796 | } | |||
2797 | unlock: | |||
2798 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
2799 | ||||
2800 | this_call_cnt = dht_frame_return (frame); | |||
2801 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
2802 | DHT_STACK_UNWIND (open, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2803, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->fd , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
2803 | local->fd, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2803, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, local->fd , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2804 | ||||
2805 | return 0; | |||
2806 | } | |||
2807 | ||||
2808 | /* | |||
2809 | * dht_normalize_stats - | |||
2810 | */ | |||
2811 | static void | |||
2812 | dht_normalize_stats (struct statvfs *buf, unsigned long bsize, | |||
2813 | unsigned long frsize) | |||
2814 | { | |||
2815 | double factor = 0; | |||
2816 | ||||
2817 | if (buf->f_bsize != bsize) { | |||
2818 | buf->f_bsize = bsize; | |||
2819 | } | |||
2820 | ||||
2821 | if (buf->f_frsize != frsize) { | |||
2822 | factor = ((double) buf->f_frsize) / frsize; | |||
2823 | buf->f_frsize = frsize; | |||
2824 | buf->f_blocks = (fsblkcnt_t) (factor * buf->f_blocks); | |||
2825 | buf->f_bfree = (fsblkcnt_t) (factor * buf->f_bfree); | |||
2826 | buf->f_bavail = (fsblkcnt_t) (factor * buf->f_bavail); | |||
2827 | ||||
2828 | } | |||
2829 | } | |||
2830 | ||||
2831 | int | |||
2832 | dht_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
2833 | int op_ret, int op_errno, struct statvfs *statvfs, dict_t *xdata) | |||
2834 | { | |||
2835 | dht_local_t *local = NULL((void*)0); | |||
2836 | int this_call_cnt = 0; | |||
2837 | int bsize = 0; | |||
2838 | int frsize = 0; | |||
2839 | ||||
2840 | ||||
2841 | local = frame->local; | |||
2842 | ||||
2843 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
2844 | { | |||
2845 | if (op_ret == -1) { | |||
2846 | local->op_errno = op_errno; | |||
2847 | goto unlock; | |||
2848 | } | |||
2849 | local->op_ret = 0; | |||
2850 | ||||
2851 | if (local->statvfs.f_bsize != 0) { | |||
2852 | bsize = max(local->statvfs.f_bsize, statvfs->f_bsize)((local->statvfs.f_bsize)>(statvfs->f_bsize)?(local-> statvfs.f_bsize):(statvfs->f_bsize)); | |||
2853 | frsize = max(local->statvfs.f_frsize, statvfs->f_frsize)((local->statvfs.f_frsize)>(statvfs->f_frsize)?(local ->statvfs.f_frsize):(statvfs->f_frsize)); | |||
2854 | dht_normalize_stats(&local->statvfs, bsize, frsize); | |||
2855 | dht_normalize_stats(statvfs, bsize, frsize); | |||
2856 | } else { | |||
2857 | local->statvfs.f_bsize = statvfs->f_bsize; | |||
2858 | local->statvfs.f_frsize = statvfs->f_frsize; | |||
2859 | } | |||
2860 | ||||
2861 | local->statvfs.f_blocks += statvfs->f_blocks; | |||
2862 | local->statvfs.f_bfree += statvfs->f_bfree; | |||
2863 | local->statvfs.f_bavail += statvfs->f_bavail; | |||
2864 | local->statvfs.f_files += statvfs->f_files; | |||
2865 | local->statvfs.f_ffree += statvfs->f_ffree; | |||
2866 | local->statvfs.f_favail += statvfs->f_favail; | |||
2867 | local->statvfs.f_fsid = statvfs->f_fsid; | |||
2868 | local->statvfs.f_flag = statvfs->f_flag; | |||
2869 | local->statvfs.f_namemax = statvfs->f_namemax; | |||
2870 | ||||
2871 | } | |||
2872 | unlock: | |||
2873 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
2874 | ||||
2875 | ||||
2876 | this_call_cnt = dht_frame_return (frame); | |||
2877 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
2878 | DHT_STACK_UNWIND (statfs, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_statfs_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2879, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_statfs_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> statvfs, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
2879 | &local->statvfs, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_statfs_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2879, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_statfs_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> statvfs, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2880 | ||||
2881 | return 0; | |||
2882 | } | |||
2883 | ||||
2884 | ||||
2885 | int | |||
2886 | dht_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) | |||
2887 | { | |||
2888 | xlator_t *subvol = NULL((void*)0); | |||
2889 | dht_local_t *local = NULL((void*)0); | |||
2890 | dht_conf_t *conf = NULL((void*)0); | |||
2891 | int op_errno = -1; | |||
2892 | int i = -1; | |||
2893 | ||||
2894 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2894, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2895 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2895, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2896 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2896, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
2897 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2897, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
2898 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2898, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
2899 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2899, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2900 | ||||
2901 | conf = this->private; | |||
2902 | ||||
2903 | local = dht_local_init (frame, NULL((void*)0), NULL((void*)0), GF_FOP_STATFS); | |||
2904 | if (!local) { | |||
2905 | op_errno = ENOMEM12; | |||
2906 | goto err; | |||
2907 | } | |||
2908 | ||||
2909 | if (IA_ISDIR (loc->inode->ia_type)(loc->inode->ia_type == IA_IFDIR)) { | |||
2910 | local->call_cnt = conf->subvolume_cnt; | |||
2911 | ||||
2912 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
2913 | STACK_WIND (frame, dht_statfs_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2916, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->statfs_cbk) tmp_cbk = dht_statfs_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->statfs"; _new ->unwind_to = "dht_statfs_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->statfs); conf-> subvolumes[i]->fops->statfs (_new, conf->subvolumes[ i], loc, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2914 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2916, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->statfs_cbk) tmp_cbk = dht_statfs_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->statfs"; _new ->unwind_to = "dht_statfs_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->statfs); conf-> subvolumes[i]->fops->statfs (_new, conf->subvolumes[ i], loc, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2915 | conf->subvolumes[i]->fops->statfs, loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2916, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->statfs_cbk) tmp_cbk = dht_statfs_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->statfs"; _new ->unwind_to = "dht_statfs_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->statfs); conf-> subvolumes[i]->fops->statfs (_new, conf->subvolumes[ i], loc, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
2916 | xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2916, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->statfs_cbk) tmp_cbk = dht_statfs_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->statfs"; _new ->unwind_to = "dht_statfs_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->statfs); conf-> subvolumes[i]->fops->statfs (_new, conf->subvolumes[ i], loc, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
2917 | } | |||
2918 | return 0; | |||
2919 | } | |||
2920 | ||||
2921 | subvol = dht_subvol_get_cached (this, loc->inode); | |||
2922 | if (!subvol) { | |||
2923 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2924, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0) | |||
2924 | "no cached subvolume for path=%s", loc->path)do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 2924, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0); | |||
2925 | op_errno = EINVAL22; | |||
2926 | goto err; | |||
2927 | } | |||
2928 | ||||
2929 | local->call_cnt = 1; | |||
2930 | ||||
2931 | STACK_WIND (frame, dht_statfs_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2932, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->statfs_cbk) tmp_cbk = dht_statfs_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->statfs" ; _new->unwind_to = "dht_statfs_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->statfs); subvol-> fops->statfs (_new, subvol, loc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
2932 | subvol, subvol->fops->statfs, loc, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2932, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->statfs_cbk) tmp_cbk = dht_statfs_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->statfs" ; _new->unwind_to = "dht_statfs_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->statfs); subvol-> fops->statfs (_new, subvol, loc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
2933 | ||||
2934 | return 0; | |||
2935 | ||||
2936 | err: | |||
2937 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2938 | DHT_STACK_UNWIND (statfs, frame, -1, op_errno, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_statfs_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2938, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_statfs_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2939 | ||||
2940 | return 0; | |||
2941 | } | |||
2942 | ||||
2943 | ||||
2944 | int | |||
2945 | dht_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, | |||
2946 | dict_t *xdata) | |||
2947 | { | |||
2948 | dht_local_t *local = NULL((void*)0); | |||
2949 | dht_conf_t *conf = NULL((void*)0); | |||
2950 | int op_errno = -1; | |||
2951 | int i = -1; | |||
2952 | ||||
2953 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2953, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
2954 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2954, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
2955 | VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 2955, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto err; } } while (0); | |||
2956 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 2956, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
2957 | ||||
2958 | conf = this->private; | |||
2959 | ||||
2960 | local = dht_local_init (frame, loc, fd, GF_FOP_OPENDIR); | |||
2961 | if (!local) { | |||
2962 | op_errno = ENOMEM12; | |||
2963 | ||||
2964 | goto err; | |||
2965 | } | |||
2966 | ||||
2967 | local->call_cnt = conf->subvolume_cnt; | |||
2968 | ||||
2969 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
2970 | STACK_WIND (frame, dht_fd_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2973, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_fd_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_fd_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->opendir); conf-> subvolumes[i]->fops->opendir (_new, conf->subvolumes [i], loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2971 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2973, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_fd_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_fd_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->opendir); conf-> subvolumes[i]->fops->opendir (_new, conf->subvolumes [i], loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2972 | conf->subvolumes[i]->fops->opendir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2973, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_fd_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_fd_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->opendir); conf-> subvolumes[i]->fops->opendir (_new, conf->subvolumes [i], loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
2973 | loc, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 2973, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_fd_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_fd_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->opendir); conf-> subvolumes[i]->fops->opendir (_new, conf->subvolumes [i], loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
2974 | } | |||
2975 | ||||
2976 | return 0; | |||
2977 | ||||
2978 | err: | |||
2979 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
2980 | DHT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 2980, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
2981 | ||||
2982 | return 0; | |||
2983 | } | |||
2984 | ||||
2985 | ||||
2986 | int | |||
2987 | dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, | |||
2988 | int op_errno, gf_dirent_t *orig_entries, dict_t *xdata) | |||
2989 | { | |||
2990 | dht_local_t *local = NULL((void*)0); | |||
2991 | gf_dirent_t entries; | |||
2992 | gf_dirent_t *orig_entry = NULL((void*)0); | |||
2993 | gf_dirent_t *entry = NULL((void*)0); | |||
2994 | call_frame_t *prev = NULL((void*)0); | |||
2995 | xlator_t *next_subvol = NULL((void*)0); | |||
2996 | off_t next_offset = 0; | |||
2997 | int count = 0; | |||
2998 | dht_layout_t *layout = 0; | |||
2999 | dht_conf_t *conf = NULL((void*)0); | |||
3000 | xlator_t *subvol = 0; | |||
3001 | int ret = 0; | |||
3002 | ||||
3003 | INIT_LIST_HEAD (&entries.list)do { (&entries.list)->next = (&entries.list)->prev = &entries.list; } while (0); | |||
3004 | prev = cookie; | |||
3005 | local = frame->local; | |||
3006 | conf = this->private; | |||
3007 | ||||
3008 | if (op_ret < 0) | |||
3009 | goto done; | |||
3010 | ||||
3011 | if (!local->layout) | |||
3012 | local->layout = dht_layout_get (this, local->fd->inode); | |||
3013 | ||||
3014 | layout = local->layout; | |||
3015 | ||||
3016 | list_for_each_entry (orig_entry, (&orig_entries->list), list)for (orig_entry = ((typeof(*orig_entry) *)((char *)(((&orig_entries ->list))->next)-(unsigned long)(&((typeof(*orig_entry ) *)0)->list))); &orig_entry->list != ((&orig_entries ->list)); orig_entry = ((typeof(*orig_entry) *)((char *)(orig_entry ->list.next)-(unsigned long)(&((typeof(*orig_entry) *) 0)->list)))) { | |||
3017 | next_offset = orig_entry->d_off; | |||
3018 | if (check_is_dir (NULL, (&orig_entry->d_stat), NULL)(((&orig_entry->d_stat)->ia_type == IA_IFDIR)) && | |||
3019 | (prev->this != dht_first_up_subvol (this))) { | |||
3020 | continue; | |||
3021 | } | |||
3022 | if (check_is_linkfile (NULL, (&orig_entry->d_stat),( ((st_mode_from_ia (((&orig_entry->d_stat))->ia_prot , ((&orig_entry->d_stat))->ia_type) & ~0170000) == (01000)) && dict_get (orig_entry->dict, conf-> link_xattr_name)) | |||
3023 | orig_entry->dict,( ((st_mode_from_ia (((&orig_entry->d_stat))->ia_prot , ((&orig_entry->d_stat))->ia_type) & ~0170000) == (01000)) && dict_get (orig_entry->dict, conf-> link_xattr_name)) | |||
3024 | conf->link_xattr_name)( ((st_mode_from_ia (((&orig_entry->d_stat))->ia_prot , ((&orig_entry->d_stat))->ia_type) & ~0170000) == (01000)) && dict_get (orig_entry->dict, conf-> link_xattr_name))) { | |||
3025 | continue; | |||
3026 | } | |||
3027 | ||||
3028 | entry = gf_dirent_for_name (orig_entry->d_name); | |||
3029 | if (!entry) { | |||
3030 | ||||
3031 | goto unwind; | |||
3032 | } | |||
3033 | ||||
3034 | /* Do this if conf->search_unhashed is set to "auto" */ | |||
3035 | if (conf->search_unhashed == GF_DHT_LOOKUP_UNHASHED_AUTO2) { | |||
3036 | subvol = dht_layout_search (this, layout, | |||
3037 | orig_entry->d_name); | |||
3038 | if (!subvol || (subvol != prev->this)) { | |||
3039 | /* TODO: Count the number of entries which need | |||
3040 | linkfile to prove its existence in fs */ | |||
3041 | layout->search_unhashed++; | |||
3042 | } | |||
3043 | } | |||
3044 | ||||
3045 | dht_itransform (this, prev->this, orig_entry->d_off, | |||
3046 | &entry->d_off); | |||
3047 | ||||
3048 | entry->d_stat = orig_entry->d_stat; | |||
3049 | entry->d_ino = orig_entry->d_ino; | |||
3050 | entry->d_type = orig_entry->d_type; | |||
3051 | entry->d_len = orig_entry->d_len; | |||
3052 | ||||
3053 | if (orig_entry->dict) | |||
3054 | entry->dict = dict_ref (orig_entry->dict); | |||
3055 | ||||
3056 | /* making sure we set the inode ctx right with layout, | |||
3057 | currently possible only for non-directories, so for | |||
3058 | directories don't set entry inodes */ | |||
3059 | if (!IA_ISDIR(entry->d_stat.ia_type)(entry->d_stat.ia_type == IA_IFDIR)) { | |||
3060 | ret = dht_layout_preset (this, prev->this, | |||
3061 | orig_entry->inode); | |||
3062 | if (ret) | |||
3063 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to link the layout in inode" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3064, GF_LOG_WARNING, "failed to link the layout in inode") ; } while (0) | |||
3064 | "failed to link the layout in inode")do { do { if (0) printf ("failed to link the layout in inode" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3064, GF_LOG_WARNING, "failed to link the layout in inode") ; } while (0); | |||
3065 | entry->inode = inode_ref (orig_entry->inode); | |||
3066 | } else if (orig_entry->inode) { | |||
3067 | dht_inode_ctx_time_update (orig_entry->inode, this, | |||
3068 | &entry->d_stat, 1); | |||
3069 | } | |||
3070 | ||||
3071 | list_add_tail (&entry->list, &entries.list); | |||
3072 | count++; | |||
3073 | } | |||
3074 | op_ret = count; | |||
3075 | /* We need to ensure that only the last subvolume's end-of-directory | |||
3076 | * notification is respected so that directory reading does not stop | |||
3077 | * before all subvolumes have been read. That could happen because the | |||
3078 | * posix for each subvolume sends a ENOENT on end-of-directory but in | |||
3079 | * distribute we're not concerned only with a posix's view of the | |||
3080 | * directory but the aggregated namespace' view of the directory. | |||
3081 | */ | |||
3082 | if (prev->this != dht_last_up_subvol (this)) | |||
3083 | op_errno = 0; | |||
3084 | ||||
3085 | done: | |||
3086 | if (count == 0) { | |||
3087 | /* non-zero next_offset means that | |||
3088 | EOF is not yet hit on the current subvol | |||
3089 | */ | |||
3090 | if (next_offset == 0) { | |||
3091 | next_subvol = dht_subvol_next (this, prev->this); | |||
3092 | } else { | |||
3093 | next_subvol = prev->this; | |||
3094 | } | |||
3095 | ||||
3096 | if (!next_subvol) { | |||
3097 | goto unwind; | |||
3098 | } | |||
3099 | ||||
3100 | if (conf->readdir_optimize == _gf_true) { | |||
3101 | if (next_subvol != dht_first_up_subvol (this)) { | |||
3102 | ret = dict_set_int32 (local->xattr, | |||
3103 | GF_READDIR_SKIP_DIRS"readdir-filter-directories", 1); | |||
3104 | if (ret) | |||
3105 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("dict set failed"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3106, GF_LOG_ERROR , "dict set failed"); } while (0) | |||
3106 | "dict set failed")do { do { if (0) printf ("dict set failed"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3106, GF_LOG_ERROR , "dict set failed"); } while (0); | |||
3107 | } | |||
3108 | } | |||
3109 | ||||
3110 | STACK_WIND (frame, dht_readdirp_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3113, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdirp_cbk) tmp_cbk = dht_readdirp_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdirp"; _new->unwind_to = "dht_readdirp_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdirp); next_subvol->fops->readdirp (_new , next_subvol, local->fd, local->size, next_offset, local ->xattr); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3111 | next_subvol, next_subvol->fops->readdirp,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3113, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdirp_cbk) tmp_cbk = dht_readdirp_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdirp"; _new->unwind_to = "dht_readdirp_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdirp); next_subvol->fops->readdirp (_new , next_subvol, local->fd, local->size, next_offset, local ->xattr); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3112 | local->fd, local->size, next_offset,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3113, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdirp_cbk) tmp_cbk = dht_readdirp_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdirp"; _new->unwind_to = "dht_readdirp_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdirp); next_subvol->fops->readdirp (_new , next_subvol, local->fd, local->size, next_offset, local ->xattr); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3113 | local->xattr)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3113, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdirp_cbk) tmp_cbk = dht_readdirp_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdirp"; _new->unwind_to = "dht_readdirp_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdirp); next_subvol->fops->readdirp (_new , next_subvol, local->fd, local->size, next_offset, local ->xattr); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3114 | return 0; | |||
3115 | } | |||
3116 | ||||
3117 | unwind: | |||
3118 | if (op_ret < 0) | |||
3119 | op_ret = 0; | |||
3120 | ||||
3121 | DHT_STACK_UNWIND (readdirp, frame, op_ret, op_errno, &entries, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_readdirp_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3121, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readdirp_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, &entries, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3122 | ||||
3123 | gf_dirent_free (&entries); | |||
3124 | ||||
3125 | return 0; | |||
3126 | } | |||
3127 | ||||
3128 | ||||
3129 | ||||
3130 | int | |||
3131 | dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
3132 | int op_ret, int op_errno, gf_dirent_t *orig_entries, | |||
3133 | dict_t *xdata) | |||
3134 | { | |||
3135 | dht_local_t *local = NULL((void*)0); | |||
3136 | gf_dirent_t entries; | |||
3137 | gf_dirent_t *orig_entry = NULL((void*)0); | |||
3138 | gf_dirent_t *entry = NULL((void*)0); | |||
3139 | call_frame_t *prev = NULL((void*)0); | |||
3140 | xlator_t *next_subvol = NULL((void*)0); | |||
3141 | off_t next_offset = 0; | |||
3142 | int count = 0; | |||
3143 | dht_layout_t *layout = 0; | |||
3144 | xlator_t *subvol = 0; | |||
3145 | ||||
3146 | INIT_LIST_HEAD (&entries.list)do { (&entries.list)->next = (&entries.list)->prev = &entries.list; } while (0); | |||
3147 | prev = cookie; | |||
3148 | local = frame->local; | |||
3149 | ||||
3150 | if (op_ret < 0) | |||
3151 | goto done; | |||
3152 | ||||
3153 | if (!local->layout) | |||
3154 | local->layout = dht_layout_get (this, local->fd->inode); | |||
3155 | ||||
3156 | layout = local->layout; | |||
3157 | ||||
3158 | list_for_each_entry (orig_entry, (&orig_entries->list), list)for (orig_entry = ((typeof(*orig_entry) *)((char *)(((&orig_entries ->list))->next)-(unsigned long)(&((typeof(*orig_entry ) *)0)->list))); &orig_entry->list != ((&orig_entries ->list)); orig_entry = ((typeof(*orig_entry) *)((char *)(orig_entry ->list.next)-(unsigned long)(&((typeof(*orig_entry) *) 0)->list)))) { | |||
3159 | next_offset = orig_entry->d_off; | |||
3160 | ||||
3161 | subvol = dht_layout_search (this, layout, orig_entry->d_name); | |||
3162 | ||||
3163 | if (!subvol || (subvol == prev->this)) { | |||
3164 | entry = gf_dirent_for_name (orig_entry->d_name); | |||
3165 | if (!entry) { | |||
3166 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("memory allocation failed :("); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3167 , GF_LOG_ERROR, "memory allocation failed :("); } while (0) | |||
3167 | "memory allocation failed :(")do { do { if (0) printf ("memory allocation failed :("); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3167 , GF_LOG_ERROR, "memory allocation failed :("); } while (0); | |||
3168 | goto unwind; | |||
3169 | } | |||
3170 | ||||
3171 | dht_itransform (this, prev->this, orig_entry->d_off, | |||
3172 | &entry->d_off); | |||
3173 | ||||
3174 | entry->d_ino = orig_entry->d_ino; | |||
3175 | entry->d_type = orig_entry->d_type; | |||
3176 | entry->d_len = orig_entry->d_len; | |||
3177 | ||||
3178 | list_add_tail (&entry->list, &entries.list); | |||
3179 | count++; | |||
3180 | } | |||
3181 | } | |||
3182 | op_ret = count; | |||
3183 | /* We need to ensure that only the last subvolume's end-of-directory | |||
3184 | * notification is respected so that directory reading does not stop | |||
3185 | * before all subvolumes have been read. That could happen because the | |||
3186 | * posix for each subvolume sends a ENOENT on end-of-directory but in | |||
3187 | * distribute we're not concerned only with a posix's view of the | |||
3188 | * directory but the aggregated namespace' view of the directory. | |||
3189 | */ | |||
3190 | if (prev->this != dht_last_up_subvol (this)) | |||
3191 | op_errno = 0; | |||
3192 | ||||
3193 | done: | |||
3194 | if (count == 0) { | |||
3195 | /* non-zero next_offset means that | |||
3196 | EOF is not yet hit on the current subvol | |||
3197 | */ | |||
3198 | if (next_offset == 0) { | |||
3199 | next_subvol = dht_subvol_next (this, prev->this); | |||
3200 | } else { | |||
3201 | next_subvol = prev->this; | |||
3202 | } | |||
3203 | ||||
3204 | if (!next_subvol) { | |||
3205 | goto unwind; | |||
3206 | } | |||
3207 | ||||
3208 | STACK_WIND (frame, dht_readdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3210, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdir_cbk) tmp_cbk = dht_readdir_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdir"; _new->unwind_to = "dht_readdir_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdir); next_subvol->fops->readdir (_new , next_subvol, local->fd, local->size, next_offset, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3209 | next_subvol, next_subvol->fops->readdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3210, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdir_cbk) tmp_cbk = dht_readdir_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdir"; _new->unwind_to = "dht_readdir_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdir); next_subvol->fops->readdir (_new , next_subvol, local->fd, local->size, next_offset, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3210 | local->fd, local->size, next_offset, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3210, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( next_subvol-> fops->readdir_cbk) tmp_cbk = dht_readdir_cbk; _new->root = frame->root; _new->this = next_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "next_subvol->fops->readdir"; _new->unwind_to = "dht_readdir_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = next_subvol; if (frame-> this->ctx->measure_latency) gf_latency_begin (_new, next_subvol ->fops->readdir); next_subvol->fops->readdir (_new , next_subvol, local->fd, local->size, next_offset, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3211 | return 0; | |||
3212 | } | |||
3213 | ||||
3214 | unwind: | |||
3215 | if (op_ret < 0) | |||
3216 | op_ret = 0; | |||
3217 | ||||
3218 | DHT_STACK_UNWIND (readdir, frame, op_ret, op_errno, &entries, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3218, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readdir_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, &entries, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3219 | ||||
3220 | gf_dirent_free (&entries); | |||
3221 | ||||
3222 | return 0; | |||
3223 | } | |||
3224 | ||||
3225 | ||||
3226 | int | |||
3227 | dht_do_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
3228 | off_t yoff, int whichop, dict_t *dict) | |||
3229 | { | |||
3230 | dht_local_t *local = NULL((void*)0); | |||
3231 | int op_errno = -1; | |||
3232 | xlator_t *xvol = NULL((void*)0); | |||
3233 | off_t xoff = 0; | |||
3234 | int ret = 0; | |||
3235 | dht_conf_t *conf = NULL((void*)0); | |||
3236 | ||||
3237 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3237, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3238 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3238, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3239 | VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3239, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto err; } } while (0); | |||
3240 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 3240, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
3241 | ||||
3242 | conf = this->private; | |||
3243 | ||||
3244 | local = dht_local_init (frame, NULL((void*)0), NULL((void*)0), whichop); | |||
3245 | if (!local) { | |||
3246 | op_errno = ENOMEM12; | |||
3247 | goto err; | |||
3248 | } | |||
3249 | ||||
3250 | local->fd = fd_ref (fd); | |||
3251 | local->size = size; | |||
3252 | local->xattr_req = (dict)? dict_ref (dict) : NULL((void*)0); | |||
3253 | ||||
3254 | dht_deitransform (this, yoff, &xvol, (uint64_t *)&xoff); | |||
3255 | ||||
3256 | /* TODO: do proper readdir */ | |||
3257 | if (whichop == GF_FOP_READDIRP) { | |||
3258 | if (dict) | |||
3259 | local->xattr = dict_ref (dict); | |||
3260 | else | |||
3261 | local->xattr = dict_new (); | |||
3262 | ||||
3263 | if (local->xattr) { | |||
3264 | ret = dict_set_uint32 (local->xattr, | |||
3265 | conf->link_xattr_name, 256); | |||
3266 | if (ret) | |||
3267 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set '%s' key", conf->link_xattr_name ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3269, GF_LOG_WARNING, "failed to set '%s' key", conf->link_xattr_name ); } while (0) | |||
3268 | "failed to set '%s' key",do { do { if (0) printf ("failed to set '%s' key", conf->link_xattr_name ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3269, GF_LOG_WARNING, "failed to set '%s' key", conf->link_xattr_name ); } while (0) | |||
3269 | conf->link_xattr_name)do { do { if (0) printf ("failed to set '%s' key", conf->link_xattr_name ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3269, GF_LOG_WARNING, "failed to set '%s' key", conf->link_xattr_name ); } while (0); | |||
3270 | if (conf->readdir_optimize == _gf_true) { | |||
3271 | if (xvol != dht_first_up_subvol (this)) { | |||
3272 | ret = dict_set_int32 (local->xattr, | |||
3273 | GF_READDIR_SKIP_DIRS"readdir-filter-directories", 1); | |||
3274 | if (ret) | |||
3275 | gf_log (this->name,do { do { if (0) printf ("Dict set failed"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3277, GF_LOG_ERROR , "Dict set failed"); } while (0) | |||
3276 | GF_LOG_ERROR,do { do { if (0) printf ("Dict set failed"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3277, GF_LOG_ERROR , "Dict set failed"); } while (0) | |||
3277 | "Dict set failed")do { do { if (0) printf ("Dict set failed"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3277, GF_LOG_ERROR , "Dict set failed"); } while (0); | |||
3278 | } | |||
3279 | } | |||
3280 | } | |||
3281 | ||||
3282 | STACK_WIND (frame, dht_readdirp_cbk, xvol, xvol->fops->readdirp,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3283, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( xvol->fops ->readdirp_cbk) tmp_cbk = dht_readdirp_cbk; _new->root = frame->root; _new->this = xvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "xvol->fops->readdirp" ; _new->unwind_to = "dht_readdirp_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = xvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, xvol->fops->readdirp); xvol->fops->readdirp (_new, xvol, fd, size, xoff, local->xattr); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3283 | fd, size, xoff, local->xattr)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3283, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( xvol->fops ->readdirp_cbk) tmp_cbk = dht_readdirp_cbk; _new->root = frame->root; _new->this = xvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "xvol->fops->readdirp" ; _new->unwind_to = "dht_readdirp_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = xvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, xvol->fops->readdirp); xvol->fops->readdirp (_new, xvol, fd, size, xoff, local->xattr); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3284 | } else { | |||
3285 | STACK_WIND (frame, dht_readdir_cbk, xvol, xvol->fops->readdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3286, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( xvol->fops ->readdir_cbk) tmp_cbk = dht_readdir_cbk; _new->root = frame ->root; _new->this = xvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "xvol->fops->readdir" ; _new->unwind_to = "dht_readdir_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = xvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, xvol->fops->readdir); xvol->fops->readdir (_new, xvol, fd, size, xoff, local->xattr); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3286 | fd, size, xoff, local->xattr)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3286, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( xvol->fops ->readdir_cbk) tmp_cbk = dht_readdir_cbk; _new->root = frame ->root; _new->this = xvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "xvol->fops->readdir" ; _new->unwind_to = "dht_readdir_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = xvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, xvol->fops->readdir); xvol->fops->readdir (_new, xvol, fd, size, xoff, local->xattr); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3287 | } | |||
3288 | ||||
3289 | return 0; | |||
3290 | ||||
3291 | err: | |||
3292 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3293 | DHT_STACK_UNWIND (readdir, frame, -1, op_errno, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3293, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_readdir_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3294 | ||||
3295 | return 0; | |||
3296 | } | |||
3297 | ||||
3298 | ||||
3299 | int | |||
3300 | dht_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
3301 | off_t yoff, dict_t *xdata) | |||
3302 | { | |||
3303 | int op = GF_FOP_READDIR; | |||
3304 | dht_conf_t *conf = NULL((void*)0); | |||
3305 | int i = 0; | |||
3306 | ||||
3307 | conf = this->private; | |||
3308 | if (!conf) | |||
3309 | goto out; | |||
3310 | ||||
3311 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
3312 | if (!conf->subvolume_status[i]) { | |||
3313 | op = GF_FOP_READDIRP; | |||
3314 | break; | |||
3315 | } | |||
3316 | } | |||
3317 | ||||
3318 | if (conf->use_readdirp) | |||
3319 | op = GF_FOP_READDIRP; | |||
3320 | ||||
3321 | out: | |||
3322 | dht_do_readdir (frame, this, fd, size, yoff, op, 0); | |||
3323 | return 0; | |||
3324 | } | |||
3325 | ||||
3326 | int | |||
3327 | dht_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
3328 | off_t yoff, dict_t *dict) | |||
3329 | { | |||
3330 | dht_do_readdir (frame, this, fd, size, yoff, GF_FOP_READDIRP, dict); | |||
3331 | return 0; | |||
3332 | } | |||
3333 | ||||
3334 | ||||
3335 | ||||
3336 | int | |||
3337 | dht_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
3338 | int op_ret, int op_errno, dict_t *xdata) | |||
3339 | { | |||
3340 | dht_local_t *local = NULL((void*)0); | |||
3341 | int this_call_cnt = 0; | |||
3342 | ||||
3343 | ||||
3344 | local = frame->local; | |||
3345 | ||||
3346 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
3347 | { | |||
3348 | if (op_ret == -1) | |||
3349 | local->op_errno = op_errno; | |||
3350 | ||||
3351 | if (op_ret == 0) | |||
3352 | local->op_ret = 0; | |||
3353 | } | |||
3354 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
3355 | ||||
3356 | this_call_cnt = dht_frame_return (frame); | |||
3357 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
3358 | DHT_STACK_UNWIND (fsyncdir, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fsyncdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3359, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fsyncdir_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3359 | local->op_errno, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fsyncdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3359, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fsyncdir_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3360 | ||||
3361 | return 0; | |||
3362 | } | |||
3363 | ||||
3364 | ||||
3365 | int | |||
3366 | dht_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
3367 | int datasync, dict_t *xdata) | |||
3368 | { | |||
3369 | dht_local_t *local = NULL((void*)0); | |||
3370 | dht_conf_t *conf = NULL((void*)0); | |||
3371 | int op_errno = -1; | |||
3372 | int i = -1; | |||
3373 | ||||
3374 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3374, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3375 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3375, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3376 | VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3376, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto err; } } while (0); | |||
3377 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 3377, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
3378 | ||||
3379 | conf = this->private; | |||
3380 | ||||
3381 | local = dht_local_init (frame, NULL((void*)0), NULL((void*)0), GF_FOP_FSYNCDIR); | |||
3382 | if (!local) { | |||
3383 | op_errno = ENOMEM12; | |||
3384 | goto err; | |||
3385 | } | |||
3386 | ||||
3387 | local->fd = fd_ref (fd); | |||
3388 | local->call_cnt = conf->subvolume_cnt; | |||
3389 | ||||
3390 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
3391 | STACK_WIND (frame, dht_fsyncdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3394, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->fsyncdir_cbk) tmp_cbk = dht_fsyncdir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->fsyncdir" ; _new->unwind_to = "dht_fsyncdir_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->fsyncdir); conf->subvolumes[i]->fops-> fsyncdir (_new, conf->subvolumes[i], fd, datasync, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3392 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3394, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->fsyncdir_cbk) tmp_cbk = dht_fsyncdir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->fsyncdir" ; _new->unwind_to = "dht_fsyncdir_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->fsyncdir); conf->subvolumes[i]->fops-> fsyncdir (_new, conf->subvolumes[i], fd, datasync, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3393 | conf->subvolumes[i]->fops->fsyncdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3394, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->fsyncdir_cbk) tmp_cbk = dht_fsyncdir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->fsyncdir" ; _new->unwind_to = "dht_fsyncdir_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->fsyncdir); conf->subvolumes[i]->fops-> fsyncdir (_new, conf->subvolumes[i], fd, datasync, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3394 | fd, datasync, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3394, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->fsyncdir_cbk) tmp_cbk = dht_fsyncdir_cbk; _new ->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->fsyncdir" ; _new->unwind_to = "dht_fsyncdir_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->fsyncdir); conf->subvolumes[i]->fops-> fsyncdir (_new, conf->subvolumes[i], fd, datasync, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3395 | } | |||
3396 | ||||
3397 | return 0; | |||
3398 | ||||
3399 | err: | |||
3400 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3401 | DHT_STACK_UNWIND (fsyncdir, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fsyncdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3401, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fsyncdir_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3402 | ||||
3403 | return 0; | |||
3404 | } | |||
3405 | ||||
3406 | ||||
3407 | int | |||
3408 | dht_newfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
3409 | int op_ret, int op_errno, | |||
3410 | inode_t *inode, struct iatt *stbuf, struct iatt *preparent, | |||
3411 | struct iatt *postparent, dict_t *xdata) | |||
3412 | { | |||
3413 | xlator_t *prev = NULL((void*)0); | |||
3414 | int ret = -1; | |||
3415 | dht_local_t *local = NULL((void*)0); | |||
3416 | ||||
3417 | ||||
3418 | if (op_ret == -1) | |||
3419 | goto out; | |||
3420 | ||||
3421 | local = frame->local; | |||
3422 | if (!local) { | |||
3423 | op_ret = -1; | |||
3424 | op_errno = EINVAL22; | |||
3425 | goto out; | |||
3426 | } | |||
3427 | ||||
3428 | prev = cookie; | |||
3429 | ||||
3430 | if (local->loc.parent) { | |||
3431 | ||||
3432 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
3433 | preparent, 0); | |||
3434 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
3435 | postparent, 1); | |||
3436 | } | |||
3437 | ||||
3438 | ret = dht_layout_preset (this, prev, inode); | |||
3439 | if (ret < 0) { | |||
3440 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("could not set pre-set layout for subvolume %s" , prev? prev->name: ((void*)0)); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 3442, GF_LOG_DEBUG, "could not set pre-set layout for subvolume %s" , prev? prev->name: ((void*)0)); } while (0) | |||
3441 | "could not set pre-set layout for subvolume %s",do { do { if (0) printf ("could not set pre-set layout for subvolume %s" , prev? prev->name: ((void*)0)); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 3442, GF_LOG_DEBUG, "could not set pre-set layout for subvolume %s" , prev? prev->name: ((void*)0)); } while (0) | |||
3442 | prev? prev->name: NULL)do { do { if (0) printf ("could not set pre-set layout for subvolume %s" , prev? prev->name: ((void*)0)); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 3442, GF_LOG_DEBUG, "could not set pre-set layout for subvolume %s" , prev? prev->name: ((void*)0)); } while (0); | |||
3443 | op_ret = -1; | |||
3444 | op_errno = EINVAL22; | |||
3445 | goto out; | |||
3446 | } | |||
3447 | if (local->linked == _gf_true) | |||
3448 | dht_linkfile_attr_heal (frame, this); | |||
3449 | out: | |||
3450 | /* | |||
3451 | * FIXME: ia_size and st_blocks of preparent and postparent do not have | |||
3452 | * correct values. since, preparent and postparent buffers correspond | |||
3453 | * to a directory these two members should have values equal to sum of | |||
3454 | * corresponding values from each of the subvolume. | |||
3455 | * See dht_iatt_merge for reference. | |||
3456 | */ | |||
3457 | DHT_STRIP_PHASE1_FLAGS (stbuf)do { if ((stbuf) && ( ((stbuf)->ia_type == IA_IFREG ) && ((stbuf)->ia_prot.sticky == 1) && ((stbuf )->ia_prot.sgid == 1))) { (stbuf)->ia_prot.sticky = 0; ( stbuf)->ia_prot.sgid = 0; } } while (0); | |||
3458 | DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, stbuf,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3459, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); dht_local_wipe (__xl, __local); } while (0) | |||
3459 | preparent, postparent, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3459, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); dht_local_wipe (__xl, __local); } while (0); | |||
3460 | return 0; | |||
3461 | } | |||
3462 | ||||
3463 | int | |||
3464 | dht_mknod_linkfile_create_cbk (call_frame_t *frame, void *cookie, | |||
3465 | xlator_t *this, | |||
3466 | int32_t op_ret, int32_t op_errno, | |||
3467 | inode_t *inode, struct iatt *stbuf, | |||
3468 | struct iatt *preparent, struct iatt *postparent, | |||
3469 | dict_t *xdata) | |||
3470 | { | |||
3471 | dht_local_t *local = NULL((void*)0); | |||
3472 | xlator_t *cached_subvol = NULL((void*)0); | |||
3473 | ||||
3474 | if (op_ret == -1) | |||
3475 | goto err; | |||
3476 | ||||
3477 | local = frame->local; | |||
3478 | if (!local || !local->cached_subvol) { | |||
3479 | op_errno = EINVAL22; | |||
3480 | goto err; | |||
3481 | } | |||
3482 | ||||
3483 | cached_subvol = local->cached_subvol; | |||
3484 | ||||
3485 | STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)cached_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3488, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)cached_subvol; _new->wind_from = __FUNCTION__; _new ->wind_to = "cached_subvol->fops->mknod"; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&frame->root->stack_lock); { frame ->ref_count++; _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock); cached_subvol->fops ->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (cached_subvol ->ctx->measure_latency) gf_latency_begin (_new, cached_subvol ->fops->mknod); cached_subvol->fops->mknod (_new, cached_subvol, &local->loc, local->mode, local-> rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3486 | cached_subvol, cached_subvol->fops->mknod,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3488, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)cached_subvol; _new->wind_from = __FUNCTION__; _new ->wind_to = "cached_subvol->fops->mknod"; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&frame->root->stack_lock); { frame ->ref_count++; _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock); cached_subvol->fops ->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (cached_subvol ->ctx->measure_latency) gf_latency_begin (_new, cached_subvol ->fops->mknod); cached_subvol->fops->mknod (_new, cached_subvol, &local->loc, local->mode, local-> rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3487 | &local->loc, local->mode, local->rdev, local->umask,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3488, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)cached_subvol; _new->wind_from = __FUNCTION__; _new ->wind_to = "cached_subvol->fops->mknod"; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&frame->root->stack_lock); { frame ->ref_count++; _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock); cached_subvol->fops ->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (cached_subvol ->ctx->measure_latency) gf_latency_begin (_new, cached_subvol ->fops->mknod); cached_subvol->fops->mknod (_new, cached_subvol, &local->loc, local->mode, local-> rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3488 | local->params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3488, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = (void *)cached_subvol; _new->wind_from = __FUNCTION__; _new ->wind_to = "cached_subvol->fops->mknod"; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init (&_new->lock, 0 ); pthread_spin_lock (&frame->root->stack_lock); { frame ->ref_count++; _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock); cached_subvol->fops ->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (cached_subvol ->ctx->measure_latency) gf_latency_begin (_new, cached_subvol ->fops->mknod); cached_subvol->fops->mknod (_new, cached_subvol, &local->loc, local->mode, local-> rdev, local->umask, local->params); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3489 | ||||
3490 | return 0; | |||
3491 | err: | |||
3492 | DHT_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3493, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3493 | NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3493, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3494 | return 0; | |||
3495 | } | |||
3496 | ||||
3497 | int | |||
3498 | dht_mknod (call_frame_t *frame, xlator_t *this, | |||
3499 | loc_t *loc, mode_t mode, dev_t rdev, mode_t umask, dict_t *params) | |||
3500 | { | |||
3501 | xlator_t *subvol = NULL((void*)0); | |||
3502 | int op_errno = -1; | |||
3503 | xlator_t *avail_subvol = NULL((void*)0); | |||
3504 | dht_local_t *local = NULL((void*)0); | |||
3505 | ||||
3506 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3506, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3507 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3507, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3508 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3508, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
3509 | ||||
3510 | dht_get_du_info (frame, this, loc); | |||
3511 | ||||
3512 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_MKNOD); | |||
3513 | if (!local) { | |||
3514 | op_errno = ENOMEM12; | |||
3515 | goto err; | |||
3516 | } | |||
3517 | ||||
3518 | subvol = dht_subvol_get_hashed (this, loc); | |||
3519 | if (!subvol) { | |||
3520 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3522, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3521 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3522, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3522 | loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3522, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0); | |||
3523 | op_errno = ENOENT2; | |||
3524 | goto err; | |||
3525 | } | |||
3526 | ||||
3527 | if (!dht_is_subvol_filled (this, subvol)) { | |||
3528 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3529, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0) | |||
3529 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3529, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0); | |||
3530 | ||||
3531 | STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3533, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3532 | subvol, subvol->fops->mknod, loc, mode,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3533, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3533 | rdev, umask, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3533, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3534 | } else { | |||
3535 | avail_subvol = dht_free_disk_available_subvol (this, subvol); | |||
3536 | if (avail_subvol != subvol) { | |||
3537 | /* Choose the minimum filled volume, and create the | |||
3538 | files there */ | |||
3539 | ||||
3540 | local->params = dict_ref (params); | |||
3541 | local->cached_subvol = avail_subvol; | |||
3542 | local->mode = mode; | |||
3543 | local->rdev = rdev; | |||
3544 | local->umask = umask; | |||
3545 | dht_linkfile_create (frame, | |||
3546 | dht_mknod_linkfile_create_cbk, | |||
3547 | this, avail_subvol, subvol, loc); | |||
3548 | } else { | |||
3549 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3550, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0) | |||
3550 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3550, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0); | |||
3551 | ||||
3552 | STACK_WIND_COOKIE (frame, dht_newfile_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3555, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3553 | (void *)subvol, subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3555, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3554 | subvol->fops->mknod, loc, mode,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3555, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3555 | rdev, umask, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3555, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->mknod_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->mknod" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->mknod_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location( )) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->mknod); subvol->fops->mknod (_new, subvol, loc, mode, rdev, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3556 | } | |||
3557 | } | |||
3558 | ||||
3559 | return 0; | |||
3560 | ||||
3561 | err: | |||
3562 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3563 | DHT_STACK_UNWIND (mknod, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3564, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3564 | NULL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3564, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3565 | ||||
3566 | return 0; | |||
3567 | } | |||
3568 | ||||
3569 | ||||
3570 | int | |||
3571 | dht_symlink (call_frame_t *frame, xlator_t *this, | |||
3572 | const char *linkname, loc_t *loc, mode_t umask, dict_t *params) | |||
3573 | { | |||
3574 | xlator_t *subvol = NULL((void*)0); | |||
3575 | int op_errno = -1; | |||
3576 | dht_local_t *local = NULL((void*)0); | |||
3577 | ||||
3578 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3578, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3579 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3579, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3580 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3580, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
3581 | ||||
3582 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_SYMLINK); | |||
3583 | if (!local) { | |||
3584 | op_errno = ENOMEM12; | |||
3585 | goto err; | |||
3586 | } | |||
3587 | ||||
3588 | subvol = dht_subvol_get_hashed (this, loc); | |||
3589 | if (!subvol) { | |||
3590 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3592, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3591 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3592, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3592 | loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3592, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0); | |||
3593 | op_errno = ENOENT2; | |||
3594 | goto err; | |||
3595 | } | |||
3596 | ||||
3597 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3598, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0) | |||
3598 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3598, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0); | |||
3599 | ||||
3600 | STACK_WIND_COOKIE (frame, dht_newfile_cbk, (void *)subvol, subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3602, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->symlink_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->symlink" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->symlink_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->symlink); subvol->fops->symlink (_new, subvol, linkname, loc, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3601 | subvol->fops->symlink, linkname, loc, umask,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3602, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->symlink_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->symlink" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->symlink_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->symlink); subvol->fops->symlink (_new, subvol, linkname, loc, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3602 | params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3602, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->symlink_cbk) tmp_cbk = dht_newfile_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = (void *)subvol; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->symlink" ; _new->unwind_to = "dht_newfile_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { frame->ref_count++; _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; } pthread_spin_unlock (&frame->root->stack_lock ); subvol->fops->symlink_cbk = dht_newfile_cbk; old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (subvol->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->symlink); subvol->fops->symlink (_new, subvol, linkname, loc, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3603 | ||||
3604 | return 0; | |||
3605 | ||||
3606 | err: | |||
3607 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3608 | DHT_STACK_UNWIND (link, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3609, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3609 | NULL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3609, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3610 | ||||
3611 | return 0; | |||
3612 | } | |||
3613 | ||||
3614 | ||||
3615 | int | |||
3616 | dht_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, | |||
3617 | dict_t *xdata) | |||
3618 | { | |||
3619 | xlator_t *cached_subvol = NULL((void*)0); | |||
3620 | xlator_t *hashed_subvol = NULL((void*)0); | |||
3621 | int op_errno = -1; | |||
3622 | dht_local_t *local = NULL((void*)0); | |||
3623 | ||||
3624 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3624, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3625 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3625, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3626 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3626, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
3627 | ||||
3628 | if (dht_filter_loc_subvol_key (this, loc, &local->loc, | |||
3629 | &cached_subvol)) { | |||
3630 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("unlinking %s on %s (given path %s)" , local->loc.path, cached_subvol->name, loc->path); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3632, GF_LOG_INFO, "unlinking %s on %s (given path %s)", local ->loc.path, cached_subvol->name, loc->path); } while (0) | |||
3631 | "unlinking %s on %s (given path %s)",do { do { if (0) printf ("unlinking %s on %s (given path %s)" , local->loc.path, cached_subvol->name, loc->path); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3632, GF_LOG_INFO, "unlinking %s on %s (given path %s)", local ->loc.path, cached_subvol->name, loc->path); } while (0) | |||
3632 | local->loc.path, cached_subvol->name, loc->path)do { do { if (0) printf ("unlinking %s on %s (given path %s)" , local->loc.path, cached_subvol->name, loc->path); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 3632, GF_LOG_INFO, "unlinking %s on %s (given path %s)", local ->loc.path, cached_subvol->name, loc->path); } while (0); | |||
3633 | STACK_WIND (frame, dht_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3635, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, &local->loc, xflag, xdata ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3634 | cached_subvol, cached_subvol->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3635, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, &local->loc, xflag, xdata ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3635 | &local->loc, xflag, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3635, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, &local->loc, xflag, xdata ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3636 | goto done; | |||
3637 | } | |||
3638 | ||||
3639 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_UNLINK); | |||
3640 | if (!local) { | |||
3641 | op_errno = ENOMEM12; | |||
3642 | ||||
3643 | goto err; | |||
3644 | } | |||
3645 | ||||
3646 | hashed_subvol = dht_subvol_get_hashed (this, loc); | |||
3647 | if (!hashed_subvol) { | |||
3648 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3650, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3649 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3650, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3650 | loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3650, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0); | |||
3651 | op_errno = EINVAL22; | |||
3652 | goto err; | |||
3653 | } | |||
3654 | ||||
3655 | cached_subvol = local->cached_subvol; | |||
3656 | if (!cached_subvol) { | |||
3657 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3658, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0) | |||
3658 | "no cached subvolume for path=%s", loc->path)do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3658, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0); | |||
3659 | op_errno = EINVAL22; | |||
3660 | goto err; | |||
3661 | } | |||
3662 | ||||
3663 | local->flags = xflag; | |||
3664 | if (hashed_subvol != cached_subvol) { | |||
3665 | STACK_WIND (frame, dht_unlink_linkfile_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3667, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_linkfile_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->unlink); hashed_subvol->fops-> unlink (_new, hashed_subvol, loc, xflag, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3666 | hashed_subvol, hashed_subvol->fops->unlink, loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3667, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_linkfile_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->unlink); hashed_subvol->fops-> unlink (_new, hashed_subvol, loc, xflag, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3667 | xflag, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3667, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_linkfile_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_linkfile_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->unlink); hashed_subvol->fops-> unlink (_new, hashed_subvol, loc, xflag, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3668 | } else { | |||
3669 | STACK_WIND (frame, dht_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3671, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, loc, xflag, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3670 | cached_subvol, cached_subvol->fops->unlink, loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3671, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, loc, xflag, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3671 | xflag, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3671, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->unlink_cbk) tmp_cbk = dht_unlink_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->unlink"; _new->unwind_to = "dht_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->unlink); cached_subvol->fops-> unlink (_new, cached_subvol, loc, xflag, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3672 | } | |||
3673 | done: | |||
3674 | return 0; | |||
3675 | err: | |||
3676 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3677 | DHT_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3677, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3678 | ||||
3679 | return 0; | |||
3680 | } | |||
3681 | ||||
3682 | ||||
3683 | int | |||
3684 | dht_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
3685 | int op_ret, int op_errno, | |||
3686 | inode_t *inode, struct iatt *stbuf, struct iatt *preparent, | |||
3687 | struct iatt *postparent, dict_t *xdata) | |||
3688 | { | |||
3689 | call_frame_t *prev = NULL((void*)0); | |||
3690 | dht_layout_t *layout = NULL((void*)0); | |||
3691 | dht_local_t *local = NULL((void*)0); | |||
3692 | ||||
3693 | prev = cookie; | |||
3694 | ||||
3695 | local = frame->local; | |||
3696 | ||||
3697 | if (op_ret == -1) | |||
3698 | goto out; | |||
3699 | ||||
3700 | layout = dht_layout_for_subvol (this, prev->this); | |||
3701 | if (!layout) { | |||
3702 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no pre-set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 3704, GF_LOG_DEBUG, "no pre-set layout for subvolume %s" , prev->this->name); } while (0) | |||
3703 | "no pre-set layout for subvolume %s",do { do { if (0) printf ("no pre-set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 3704, GF_LOG_DEBUG, "no pre-set layout for subvolume %s" , prev->this->name); } while (0) | |||
3704 | prev->this->name)do { do { if (0) printf ("no pre-set layout for subvolume %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 3704, GF_LOG_DEBUG, "no pre-set layout for subvolume %s" , prev->this->name); } while (0); | |||
3705 | op_ret = -1; | |||
3706 | op_errno = EINVAL22; | |||
3707 | goto out; | |||
3708 | } | |||
3709 | ||||
3710 | if (local->loc.parent) { | |||
3711 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
3712 | preparent, 0); | |||
3713 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
3714 | postparent, 1); | |||
3715 | } | |||
3716 | if (local->linked == _gf_true) { | |||
3717 | local->stbuf = *stbuf; | |||
3718 | dht_linkfile_attr_heal (frame, this); | |||
3719 | } | |||
3720 | out: | |||
3721 | DHT_STRIP_PHASE1_FLAGS (stbuf)do { if ((stbuf) && ( ((stbuf)->ia_type == IA_IFREG ) && ((stbuf)->ia_prot.sticky == 1) && ((stbuf )->ia_prot.sgid == 1))) { (stbuf)->ia_prot.sticky = 0; ( stbuf)->ia_prot.sgid = 0; } } while (0); | |||
3722 | DHT_STACK_UNWIND (link, frame, op_ret, op_errno, inode, stbuf, preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3723, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3723 | postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3723, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3724 | ||||
3725 | return 0; | |||
3726 | } | |||
3727 | ||||
3728 | ||||
3729 | int | |||
3730 | dht_link_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
3731 | int op_ret, int op_errno, | |||
3732 | inode_t *inode, struct iatt *stbuf, | |||
3733 | struct iatt *preparent, struct iatt *postparent, | |||
3734 | dict_t *xdata) | |||
3735 | { | |||
3736 | dht_local_t *local = NULL((void*)0); | |||
3737 | xlator_t *srcvol = NULL((void*)0); | |||
3738 | ||||
3739 | if (op_ret == -1) | |||
3740 | goto err; | |||
3741 | ||||
3742 | local = frame->local; | |||
3743 | srcvol = local->linkfile.srcvol; | |||
3744 | ||||
3745 | STACK_WIND (frame, dht_link_cbk, srcvol, srcvol->fops->link,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3746, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( srcvol->fops ->link_cbk) tmp_cbk = dht_link_cbk; _new->root = frame-> root; _new->this = srcvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "srcvol->fops->link" ; _new->unwind_to = "dht_link_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = srcvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, srcvol->fops->link); srcvol-> fops->link (_new, srcvol, &local->loc, &local-> loc2, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3746 | &local->loc, &local->loc2, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3746, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( srcvol->fops ->link_cbk) tmp_cbk = dht_link_cbk; _new->root = frame-> root; _new->this = srcvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "srcvol->fops->link" ; _new->unwind_to = "dht_link_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = srcvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, srcvol->fops->link); srcvol-> fops->link (_new, srcvol, &local->loc, &local-> loc2, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3747 | ||||
3748 | return 0; | |||
3749 | ||||
3750 | err: | |||
3751 | DHT_STRIP_PHASE1_FLAGS (stbuf)do { if ((stbuf) && ( ((stbuf)->ia_type == IA_IFREG ) && ((stbuf)->ia_prot.sticky == 1) && ((stbuf )->ia_prot.sgid == 1))) { (stbuf)->ia_prot.sticky = 0; ( stbuf)->ia_prot.sgid = 0; } } while (0); | |||
3752 | DHT_STACK_UNWIND (link, frame, op_ret, op_errno, inode, stbuf, preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3753, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3753 | postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3753, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, inode, stbuf, preparent, postparent , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3754 | ||||
3755 | return 0; | |||
3756 | } | |||
3757 | ||||
3758 | ||||
3759 | int | |||
3760 | dht_link (call_frame_t *frame, xlator_t *this, | |||
3761 | loc_t *oldloc, loc_t *newloc, dict_t *xdata) | |||
3762 | { | |||
3763 | xlator_t *cached_subvol = NULL((void*)0); | |||
3764 | xlator_t *hashed_subvol = NULL((void*)0); | |||
3765 | int op_errno = -1; | |||
3766 | int ret = -1; | |||
3767 | dht_local_t *local = NULL((void*)0); | |||
3768 | ||||
3769 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3769, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3770 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3770, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3771 | VALIDATE_OR_GOTO (oldloc, err)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3771, GF_LOG_WARNING, "invalid argument: " "oldloc" ); } while (0); goto err; } } while (0); | |||
3772 | VALIDATE_OR_GOTO (newloc, err)do { if (!newloc) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "newloc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3772, GF_LOG_WARNING, "invalid argument: " "newloc" ); } while (0); goto err; } } while (0); | |||
3773 | ||||
3774 | local = dht_local_init (frame, oldloc, NULL((void*)0), GF_FOP_LINK); | |||
3775 | if (!local) { | |||
3776 | op_errno = ENOMEM12; | |||
3777 | ||||
3778 | goto err; | |||
3779 | } | |||
3780 | ||||
3781 | cached_subvol = local->cached_subvol; | |||
3782 | if (!cached_subvol) { | |||
3783 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", oldloc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3784, GF_LOG_DEBUG, "no cached subvolume for path=%s" , oldloc->path); } while (0) | |||
3784 | "no cached subvolume for path=%s", oldloc->path)do { do { if (0) printf ("no cached subvolume for path=%s", oldloc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3784, GF_LOG_DEBUG, "no cached subvolume for path=%s" , oldloc->path); } while (0); | |||
3785 | op_errno = EINVAL22; | |||
3786 | goto err; | |||
3787 | } | |||
3788 | ||||
3789 | hashed_subvol = dht_subvol_get_hashed (this, newloc); | |||
3790 | if (!hashed_subvol) { | |||
3791 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , newloc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3793, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , newloc->path); } while (0) | |||
3792 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , newloc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3793, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , newloc->path); } while (0) | |||
3793 | newloc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , newloc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3793, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , newloc->path); } while (0); | |||
3794 | op_errno = EINVAL22; | |||
3795 | goto err; | |||
3796 | } | |||
3797 | ||||
3798 | ret = loc_copy (&local->loc2, newloc); | |||
3799 | if (ret == -1) { | |||
3800 | op_errno = ENOMEM12; | |||
3801 | goto err; | |||
3802 | } | |||
3803 | ||||
3804 | if (hashed_subvol != cached_subvol) { | |||
3805 | uuid_copy (local->gfid, oldloc->inode->gfid); | |||
3806 | dht_linkfile_create (frame, dht_link_linkfile_cbk, this, | |||
3807 | cached_subvol, hashed_subvol, newloc); | |||
3808 | } else { | |||
3809 | STACK_WIND (frame, dht_link_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3811, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->link_cbk) tmp_cbk = dht_link_cbk; _new->root = frame->root; _new->this = cached_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->link"; _new->unwind_to = "dht_link_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->link); cached_subvol->fops-> link (_new, cached_subvol, oldloc, newloc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3810 | cached_subvol, cached_subvol->fops->link,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3811, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->link_cbk) tmp_cbk = dht_link_cbk; _new->root = frame->root; _new->this = cached_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->link"; _new->unwind_to = "dht_link_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->link); cached_subvol->fops-> link (_new, cached_subvol, oldloc, newloc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
3811 | oldloc, newloc, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3811, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->link_cbk) tmp_cbk = dht_link_cbk; _new->root = frame->root; _new->this = cached_subvol; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->link"; _new->unwind_to = "dht_link_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->link); cached_subvol->fops-> link (_new, cached_subvol, oldloc, newloc, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
3812 | } | |||
3813 | ||||
3814 | return 0; | |||
3815 | ||||
3816 | err: | |||
3817 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3818 | DHT_STACK_UNWIND (link, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3818, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent->ref_count --; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3819 | ||||
3820 | return 0; | |||
3821 | } | |||
3822 | ||||
3823 | ||||
3824 | int | |||
3825 | dht_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
3826 | int op_ret, int op_errno, | |||
3827 | fd_t *fd, inode_t *inode, struct iatt *stbuf, | |||
3828 | struct iatt *preparent, struct iatt *postparent, dict_t *xdata) | |||
3829 | { | |||
3830 | call_frame_t *prev = NULL((void*)0); | |||
3831 | int ret = -1; | |||
3832 | dht_local_t *local = NULL((void*)0); | |||
3833 | ||||
3834 | if (op_ret == -1) | |||
3835 | goto out; | |||
3836 | ||||
3837 | local = frame->local; | |||
3838 | if (!local) { | |||
3839 | op_ret = -1; | |||
3840 | op_errno = EINVAL22; | |||
3841 | goto out; | |||
3842 | } | |||
3843 | ||||
3844 | prev = cookie; | |||
3845 | ||||
3846 | if (local->loc.parent) { | |||
3847 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
3848 | preparent, 0); | |||
3849 | ||||
3850 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
3851 | postparent, 1); | |||
3852 | } | |||
3853 | ||||
3854 | ret = dht_layout_preset (this, prev->this, inode); | |||
3855 | if (ret != 0) { | |||
3856 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("could not set preset layout for subvol %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 3858, GF_LOG_DEBUG, "could not set preset layout for subvol %s" , prev->this->name); } while (0) | |||
3857 | "could not set preset layout for subvol %s",do { do { if (0) printf ("could not set preset layout for subvol %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 3858, GF_LOG_DEBUG, "could not set preset layout for subvol %s" , prev->this->name); } while (0) | |||
3858 | prev->this->name)do { do { if (0) printf ("could not set preset layout for subvol %s" , prev->this->name); } while (0); _gf_log (this->name , "dht-common.c", __FUNCTION__, 3858, GF_LOG_DEBUG, "could not set preset layout for subvol %s" , prev->this->name); } while (0); | |||
3859 | op_ret = -1; | |||
3860 | op_errno = EINVAL22; | |||
3861 | goto out; | |||
3862 | } | |||
3863 | if (local->linked == _gf_true) { | |||
3864 | local->stbuf = *stbuf; | |||
3865 | dht_linkfile_attr_heal (frame, this); | |||
3866 | } | |||
3867 | out: | |||
3868 | DHT_STRIP_PHASE1_FLAGS (stbuf)do { if ((stbuf) && ( ((stbuf)->ia_type == IA_IFREG ) && ((stbuf)->ia_prot.sticky == 1) && ((stbuf )->ia_prot.sgid == 1))) { (stbuf)->ia_prot.sticky = 0; ( stbuf)->ia_prot.sgid = 0; } } while (0); | |||
3869 | DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, inode, stbuf, preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3870, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, fd, inode, stbuf, preparent, postparent , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3870 | postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3870, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, fd, inode, stbuf, preparent, postparent , ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3871 | return 0; | |||
3872 | } | |||
3873 | ||||
3874 | ||||
3875 | int | |||
3876 | dht_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, | |||
3877 | xlator_t *this, | |||
3878 | int32_t op_ret, int32_t op_errno, | |||
3879 | inode_t *inode, struct iatt *stbuf, | |||
3880 | struct iatt *preparent, struct iatt *postparent, | |||
3881 | dict_t *xdata) | |||
3882 | { | |||
3883 | dht_local_t *local = NULL((void*)0); | |||
3884 | xlator_t *cached_subvol = NULL((void*)0); | |||
3885 | ||||
3886 | if (op_ret == -1) | |||
3887 | goto err; | |||
3888 | ||||
3889 | local = frame->local; | |||
3890 | cached_subvol = local->cached_subvol; | |||
3891 | ||||
3892 | STACK_WIND (frame, dht_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3895, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->create); cached_subvol->fops-> create (_new, cached_subvol, &local->loc, local->flags , local->mode, local->umask, local->fd, local->params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3893 | cached_subvol, cached_subvol->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3895, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->create); cached_subvol->fops-> create (_new, cached_subvol, &local->loc, local->flags , local->mode, local->umask, local->fd, local->params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3894 | &local->loc, local->flags, local->mode,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3895, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->create); cached_subvol->fops-> create (_new, cached_subvol, &local->loc, local->flags , local->mode, local->umask, local->fd, local->params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3895 | local->umask, local->fd, local->params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3895, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( cached_subvol ->fops->create_cbk) tmp_cbk = dht_create_cbk; _new-> root = frame->root; _new->this = cached_subvol; _new-> ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "cached_subvol->fops->create"; _new->unwind_to = "dht_create_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = cached_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , cached_subvol->fops->create); cached_subvol->fops-> create (_new, cached_subvol, &local->loc, local->flags , local->mode, local->umask, local->fd, local->params ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3896 | ||||
3897 | return 0; | |||
3898 | err: | |||
3899 | DHT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3900, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3900 | NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3900, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3901 | return 0; | |||
3902 | } | |||
3903 | ||||
3904 | int | |||
3905 | dht_create (call_frame_t *frame, xlator_t *this, | |||
3906 | loc_t *loc, int32_t flags, mode_t mode, | |||
3907 | mode_t umask, fd_t *fd, dict_t *params) | |||
3908 | { | |||
3909 | int op_errno = -1; | |||
3910 | xlator_t *subvol = NULL((void*)0); | |||
3911 | dht_local_t *local = NULL((void*)0); | |||
3912 | xlator_t *avail_subvol = NULL((void*)0); | |||
3913 | ||||
3914 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3914, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
3915 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3915, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
3916 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 3916, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
3917 | ||||
3918 | dht_get_du_info (frame, this, loc); | |||
3919 | ||||
3920 | local = dht_local_init (frame, loc, fd, GF_FOP_CREATE); | |||
3921 | if (!local) { | |||
3922 | op_errno = ENOMEM12; | |||
3923 | goto err; | |||
3924 | } | |||
3925 | ||||
3926 | if (dht_filter_loc_subvol_key (this, loc, &local->loc, | |||
3927 | &subvol)) { | |||
3928 | gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("creating %s on %s (got create on %s)" , local->loc.path, subvol->name, loc->path); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3930 , GF_LOG_INFO, "creating %s on %s (got create on %s)", local-> loc.path, subvol->name, loc->path); } while (0) | |||
3929 | "creating %s on %s (got create on %s)",do { do { if (0) printf ("creating %s on %s (got create on %s)" , local->loc.path, subvol->name, loc->path); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3930 , GF_LOG_INFO, "creating %s on %s (got create on %s)", local-> loc.path, subvol->name, loc->path); } while (0) | |||
3930 | local->loc.path, subvol->name, loc->path)do { do { if (0) printf ("creating %s on %s (got create on %s)" , local->loc.path, subvol->name, loc->path); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3930 , GF_LOG_INFO, "creating %s on %s (got create on %s)", local-> loc.path, subvol->name, loc->path); } while (0); | |||
3931 | STACK_WIND (frame, dht_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3933, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, &local->loc, flags, mode , umask, fd, params); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
3932 | subvol, subvol->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3933, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, &local->loc, flags, mode , umask, fd, params); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
3933 | &local->loc, flags, mode, umask, fd, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3933, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, &local->loc, flags, mode , umask, fd, params); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
3934 | goto done; | |||
3935 | } | |||
3936 | ||||
3937 | subvol = dht_subvol_get_hashed (this, loc); | |||
3938 | if (!subvol) { | |||
3939 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3941, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3940 | "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3941, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0) | |||
3941 | loc->path)do { do { if (0) printf ("no subvolume in layout for path=%s" , loc->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3941, GF_LOG_DEBUG, "no subvolume in layout for path=%s" , loc->path); } while (0); | |||
3942 | op_errno = ENOENT2; | |||
3943 | goto err; | |||
3944 | } | |||
3945 | ||||
3946 | if (!dht_is_subvol_filled (this, subvol)) { | |||
3947 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3948, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0) | |||
3948 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3948, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0); | |||
3949 | STACK_WIND (frame, dht_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3951, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3950 | subvol, subvol->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3951, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3951 | loc, flags, mode, umask, fd, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3951, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3952 | goto done; | |||
3953 | } | |||
3954 | /* Choose the minimum filled volume, and create the | |||
3955 | files there */ | |||
3956 | avail_subvol = dht_free_disk_available_subvol (this, subvol); | |||
3957 | if (avail_subvol != subvol) { | |||
3958 | local->params = dict_ref (params); | |||
3959 | local->flags = flags; | |||
3960 | local->mode = mode; | |||
3961 | local->umask = umask; | |||
3962 | local->cached_subvol = avail_subvol; | |||
3963 | local->hashed_subvol = subvol; | |||
3964 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s (link at %s)", loc ->path, avail_subvol->name, subvol->name); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3966 , GF_LOG_TRACE, "creating %s on %s (link at %s)", loc->path , avail_subvol->name, subvol->name); } while (0) | |||
3965 | "creating %s on %s (link at %s)", loc->path,do { do { if (0) printf ("creating %s on %s (link at %s)", loc ->path, avail_subvol->name, subvol->name); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3966 , GF_LOG_TRACE, "creating %s on %s (link at %s)", loc->path , avail_subvol->name, subvol->name); } while (0) | |||
3966 | avail_subvol->name, subvol->name)do { do { if (0) printf ("creating %s on %s (link at %s)", loc ->path, avail_subvol->name, subvol->name); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 3966 , GF_LOG_TRACE, "creating %s on %s (link at %s)", loc->path , avail_subvol->name, subvol->name); } while (0); | |||
3967 | dht_linkfile_create (frame, dht_create_linkfile_create_cbk, | |||
3968 | this, avail_subvol, subvol, loc); | |||
3969 | goto done; | |||
3970 | } | |||
3971 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3972, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0) | |||
3972 | "creating %s on %s", loc->path, subvol->name)do { do { if (0) printf ("creating %s on %s", loc->path, subvol ->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 3972, GF_LOG_TRACE, "creating %s on %s", loc-> path, subvol->name); } while (0); | |||
3973 | STACK_WIND (frame, dht_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3975, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3974 | subvol, subvol->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3975, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
3975 | loc, flags, mode, umask, fd, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 3975, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->create_cbk) tmp_cbk = dht_create_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->create" ; _new->unwind_to = "dht_create_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->create); subvol-> fops->create (_new, subvol, loc, flags, mode, umask, fd, params ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
3976 | done: | |||
3977 | return 0; | |||
3978 | ||||
3979 | err: | |||
3980 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
3981 | DHT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3982, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
3982 | NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 3982, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
3983 | ||||
3984 | return 0; | |||
3985 | } | |||
3986 | ||||
3987 | ||||
3988 | int | |||
3989 | dht_mkdir_selfheal_cbk (call_frame_t *frame, void *cookie, | |||
3990 | xlator_t *this, | |||
3991 | int32_t op_ret, int32_t op_errno, dict_t *xdata) | |||
3992 | { | |||
3993 | dht_local_t *local = NULL((void*)0); | |||
3994 | dht_layout_t *layout = NULL((void*)0); | |||
3995 | ||||
3996 | local = frame->local; | |||
3997 | layout = local->selfheal.layout; | |||
3998 | ||||
3999 | if (op_ret == 0) { | |||
4000 | dht_layout_set (this, local->inode, layout); | |||
4001 | if (local->loc.parent) { | |||
4002 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
4003 | &local->preparent, 0); | |||
4004 | ||||
4005 | dht_inode_ctx_time_update (local->loc.parent, this, | |||
4006 | &local->postparent, 1); | |||
4007 | } | |||
4008 | } | |||
4009 | ||||
4010 | DHT_STACK_UNWIND (mkdir, frame, op_ret, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4012, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, local->inode, &local-> stbuf, &local->preparent, &local->postparent, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4011 | local->inode, &local->stbuf, &local->preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4012, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, local->inode, &local-> stbuf, &local->preparent, &local->postparent, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4012 | &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4012, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, local->inode, &local-> stbuf, &local->preparent, &local->postparent, ( (void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4013 | ||||
4014 | return 0; | |||
4015 | } | |||
4016 | ||||
4017 | int | |||
4018 | dht_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4019 | int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, | |||
4020 | struct iatt *preparent, struct iatt *postparent, dict_t *xdata) | |||
4021 | { | |||
4022 | dht_local_t *local = NULL((void*)0); | |||
4023 | int this_call_cnt = 0; | |||
4024 | int ret = -1; | |||
4025 | gf_boolean_t subvol_filled = _gf_false; | |||
4026 | call_frame_t *prev = NULL((void*)0); | |||
4027 | dht_layout_t *layout = NULL((void*)0); | |||
4028 | ||||
4029 | local = frame->local; | |||
4030 | prev = cookie; | |||
4031 | layout = local->layout; | |||
4032 | ||||
4033 | subvol_filled = dht_is_subvol_filled (this, prev->this); | |||
4034 | ||||
4035 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
4036 | { | |||
4037 | if (subvol_filled && (op_ret != -1)) { | |||
4038 | ret = dht_layout_merge (this, layout, prev->this, | |||
4039 | -1, ENOSPC28, NULL((void*)0)); | |||
4040 | } else { | |||
4041 | if (op_ret == -1 && op_errno == EEXIST17) | |||
4042 | /* Very likely just a race between mkdir and | |||
4043 | self-heal (from lookup of a concurrent mkdir | |||
4044 | attempt). | |||
4045 | Ignore error for now. layout setting will | |||
4046 | anyways fail if this was a different (old) | |||
4047 | pre-existing different directory. | |||
4048 | */ | |||
4049 | op_ret = 0; | |||
4050 | ret = dht_layout_merge (this, layout, prev->this, | |||
4051 | op_ret, op_errno, NULL((void*)0)); | |||
4052 | } | |||
4053 | if (ret) | |||
4054 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to merge layouts", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4055, GF_LOG_WARNING, "%s: failed to merge layouts" , local->loc.path); } while (0) | |||
4055 | "%s: failed to merge layouts", local->loc.path)do { do { if (0) printf ("%s: failed to merge layouts", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4055, GF_LOG_WARNING, "%s: failed to merge layouts" , local->loc.path); } while (0); | |||
4056 | ||||
4057 | if (op_ret == -1) { | |||
4058 | local->op_errno = op_errno; | |||
4059 | goto unlock; | |||
4060 | } | |||
4061 | dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); | |||
4062 | dht_iatt_merge (this, &local->preparent, preparent, prev->this); | |||
4063 | dht_iatt_merge (this, &local->postparent, postparent, | |||
4064 | prev->this); | |||
4065 | } | |||
4066 | unlock: | |||
4067 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
4068 | ||||
4069 | this_call_cnt = dht_frame_return (frame); | |||
4070 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
4071 | dht_selfheal_new_directory (frame, dht_mkdir_selfheal_cbk, | |||
4072 | layout); | |||
4073 | } | |||
4074 | ||||
4075 | return 0; | |||
4076 | } | |||
4077 | ||||
4078 | int | |||
4079 | dht_mkdir_hashed_cbk (call_frame_t *frame, void *cookie, | |||
4080 | xlator_t *this, int op_ret, int op_errno, | |||
4081 | inode_t *inode, struct iatt *stbuf, | |||
4082 | struct iatt *preparent, struct iatt *postparent, | |||
4083 | dict_t *xdata) | |||
4084 | { | |||
4085 | dht_local_t *local = NULL((void*)0); | |||
4086 | int ret = -1; | |||
4087 | call_frame_t *prev = NULL((void*)0); | |||
4088 | dht_layout_t *layout = NULL((void*)0); | |||
4089 | dht_conf_t *conf = NULL((void*)0); | |||
4090 | int i = 0; | |||
4091 | xlator_t *hashed_subvol = NULL((void*)0); | |||
4092 | ||||
4093 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4093, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
4094 | ||||
4095 | local = frame->local; | |||
4096 | prev = cookie; | |||
4097 | layout = local->layout; | |||
4098 | conf = this->private; | |||
4099 | hashed_subvol = local->hashed_subvol; | |||
4100 | ||||
4101 | if (uuid_is_null (local->loc.gfid) && !op_ret) | |||
4102 | uuid_copy (local->loc.gfid, stbuf->ia_gfid); | |||
4103 | ||||
4104 | if (dht_is_subvol_filled (this, hashed_subvol)) | |||
4105 | ret = dht_layout_merge (this, layout, prev->this, | |||
4106 | -1, ENOSPC28, NULL((void*)0)); | |||
4107 | else | |||
4108 | ret = dht_layout_merge (this, layout, prev->this, | |||
4109 | op_ret, op_errno, NULL((void*)0)); | |||
4110 | ||||
4111 | /* TODO: we may have to return from the function | |||
4112 | if layout merge fails. For now, lets just log an error */ | |||
4113 | if (ret) | |||
4114 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to merge layouts", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4115, GF_LOG_WARNING, "%s: failed to merge layouts" , local->loc.path); } while (0) | |||
4115 | "%s: failed to merge layouts", local->loc.path)do { do { if (0) printf ("%s: failed to merge layouts", local ->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4115, GF_LOG_WARNING, "%s: failed to merge layouts" , local->loc.path); } while (0); | |||
4116 | ||||
4117 | if (op_ret == -1) { | |||
4118 | local->op_errno = op_errno; | |||
4119 | goto err; | |||
4120 | } | |||
4121 | local->op_ret = 0; | |||
4122 | ||||
4123 | dht_iatt_merge (this, &local->stbuf, stbuf, prev->this); | |||
4124 | dht_iatt_merge (this, &local->preparent, preparent, prev->this); | |||
4125 | dht_iatt_merge (this, &local->postparent, postparent, prev->this); | |||
4126 | ||||
4127 | local->call_cnt = conf->subvolume_cnt - 1; | |||
4128 | ||||
4129 | if (uuid_is_null (local->loc.gfid)) | |||
4130 | uuid_copy (local->loc.gfid, stbuf->ia_gfid); | |||
4131 | if (local->call_cnt == 0) { | |||
4132 | dht_selfheal_directory (frame, dht_mkdir_selfheal_cbk, | |||
4133 | &local->loc, layout); | |||
4134 | } | |||
4135 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
4136 | if (conf->subvolumes[i] == hashed_subvol) | |||
4137 | continue; | |||
4138 | STACK_WIND (frame, dht_mkdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4141, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->mkdir_cbk) tmp_cbk = dht_mkdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->mkdir"; _new ->unwind_to = "dht_mkdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->mkdir); conf-> subvolumes[i]->fops->mkdir (_new, conf->subvolumes[i ], &local->loc, local->mode, local->umask, local ->params); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4139 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4141, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->mkdir_cbk) tmp_cbk = dht_mkdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->mkdir"; _new ->unwind_to = "dht_mkdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->mkdir); conf-> subvolumes[i]->fops->mkdir (_new, conf->subvolumes[i ], &local->loc, local->mode, local->umask, local ->params); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4140 | conf->subvolumes[i]->fops->mkdir, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4141, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->mkdir_cbk) tmp_cbk = dht_mkdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->mkdir"; _new ->unwind_to = "dht_mkdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->mkdir); conf-> subvolumes[i]->fops->mkdir (_new, conf->subvolumes[i ], &local->loc, local->mode, local->umask, local ->params); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4141 | local->mode, local->umask, local->params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4141, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->mkdir_cbk) tmp_cbk = dht_mkdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->mkdir"; _new ->unwind_to = "dht_mkdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->mkdir); conf-> subvolumes[i]->fops->mkdir (_new, conf->subvolumes[i ], &local->loc, local->mode, local->umask, local ->params); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
4142 | } | |||
4143 | return 0; | |||
4144 | err: | |||
4145 | DHT_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4146, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4146 | NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4146, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4147 | return 0; | |||
4148 | } | |||
4149 | ||||
4150 | ||||
4151 | int | |||
4152 | dht_mkdir (call_frame_t *frame, xlator_t *this, | |||
4153 | loc_t *loc, mode_t mode, mode_t umask, dict_t *params) | |||
4154 | { | |||
4155 | dht_local_t *local = NULL((void*)0); | |||
4156 | dht_conf_t *conf = NULL((void*)0); | |||
4157 | int op_errno = -1; | |||
4158 | xlator_t *hashed_subvol = NULL((void*)0); | |||
4159 | ||||
4160 | ||||
4161 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4161, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
4162 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4162, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
4163 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4163, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
4164 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4164, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
4165 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4165, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
4166 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4166, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
4167 | ||||
4168 | conf = this->private; | |||
4169 | ||||
4170 | dht_get_du_info (frame, this, loc); | |||
4171 | ||||
4172 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_MKDIR); | |||
4173 | if (!local) { | |||
4174 | op_errno = ENOMEM12; | |||
4175 | goto err; | |||
4176 | } | |||
4177 | ||||
4178 | hashed_subvol = dht_subvol_get_hashed (this, loc); | |||
4179 | if (hashed_subvol == NULL((void*)0)) { | |||
4180 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("hashed subvol not found for %s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4182, GF_LOG_DEBUG, "hashed subvol not found for %s" , loc->path); } while (0) | |||
4181 | "hashed subvol not found for %s",do { do { if (0) printf ("hashed subvol not found for %s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4182, GF_LOG_DEBUG, "hashed subvol not found for %s" , loc->path); } while (0) | |||
4182 | loc->path)do { do { if (0) printf ("hashed subvol not found for %s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4182, GF_LOG_DEBUG, "hashed subvol not found for %s" , loc->path); } while (0); | |||
4183 | op_errno = EINVAL22; | |||
4184 | goto err; | |||
4185 | } | |||
4186 | ||||
4187 | local->hashed_subvol = hashed_subvol; | |||
4188 | local->mode = mode; | |||
4189 | local->umask = umask; | |||
4190 | local->params = dict_ref (params); | |||
4191 | local->inode = inode_ref (loc->inode); | |||
4192 | ||||
4193 | local->layout = dht_layout_new (this, conf->subvolume_cnt); | |||
4194 | if (!local->layout) { | |||
4195 | op_errno = ENOMEM12; | |||
4196 | goto err; | |||
4197 | } | |||
4198 | ||||
4199 | STACK_WIND (frame, dht_mkdir_hashed_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4202, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->mkdir_cbk) tmp_cbk = dht_mkdir_hashed_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->mkdir"; _new->unwind_to = "dht_mkdir_hashed_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->mkdir); hashed_subvol->fops-> mkdir (_new, hashed_subvol, loc, mode, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
4200 | hashed_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4202, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->mkdir_cbk) tmp_cbk = dht_mkdir_hashed_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->mkdir"; _new->unwind_to = "dht_mkdir_hashed_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->mkdir); hashed_subvol->fops-> mkdir (_new, hashed_subvol, loc, mode, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
4201 | hashed_subvol->fops->mkdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4202, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->mkdir_cbk) tmp_cbk = dht_mkdir_hashed_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->mkdir"; _new->unwind_to = "dht_mkdir_hashed_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->mkdir); hashed_subvol->fops-> mkdir (_new, hashed_subvol, loc, mode, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
4202 | loc, mode, umask, params)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4202, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( hashed_subvol ->fops->mkdir_cbk) tmp_cbk = dht_mkdir_hashed_cbk; _new ->root = frame->root; _new->this = hashed_subvol; _new ->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new-> cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "hashed_subvol->fops->mkdir"; _new->unwind_to = "dht_mkdir_hashed_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = hashed_subvol; if (frame ->this->ctx->measure_latency) gf_latency_begin (_new , hashed_subvol->fops->mkdir); hashed_subvol->fops-> mkdir (_new, hashed_subvol, loc, mode, umask, params); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
4203 | ||||
4204 | return 0; | |||
4205 | ||||
4206 | err: | |||
4207 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
4208 | DHT_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4209, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4209 | NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4209, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), ( (void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4210 | ||||
4211 | return 0; | |||
4212 | } | |||
4213 | ||||
4214 | ||||
4215 | int | |||
4216 | dht_rmdir_selfheal_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4217 | int op_ret, int op_errno, dict_t *xdata) | |||
4218 | { | |||
4219 | dht_local_t *local = NULL((void*)0); | |||
4220 | ||||
4221 | local = frame->local; | |||
4222 | ||||
4223 | DHT_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4224, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4224 | &local->preparent, &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4224, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4225 | ||||
4226 | return 0; | |||
4227 | } | |||
4228 | ||||
4229 | ||||
4230 | int | |||
4231 | dht_rmdir_hashed_subvol_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4232 | int op_ret, int op_errno, struct iatt *preparent, | |||
4233 | struct iatt *postparent, dict_t *xdata) | |||
4234 | { | |||
4235 | dht_local_t *local = NULL((void*)0); | |||
4236 | int this_call_cnt = 0; | |||
4237 | call_frame_t *prev = NULL((void*)0); | |||
4238 | ||||
4239 | local = frame->local; | |||
4240 | prev = cookie; | |||
4241 | ||||
4242 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
4243 | { | |||
4244 | if (op_ret == -1) { | |||
4245 | local->op_errno = op_errno; | |||
4246 | local->op_ret = -1; | |||
4247 | if (op_errno != ENOENT2 && op_errno != EACCES13) { | |||
4248 | local->need_selfheal = 1; | |||
4249 | } | |||
4250 | ||||
4251 | ||||
4252 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4255, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4253 | "rmdir on %s for %s failed (%s)",do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4255, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4254 | prev->this->name, local->loc.path,do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4255, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4255 | strerror (op_errno))do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4255, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0); | |||
4256 | goto unlock; | |||
4257 | } | |||
4258 | ||||
4259 | dht_iatt_merge (this, &local->preparent, preparent, prev->this); | |||
4260 | dht_iatt_merge (this, &local->postparent, postparent, | |||
4261 | prev->this); | |||
4262 | ||||
4263 | } | |||
4264 | unlock: | |||
4265 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
4266 | ||||
4267 | this_call_cnt = dht_frame_return (frame); | |||
4268 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
4269 | if (local->need_selfheal) { | |||
4270 | local->layout = | |||
4271 | dht_layout_get (this, local->loc.inode); | |||
4272 | ||||
4273 | /* TODO: neater interface needed below */ | |||
4274 | local->stbuf.ia_type = local->loc.inode->ia_type; | |||
4275 | ||||
4276 | uuid_copy (local->gfid, local->loc.inode->gfid); | |||
4277 | dht_selfheal_restore (frame, dht_rmdir_selfheal_cbk, | |||
4278 | &local->loc, local->layout); | |||
4279 | } else { | |||
4280 | ||||
4281 | if (local->loc.parent) { | |||
4282 | dht_inode_ctx_time_update (local->loc.parent, | |||
4283 | this, | |||
4284 | &local->preparent, | |||
4285 | 0); | |||
4286 | ||||
4287 | dht_inode_ctx_time_update (local->loc.parent, | |||
4288 | this, | |||
4289 | &local->postparent, | |||
4290 | 1); | |||
4291 | } | |||
4292 | ||||
4293 | DHT_STACK_UNWIND (rmdir, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4295, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4294 | local->op_errno, &local->preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4295, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4295 | &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4295, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4296 | } | |||
4297 | } | |||
4298 | ||||
4299 | return 0; | |||
4300 | } | |||
4301 | ||||
4302 | ||||
4303 | int | |||
4304 | dht_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4305 | int op_ret, int op_errno, struct iatt *preparent, | |||
4306 | struct iatt *postparent, dict_t *xdata) | |||
4307 | { | |||
4308 | dht_local_t *local = NULL((void*)0); | |||
4309 | int this_call_cnt = 0; | |||
4310 | call_frame_t *prev = NULL((void*)0); | |||
4311 | int done = 0; | |||
4312 | ||||
4313 | local = frame->local; | |||
4314 | prev = cookie; | |||
4315 | ||||
4316 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
4317 | { | |||
4318 | if (op_ret == -1) { | |||
4319 | local->op_errno = op_errno; | |||
4320 | local->op_ret = -1; | |||
4321 | ||||
4322 | if (op_errno != ENOENT2 && op_errno != EACCES13) { | |||
4323 | local->need_selfheal = 1; | |||
4324 | } | |||
4325 | ||||
4326 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4329, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4327 | "rmdir on %s for %s failed (%s)",do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4329, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4328 | prev->this->name, local->loc.path,do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4329, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4329 | strerror (op_errno))do { do { if (0) printf ("rmdir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4329, GF_LOG_DEBUG, "rmdir on %s for %s failed (%s)", prev-> this->name, local->loc.path, strerror (op_errno)); } while (0); | |||
4330 | goto unlock; | |||
4331 | } | |||
4332 | ||||
4333 | /* Track if rmdir succeeded on atleast one subvol*/ | |||
4334 | local->fop_succeeded = 1; | |||
4335 | dht_iatt_merge (this, &local->preparent, preparent, prev->this); | |||
4336 | dht_iatt_merge (this, &local->postparent, postparent, | |||
4337 | prev->this); | |||
4338 | } | |||
4339 | unlock: | |||
4340 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
4341 | ||||
4342 | ||||
4343 | this_call_cnt = dht_frame_return (frame); | |||
4344 | ||||
4345 | /* if local->hashed_subvol, we are yet to wind to hashed_subvol. */ | |||
4346 | if (local->hashed_subvol && (this_call_cnt == 1)) { | |||
4347 | done = 1; | |||
4348 | } else if (!local->hashed_subvol && !this_call_cnt) { | |||
4349 | done = 1; | |||
4350 | } | |||
4351 | ||||
4352 | ||||
4353 | if (done) { | |||
4354 | if (local->need_selfheal && local->fop_succeeded) { | |||
4355 | local->layout = | |||
4356 | dht_layout_get (this, local->loc.inode); | |||
4357 | ||||
4358 | /* TODO: neater interface needed below */ | |||
4359 | local->stbuf.ia_type = local->loc.inode->ia_type; | |||
4360 | ||||
4361 | uuid_copy (local->gfid, local->loc.inode->gfid); | |||
4362 | dht_selfheal_restore (frame, dht_rmdir_selfheal_cbk, | |||
4363 | &local->loc, local->layout); | |||
4364 | } else if (this_call_cnt) { | |||
4365 | /* If non-hashed subvol's have responded, proceed */ | |||
4366 | ||||
4367 | local->need_selfheal = 0; | |||
4368 | STACK_WIND (frame, dht_rmdir_hashed_subvol_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4371, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->rmdir); local->hashed_subvol->fops->rmdir (_new, local->hashed_subvol, &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4369 | local->hashed_subvol,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4371, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->rmdir); local->hashed_subvol->fops->rmdir (_new, local->hashed_subvol, &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4370 | local->hashed_subvol->fops->rmdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4371, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->rmdir); local->hashed_subvol->fops->rmdir (_new, local->hashed_subvol, &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4371 | &local->loc, local->flags, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4371, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( local->hashed_subvol ->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = local->hashed_subvol ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "local->hashed_subvol->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = local->hashed_subvol; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, local->hashed_subvol ->fops->rmdir); local->hashed_subvol->fops->rmdir (_new, local->hashed_subvol, &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
4372 | } else if (!this_call_cnt) { | |||
4373 | /* All subvol's have responded, proceed */ | |||
4374 | ||||
4375 | if (local->loc.parent) { | |||
4376 | ||||
4377 | dht_inode_ctx_time_update (local->loc.parent, | |||
4378 | this, | |||
4379 | &local->preparent, | |||
4380 | 0); | |||
4381 | ||||
4382 | dht_inode_ctx_time_update (local->loc.parent, | |||
4383 | this, | |||
4384 | &local->postparent, | |||
4385 | 1); | |||
4386 | ||||
4387 | } | |||
4388 | ||||
4389 | DHT_STACK_UNWIND (rmdir, frame, local->op_ret,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4391, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4390 | local->op_errno, &local->preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4391, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4391 | &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4391, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4392 | } | |||
4393 | } | |||
4394 | ||||
4395 | return 0; | |||
4396 | } | |||
4397 | ||||
4398 | ||||
4399 | int | |||
4400 | dht_rmdir_do (call_frame_t *frame, xlator_t *this) | |||
4401 | { | |||
4402 | dht_local_t *local = NULL((void*)0); | |||
4403 | dht_conf_t *conf = NULL((void*)0); | |||
4404 | int i = 0; | |||
4405 | xlator_t *hashed_subvol = NULL((void*)0); | |||
4406 | ||||
4407 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4407, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
4408 | ||||
4409 | conf = this->private; | |||
4410 | local = frame->local; | |||
4411 | ||||
4412 | if (local->op_ret == -1) | |||
4413 | goto err; | |||
4414 | ||||
4415 | local->call_cnt = conf->subvolume_cnt; | |||
4416 | ||||
4417 | /* first remove from non-hashed_subvol */ | |||
4418 | hashed_subvol = dht_subvol_get_hashed (this, &local->loc); | |||
4419 | ||||
4420 | if (!hashed_subvol) { | |||
4421 | gf_log (this->name, GF_LOG_WARNING, "failed to get hashed "do { do { if (0) printf ("failed to get hashed " "subvol for %s" ,local->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4422, GF_LOG_WARNING, "failed to get hashed " "subvol for %s",local->loc.path); } while (0) | |||
4422 | "subvol for %s",local->loc.path)do { do { if (0) printf ("failed to get hashed " "subvol for %s" ,local->loc.path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4422, GF_LOG_WARNING, "failed to get hashed " "subvol for %s",local->loc.path); } while (0); | |||
4423 | } else { | |||
4424 | local->hashed_subvol = hashed_subvol; | |||
4425 | } | |||
4426 | ||||
4427 | /* When DHT has only 1 child */ | |||
4428 | if (conf->subvolume_cnt == 1) { | |||
4429 | STACK_WIND (frame, dht_rmdir_hashed_subvol_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [0]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [0]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[0]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[0]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ 0]->fops->rmdir); conf->subvolumes[0]->fops->rmdir (_new, conf->subvolumes[0], &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4430 | conf->subvolumes[0],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [0]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [0]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[0]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[0]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ 0]->fops->rmdir); conf->subvolumes[0]->fops->rmdir (_new, conf->subvolumes[0], &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4431 | conf->subvolumes[0]->fops->rmdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [0]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [0]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[0]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[0]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ 0]->fops->rmdir); conf->subvolumes[0]->fops->rmdir (_new, conf->subvolumes[0], &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4432 | &local->loc, local->flags, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [0]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_hashed_subvol_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [0]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[0]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_hashed_subvol_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[0]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ 0]->fops->rmdir); conf->subvolumes[0]->fops->rmdir (_new, conf->subvolumes[0], &local->loc, local-> flags, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
4433 | return 0; | |||
4434 | } | |||
4435 | ||||
4436 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
4437 | if (hashed_subvol && | |||
4438 | (hashed_subvol == conf->subvolumes[i])) | |||
4439 | continue; | |||
4440 | ||||
4441 | STACK_WIND (frame, dht_rmdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4444, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->rmdir); conf-> subvolumes[i]->fops->rmdir (_new, conf->subvolumes[i ], &local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
4442 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4444, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->rmdir); conf-> subvolumes[i]->fops->rmdir (_new, conf->subvolumes[i ], &local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
4443 | conf->subvolumes[i]->fops->rmdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4444, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->rmdir); conf-> subvolumes[i]->fops->rmdir (_new, conf->subvolumes[i ], &local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
4444 | &local->loc, local->flags, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4444, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->rmdir_cbk) tmp_cbk = dht_rmdir_cbk; _new-> root = frame->root; _new->this = conf->subvolumes[i] ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->rmdir"; _new ->unwind_to = "dht_rmdir_cbk"; pthread_spin_init (&_new ->lock, 0); pthread_spin_lock (&frame->root->stack_lock ); { _new->next = frame->root->frames.next; _new-> prev = &frame->root->frames; if (frame->root-> frames.next) frame->root->frames.next->prev = _new; frame ->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = conf->subvolumes[i]; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, conf->subvolumes[i]->fops->rmdir); conf-> subvolumes[i]->fops->rmdir (_new, conf->subvolumes[i ], &local->loc, local->flags, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
4445 | } | |||
4446 | ||||
4447 | return 0; | |||
4448 | ||||
4449 | err: | |||
4450 | DHT_STACK_UNWIND (rmdir, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4451, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4451 | &local->preparent, &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4451, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, local->op_ret, local->op_errno, &local-> preparent, &local->postparent, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4452 | return 0; | |||
4453 | } | |||
4454 | ||||
4455 | ||||
4456 | int | |||
4457 | dht_rmdir_linkfile_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4458 | int op_ret, int op_errno, struct iatt *preparent, | |||
4459 | struct iatt *postparent, dict_t *xdata) | |||
4460 | { | |||
4461 | dht_local_t *local = NULL((void*)0); | |||
4462 | call_frame_t *prev = NULL((void*)0); | |||
4463 | xlator_t *src = NULL((void*)0); | |||
4464 | call_frame_t *main_frame = NULL((void*)0); | |||
4465 | dht_local_t *main_local = NULL((void*)0); | |||
4466 | int this_call_cnt = 0; | |||
4467 | ||||
4468 | local = frame->local; | |||
4469 | prev = cookie; | |||
4470 | src = prev->this; | |||
4471 | ||||
4472 | main_frame = local->main_frame; | |||
4473 | main_local = main_frame->local; | |||
4474 | ||||
4475 | if (op_ret == 0) { | |||
4476 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("unlinked linkfile %s on %s", local-> loc.path, src->name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4478, GF_LOG_TRACE, "unlinked linkfile %s on %s" , local->loc.path, src->name); } while (0) | |||
4477 | "unlinked linkfile %s on %s",do { do { if (0) printf ("unlinked linkfile %s on %s", local-> loc.path, src->name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4478, GF_LOG_TRACE, "unlinked linkfile %s on %s" , local->loc.path, src->name); } while (0) | |||
4478 | local->loc.path, src->name)do { do { if (0) printf ("unlinked linkfile %s on %s", local-> loc.path, src->name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4478, GF_LOG_TRACE, "unlinked linkfile %s on %s" , local->loc.path, src->name); } while (0); | |||
4479 | } else { | |||
4480 | main_local->op_ret = -1; | |||
4481 | main_local->op_errno = op_errno; | |||
4482 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("unlink of %s on %s failed (%s)", local ->loc.path, src->name, strerror (op_errno)); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4484 , GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->loc .path, src->name, strerror (op_errno)); } while (0) | |||
4483 | "unlink of %s on %s failed (%s)",do { do { if (0) printf ("unlink of %s on %s failed (%s)", local ->loc.path, src->name, strerror (op_errno)); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4484 , GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->loc .path, src->name, strerror (op_errno)); } while (0) | |||
4484 | local->loc.path, src->name, strerror (op_errno))do { do { if (0) printf ("unlink of %s on %s failed (%s)", local ->loc.path, src->name, strerror (op_errno)); } while (0 ); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4484 , GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->loc .path, src->name, strerror (op_errno)); } while (0); | |||
4485 | } | |||
4486 | ||||
4487 | this_call_cnt = dht_frame_return (main_frame); | |||
4488 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
4489 | dht_rmdir_do (main_frame, this); | |||
4490 | ||||
4491 | DHT_STACK_DESTROY (frame)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); __xl = frame->this; __local = frame->local; frame ->local = ((void*)0); STACK_DESTROY (frame->root); dht_local_wipe (__xl, __local); } while (0); | |||
4492 | return 0; | |||
4493 | } | |||
4494 | ||||
4495 | ||||
4496 | int | |||
4497 | dht_rmdir_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4498 | int op_ret, int op_errno, inode_t *inode, | |||
4499 | struct iatt *stbuf, dict_t *xattr, struct iatt *parent) | |||
4500 | { | |||
4501 | dht_local_t *local = NULL((void*)0); | |||
4502 | call_frame_t *prev = NULL((void*)0); | |||
4503 | xlator_t *src = NULL((void*)0); | |||
4504 | call_frame_t *main_frame = NULL((void*)0); | |||
4505 | dht_local_t *main_local = NULL((void*)0); | |||
4506 | int this_call_cnt = 0; | |||
4507 | dht_conf_t *conf = this->private; | |||
4508 | ||||
4509 | local = frame->local; | |||
4510 | prev = cookie; | |||
4511 | src = prev->this; | |||
4512 | ||||
4513 | main_frame = local->main_frame; | |||
4514 | main_local = main_frame->local; | |||
4515 | ||||
4516 | if (op_ret != 0) | |||
4517 | goto err; | |||
4518 | ||||
4519 | if (!check_is_linkfile (inode, stbuf, xattr, conf->link_xattr_name)( ((st_mode_from_ia ((stbuf)->ia_prot, (stbuf)->ia_type ) & ~0170000) == (01000)) && dict_get (xattr, conf ->link_xattr_name))) { | |||
4520 | main_local->op_ret = -1; | |||
4521 | main_local->op_errno = ENOTEMPTY39; | |||
4522 | ||||
4523 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s on %s found to be not a linkfile (type=0%o)" , local->loc.path, src->name, stbuf->ia_type); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4525 , GF_LOG_WARNING, "%s on %s found to be not a linkfile (type=0%o)" , local->loc.path, src->name, stbuf->ia_type); } while (0) | |||
4524 | "%s on %s found to be not a linkfile (type=0%o)",do { do { if (0) printf ("%s on %s found to be not a linkfile (type=0%o)" , local->loc.path, src->name, stbuf->ia_type); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4525 , GF_LOG_WARNING, "%s on %s found to be not a linkfile (type=0%o)" , local->loc.path, src->name, stbuf->ia_type); } while (0) | |||
4525 | local->loc.path, src->name, stbuf->ia_type)do { do { if (0) printf ("%s on %s found to be not a linkfile (type=0%o)" , local->loc.path, src->name, stbuf->ia_type); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4525 , GF_LOG_WARNING, "%s on %s found to be not a linkfile (type=0%o)" , local->loc.path, src->name, stbuf->ia_type); } while (0); | |||
4526 | goto err; | |||
4527 | } | |||
4528 | ||||
4529 | STACK_WIND (frame, dht_rmdir_linkfile_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4530, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( src->fops ->unlink_cbk) tmp_cbk = dht_rmdir_linkfile_unlink_cbk; _new ->root = frame->root; _new->this = src; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "src->fops->unlink"; _new->unwind_to = "dht_rmdir_linkfile_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = src; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, src-> fops->unlink); src->fops->unlink (_new, src, &local ->loc, 0, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4530 | src, src->fops->unlink, &local->loc, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4530, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( src->fops ->unlink_cbk) tmp_cbk = dht_rmdir_linkfile_unlink_cbk; _new ->root = frame->root; _new->this = src; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "src->fops->unlink"; _new->unwind_to = "dht_rmdir_linkfile_unlink_cbk" ; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root->stack_lock); { _new->next = frame ->root->frames.next; _new->prev = &frame->root ->frames; if (frame->root->frames.next) frame->root ->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock (&frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = src; if (frame->this ->ctx->measure_latency) gf_latency_begin (_new, src-> fops->unlink); src->fops->unlink (_new, src, &local ->loc, 0, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
4531 | return 0; | |||
4532 | err: | |||
4533 | ||||
4534 | this_call_cnt = dht_frame_return (main_frame); | |||
4535 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) | |||
4536 | dht_rmdir_do (main_frame, this); | |||
4537 | ||||
4538 | DHT_STACK_DESTROY (frame)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); __xl = frame->this; __local = frame->local; frame ->local = ((void*)0); STACK_DESTROY (frame->root); dht_local_wipe (__xl, __local); } while (0); | |||
4539 | return 0; | |||
4540 | } | |||
4541 | ||||
4542 | ||||
4543 | int | |||
4544 | dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this, | |||
4545 | gf_dirent_t *entries, xlator_t *src) | |||
4546 | { | |||
4547 | int ret = 0; | |||
4548 | int build_ret = 0; | |||
4549 | gf_dirent_t *trav = NULL((void*)0); | |||
4550 | call_frame_t *lookup_frame = NULL((void*)0); | |||
4551 | dht_local_t *lookup_local = NULL((void*)0); | |||
4552 | dht_local_t *local = NULL((void*)0); | |||
4553 | dict_t *xattrs = NULL((void*)0); | |||
4554 | dht_conf_t *conf = this->private; | |||
4555 | ||||
4556 | local = frame->local; | |||
4557 | ||||
4558 | list_for_each_entry (trav, &entries->list, list)for (trav = ((typeof(*trav) *)((char *)((&entries->list )->next)-(unsigned long)(&((typeof(*trav) *)0)->list ))); &trav->list != (&entries->list); trav = (( typeof(*trav) *)((char *)(trav->list.next)-(unsigned long) (&((typeof(*trav) *)0)->list)))) { | |||
4559 | if (strcmp (trav->d_name, ".") == 0) | |||
4560 | continue; | |||
4561 | if (strcmp (trav->d_name, "..") == 0) | |||
4562 | continue; | |||
4563 | if (check_is_linkfile (NULL, (&trav->d_stat), trav->dict,( ((st_mode_from_ia (((&trav->d_stat))->ia_prot, (( &trav->d_stat))->ia_type) & ~0170000) == (01000 )) && dict_get (trav->dict, conf->link_xattr_name )) | |||
4564 | conf->link_xattr_name)( ((st_mode_from_ia (((&trav->d_stat))->ia_prot, (( &trav->d_stat))->ia_type) & ~0170000) == (01000 )) && dict_get (trav->dict, conf->link_xattr_name ))) { | |||
4565 | ret++; | |||
4566 | continue; | |||
4567 | } | |||
4568 | ||||
4569 | /* this entry is either a directory which is neither "." nor "..", | |||
4570 | or a non directory which is not a linkfile. the directory is to | |||
4571 | be treated as non-empty | |||
4572 | */ | |||
4573 | return 0; | |||
4574 | } | |||
4575 | ||||
4576 | xattrs = dict_new (); | |||
4577 | if (!xattrs) { | |||
4578 | gf_log (this->name, GF_LOG_ERROR, "dict_new failed")do { do { if (0) printf ("dict_new failed"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4578, GF_LOG_ERROR , "dict_new failed"); } while (0); | |||
4579 | return -1; | |||
4580 | } | |||
4581 | ||||
4582 | ret = dict_set_uint32 (xattrs, conf->link_xattr_name, 256); | |||
4583 | if (ret) { | |||
4584 | gf_log (this->name, GF_LOG_ERROR, "failed to set linkto key"do { do { if (0) printf ("failed to set linkto key" " in dict" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4585, GF_LOG_ERROR, "failed to set linkto key" " in dict"); } while (0) | |||
4585 | " in dict")do { do { if (0) printf ("failed to set linkto key" " in dict" ); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4585, GF_LOG_ERROR, "failed to set linkto key" " in dict"); } while (0); | |||
4586 | if (xattrs) | |||
4587 | dict_unref (xattrs); | |||
4588 | return -1; | |||
4589 | } | |||
4590 | ||||
4591 | list_for_each_entry (trav, &entries->list, list)for (trav = ((typeof(*trav) *)((char *)((&entries->list )->next)-(unsigned long)(&((typeof(*trav) *)0)->list ))); &trav->list != (&entries->list); trav = (( typeof(*trav) *)((char *)(trav->list.next)-(unsigned long) (&((typeof(*trav) *)0)->list)))) { | |||
4592 | if (strcmp (trav->d_name, ".") == 0) | |||
4593 | continue; | |||
4594 | if (strcmp (trav->d_name, "..") == 0) | |||
4595 | continue; | |||
4596 | ||||
4597 | lookup_frame = NULL((void*)0); | |||
4598 | lookup_local = NULL((void*)0); | |||
4599 | ||||
4600 | lookup_frame = copy_frame (frame); | |||
4601 | if (!lookup_frame) { | |||
4602 | /* out of memory, let the rmdir fail | |||
4603 | (as non-empty, unfortunately) */ | |||
4604 | goto err; | |||
4605 | } | |||
4606 | ||||
4607 | lookup_local = mem_get0 (this->local_pool); | |||
4608 | if (!lookup_local) { | |||
4609 | goto err; | |||
4610 | } | |||
4611 | ||||
4612 | lookup_frame->local = lookup_local; | |||
4613 | lookup_local->main_frame = frame; | |||
4614 | ||||
4615 | build_ret = dht_build_child_loc (this, &lookup_local->loc, | |||
4616 | &local->loc, trav->d_name); | |||
4617 | if (build_ret != 0) | |||
4618 | goto err; | |||
4619 | ||||
4620 | uuid_copy (lookup_local->loc.gfid, trav->d_stat.ia_gfid); | |||
4621 | ||||
4622 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("looking up %s on %s", lookup_local-> loc.path, src->name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4624, GF_LOG_TRACE, "looking up %s on %s" , lookup_local->loc.path, src->name); } while (0) | |||
4623 | "looking up %s on %s",do { do { if (0) printf ("looking up %s on %s", lookup_local-> loc.path, src->name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4624, GF_LOG_TRACE, "looking up %s on %s" , lookup_local->loc.path, src->name); } while (0) | |||
4624 | lookup_local->loc.path, src->name)do { do { if (0) printf ("looking up %s on %s", lookup_local-> loc.path, src->name); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4624, GF_LOG_TRACE, "looking up %s on %s" , lookup_local->loc.path, src->name); } while (0); | |||
4625 | ||||
4626 | LOCK (&frame->lock)pthread_spin_lock (&frame->lock); | |||
4627 | { | |||
4628 | local->call_cnt++; | |||
4629 | } | |||
4630 | UNLOCK (&frame->lock)pthread_spin_unlock (&frame->lock); | |||
4631 | ||||
4632 | STACK_WIND (lookup_frame, dht_rmdir_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (lookup_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4634, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( src->fops->lookup_cbk) tmp_cbk = dht_rmdir_lookup_cbk ; _new->root = lookup_frame->root; _new->this = src; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = lookup_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "src->fops->lookup"; _new->unwind_to = "dht_rmdir_lookup_cbk"; pthread_spin_init (&_new->lock , 0); pthread_spin_lock (&lookup_frame->root->stack_lock ); { _new->next = lookup_frame->root->frames.next; _new ->prev = &lookup_frame->root->frames; if (lookup_frame ->root->frames.next) lookup_frame->root->frames.next ->prev = _new; lookup_frame->root->frames.next = _new ; lookup_frame->ref_count++; } pthread_spin_unlock (&lookup_frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = src; if (lookup_frame-> this->ctx->measure_latency) gf_latency_begin (_new, src ->fops->lookup); src->fops->lookup (_new, src, & lookup_local->loc, xattrs); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4633 | src, src->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (lookup_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4634, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( src->fops->lookup_cbk) tmp_cbk = dht_rmdir_lookup_cbk ; _new->root = lookup_frame->root; _new->this = src; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = lookup_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "src->fops->lookup"; _new->unwind_to = "dht_rmdir_lookup_cbk"; pthread_spin_init (&_new->lock , 0); pthread_spin_lock (&lookup_frame->root->stack_lock ); { _new->next = lookup_frame->root->frames.next; _new ->prev = &lookup_frame->root->frames; if (lookup_frame ->root->frames.next) lookup_frame->root->frames.next ->prev = _new; lookup_frame->root->frames.next = _new ; lookup_frame->ref_count++; } pthread_spin_unlock (&lookup_frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = src; if (lookup_frame-> this->ctx->measure_latency) gf_latency_begin (_new, src ->fops->lookup); src->fops->lookup (_new, src, & lookup_local->loc, xattrs); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4634 | &lookup_local->loc, xattrs)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (lookup_frame->root->pool-> frame_mem_pool); if (!_new) { do { do { if (0) printf ("alloc failed" ); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4634, GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof ( src->fops->lookup_cbk) tmp_cbk = dht_rmdir_lookup_cbk ; _new->root = lookup_frame->root; _new->this = src; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = lookup_frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "src->fops->lookup"; _new->unwind_to = "dht_rmdir_lookup_cbk"; pthread_spin_init (&_new->lock , 0); pthread_spin_lock (&lookup_frame->root->stack_lock ); { _new->next = lookup_frame->root->frames.next; _new ->prev = &lookup_frame->root->frames; if (lookup_frame ->root->frames.next) lookup_frame->root->frames.next ->prev = _new; lookup_frame->root->frames.next = _new ; lookup_frame->ref_count++; } pthread_spin_unlock (&lookup_frame ->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = src; if (lookup_frame-> this->ctx->measure_latency) gf_latency_begin (_new, src ->fops->lookup); src->fops->lookup (_new, src, & lookup_local->loc, xattrs); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
4635 | ret++; | |||
4636 | } | |||
4637 | ||||
4638 | if (xattrs) | |||
4639 | dict_unref (xattrs); | |||
4640 | ||||
4641 | return ret; | |||
4642 | err: | |||
4643 | if (xattrs) | |||
4644 | dict_unref (xattrs); | |||
4645 | ||||
4646 | DHT_STACK_DESTROY (lookup_frame)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); __xl = lookup_frame->this; __local = lookup_frame-> local; lookup_frame->local = ((void*)0); STACK_DESTROY (lookup_frame ->root); dht_local_wipe (__xl, __local); } while (0); | |||
4647 | return 0; | |||
4648 | } | |||
4649 | ||||
4650 | ||||
4651 | int | |||
4652 | dht_rmdir_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4653 | int op_ret, int op_errno, gf_dirent_t *entries, | |||
4654 | dict_t *xdata) | |||
4655 | { | |||
4656 | dht_local_t *local = NULL((void*)0); | |||
4657 | int this_call_cnt = -1; | |||
4658 | call_frame_t *prev = NULL((void*)0); | |||
4659 | xlator_t *src = NULL((void*)0); | |||
4660 | int ret = 0; | |||
4661 | ||||
4662 | local = frame->local; | |||
4663 | prev = cookie; | |||
4664 | src = prev->this; | |||
4665 | ||||
4666 | if (op_ret > 2) { | |||
4667 | ret = dht_rmdir_is_subvol_empty (frame, this, entries, src); | |||
4668 | ||||
4669 | switch (ret) { | |||
4670 | case 0: /* non linkfiles exist */ | |||
4671 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("readdir on %s for %s returned %d entries" , prev->this->name, local->loc.path, op_ret); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4673 , GF_LOG_TRACE, "readdir on %s for %s returned %d entries", prev ->this->name, local->loc.path, op_ret); } while (0) | |||
4672 | "readdir on %s for %s returned %d entries",do { do { if (0) printf ("readdir on %s for %s returned %d entries" , prev->this->name, local->loc.path, op_ret); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4673 , GF_LOG_TRACE, "readdir on %s for %s returned %d entries", prev ->this->name, local->loc.path, op_ret); } while (0) | |||
4673 | prev->this->name, local->loc.path, op_ret)do { do { if (0) printf ("readdir on %s for %s returned %d entries" , prev->this->name, local->loc.path, op_ret); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4673 , GF_LOG_TRACE, "readdir on %s for %s returned %d entries", prev ->this->name, local->loc.path, op_ret); } while (0); | |||
4674 | local->op_ret = -1; | |||
4675 | local->op_errno = ENOTEMPTY39; | |||
4676 | break; | |||
4677 | default: | |||
4678 | /* @ret number of linkfiles are getting unlinked */ | |||
4679 | gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("readdir on %s for %s found %d linkfiles" , prev->this->name, local->loc.path, ret); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4681 , GF_LOG_TRACE, "readdir on %s for %s found %d linkfiles", prev ->this->name, local->loc.path, ret); } while (0) | |||
4680 | "readdir on %s for %s found %d linkfiles",do { do { if (0) printf ("readdir on %s for %s found %d linkfiles" , prev->this->name, local->loc.path, ret); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4681 , GF_LOG_TRACE, "readdir on %s for %s found %d linkfiles", prev ->this->name, local->loc.path, ret); } while (0) | |||
4681 | prev->this->name, local->loc.path, ret)do { do { if (0) printf ("readdir on %s for %s found %d linkfiles" , prev->this->name, local->loc.path, ret); } while ( 0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 4681 , GF_LOG_TRACE, "readdir on %s for %s found %d linkfiles", prev ->this->name, local->loc.path, ret); } while (0); | |||
4682 | break; | |||
4683 | } | |||
4684 | } | |||
4685 | ||||
4686 | this_call_cnt = dht_frame_return (frame); | |||
4687 | ||||
4688 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
4689 | dht_rmdir_do (frame, this); | |||
4690 | } | |||
4691 | ||||
4692 | return 0; | |||
4693 | } | |||
4694 | ||||
4695 | ||||
4696 | int | |||
4697 | dht_rmdir_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
4698 | int op_ret, int op_errno, fd_t *fd, dict_t *xdata) | |||
4699 | { | |||
4700 | dht_local_t *local = NULL((void*)0); | |||
4701 | int this_call_cnt = -1; | |||
4702 | call_frame_t *prev = NULL((void*)0); | |||
4703 | dict_t *dict = NULL((void*)0); | |||
4704 | int ret = 0; | |||
4705 | dht_conf_t *conf = this->private; | |||
4706 | ||||
4707 | local = frame->local; | |||
4708 | prev = cookie; | |||
4709 | ||||
4710 | if (op_ret == -1) { | |||
4711 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4714, GF_LOG_DEBUG, "opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4712 | "opendir on %s for %s failed (%s)",do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4714, GF_LOG_DEBUG, "opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4713 | prev->this->name, local->loc.path,do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4714, GF_LOG_DEBUG, "opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0) | |||
4714 | strerror (op_errno))do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4714, GF_LOG_DEBUG, "opendir on %s for %s failed (%s)", prev ->this->name, local->loc.path, strerror (op_errno)); } while (0); | |||
4715 | if (op_errno != ENOENT2) { | |||
4716 | local->op_ret = -1; | |||
4717 | local->op_errno = op_errno; | |||
4718 | } | |||
4719 | goto err; | |||
4720 | } | |||
4721 | ||||
4722 | dict = dict_new (); | |||
4723 | if (!dict) { | |||
4724 | local->op_ret = -1; | |||
4725 | local->op_errno = ENOMEM12; | |||
4726 | goto err; | |||
4727 | } | |||
4728 | ||||
4729 | ret = dict_set_uint32 (dict, conf->link_xattr_name, 256); | |||
4730 | if (ret) | |||
4731 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to set '%s' key", local-> loc.path, conf->link_xattr_name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 4733, GF_LOG_WARNING , "%s: failed to set '%s' key", local->loc.path, conf-> link_xattr_name); } while (0) | |||
4732 | "%s: failed to set '%s' key",do { do { if (0) printf ("%s: failed to set '%s' key", local-> loc.path, conf->link_xattr_name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 4733, GF_LOG_WARNING , "%s: failed to set '%s' key", local->loc.path, conf-> link_xattr_name); } while (0) | |||
4733 | local->loc.path, conf->link_xattr_name)do { do { if (0) printf ("%s: failed to set '%s' key", local-> loc.path, conf->link_xattr_name); } while (0); _gf_log (this ->name, "dht-common.c", __FUNCTION__, 4733, GF_LOG_WARNING , "%s: failed to set '%s' key", local->loc.path, conf-> link_xattr_name); } while (0); | |||
4734 | ||||
4735 | STACK_WIND (frame, dht_rmdir_readdirp_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4737, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( prev->this ->fops->readdirp_cbk) tmp_cbk = dht_rmdir_readdirp_cbk; _new->root = frame->root; _new->this = prev->this ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "prev->this->fops->readdirp"; _new-> unwind_to = "dht_rmdir_readdirp_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = prev->this; if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, prev->this->fops->readdirp ); prev->this->fops->readdirp (_new, prev->this, local ->fd, 4096, 0, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4736 | prev->this, prev->this->fops->readdirp,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4737, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( prev->this ->fops->readdirp_cbk) tmp_cbk = dht_rmdir_readdirp_cbk; _new->root = frame->root; _new->this = prev->this ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "prev->this->fops->readdirp"; _new-> unwind_to = "dht_rmdir_readdirp_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = prev->this; if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, prev->this->fops->readdirp ); prev->this->fops->readdirp (_new, prev->this, local ->fd, 4096, 0, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4737 | local->fd, 4096, 0, dict)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4737, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( prev->this ->fops->readdirp_cbk) tmp_cbk = dht_rmdir_readdirp_cbk; _new->root = frame->root; _new->this = prev->this ; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "prev->this->fops->readdirp"; _new-> unwind_to = "dht_rmdir_readdirp_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = prev->this; if (frame->this->ctx->measure_latency ) gf_latency_begin (_new, prev->this->fops->readdirp ); prev->this->fops->readdirp (_new, prev->this, local ->fd, 4096, 0, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
4738 | ||||
4739 | if (dict) | |||
4740 | dict_unref (dict); | |||
4741 | ||||
4742 | return 0; | |||
4743 | ||||
4744 | err: | |||
4745 | this_call_cnt = dht_frame_return (frame); | |||
4746 | ||||
4747 | if (is_last_call (this_call_cnt)(this_call_cnt == 0)) { | |||
4748 | dht_rmdir_do (frame, this); | |||
4749 | } | |||
4750 | ||||
4751 | return 0; | |||
4752 | } | |||
4753 | ||||
4754 | ||||
4755 | int | |||
4756 | dht_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, | |||
4757 | dict_t *xdata) | |||
4758 | { | |||
4759 | dht_local_t *local = NULL((void*)0); | |||
4760 | dht_conf_t *conf = NULL((void*)0); | |||
4761 | int op_errno = -1; | |||
4762 | int i = -1; | |||
4763 | ||||
4764 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4764, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
4765 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4765, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
4766 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4766, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
4767 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4767, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
4768 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4768, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
4769 | VALIDATE_OR_GOTO (this->private, err)do { if (!this->private) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "this->private" ); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4769, GF_LOG_WARNING, "invalid argument: " "this->private"); } while (0); goto err; } } while (0); | |||
4770 | ||||
4771 | conf = this->private; | |||
4772 | ||||
4773 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_RMDIR); | |||
4774 | if (!local) { | |||
4775 | op_errno = ENOMEM12; | |||
4776 | goto err; | |||
4777 | } | |||
4778 | ||||
4779 | local->call_cnt = conf->subvolume_cnt; | |||
4780 | local->op_ret = 0; | |||
4781 | local->fop_succeeded = 0; | |||
4782 | ||||
4783 | local->flags = flags; | |||
4784 | ||||
4785 | local->fd = fd_create (local->loc.inode, frame->root->pid); | |||
4786 | if (!local->fd) { | |||
4787 | ||||
4788 | op_errno = ENOMEM12; | |||
4789 | goto err; | |||
4790 | } | |||
4791 | ||||
4792 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
4793 | STACK_WIND (frame, dht_rmdir_opendir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4796, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_rmdir_opendir_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_rmdir_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->opendir); conf->subvolumes[i]->fops-> opendir (_new, conf->subvolumes[i], loc, local->fd, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4794 | conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4796, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_rmdir_opendir_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_rmdir_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->opendir); conf->subvolumes[i]->fops-> opendir (_new, conf->subvolumes[i], loc, local->fd, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4795 | conf->subvolumes[i]->fops->opendir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4796, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_rmdir_opendir_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_rmdir_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->opendir); conf->subvolumes[i]->fops-> opendir (_new, conf->subvolumes[i], loc, local->fd, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
4796 | loc, local->fd, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4796, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( conf->subvolumes [i]->fops->opendir_cbk) tmp_cbk = dht_rmdir_opendir_cbk ; _new->root = frame->root; _new->this = conf->subvolumes [i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame ; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new ->wind_to = "conf->subvolumes[i]->fops->opendir"; _new->unwind_to = "dht_rmdir_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = conf->subvolumes[i]; if (frame->this->ctx-> measure_latency) gf_latency_begin (_new, conf->subvolumes[ i]->fops->opendir); conf->subvolumes[i]->fops-> opendir (_new, conf->subvolumes[i], loc, local->fd, ((void *)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
4797 | } | |||
4798 | ||||
4799 | return 0; | |||
4800 | ||||
4801 | err: | |||
4802 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
4803 | DHT_STACK_UNWIND (rmdir, frame, -1, op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4804, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0) | |||
4804 | NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t * old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ( "!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4804, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4805 | ||||
4806 | return 0; | |||
4807 | } | |||
4808 | ||||
4809 | int | |||
4810 | dht_entrylk_cbk (call_frame_t *frame, void *cookie, | |||
4811 | xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) | |||
4812 | ||||
4813 | { | |||
4814 | DHT_STACK_UNWIND (entrylk, frame, op_ret, op_errno, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_entrylk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4814, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_entrylk_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4815 | return 0; | |||
4816 | } | |||
4817 | ||||
4818 | ||||
4819 | int | |||
4820 | dht_entrylk (call_frame_t *frame, xlator_t *this, | |||
4821 | const char *volume, loc_t *loc, const char *basename__xpg_basename, | |||
4822 | entrylk_cmd cmd, entrylk_type type, dict_t *xdata) | |||
4823 | { | |||
4824 | xlator_t *subvol = NULL((void*)0); | |||
4825 | int op_errno = -1; | |||
4826 | dht_local_t *local = NULL((void*)0); | |||
4827 | ||||
4828 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4828, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
4829 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4829, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
4830 | VALIDATE_OR_GOTO (loc, err)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4830, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto err; } } while (0); | |||
4831 | VALIDATE_OR_GOTO (loc->inode, err)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->inode"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4831, GF_LOG_WARNING, "invalid argument: " "loc->inode"); } while (0); goto err; } } while (0); | |||
4832 | VALIDATE_OR_GOTO (loc->path, err)do { if (!loc->path) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "loc->path"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)" ), "dht-common.c", __FUNCTION__, 4832, GF_LOG_WARNING, "invalid argument: " "loc->path"); } while (0); goto err; } } while (0); | |||
4833 | ||||
4834 | local = dht_local_init (frame, loc, NULL((void*)0), GF_FOP_ENTRYLK); | |||
4835 | if (!local) { | |||
4836 | op_errno = ENOMEM12; | |||
4837 | goto err; | |||
4838 | } | |||
4839 | ||||
4840 | subvol = local->cached_subvol; | |||
4841 | if (!subvol) { | |||
4842 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4843, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0) | |||
4843 | "no cached subvolume for path=%s", loc->path)do { do { if (0) printf ("no cached subvolume for path=%s", loc ->path); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4843, GF_LOG_DEBUG, "no cached subvolume for path=%s" , loc->path); } while (0); | |||
4844 | op_errno = EINVAL22; | |||
4845 | goto err; | |||
4846 | } | |||
4847 | ||||
4848 | local->call_cnt = 1; | |||
4849 | ||||
4850 | STACK_WIND (frame, dht_entrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4852, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->entrylk_cbk) tmp_cbk = dht_entrylk_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->entrylk" ; _new->unwind_to = "dht_entrylk_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->entrylk); subvol ->fops->entrylk (_new, subvol, volume, loc, __xpg_basename , cmd, type, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4851 | subvol, subvol->fops->entrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4852, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->entrylk_cbk) tmp_cbk = dht_entrylk_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->entrylk" ; _new->unwind_to = "dht_entrylk_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->entrylk); subvol ->fops->entrylk (_new, subvol, volume, loc, __xpg_basename , cmd, type, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4852 | volume, loc, basename, cmd, type, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4852, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->entrylk_cbk) tmp_cbk = dht_entrylk_cbk; _new->root = frame ->root; _new->this = subvol; _new->ret = (ret_fn_t) tmp_cbk ; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->entrylk" ; _new->unwind_to = "dht_entrylk_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->entrylk); subvol ->fops->entrylk (_new, subvol, volume, loc, __xpg_basename , cmd, type, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
4853 | ||||
4854 | return 0; | |||
4855 | ||||
4856 | err: | |||
4857 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
4858 | DHT_STACK_UNWIND (entrylk, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_entrylk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4858, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_entrylk_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4859 | ||||
4860 | return 0; | |||
4861 | } | |||
4862 | ||||
4863 | ||||
4864 | int | |||
4865 | dht_fentrylk_cbk (call_frame_t *frame, void *cookie, | |||
4866 | xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) | |||
4867 | ||||
4868 | { | |||
4869 | DHT_STACK_UNWIND (fentrylk, frame, op_ret, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fentrylk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4869, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fentrylk_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, op_ret, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4870 | return 0; | |||
4871 | } | |||
4872 | ||||
4873 | ||||
4874 | int | |||
4875 | dht_fentrylk (call_frame_t *frame, xlator_t *this, | |||
4876 | const char *volume, fd_t *fd, const char *basename__xpg_basename, | |||
4877 | entrylk_cmd cmd, entrylk_type type, dict_t *xdata) | |||
4878 | { | |||
4879 | xlator_t *subvol = NULL((void*)0); | |||
4880 | int op_errno = -1; | |||
4881 | ||||
4882 | VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4882, GF_LOG_WARNING, "invalid argument: " "frame" ); } while (0); goto err; } } while (0); | |||
4883 | VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if ( 0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4883, GF_LOG_WARNING, "invalid argument: " "this" ); } while (0); goto err; } } while (0); | |||
4884 | VALIDATE_OR_GOTO (fd, err)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0) printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "dht-common.c" , __FUNCTION__, 4884, GF_LOG_WARNING, "invalid argument: " "fd" ); } while (0); goto err; } } while (0); | |||
4885 | ||||
4886 | subvol = dht_subvol_get_cached (this, fd->inode); | |||
4887 | if (!subvol) { | |||
4888 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("no cached subvolume for fd=%p", fd) ; } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4889, GF_LOG_DEBUG, "no cached subvolume for fd=%p", fd); } while (0) | |||
4889 | "no cached subvolume for fd=%p", fd)do { do { if (0) printf ("no cached subvolume for fd=%p", fd) ; } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__ , 4889, GF_LOG_DEBUG, "no cached subvolume for fd=%p", fd); } while (0); | |||
4890 | op_errno = EINVAL22; | |||
4891 | goto err; | |||
4892 | } | |||
4893 | ||||
4894 | STACK_WIND (frame, dht_fentrylk_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4896, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fentrylk_cbk) tmp_cbk = dht_fentrylk_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fentrylk" ; _new->unwind_to = "dht_fentrylk_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fentrylk); subvol ->fops->fentrylk (_new, subvol, volume, fd, __xpg_basename , cmd, type, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4895 | subvol, subvol->fops->fentrylk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4896, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fentrylk_cbk) tmp_cbk = dht_fentrylk_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fentrylk" ; _new->unwind_to = "dht_fentrylk_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fentrylk); subvol ->fops->fentrylk (_new, subvol, volume, fd, __xpg_basename , cmd, type, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
4896 | volume, fd, basename, cmd, type, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__, 4896, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( subvol->fops ->fentrylk_cbk) tmp_cbk = dht_fentrylk_cbk; _new->root = frame->root; _new->this = subvol; _new->ret = (ret_fn_t ) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new ->wind_from = __FUNCTION__; _new->wind_to = "subvol->fops->fentrylk" ; _new->unwind_to = "dht_fentrylk_cbk"; pthread_spin_init ( &_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = subvol; if (frame->this->ctx->measure_latency) gf_latency_begin (_new, subvol->fops->fentrylk); subvol ->fops->fentrylk (_new, subvol, volume, fd, __xpg_basename , cmd, type, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
4897 | ||||
4898 | return 0; | |||
4899 | ||||
4900 | err: | |||
4901 | op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno; | |||
4902 | DHT_STACK_UNWIND (fentrylk, frame, -1, op_errno, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void *)0); if (frame) { __xl = frame->this; __local = frame-> local; frame->local = ((void*)0); } do { fop_fentrylk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack", "dht-common.c", __FUNCTION__ , 4902, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fentrylk_cbk_t )frame->ret; _parent = frame->parent ; pthread_spin_lock (&frame->root->stack_lock); { _parent ->ref_count--; } pthread_spin_unlock (&frame->root-> stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = _parent->this; frame->complete = _gf_true; frame-> unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency ) gf_latency_end (frame); fn (_parent, frame->cookie, _parent ->this, -1, op_errno, ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); } while (0); | |||
4903 | ||||
4904 | return 0; | |||
4905 | } | |||
4906 | ||||
4907 | ||||
4908 | int | |||
4909 | dht_forget (xlator_t *this, inode_t *inode) | |||
4910 | { | |||
4911 | uint64_t ctx_int = 0; | |||
4912 | dht_inode_ctx_t *ctx = NULL((void*)0); | |||
4913 | dht_layout_t *layout = NULL((void*)0); | |||
4914 | ||||
4915 | inode_ctx_del (inode, this, &ctx_int)inode_ctx_del2(inode,this,&ctx_int,0); | |||
4916 | ||||
4917 | if (!ctx_int) | |||
4918 | return 0; | |||
4919 | ||||
4920 | ctx = (dht_inode_ctx_t *) (long) ctx_int; | |||
4921 | ||||
4922 | layout = ctx->layout; | |||
4923 | ctx->layout = NULL((void*)0); | |||
4924 | dht_layout_unref (this, layout); | |||
4925 | GF_FREE (ctx)__gf_free (ctx); | |||
4926 | ||||
4927 | return 0; | |||
4928 | } | |||
4929 | ||||
4930 | ||||
4931 | int | |||
4932 | dht_notify (xlator_t *this, int event, void *data, ...) | |||
4933 | { | |||
4934 | xlator_t *subvol = NULL((void*)0); | |||
4935 | int cnt = -1; | |||
4936 | int i = -1; | |||
4937 | dht_conf_t *conf = NULL((void*)0); | |||
4938 | int ret = -1; | |||
4939 | int propagate = 0; | |||
4940 | ||||
4941 | int had_heard_from_all = 0; | |||
4942 | int have_heard_from_all = 0; | |||
4943 | struct timeval time = {0,}; | |||
4944 | gf_defrag_info_t *defrag = NULL((void*)0); | |||
4945 | dict_t *dict = NULL((void*)0); | |||
4946 | gf_defrag_type cmd = 0; | |||
4947 | dict_t *output = NULL((void*)0); | |||
4948 | va_list ap; | |||
4949 | ||||
4950 | ||||
4951 | conf = this->private; | |||
4952 | if (!conf) | |||
4953 | return ret; | |||
4954 | ||||
4955 | /* had all subvolumes reported status once till now? */ | |||
4956 | had_heard_from_all = 1; | |||
4957 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
4958 | if (!conf->last_event[i]) { | |||
4959 | had_heard_from_all = 0; | |||
4960 | } | |||
4961 | } | |||
4962 | ||||
4963 | switch (event) { | |||
4964 | case GF_EVENT_CHILD_UP: | |||
4965 | subvol = data; | |||
4966 | ||||
4967 | conf->gen++; | |||
4968 | ||||
4969 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
4970 | if (subvol == conf->subvolumes[i]) { | |||
4971 | cnt = i; | |||
4972 | break; | |||
4973 | } | |||
4974 | } | |||
4975 | ||||
4976 | if (cnt == -1) { | |||
4977 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("got GF_EVENT_CHILD_UP bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4979, GF_LOG_DEBUG, "got GF_EVENT_CHILD_UP bad subvolume %s" , subvol->name); } while (0) | |||
4978 | "got GF_EVENT_CHILD_UP bad subvolume %s",do { do { if (0) printf ("got GF_EVENT_CHILD_UP bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4979, GF_LOG_DEBUG, "got GF_EVENT_CHILD_UP bad subvolume %s" , subvol->name); } while (0) | |||
4979 | subvol->name)do { do { if (0) printf ("got GF_EVENT_CHILD_UP bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 4979, GF_LOG_DEBUG, "got GF_EVENT_CHILD_UP bad subvolume %s" , subvol->name); } while (0); | |||
4980 | break; | |||
4981 | } | |||
4982 | ||||
4983 | gettimeofday (&time, NULL((void*)0)); | |||
4984 | LOCK (&conf->subvolume_lock)pthread_spin_lock (&conf->subvolume_lock); | |||
4985 | { | |||
4986 | conf->subvolume_status[cnt] = 1; | |||
4987 | conf->last_event[cnt] = event; | |||
4988 | conf->subvol_up_time[cnt] = time.tv_sec; | |||
4989 | } | |||
4990 | UNLOCK (&conf->subvolume_lock)pthread_spin_unlock (&conf->subvolume_lock); | |||
4991 | ||||
4992 | /* one of the node came back up, do a stat update */ | |||
4993 | dht_get_du_info_for_subvol (this, cnt); | |||
4994 | ||||
4995 | break; | |||
4996 | ||||
4997 | case GF_EVENT_CHILD_MODIFIED: | |||
4998 | subvol = data; | |||
4999 | ||||
5000 | conf->gen++; | |||
5001 | propagate = 1; | |||
5002 | ||||
5003 | break; | |||
5004 | ||||
5005 | case GF_EVENT_CHILD_DOWN: | |||
5006 | subvol = data; | |||
5007 | ||||
5008 | if (conf->assert_no_child_down) { | |||
5009 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Received CHILD_DOWN. Exiting"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 5010 , GF_LOG_WARNING, "Received CHILD_DOWN. Exiting"); } while (0 ) | |||
5010 | "Received CHILD_DOWN. Exiting")do { do { if (0) printf ("Received CHILD_DOWN. Exiting"); } while (0); _gf_log (this->name, "dht-common.c", __FUNCTION__, 5010 , GF_LOG_WARNING, "Received CHILD_DOWN. Exiting"); } while (0 ); | |||
5011 | if (conf->defrag) { | |||
5012 | gf_defrag_stop (conf->defrag, NULL((void*)0)); | |||
5013 | } else { | |||
5014 | kill (getpid(), SIGTERM15); | |||
5015 | } | |||
5016 | } | |||
5017 | ||||
5018 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
5019 | if (subvol == conf->subvolumes[i]) { | |||
5020 | cnt = i; | |||
5021 | break; | |||
5022 | } | |||
5023 | } | |||
5024 | ||||
5025 | if (cnt == -1) { | |||
5026 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("got GF_EVENT_CHILD_DOWN bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 5028, GF_LOG_DEBUG, "got GF_EVENT_CHILD_DOWN bad subvolume %s" , subvol->name); } while (0) | |||
5027 | "got GF_EVENT_CHILD_DOWN bad subvolume %s",do { do { if (0) printf ("got GF_EVENT_CHILD_DOWN bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 5028, GF_LOG_DEBUG, "got GF_EVENT_CHILD_DOWN bad subvolume %s" , subvol->name); } while (0) | |||
5028 | subvol->name)do { do { if (0) printf ("got GF_EVENT_CHILD_DOWN bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 5028, GF_LOG_DEBUG, "got GF_EVENT_CHILD_DOWN bad subvolume %s" , subvol->name); } while (0); | |||
5029 | break; | |||
5030 | } | |||
5031 | ||||
5032 | LOCK (&conf->subvolume_lock)pthread_spin_lock (&conf->subvolume_lock); | |||
5033 | { | |||
5034 | conf->subvolume_status[cnt] = 0; | |||
5035 | conf->last_event[cnt] = event; | |||
5036 | conf->subvol_up_time[cnt] = 0; | |||
5037 | } | |||
5038 | UNLOCK (&conf->subvolume_lock)pthread_spin_unlock (&conf->subvolume_lock); | |||
5039 | ||||
5040 | break; | |||
5041 | ||||
5042 | case GF_EVENT_CHILD_CONNECTING: | |||
5043 | subvol = data; | |||
5044 | ||||
5045 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
5046 | if (subvol == conf->subvolumes[i]) { | |||
5047 | cnt = i; | |||
5048 | break; | |||
5049 | } | |||
5050 | } | |||
5051 | ||||
5052 | if (cnt == -1) { | |||
5053 | gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("got GF_EVENT_CHILD_CONNECTING bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 5055, GF_LOG_DEBUG, "got GF_EVENT_CHILD_CONNECTING bad subvolume %s" , subvol->name); } while (0) | |||
5054 | "got GF_EVENT_CHILD_CONNECTING bad subvolume %s",do { do { if (0) printf ("got GF_EVENT_CHILD_CONNECTING bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 5055, GF_LOG_DEBUG, "got GF_EVENT_CHILD_CONNECTING bad subvolume %s" , subvol->name); } while (0) | |||
5055 | subvol->name)do { do { if (0) printf ("got GF_EVENT_CHILD_CONNECTING bad subvolume %s" , subvol->name); } while (0); _gf_log (this->name, "dht-common.c" , __FUNCTION__, 5055, GF_LOG_DEBUG, "got GF_EVENT_CHILD_CONNECTING bad subvolume %s" , subvol->name); } while (0); | |||
5056 | break; | |||
5057 | } | |||
5058 | ||||
5059 | LOCK (&conf->subvolume_lock)pthread_spin_lock (&conf->subvolume_lock); | |||
5060 | { | |||
5061 | conf->last_event[cnt] = event; | |||
5062 | } | |||
5063 | UNLOCK (&conf->subvolume_lock)pthread_spin_unlock (&conf->subvolume_lock); | |||
5064 | ||||
5065 | break; | |||
5066 | case GF_EVENT_VOLUME_DEFRAG: | |||
5067 | { | |||
5068 | if (!conf->defrag) { | |||
5069 | return ret; | |||
5070 | } | |||
5071 | defrag = conf->defrag; | |||
5072 | ||||
5073 | dict = data; | |||
5074 | va_start (ap, data)__builtin_va_start(ap, data); | |||
5075 | output = va_arg (ap, dict_t*)__builtin_va_arg(ap, dict_t*); | |||
5076 | ||||
5077 | ret = dict_get_int32 (dict, "rebalance-command", | |||
5078 | (int32_t*)&cmd); | |||
5079 | if (ret) | |||
5080 | return ret; | |||
5081 | LOCK (&defrag->lock)pthread_spin_lock (&defrag->lock); | |||
5082 | { | |||
5083 | if (defrag->is_exiting) | |||
5084 | goto unlock; | |||
5085 | if (cmd == GF_DEFRAG_CMD_STATUS) | |||
5086 | gf_defrag_status_get (defrag, output); | |||
5087 | else if (cmd == GF_DEFRAG_CMD_STOP) | |||
5088 | gf_defrag_stop (defrag, output); | |||
5089 | } | |||
5090 | unlock: | |||
5091 | UNLOCK (&defrag->lock)pthread_spin_unlock (&defrag->lock); | |||
5092 | return 0; | |||
5093 | break; | |||
5094 | } | |||
5095 | ||||
5096 | default: | |||
5097 | propagate = 1; | |||
5098 | break; | |||
5099 | } | |||
5100 | ||||
5101 | ||||
5102 | /* have all subvolumes reported status once by now? */ | |||
5103 | have_heard_from_all = 1; | |||
5104 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
5105 | if (!conf->last_event[i]) | |||
5106 | have_heard_from_all = 0; | |||
5107 | } | |||
5108 | ||||
5109 | /* if all subvols have reported status, no need to hide anything | |||
5110 | or wait for anything else. Just propagate blindly */ | |||
5111 | if (have_heard_from_all) { | |||
5112 | propagate = 1; | |||
5113 | ||||
5114 | } | |||
5115 | ||||
5116 | ||||
5117 | if (!had_heard_from_all && have_heard_from_all) { | |||
5118 | /* This is the first event which completes aggregation | |||
5119 | of events from all subvolumes. If at least one subvol | |||
5120 | had come up, propagate CHILD_UP, but only this time | |||
5121 | */ | |||
5122 | event = GF_EVENT_CHILD_DOWN; | |||
5123 | ||||
5124 | for (i = 0; i < conf->subvolume_cnt; i++) { | |||
5125 | if (conf->last_event[i] == GF_EVENT_CHILD_UP) { | |||
5126 | event = GF_EVENT_CHILD_UP; | |||
5127 | break; | |||
5128 | } | |||
5129 | ||||
5130 | if (conf->last_event[i] == GF_EVENT_CHILD_CONNECTING) { | |||
5131 | event = GF_EVENT_CHILD_CONNECTING; | |||
5132 | /* continue to check other events for CHILD_UP */ | |||
5133 | } | |||
5134 | } | |||
5135 | ||||
5136 | /* rebalance is started with assert_no_child_down. So we do | |||
5137 | * not need to handle CHILD_DOWN event here. | |||
5138 | */ | |||
5139 | if (conf->defrag) { | |||
5140 | ret = pthread_create (&conf->defrag->th, NULL((void*)0), | |||
5141 | gf_defrag_start, this); | |||
5142 | if (ret) { | |||
5143 | conf->defrag = NULL((void*)0); | |||
5144 | GF_FREE (conf->defrag)__gf_free (conf->defrag); | |||
5145 | kill (getpid(), SIGTERM15); | |||
5146 | } | |||
5147 | } | |||
5148 | } | |||
5149 | ||||
5150 | ret = 0; | |||
5151 | if (propagate) | |||
5152 | ret = default_notify (this, event, data); | |||
5153 | ||||
5154 | return ret; | |||
5155 | } | |||
5156 | ||||
5157 | int | |||
5158 | dht_inode_ctx_layout_get (inode_t *inode, xlator_t *this, dht_layout_t **layout) | |||
5159 | { | |||
5160 | dht_inode_ctx_t *ctx = NULL((void*)0); | |||
5161 | int ret = -1; | |||
5162 | ||||
5163 | ret = dht_inode_ctx_get (inode, this, &ctx); | |||
5164 | ||||
5165 | if (!ret && ctx) { | |||
5166 | if (ctx->layout) { | |||
5167 | if (layout) | |||
5168 | *layout = ctx->layout; | |||
5169 | ret = 0; | |||
5170 | } else { | |||
5171 | ret = -1; | |||
5172 | } | |||
5173 | } | |||
5174 | ||||
5175 | return ret; | |||
5176 | } |