File: | xlators/features/index/src/index.c |
Location: | line 70, column 33 |
Description: | Value stored to 'ret' is never read |
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 | #ifndef _CONFIG_H |
11 | #define _CONFIG_H |
12 | #include "config.h" |
13 | #endif |
14 | |
15 | #include "index.h" |
16 | #include "options.h" |
17 | #include "glusterfs3-xdr.h" |
18 | |
19 | #define XATTROP_SUBDIR"xattrop" "xattrop" |
20 | |
21 | call_stub_t * |
22 | __index_dequeue (struct list_head *callstubs) |
23 | { |
24 | call_stub_t *stub = NULL((void*)0); |
25 | |
26 | if (!list_empty (callstubs)) { |
27 | stub = list_entry (callstubs->next, call_stub_t, list)((call_stub_t *)((char *)(callstubs->next)-(unsigned long) (&((call_stub_t *)0)->list))); |
28 | list_del_init (&stub->list); |
29 | } |
30 | |
31 | return stub; |
32 | } |
33 | |
34 | inline static void |
35 | __index_enqueue (struct list_head *callstubs, call_stub_t *stub) |
36 | { |
37 | list_add_tail (&stub->list, callstubs); |
38 | } |
39 | |
40 | static void |
41 | worker_enqueue (xlator_t *this, call_stub_t *stub) |
42 | { |
43 | index_priv_t *priv = NULL((void*)0); |
44 | |
45 | priv = this->private; |
46 | pthread_mutex_lock (&priv->mutex); |
47 | { |
48 | __index_enqueue (&priv->callstubs, stub); |
49 | pthread_cond_signal (&priv->cond); |
50 | } |
51 | pthread_mutex_unlock (&priv->mutex); |
52 | } |
53 | |
54 | void * |
55 | index_worker (void *data) |
56 | { |
57 | index_priv_t *priv = NULL((void*)0); |
58 | xlator_t *this = NULL((void*)0); |
59 | call_stub_t *stub = NULL((void*)0); |
60 | int ret = 0; |
61 | |
62 | THIS(*__glusterfs_this_location()) = data; |
63 | this = data; |
64 | priv = this->private; |
65 | |
66 | for (;;) { |
67 | pthread_mutex_lock (&priv->mutex); |
68 | { |
69 | while (list_empty (&priv->callstubs)) { |
70 | ret = pthread_cond_wait (&priv->cond, |
Value stored to 'ret' is never read | |
71 | &priv->mutex); |
72 | } |
73 | |
74 | stub = __index_dequeue (&priv->callstubs); |
75 | } |
76 | pthread_mutex_unlock (&priv->mutex); |
77 | |
78 | if (stub) /* guard against spurious wakeups */ |
79 | call_resume (stub); |
80 | } |
81 | |
82 | return NULL((void*)0); |
83 | } |
84 | int |
85 | __index_inode_ctx_get (inode_t *inode, xlator_t *this, index_inode_ctx_t **ctx) |
86 | { |
87 | int ret = 0; |
88 | index_inode_ctx_t *ictx = NULL((void*)0); |
89 | uint64_t tmpctx = 0; |
90 | |
91 | ret = __inode_ctx_get (inode, this, &tmpctx)__inode_ctx_get2(inode,this,&tmpctx,0); |
92 | if (!ret) { |
93 | ictx = (index_inode_ctx_t*) (long) tmpctx; |
94 | goto out; |
95 | } |
96 | ictx = GF_CALLOC (1, sizeof (*ictx), gf_index_inode_ctx_t)__gf_calloc (1, sizeof (*ictx), gf_index_inode_ctx_t); |
97 | if (!ictx) { |
98 | ret = -1; |
99 | goto out; |
100 | } |
101 | |
102 | INIT_LIST_HEAD (&ictx->callstubs)do { (&ictx->callstubs)->next = (&ictx->callstubs )->prev = &ictx->callstubs; } while (0); |
103 | ret = __inode_ctx_put (inode, this, (uint64_t)ictx); |
104 | if (ret) { |
105 | GF_FREE (ictx)__gf_free (ictx); |
106 | ictx = NULL((void*)0); |
107 | goto out; |
108 | } |
109 | out: |
110 | if (ictx) |
111 | *ctx = ictx; |
112 | return ret; |
113 | } |
114 | |
115 | int |
116 | index_inode_ctx_get (inode_t *inode, xlator_t *this, index_inode_ctx_t **ctx) |
117 | { |
118 | int ret = 0; |
119 | |
120 | LOCK (&inode->lock)pthread_spin_lock (&inode->lock); |
121 | { |
122 | ret = __index_inode_ctx_get (inode, this, ctx); |
123 | } |
124 | UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock); |
125 | |
126 | return ret; |
127 | } |
128 | |
129 | static void |
130 | make_index_dir_path (char *base, const char *subdir, |
131 | char *index_dir, size_t len) |
132 | { |
133 | snprintf (index_dir, len, "%s/%s", base, subdir); |
134 | } |
135 | |
136 | int |
137 | index_dir_create (xlator_t *this, const char *subdir) |
138 | { |
139 | int ret = 0; |
140 | struct stat st = {0}; |
141 | char fullpath[PATH_MAX4096] = {0}; |
142 | char path[PATH_MAX4096] = {0}; |
143 | char *dir = NULL((void*)0); |
144 | index_priv_t *priv = NULL((void*)0); |
145 | size_t len = 0; |
146 | size_t pathlen = 0; |
147 | |
148 | priv = this->private; |
149 | make_index_dir_path (priv->index_basepath, subdir, fullpath, |
150 | sizeof (fullpath)); |
151 | ret = stat (fullpath, &st); |
152 | if (!ret) { |
153 | if (!S_ISDIR (st.st_mode)((((st.st_mode)) & 0170000) == (0040000))) |
154 | ret = -2; |
155 | goto out; |
156 | } |
157 | |
158 | pathlen = strlen (fullpath); |
159 | if ((pathlen > 1) && fullpath[pathlen - 1] == '/') |
160 | fullpath[pathlen - 1] = '\0'; |
161 | dir = strchr (fullpath, '/'); |
162 | while (dir) { |
163 | dir = strchr (dir + 1, '/'); |
164 | if (dir) |
165 | len = pathlen - strlen (dir); |
166 | else |
167 | len = pathlen; |
168 | strncpy (path, fullpath, len); |
169 | path[len] = '\0'; |
170 | ret = mkdir (path, 0600); |
171 | if (ret && (errno(*__errno_location ()) != EEXIST17)) |
172 | goto out; |
173 | } |
174 | ret = 0; |
175 | out: |
176 | if (ret == -1) { |
177 | gf_log (this->name, GF_LOG_ERROR, "%s/%s: Failed to "do { do { if (0) printf ("%s/%s: Failed to " "create (%s)", priv ->index_basepath, subdir, strerror ((*__errno_location ()) )); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 179, GF_LOG_ERROR, "%s/%s: Failed to " "create (%s)", priv-> index_basepath, subdir, strerror ((*__errno_location ()))); } while (0) |
178 | "create (%s)", priv->index_basepath, subdir,do { do { if (0) printf ("%s/%s: Failed to " "create (%s)", priv ->index_basepath, subdir, strerror ((*__errno_location ()) )); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 179, GF_LOG_ERROR, "%s/%s: Failed to " "create (%s)", priv-> index_basepath, subdir, strerror ((*__errno_location ()))); } while (0) |
179 | strerror (errno))do { do { if (0) printf ("%s/%s: Failed to " "create (%s)", priv ->index_basepath, subdir, strerror ((*__errno_location ()) )); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 179, GF_LOG_ERROR, "%s/%s: Failed to " "create (%s)", priv-> index_basepath, subdir, strerror ((*__errno_location ()))); } while (0); |
180 | } else if (ret == -2) { |
181 | gf_log (this->name, GF_LOG_ERROR, "%s/%s: Failed to create, "do { do { if (0) printf ("%s/%s: Failed to create, " "path exists, not a directory " , priv->index_basepath, subdir); } while (0); _gf_log (this ->name, "index.c", __FUNCTION__, 183, GF_LOG_ERROR, "%s/%s: Failed to create, " "path exists, not a directory ", priv->index_basepath, subdir ); } while (0) |
182 | "path exists, not a directory ", priv->index_basepath,do { do { if (0) printf ("%s/%s: Failed to create, " "path exists, not a directory " , priv->index_basepath, subdir); } while (0); _gf_log (this ->name, "index.c", __FUNCTION__, 183, GF_LOG_ERROR, "%s/%s: Failed to create, " "path exists, not a directory ", priv->index_basepath, subdir ); } while (0) |
183 | subdir)do { do { if (0) printf ("%s/%s: Failed to create, " "path exists, not a directory " , priv->index_basepath, subdir); } while (0); _gf_log (this ->name, "index.c", __FUNCTION__, 183, GF_LOG_ERROR, "%s/%s: Failed to create, " "path exists, not a directory ", priv->index_basepath, subdir ); } while (0); |
184 | } |
185 | return ret; |
186 | } |
187 | |
188 | void |
189 | index_get_index (index_priv_t *priv, uuid_t index) |
190 | { |
191 | LOCK (&priv->lock)pthread_spin_lock (&priv->lock); |
192 | { |
193 | uuid_copy (index, priv->index); |
194 | } |
195 | UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock); |
196 | } |
197 | |
198 | void |
199 | index_generate_index (index_priv_t *priv, uuid_t index) |
200 | { |
201 | LOCK (&priv->lock)pthread_spin_lock (&priv->lock); |
202 | { |
203 | //To prevent duplicate generates. |
204 | //This method fails if number of contending threads is greater |
205 | //than MAX_LINK count of the fs |
206 | if (!uuid_compare (priv->index, index)) |
207 | uuid_generate (priv->index); |
208 | uuid_copy (index, priv->index); |
209 | } |
210 | UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock); |
211 | } |
212 | |
213 | static void |
214 | make_index_path (char *base, const char *subdir, uuid_t index, |
215 | char *index_path, size_t len) |
216 | { |
217 | make_index_dir_path (base, subdir, index_path, len); |
218 | snprintf (index_path + strlen (index_path), len - strlen (index_path), |
219 | "/%s-%s", subdir, uuid_utoa (index)); |
220 | } |
221 | |
222 | static void |
223 | make_gfid_path (char *base, const char *subdir, uuid_t gfid, |
224 | char *gfid_path, size_t len) |
225 | { |
226 | make_index_dir_path (base, subdir, gfid_path, len); |
227 | snprintf (gfid_path + strlen (gfid_path), len - strlen (gfid_path), |
228 | "/%s", uuid_utoa (gfid)); |
229 | } |
230 | |
231 | static void |
232 | make_file_path (char *base, const char *subdir, const char *filename, |
233 | char *file_path, size_t len) |
234 | { |
235 | make_index_dir_path (base, subdir, file_path, len); |
236 | snprintf (file_path + strlen (file_path), len - strlen (file_path), |
237 | "/%s", filename); |
238 | } |
239 | |
240 | static void |
241 | check_delete_stale_index_file (xlator_t *this, char *filename) |
242 | { |
243 | int ret = 0; |
244 | struct stat st = {0}; |
245 | char filepath[PATH_MAX4096] = {0}; |
246 | index_priv_t *priv = NULL((void*)0); |
247 | |
248 | priv = this->private; |
249 | make_file_path (priv->index_basepath, XATTROP_SUBDIR"xattrop", |
250 | filename, filepath, sizeof (filepath)); |
251 | ret = stat (filepath, &st); |
252 | if (!ret && st.st_nlink == 1) |
253 | unlink (filepath); |
254 | } |
255 | |
256 | static int |
257 | index_fill_readdir (fd_t *fd, DIR *dir, off_t off, |
258 | size_t size, gf_dirent_t *entries) |
259 | { |
260 | off_t in_case = -1; |
261 | size_t filled = 0; |
262 | int count = 0; |
263 | char entrybuf[sizeof(struct dirent) + 256 + 8]; |
264 | struct dirent *entry = NULL((void*)0); |
265 | int32_t this_size = -1; |
266 | gf_dirent_t *this_entry = NULL((void*)0); |
267 | xlator_t *this = NULL((void*)0); |
268 | |
269 | this = THIS(*__glusterfs_this_location()); |
270 | if (!off) { |
271 | rewinddir (dir); |
272 | } else { |
273 | seekdir (dir, off); |
274 | } |
275 | |
276 | while (filled <= size) { |
277 | in_case = telldir (dir); |
278 | |
279 | if (in_case == -1) { |
280 | gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("telldir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); _gf_log ((* __glusterfs_this_location())->name, "index.c", __FUNCTION__ , 282, GF_LOG_ERROR, "telldir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0) |
281 | "telldir failed on dir=%p: %s",do { do { if (0) printf ("telldir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); _gf_log ((* __glusterfs_this_location())->name, "index.c", __FUNCTION__ , 282, GF_LOG_ERROR, "telldir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0) |
282 | dir, strerror (errno))do { do { if (0) printf ("telldir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); _gf_log ((* __glusterfs_this_location())->name, "index.c", __FUNCTION__ , 282, GF_LOG_ERROR, "telldir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); |
283 | goto out; |
284 | } |
285 | |
286 | errno(*__errno_location ()) = 0; |
287 | entry = NULL((void*)0); |
288 | readdir_r (dir, (struct dirent *)entrybuf, &entry); |
289 | |
290 | if (!entry) { |
291 | if (errno(*__errno_location ()) == EBADF9) { |
292 | gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("readdir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); _gf_log ((* __glusterfs_this_location())->name, "index.c", __FUNCTION__ , 294, GF_LOG_WARNING, "readdir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0) |
293 | "readdir failed on dir=%p: %s",do { do { if (0) printf ("readdir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); _gf_log ((* __glusterfs_this_location())->name, "index.c", __FUNCTION__ , 294, GF_LOG_WARNING, "readdir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0) |
294 | dir, strerror (errno))do { do { if (0) printf ("readdir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); _gf_log ((* __glusterfs_this_location())->name, "index.c", __FUNCTION__ , 294, GF_LOG_WARNING, "readdir failed on dir=%p: %s", dir, strerror ((*__errno_location ()))); } while (0); |
295 | goto out; |
296 | } |
297 | break; |
298 | } |
299 | |
300 | if (!strncmp (entry->d_name, XATTROP_SUBDIR"xattrop""-", |
301 | strlen (XATTROP_SUBDIR"xattrop""-"))) { |
302 | check_delete_stale_index_file (this, entry->d_name); |
303 | continue; |
304 | } |
305 | |
306 | this_size = max (sizeof (gf_dirent_t),((sizeof (gf_dirent_t))>(sizeof (gfs3_dirplist))?(sizeof ( gf_dirent_t)):(sizeof (gfs3_dirplist))) |
307 | sizeof (gfs3_dirplist))((sizeof (gf_dirent_t))>(sizeof (gfs3_dirplist))?(sizeof ( gf_dirent_t)):(sizeof (gfs3_dirplist))) |
308 | + strlen (entry->d_name) + 1; |
309 | |
310 | if (this_size + filled > size) { |
311 | seekdir (dir, in_case); |
312 | break; |
313 | } |
314 | |
315 | this_entry = gf_dirent_for_name (entry->d_name); |
316 | |
317 | if (!this_entry) { |
318 | gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("could not create gf_dirent for entry %s: (%s)" , entry->d_name, strerror ((*__errno_location ()))); } while (0); _gf_log ((*__glusterfs_this_location())->name, "index.c" , __FUNCTION__, 320, GF_LOG_ERROR, "could not create gf_dirent for entry %s: (%s)" , entry->d_name, strerror ((*__errno_location ()))); } while (0) |
319 | "could not create gf_dirent for entry %s: (%s)",do { do { if (0) printf ("could not create gf_dirent for entry %s: (%s)" , entry->d_name, strerror ((*__errno_location ()))); } while (0); _gf_log ((*__glusterfs_this_location())->name, "index.c" , __FUNCTION__, 320, GF_LOG_ERROR, "could not create gf_dirent for entry %s: (%s)" , entry->d_name, strerror ((*__errno_location ()))); } while (0) |
320 | entry->d_name, strerror (errno))do { do { if (0) printf ("could not create gf_dirent for entry %s: (%s)" , entry->d_name, strerror ((*__errno_location ()))); } while (0); _gf_log ((*__glusterfs_this_location())->name, "index.c" , __FUNCTION__, 320, GF_LOG_ERROR, "could not create gf_dirent for entry %s: (%s)" , entry->d_name, strerror ((*__errno_location ()))); } while (0); |
321 | goto out; |
322 | } |
323 | this_entry->d_off = telldir (dir); |
324 | this_entry->d_ino = entry->d_ino; |
325 | |
326 | list_add_tail (&this_entry->list, &entries->list); |
327 | |
328 | filled += this_size; |
329 | count ++; |
330 | } |
331 | |
332 | if ((!readdir (dir) && (errno(*__errno_location ()) == 0))) |
333 | /* Indicate EOF */ |
334 | errno(*__errno_location ()) = ENOENT2; |
335 | out: |
336 | return count; |
337 | } |
338 | |
339 | int |
340 | index_add (xlator_t *this, uuid_t gfid, const char *subdir) |
341 | { |
342 | int32_t op_errno = 0; |
343 | char gfid_path[PATH_MAX4096] = {0}; |
344 | char index_path[PATH_MAX4096] = {0}; |
345 | int ret = 0; |
346 | uuid_t index = {0}; |
347 | index_priv_t *priv = NULL((void*)0); |
348 | struct stat st = {0}; |
349 | int fd = 0; |
350 | |
351 | priv = this->private; |
352 | GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !uuid_is_null (gfid),do { if (!!uuid_is_null (gfid)) { do { if (!(0)) { do { do { if (0) printf ("Assertion failed: " "0"); } while (0); _gf_log_callingfn ("", "index.c", __FUNCTION__, 353, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); } } while (0); op_errno = 22; goto out; } }while (0) |
353 | out, op_errno, EINVAL)do { if (!!uuid_is_null (gfid)) { do { if (!(0)) { do { do { if (0) printf ("Assertion failed: " "0"); } while (0); _gf_log_callingfn ("", "index.c", __FUNCTION__, 353, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); } } while (0); op_errno = 22; goto out; } }while (0); |
354 | |
355 | make_gfid_path (priv->index_basepath, subdir, gfid, |
356 | gfid_path, sizeof (gfid_path)); |
357 | |
358 | ret = stat (gfid_path, &st); |
359 | if (!ret) |
360 | goto out; |
361 | index_get_index (priv, index); |
362 | make_index_path (priv->index_basepath, subdir, |
363 | index, index_path, sizeof (index_path)); |
364 | ret = link (index_path, gfid_path); |
365 | if (!ret || (errno(*__errno_location ()) == EEXIST17)) { |
366 | ret = 0; |
367 | goto out; |
368 | } |
369 | |
370 | op_errno = errno(*__errno_location ()); |
371 | if (op_errno == ENOENT2) { |
372 | ret = index_dir_create (this, subdir); |
373 | if (ret) |
374 | goto out; |
375 | } else if (op_errno == EMLINK31) { |
376 | index_generate_index (priv, index); |
377 | make_index_path (priv->index_basepath, subdir, |
378 | index, index_path, sizeof (index_path)); |
379 | } else { |
380 | goto out; |
381 | } |
382 | |
383 | fd = creat (index_path, 0); |
384 | if ((fd < 0) && (errno(*__errno_location ()) != EEXIST17)) { |
385 | ret = -1; |
386 | gf_log (this->name, GF_LOG_ERROR, "%s: Not able to "do { do { if (0) printf ("%s: Not able to " "create index (%s)" , uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 388, GF_LOG_ERROR , "%s: Not able to " "create index (%s)", uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0) |
387 | "create index (%s)", uuid_utoa (gfid),do { do { if (0) printf ("%s: Not able to " "create index (%s)" , uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 388, GF_LOG_ERROR , "%s: Not able to " "create index (%s)", uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0) |
388 | strerror (errno))do { do { if (0) printf ("%s: Not able to " "create index (%s)" , uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 388, GF_LOG_ERROR , "%s: Not able to " "create index (%s)", uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); |
389 | goto out; |
390 | } |
391 | |
392 | if (fd >= 0) |
393 | close (fd); |
394 | |
395 | ret = link (index_path, gfid_path); |
396 | if (ret && (errno(*__errno_location ()) != EEXIST17)) { |
397 | gf_log (this->name, GF_LOG_ERROR, "%s: Not able to "do { do { if (0) printf ("%s: Not able to " "add to index (%s)" , uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 399, GF_LOG_ERROR , "%s: Not able to " "add to index (%s)", uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0) |
398 | "add to index (%s)", uuid_utoa (gfid),do { do { if (0) printf ("%s: Not able to " "add to index (%s)" , uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 399, GF_LOG_ERROR , "%s: Not able to " "add to index (%s)", uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0) |
399 | strerror (errno))do { do { if (0) printf ("%s: Not able to " "add to index (%s)" , uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 399, GF_LOG_ERROR , "%s: Not able to " "add to index (%s)", uuid_utoa (gfid), strerror ((*__errno_location ()))); } while (0); |
400 | goto out; |
401 | } |
402 | |
403 | ret = 0; |
404 | out: |
405 | return ret; |
406 | } |
407 | |
408 | int |
409 | index_del (xlator_t *this, uuid_t gfid, const char *subdir) |
410 | { |
411 | int32_t op_errno __attribute__((unused)) = 0; |
412 | index_priv_t *priv = NULL((void*)0); |
413 | int ret = 0; |
414 | char gfid_path[PATH_MAX4096] = {0}; |
415 | |
416 | priv = this->private; |
417 | GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !uuid_is_null (gfid),do { if (!!uuid_is_null (gfid)) { do { if (!(0)) { do { do { if (0) printf ("Assertion failed: " "0"); } while (0); _gf_log_callingfn ("", "index.c", __FUNCTION__, 418, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); } } while (0); op_errno = 22; goto out; } }while (0) |
418 | out, op_errno, EINVAL)do { if (!!uuid_is_null (gfid)) { do { if (!(0)) { do { do { if (0) printf ("Assertion failed: " "0"); } while (0); _gf_log_callingfn ("", "index.c", __FUNCTION__, 418, GF_LOG_ERROR, "Assertion failed: " "0"); } while (0); } } while (0); op_errno = 22; goto out; } }while (0); |
419 | make_gfid_path (priv->index_basepath, subdir, gfid, |
420 | gfid_path, sizeof (gfid_path)); |
421 | ret = unlink (gfid_path); |
422 | if (ret && (errno(*__errno_location ()) != ENOENT2)) { |
423 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s: failed to delete from index (%s)" , gfid_path, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 425, GF_LOG_ERROR , "%s: failed to delete from index (%s)", gfid_path, strerror ((*__errno_location ()))); } while (0) |
424 | "%s: failed to delete from index (%s)",do { do { if (0) printf ("%s: failed to delete from index (%s)" , gfid_path, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 425, GF_LOG_ERROR , "%s: failed to delete from index (%s)", gfid_path, strerror ((*__errno_location ()))); } while (0) |
425 | gfid_path, strerror (errno))do { do { if (0) printf ("%s: failed to delete from index (%s)" , gfid_path, strerror ((*__errno_location ()))); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 425, GF_LOG_ERROR , "%s: failed to delete from index (%s)", gfid_path, strerror ((*__errno_location ()))); } while (0); |
426 | ret = -errno(*__errno_location ()); |
427 | goto out; |
428 | } |
429 | ret = 0; |
430 | out: |
431 | return ret; |
432 | } |
433 | |
434 | static int |
435 | _check_key_is_zero_filled (dict_t *d, char *k, data_t *v, |
436 | void *tmp) |
437 | { |
438 | if (mem_0filled ((const char*)v->data, v->len)) { |
439 | /* -1 means, no more iterations, treat as 'break' */ |
440 | return -1; |
441 | } |
442 | return 0; |
443 | } |
444 | |
445 | |
446 | void |
447 | _xattrop_index_action (xlator_t *this, inode_t *inode, dict_t *xattr) |
448 | { |
449 | gf_boolean_t zero_xattr = _gf_true; |
450 | index_inode_ctx_t *ctx = NULL((void*)0); |
451 | int ret = 0; |
452 | |
453 | ret = dict_foreach (xattr, _check_key_is_zero_filled, NULL((void*)0)); |
454 | if (ret == -1) |
455 | zero_xattr = _gf_false; |
456 | |
457 | ret = index_inode_ctx_get (inode, this, &ctx); |
458 | if (ret) { |
459 | gf_log (this->name, GF_LOG_ERROR, "Not able to %s %s -> index",do { do { if (0) printf ("Not able to %s %s -> index", zero_xattr ?"add":"del", uuid_utoa (inode->gfid)); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 460, GF_LOG_ERROR, "Not able to %s %s -> index" , zero_xattr?"add":"del", uuid_utoa (inode->gfid)); } while (0) |
460 | zero_xattr?"add":"del", uuid_utoa (inode->gfid))do { do { if (0) printf ("Not able to %s %s -> index", zero_xattr ?"add":"del", uuid_utoa (inode->gfid)); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 460, GF_LOG_ERROR, "Not able to %s %s -> index" , zero_xattr?"add":"del", uuid_utoa (inode->gfid)); } while (0); |
461 | goto out; |
462 | } |
463 | if (zero_xattr) { |
464 | if (ctx->state == NOTIN) |
465 | goto out; |
466 | ret = index_del (this, inode->gfid, XATTROP_SUBDIR"xattrop"); |
467 | if (!ret) |
468 | ctx->state = NOTIN; |
469 | } else { |
470 | if (ctx->state == IN) |
471 | goto out; |
472 | ret = index_add (this, inode->gfid, XATTROP_SUBDIR"xattrop"); |
473 | if (!ret) |
474 | ctx->state = IN; |
475 | } |
476 | out: |
477 | return; |
478 | } |
479 | |
480 | void |
481 | fop_xattrop_index_action (xlator_t *this, inode_t *inode, dict_t *xattr) |
482 | { |
483 | _xattrop_index_action (this, inode, xattr); |
484 | } |
485 | |
486 | void |
487 | fop_fxattrop_index_action (xlator_t *this, inode_t *inode, dict_t *xattr) |
488 | { |
489 | _xattrop_index_action (this, inode, xattr); |
490 | } |
491 | |
492 | inline gf_boolean_t |
493 | index_xattrop_track (loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict) |
494 | { |
495 | return (flags == GF_XATTROP_ADD_ARRAY); |
496 | } |
497 | |
498 | inline gf_boolean_t |
499 | index_fxattrop_track (fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict) |
500 | { |
501 | return (flags == GF_XATTROP_ADD_ARRAY); |
502 | } |
503 | |
504 | int |
505 | __index_fd_ctx_get (fd_t *fd, xlator_t *this, index_fd_ctx_t **ctx) |
506 | { |
507 | int ret = 0; |
508 | index_fd_ctx_t *fctx = NULL((void*)0); |
509 | uint64_t tmpctx = 0; |
510 | char index_dir[PATH_MAX4096] = {0}; |
511 | index_priv_t *priv = NULL((void*)0); |
512 | |
513 | priv = this->private; |
514 | if (uuid_compare (fd->inode->gfid, priv->xattrop_vgfid)) { |
515 | ret = -EINVAL22; |
516 | goto out; |
517 | } |
518 | |
519 | ret = __fd_ctx_get (fd, this, &tmpctx); |
520 | if (!ret) { |
521 | fctx = (index_fd_ctx_t*) (long) tmpctx; |
522 | goto out; |
523 | } |
524 | |
525 | fctx = GF_CALLOC (1, sizeof (*fctx), gf_index_fd_ctx_t)__gf_calloc (1, sizeof (*fctx), gf_index_fd_ctx_t); |
526 | if (!fctx) { |
527 | ret = -ENOMEM12; |
528 | goto out; |
529 | } |
530 | |
531 | make_index_dir_path (priv->index_basepath, XATTROP_SUBDIR"xattrop", |
532 | index_dir, sizeof (index_dir)); |
533 | fctx->dir = opendir (index_dir); |
534 | if (!fctx->dir) { |
535 | ret = -errno(*__errno_location ()); |
536 | GF_FREE (fctx)__gf_free (fctx); |
537 | fctx = NULL((void*)0); |
538 | goto out; |
539 | } |
540 | |
541 | ret = __fd_ctx_set (fd, this, (uint64_t)(long)fctx); |
542 | if (ret) { |
543 | GF_FREE (fctx)__gf_free (fctx); |
544 | fctx = NULL((void*)0); |
545 | ret = -EINVAL22; |
546 | goto out; |
547 | } |
548 | out: |
549 | if (fctx) |
550 | *ctx = fctx; |
551 | return ret; |
552 | } |
553 | |
554 | int |
555 | index_fd_ctx_get (fd_t *fd, xlator_t *this, index_fd_ctx_t **ctx) |
556 | { |
557 | int ret = 0; |
558 | LOCK (&fd->lock)pthread_spin_lock (&fd->lock); |
559 | { |
560 | ret = __index_fd_ctx_get (fd, this, ctx); |
561 | } |
562 | UNLOCK (&fd->lock)pthread_spin_unlock (&fd->lock); |
563 | return ret; |
564 | } |
565 | |
566 | //new - Not NULL means start a fop |
567 | //new - NULL means done processing the fop |
568 | void |
569 | index_queue_process (xlator_t *this, inode_t *inode, call_stub_t *new) |
570 | { |
571 | call_stub_t *stub = NULL((void*)0); |
572 | index_inode_ctx_t *ctx = NULL((void*)0); |
573 | int ret = 0; |
574 | call_frame_t *frame = NULL((void*)0); |
575 | |
576 | LOCK (&inode->lock)pthread_spin_lock (&inode->lock); |
577 | { |
578 | ret = __index_inode_ctx_get (inode, this, &ctx); |
579 | if (ret) |
580 | goto unlock; |
581 | |
582 | if (new) { |
583 | __index_enqueue (&ctx->callstubs, new); |
584 | new = NULL((void*)0); |
585 | } else { |
586 | ctx->processing = _gf_false; |
587 | } |
588 | |
589 | if (!ctx->processing) { |
590 | stub = __index_dequeue (&ctx->callstubs); |
591 | if (stub) |
592 | ctx->processing = _gf_true; |
593 | else |
594 | ctx->processing = _gf_false; |
595 | } |
596 | } |
597 | unlock: |
598 | UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock); |
599 | |
600 | if (ret && new) { |
601 | frame = new->frame; |
602 | if (new->fop == GF_FOP_XATTROP) { |
603 | INDEX_STACK_UNWIND (xattrop, frame, -1, ENOMEM,do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_xattrop_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", "index.c", __FUNCTION__ , 604, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_xattrop_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)); (*__glusterfs_this_location ()) = old_THIS; } while (0); } while (0) |
604 | NULL, NULL)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_xattrop_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", "index.c", __FUNCTION__ , 604, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_xattrop_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)); (*__glusterfs_this_location ()) = old_THIS; } while (0); } while (0); |
605 | } else if (new->fop == GF_FOP_FXATTROP) { |
606 | INDEX_STACK_UNWIND (fxattrop, frame, -1, ENOMEM,do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_fxattrop_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", "index.c", __FUNCTION__ , 607, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fxattrop_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)); (*__glusterfs_this_location ()) = old_THIS; } while (0); } while (0) |
607 | NULL, NULL)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_fxattrop_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", "index.c", __FUNCTION__ , 607, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fxattrop_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)); (*__glusterfs_this_location ()) = old_THIS; } while (0); } while (0); |
608 | } |
609 | call_stub_destroy (new); |
610 | } else if (stub) { |
611 | call_resume (stub); |
612 | } |
613 | return; |
614 | } |
615 | |
616 | int32_t |
617 | index_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
618 | int32_t op_ret, int32_t op_errno, dict_t *xattr, dict_t *xdata) |
619 | { |
620 | inode_t *inode = NULL((void*)0); |
621 | |
622 | inode = inode_ref (frame->local); |
623 | if (op_ret < 0) |
624 | goto out; |
625 | fop_xattrop_index_action (this, frame->local, xattr); |
626 | out: |
627 | INDEX_STACK_UNWIND (xattrop, frame, op_ret, op_errno, xattr, xdata)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_xattrop_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", "index.c", __FUNCTION__ , 627, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_xattrop_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); } while (0); |
628 | index_queue_process (this, inode, NULL((void*)0)); |
629 | inode_unref (inode); |
630 | |
631 | return 0; |
632 | } |
633 | |
634 | int32_t |
635 | index_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, |
636 | int32_t op_ret, int32_t op_errno, dict_t *xattr, |
637 | dict_t *xdata) |
638 | { |
639 | inode_t *inode = NULL((void*)0); |
640 | |
641 | inode = inode_ref (frame->local); |
642 | if (op_ret < 0) |
643 | goto out; |
644 | |
645 | fop_fxattrop_index_action (this, frame->local, xattr); |
646 | out: |
647 | INDEX_STACK_UNWIND (fxattrop, frame, op_ret, op_errno, xattr, xdata)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_fxattrop_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", "index.c", __FUNCTION__ , 647, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fxattrop_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); } while (0); |
648 | index_queue_process (this, inode, NULL((void*)0)); |
649 | inode_unref (inode); |
650 | |
651 | return 0; |
652 | } |
653 | |
654 | int |
655 | index_xattrop_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, |
656 | gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) |
657 | { |
658 | STACK_WIND (frame, index_xattrop_cbk, FIRST_CHILD (this),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", "index.c", __FUNCTION__, 660, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->xattrop_cbk) tmp_cbk = index_xattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->xattrop" ; _new->unwind_to = "index_xattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->xattrop); (this->children->xlator )->fops->xattrop (_new, (this->children->xlator), loc, optype, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) |
659 | FIRST_CHILD (this)->fops->xattrop, loc, optype, 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", "index.c", __FUNCTION__, 660, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->xattrop_cbk) tmp_cbk = index_xattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->xattrop" ; _new->unwind_to = "index_xattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->xattrop); (this->children->xlator )->fops->xattrop (_new, (this->children->xlator), loc, optype, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) |
660 | 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", "index.c", __FUNCTION__, 660, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->xattrop_cbk) tmp_cbk = index_xattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->xattrop" ; _new->unwind_to = "index_xattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->xattrop); (this->children->xlator )->fops->xattrop (_new, (this->children->xlator), loc, optype, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); |
661 | return 0; |
662 | } |
663 | |
664 | int |
665 | index_fxattrop_wrapper (call_frame_t *frame, xlator_t *this, fd_t *fd, |
666 | gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) |
667 | { |
668 | STACK_WIND (frame, index_fxattrop_cbk, FIRST_CHILD (this),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", "index.c", __FUNCTION__, 670, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fxattrop_cbk) tmp_cbk = index_fxattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fxattrop" ; _new->unwind_to = "index_fxattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fxattrop); (this->children->xlator )->fops->fxattrop (_new, (this->children->xlator) , fd, optype, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) |
669 | FIRST_CHILD (this)->fops->fxattrop, fd, optype, 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", "index.c", __FUNCTION__, 670, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fxattrop_cbk) tmp_cbk = index_fxattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fxattrop" ; _new->unwind_to = "index_fxattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fxattrop); (this->children->xlator )->fops->fxattrop (_new, (this->children->xlator) , fd, optype, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) |
670 | 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", "index.c", __FUNCTION__, 670, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fxattrop_cbk) tmp_cbk = index_fxattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->fxattrop" ; _new->unwind_to = "index_fxattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fxattrop); (this->children->xlator )->fops->fxattrop (_new, (this->children->xlator) , fd, optype, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); |
671 | return 0; |
672 | } |
673 | |
674 | int32_t |
675 | index_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, |
676 | gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) |
677 | { |
678 | call_stub_t *stub = NULL((void*)0); |
679 | |
680 | if (!index_xattrop_track (loc, flags, dict)) |
681 | goto out; |
682 | |
683 | frame->local = inode_ref (loc->inode); |
684 | stub = fop_xattrop_stub (frame, index_xattrop_wrapper, |
685 | loc, flags, dict, xdata); |
686 | if (!stub) { |
687 | INDEX_STACK_UNWIND (xattrop, frame, -1, ENOMEM, NULL, NULL)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_xattrop_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", "index.c", __FUNCTION__ , 687, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_xattrop_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)); (*__glusterfs_this_location ()) = old_THIS; } while (0); } while (0); |
688 | return 0; |
689 | } |
690 | |
691 | index_queue_process (this, loc->inode, stub); |
692 | return 0; |
693 | out: |
694 | STACK_WIND (frame, default_xattrop_cbk, FIRST_CHILD(this),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", "index.c", __FUNCTION__, 695, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->xattrop_cbk) tmp_cbk = default_xattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop" ; _new->unwind_to = "default_xattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->xattrop); (this->children->xlator )->fops->xattrop (_new, (this->children->xlator), loc, flags, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
695 | FIRST_CHILD(this)->fops->xattrop, loc, flags, dict, 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", "index.c", __FUNCTION__, 695, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->xattrop_cbk) tmp_cbk = default_xattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop" ; _new->unwind_to = "default_xattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->xattrop); (this->children->xlator )->fops->xattrop (_new, (this->children->xlator), loc, flags, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
696 | return 0; |
697 | } |
698 | |
699 | int32_t |
700 | index_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, |
701 | gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) |
702 | { |
703 | call_stub_t *stub = NULL((void*)0); |
704 | |
705 | if (!index_fxattrop_track (fd, flags, dict)) |
706 | goto out; |
707 | |
708 | frame->local = inode_ref (fd->inode); |
709 | stub = fop_fxattrop_stub (frame, index_fxattrop_wrapper, |
710 | fd, flags, dict, xdata); |
711 | if (!stub) { |
712 | INDEX_STACK_UNWIND (fxattrop, frame, -1, ENOMEM, NULL, xdata)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } do { fop_fxattrop_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", "index.c", __FUNCTION__ , 712, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (fop_fxattrop_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), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); } while (0); |
713 | return 0; |
714 | } |
715 | |
716 | index_queue_process (this, fd->inode, stub); |
717 | return 0; |
718 | out: |
719 | STACK_WIND (frame, default_fxattrop_cbk, FIRST_CHILD(this),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", "index.c", __FUNCTION__, 720, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fxattrop_cbk) tmp_cbk = default_fxattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fxattrop" ; _new->unwind_to = "default_fxattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fxattrop); (this->children->xlator )->fops->fxattrop (_new, (this->children->xlator) , fd, flags, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
720 | FIRST_CHILD(this)->fops->fxattrop, fd, flags, dict, 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", "index.c", __FUNCTION__, 720, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fxattrop_cbk) tmp_cbk = default_fxattrop_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fxattrop" ; _new->unwind_to = "default_fxattrop_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fxattrop); (this->children->xlator )->fops->fxattrop (_new, (this->children->xlator) , fd, flags, dict, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
721 | return 0; |
722 | } |
723 | |
724 | int32_t |
725 | index_getxattr_wrapper (call_frame_t *frame, xlator_t *this, |
726 | loc_t *loc, const char *name, dict_t *xdata) |
727 | { |
728 | index_priv_t *priv = NULL((void*)0); |
729 | dict_t *xattr = NULL((void*)0); |
730 | int ret = 0; |
731 | |
732 | priv = this->private; |
733 | |
734 | xattr = dict_new (); |
735 | if (!xattr) { |
736 | ret = -ENOMEM12; |
737 | goto done; |
738 | } |
739 | |
740 | ret = dict_set_static_bin (xattr, (char*)name, priv->xattrop_vgfid, |
741 | sizeof (priv->xattrop_vgfid)); |
742 | if (ret) { |
743 | ret = -ENOMEM12; |
744 | gf_log (THIS->name, GF_LOG_ERROR, "xattrop index "do { do { if (0) printf ("xattrop index " "gfid set failed"); } while (0); _gf_log ((*__glusterfs_this_location())->name , "index.c", __FUNCTION__, 745, GF_LOG_ERROR, "xattrop index " "gfid set failed"); } while (0) |
745 | "gfid set failed")do { do { if (0) printf ("xattrop index " "gfid set failed"); } while (0); _gf_log ((*__glusterfs_this_location())->name , "index.c", __FUNCTION__, 745, GF_LOG_ERROR, "xattrop index " "gfid set failed"); } while (0); |
746 | goto done; |
747 | } |
748 | done: |
749 | if (ret) |
750 | STACK_UNWIND_STRICT (getxattr, frame, -1, -ret, xattr, xdata)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" , "index.c", __FUNCTION__, 750, 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 , -ret, xattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
751 | else |
752 | STACK_UNWIND_STRICT (getxattr, frame, 0, 0, xattr, xdata)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" , "index.c", __FUNCTION__, 752, 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, xattr, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); |
753 | |
754 | if (xattr) |
755 | dict_unref (xattr); |
756 | |
757 | return 0; |
758 | } |
759 | |
760 | int32_t |
761 | index_lookup_wrapper (call_frame_t *frame, xlator_t *this, |
762 | loc_t *loc, dict_t *xattr_req) |
763 | { |
764 | index_priv_t *priv = NULL((void*)0); |
765 | struct stat lstatbuf = {0}; |
766 | int ret = 0; |
767 | int32_t op_errno = EINVAL22; |
768 | int32_t op_ret = -1; |
769 | char path[PATH_MAX4096] = {0}; |
770 | struct iatt stbuf = {0, }; |
771 | struct iatt postparent = {0,}; |
772 | dict_t *xattr = NULL((void*)0); |
773 | gf_boolean_t is_dir = _gf_false; |
774 | |
775 | priv = this->private; |
776 | |
777 | VALIDATE_OR_GOTO (loc, done)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0 ) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"), "index.c" , __FUNCTION__, 777, GF_LOG_WARNING, "invalid argument: " "loc" ); } while (0); goto done; } } while (0); |
778 | if (!uuid_compare (loc->gfid, priv->xattrop_vgfid)) { |
779 | make_index_dir_path (priv->index_basepath, XATTROP_SUBDIR"xattrop", |
780 | path, sizeof (path)); |
781 | is_dir = _gf_true; |
782 | } else if (!uuid_compare (loc->pargfid, priv->xattrop_vgfid)) { |
783 | make_file_path (priv->index_basepath, XATTROP_SUBDIR"xattrop", |
784 | loc->name, path, sizeof (path)); |
785 | } |
786 | |
787 | ret = lstat (path, &lstatbuf); |
788 | if (ret) { |
789 | gf_log (this->name, GF_LOG_DEBUG, "Stat failed on index dir "do { do { if (0) printf ("Stat failed on index dir " "(%s)", strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "index.c", __FUNCTION__, 790, GF_LOG_DEBUG, "Stat failed on index dir " "(%s)", strerror ((*__errno_location ()))); } while (0) |
790 | "(%s)", strerror (errno))do { do { if (0) printf ("Stat failed on index dir " "(%s)", strerror ((*__errno_location ()))); } while (0); _gf_log (this->name , "index.c", __FUNCTION__, 790, GF_LOG_DEBUG, "Stat failed on index dir " "(%s)", strerror ((*__errno_location ()))); } while (0); |
791 | op_errno = errno(*__errno_location ()); |
792 | goto done; |
793 | } else if (!S_ISDIR (lstatbuf.st_mode)((((lstatbuf.st_mode)) & 0170000) == (0040000)) && is_dir) { |
794 | gf_log (this->name, GF_LOG_DEBUG, "Stat failed on index dir, "do { do { if (0) printf ("Stat failed on index dir, " "not a directory" ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 795, GF_LOG_DEBUG, "Stat failed on index dir, " "not a directory" ); } while (0) |
795 | "not a directory")do { do { if (0) printf ("Stat failed on index dir, " "not a directory" ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 795, GF_LOG_DEBUG, "Stat failed on index dir, " "not a directory" ); } while (0); |
796 | op_errno = ENOENT2; |
797 | goto done; |
798 | } |
799 | xattr = dict_new (); |
800 | if (!xattr) { |
801 | op_errno = ENOMEM12; |
802 | goto done; |
803 | } |
804 | |
805 | iatt_from_stat (&stbuf, &lstatbuf); |
806 | if (is_dir) |
807 | uuid_copy (stbuf.ia_gfid, priv->xattrop_vgfid); |
808 | else |
809 | uuid_generate (stbuf.ia_gfid); |
810 | stbuf.ia_ino = -1; |
811 | op_ret = 0; |
812 | done: |
813 | STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno,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" , "index.c", __FUNCTION__, 814, 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, loc->inode, &stbuf, xattr, &postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0) |
814 | loc->inode, &stbuf, xattr, &postparent)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" , "index.c", __FUNCTION__, 814, 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, loc->inode, &stbuf, xattr, &postparent ); (*__glusterfs_this_location()) = old_THIS; } while (0); |
815 | if (xattr) |
816 | dict_unref (xattr); |
817 | return 0; |
818 | } |
819 | |
820 | int32_t |
821 | index_readdir_wrapper (call_frame_t *frame, xlator_t *this, |
822 | fd_t *fd, size_t size, off_t off, dict_t *xdata) |
823 | { |
824 | index_fd_ctx_t *fctx = NULL((void*)0); |
825 | DIR *dir = NULL((void*)0); |
826 | int ret = -1; |
827 | int32_t op_ret = -1; |
828 | int32_t op_errno = 0; |
829 | int count = 0; |
830 | gf_dirent_t entries; |
831 | |
832 | INIT_LIST_HEAD (&entries.list)do { (&entries.list)->next = (&entries.list)->prev = &entries.list; } while (0); |
833 | |
834 | ret = index_fd_ctx_get (fd, this, &fctx); |
835 | if (ret < 0) { |
836 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while ( 0); _gf_log (this->name, "index.c", __FUNCTION__, 837, GF_LOG_WARNING , "pfd is NULL, fd=%p", fd); } while (0) |
837 | "pfd is NULL, fd=%p", fd)do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while ( 0); _gf_log (this->name, "index.c", __FUNCTION__, 837, GF_LOG_WARNING , "pfd is NULL, fd=%p", fd); } while (0); |
838 | op_errno = -ret; |
839 | goto done; |
840 | } |
841 | |
842 | dir = fctx->dir; |
843 | |
844 | if (!dir) { |
845 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dir is NULL for fd=%p", fd); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 846, GF_LOG_WARNING , "dir is NULL for fd=%p", fd); } while (0) |
846 | "dir is NULL for fd=%p", fd)do { do { if (0) printf ("dir is NULL for fd=%p", fd); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 846, GF_LOG_WARNING , "dir is NULL for fd=%p", fd); } while (0); |
847 | op_errno = EINVAL22; |
848 | goto done; |
849 | } |
850 | |
851 | count = index_fill_readdir (fd, dir, off, size, &entries); |
852 | |
853 | /* pick ENOENT to indicate EOF */ |
854 | op_errno = errno(*__errno_location ()); |
855 | op_ret = count; |
856 | done: |
857 | STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, &entries, xdata)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" , "index.c", __FUNCTION__, 857, 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, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
858 | gf_dirent_free (&entries); |
859 | return 0; |
860 | } |
861 | |
862 | int |
863 | index_unlink_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flag, |
864 | dict_t *xdata) |
865 | { |
866 | index_priv_t *priv = NULL((void*)0); |
867 | int32_t op_ret = 0; |
868 | int32_t op_errno = 0; |
869 | int ret = 0; |
870 | struct iatt preparent = {0}; |
871 | struct iatt postparent = {0}; |
872 | char index_dir[PATH_MAX4096] = {0}; |
873 | struct stat lstatbuf = {0}; |
874 | uuid_t gfid = {0}; |
875 | |
876 | priv = this->private; |
877 | make_index_dir_path (priv->index_basepath, XATTROP_SUBDIR"xattrop", |
878 | index_dir, sizeof (index_dir)); |
879 | ret = lstat (index_dir, &lstatbuf); |
880 | if (ret < 0) { |
881 | op_ret = -1; |
882 | op_errno = errno(*__errno_location ()); |
883 | goto done; |
884 | } |
885 | |
886 | iatt_from_stat (&preparent, &lstatbuf); |
887 | uuid_copy (preparent.ia_gfid, priv->xattrop_vgfid); |
888 | preparent.ia_ino = -1; |
889 | uuid_parse (loc->name, gfid); |
890 | ret = index_del (this, gfid, XATTROP_SUBDIR"xattrop"); |
891 | if (ret < 0) { |
892 | op_ret = -1; |
893 | op_errno = -ret; |
894 | goto done; |
895 | } |
896 | memset (&lstatbuf, 0, sizeof (lstatbuf)); |
897 | ret = lstat (index_dir, &lstatbuf); |
898 | if (ret < 0) { |
899 | op_ret = -1; |
900 | op_errno = errno(*__errno_location ()); |
901 | goto done; |
902 | } |
903 | iatt_from_stat (&postparent, &lstatbuf); |
904 | uuid_copy (postparent.ia_gfid, priv->xattrop_vgfid); |
905 | postparent.ia_ino = -1; |
906 | done: |
907 | INDEX_STACK_UNWIND (unlink, frame, op_ret, op_errno, &preparent,do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } 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", "index.c", __FUNCTION__ , 908, 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, op_ret, op_errno, &preparent, &postparent, xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); } while (0) |
908 | &postparent, xdata)do { if (frame) { inode_t *_inode = frame->local; frame-> local = ((void*)0); inode_unref (_inode); } 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", "index.c", __FUNCTION__ , 908, 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, op_ret, op_errno, &preparent, &postparent, xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); } while (0); |
909 | return 0; |
910 | } |
911 | |
912 | int32_t |
913 | index_getxattr (call_frame_t *frame, xlator_t *this, |
914 | loc_t *loc, const char *name, dict_t *xdata) |
915 | { |
916 | call_stub_t *stub = NULL((void*)0); |
917 | |
918 | if (!name || strcmp (GF_XATTROP_INDEX_GFID"glusterfs.xattrop_index_gfid", name)) |
919 | goto out; |
920 | |
921 | stub = fop_getxattr_stub (frame, index_getxattr_wrapper, loc, name, |
922 | xdata); |
923 | if (!stub) { |
924 | STACK_UNWIND_STRICT (getxattr, frame, -1, ENOMEM, NULL, NULL)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" , "index.c", __FUNCTION__, 924, 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 , 12, ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); |
925 | return 0; |
926 | } |
927 | worker_enqueue (this, stub); |
928 | return 0; |
929 | out: |
930 | STACK_WIND (frame, default_getxattr_cbk, FIRST_CHILD(this),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", "index.c", __FUNCTION__, 931, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = default_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
931 | FIRST_CHILD(this)->fops->getxattr, loc, name, 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", "index.c", __FUNCTION__, 931, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = default_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
932 | return 0; |
933 | } |
934 | |
935 | int32_t |
936 | index_lookup (call_frame_t *frame, xlator_t *this, |
937 | loc_t *loc, dict_t *xattr_req) |
938 | { |
939 | call_stub_t *stub = NULL((void*)0); |
940 | index_priv_t *priv = NULL((void*)0); |
941 | |
942 | priv = this->private; |
943 | |
944 | if (uuid_compare (loc->gfid, priv->xattrop_vgfid) && |
945 | uuid_compare (loc->pargfid, priv->xattrop_vgfid)) |
946 | goto normal; |
947 | |
948 | stub = fop_lookup_stub (frame, index_lookup_wrapper, loc, xattr_req); |
949 | if (!stub) { |
950 | STACK_UNWIND_STRICT (lookup, frame, -1, ENOMEM, loc->inode,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" , "index.c", __FUNCTION__, 951, 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, loc->inode, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
951 | NULL, NULL, NULL)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" , "index.c", __FUNCTION__, 951, 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, loc->inode, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
952 | return 0; |
953 | } |
954 | worker_enqueue (this, stub); |
955 | return 0; |
956 | normal: |
957 | STACK_WIND (frame, default_lookup_cbk, FIRST_CHILD(this),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", "index.c", __FUNCTION__, 958, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = default_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0) |
958 | FIRST_CHILD(this)->fops->lookup, loc, 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", "index.c", __FUNCTION__, 958, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = default_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , xattr_req); (*__glusterfs_this_location()) = old_THIS; } while (0); |
959 | |
960 | return 0; |
961 | } |
962 | |
963 | int32_t |
964 | index_readdir (call_frame_t *frame, xlator_t *this, |
965 | fd_t *fd, size_t size, off_t off, dict_t *xdata) |
966 | { |
967 | call_stub_t *stub = NULL((void*)0); |
968 | index_priv_t *priv = NULL((void*)0); |
969 | |
970 | priv = this->private; |
971 | if (uuid_compare (fd->inode->gfid, priv->xattrop_vgfid)) |
972 | goto out; |
973 | stub = fop_readdir_stub (frame, index_readdir_wrapper, fd, size, off, |
974 | xdata); |
975 | if (!stub) { |
976 | STACK_UNWIND_STRICT (readdir, frame, -1, ENOMEM, NULL, NULL)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" , "index.c", __FUNCTION__, 976, 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 , 12, ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); |
977 | return 0; |
978 | } |
979 | worker_enqueue (this, stub); |
980 | return 0; |
981 | out: |
982 | STACK_WIND (frame, default_readdir_cbk, FIRST_CHILD(this),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", "index.c", __FUNCTION__, 983, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdir_cbk) tmp_cbk = default_readdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdir" ; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdir); (this->children->xlator )->fops->readdir (_new, (this->children->xlator), fd, size, off, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) |
983 | FIRST_CHILD(this)->fops->readdir, fd, size, off, 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", "index.c", __FUNCTION__, 983, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdir_cbk) tmp_cbk = default_readdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdir" ; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdir); (this->children->xlator )->fops->readdir (_new, (this->children->xlator), fd, size, off, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); |
984 | return 0; |
985 | } |
986 | |
987 | int |
988 | index_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, |
989 | dict_t *xdata) |
990 | { |
991 | call_stub_t *stub = NULL((void*)0); |
992 | index_priv_t *priv = NULL((void*)0); |
993 | |
994 | priv = this->private; |
995 | if (uuid_compare (loc->pargfid, priv->xattrop_vgfid)) |
996 | goto out; |
997 | |
998 | stub = fop_unlink_stub (frame, index_unlink_wrapper, loc, xflag, xdata); |
999 | if (!stub) { |
1000 | STACK_UNWIND_STRICT (unlink, frame, -1, ENOMEM, NULL, NULL,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" , "index.c", __FUNCTION__, 1001, 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 , 12, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) |
1001 | NULL)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" , "index.c", __FUNCTION__, 1001, 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 , 12, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); |
1002 | return 0; |
1003 | } |
1004 | worker_enqueue (this, stub); |
1005 | return 0; |
1006 | out: |
1007 | STACK_WIND (frame, default_unlink_cbk, FIRST_CHILD(this),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", "index.c", __FUNCTION__, 1008, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->unlink_cbk) tmp_cbk = default_unlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->unlink"; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->unlink); (this->children->xlator )->fops->unlink (_new, (this->children->xlator), loc , xflag, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) |
1008 | FIRST_CHILD(this)->fops->unlink, 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", "index.c", __FUNCTION__, 1008, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->unlink_cbk) tmp_cbk = default_unlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->unlink"; _new->unwind_to = "default_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 ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->unlink); (this->children->xlator )->fops->unlink (_new, (this->children->xlator), loc , xflag, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); |
1009 | return 0; |
1010 | } |
1011 | |
1012 | int32_t |
1013 | mem_acct_init (xlator_t *this) |
1014 | { |
1015 | int ret = -1; |
1016 | |
1017 | ret = xlator_mem_acct_init (this, gf_index_mt_end + 1); |
1018 | |
1019 | return ret; |
1020 | } |
1021 | |
1022 | int |
1023 | init (xlator_t *this) |
1024 | { |
1025 | int ret = -1; |
1026 | index_priv_t *priv = NULL((void*)0); |
1027 | pthread_t thread; |
1028 | pthread_attr_t w_attr; |
1029 | gf_boolean_t mutex_inited = _gf_false; |
1030 | gf_boolean_t cond_inited = _gf_false; |
1031 | gf_boolean_t attr_inited = _gf_false; |
1032 | |
1033 | if (!this->children || this->children->next) { |
1034 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("'index' not configured with exactly one child" ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1035, GF_LOG_ERROR, "'index' not configured with exactly one child" ); } while (0) |
1035 | "'index' not configured with exactly one child")do { do { if (0) printf ("'index' not configured with exactly one child" ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1035, GF_LOG_ERROR, "'index' not configured with exactly one child" ); } while (0); |
1036 | goto out; |
1037 | } |
1038 | |
1039 | if (!this->parents) { |
1040 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dangling volume. check volfile "); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 1041 , GF_LOG_WARNING, "dangling volume. check volfile "); } while (0) |
1041 | "dangling volume. check volfile ")do { do { if (0) printf ("dangling volume. check volfile "); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 1041 , GF_LOG_WARNING, "dangling volume. check volfile "); } while (0); |
1042 | } |
1043 | |
1044 | priv = GF_CALLOC (1, sizeof (*priv), gf_index_mt_priv_t)__gf_calloc (1, sizeof (*priv), gf_index_mt_priv_t); |
1045 | if (!priv) |
1046 | goto out; |
1047 | |
1048 | LOCK_INIT (&priv->lock)pthread_spin_init (&priv->lock, 0); |
1049 | if ((ret = pthread_cond_init(&priv->cond, NULL((void*)0))) != 0) { |
1050 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pthread_cond_init failed (%d)", ret ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1051, GF_LOG_ERROR, "pthread_cond_init failed (%d)", ret); } while (0) |
1051 | "pthread_cond_init failed (%d)", ret)do { do { if (0) printf ("pthread_cond_init failed (%d)", ret ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1051, GF_LOG_ERROR, "pthread_cond_init failed (%d)", ret); } while (0); |
1052 | goto out; |
1053 | } |
1054 | cond_inited = _gf_true; |
1055 | |
1056 | if ((ret = pthread_mutex_init(&priv->mutex, NULL((void*)0))) != 0) { |
1057 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pthread_mutex_init failed (%d)", ret ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1058, GF_LOG_ERROR, "pthread_mutex_init failed (%d)", ret); } while (0) |
1058 | "pthread_mutex_init failed (%d)", ret)do { do { if (0) printf ("pthread_mutex_init failed (%d)", ret ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1058, GF_LOG_ERROR, "pthread_mutex_init failed (%d)", ret); } while (0); |
1059 | goto out; |
1060 | } |
1061 | mutex_inited = _gf_true; |
1062 | |
1063 | if ((ret = pthread_attr_init (&w_attr)) != 0) { |
1064 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pthread_attr_init failed (%d)", ret ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1065, GF_LOG_ERROR, "pthread_attr_init failed (%d)", ret); } while (0) |
1065 | "pthread_attr_init failed (%d)", ret)do { do { if (0) printf ("pthread_attr_init failed (%d)", ret ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1065, GF_LOG_ERROR, "pthread_attr_init failed (%d)", ret); } while (0); |
1066 | goto out; |
1067 | } |
1068 | attr_inited = _gf_true; |
1069 | |
1070 | ret = pthread_attr_setstacksize (&w_attr, INDEX_THREAD_STACK_SIZE((size_t)(1024*1024))); |
1071 | if (ret == EINVAL22) { |
1072 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Using default thread stack size"); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 1073 , GF_LOG_WARNING, "Using default thread stack size"); } while (0) |
1073 | "Using default thread stack size")do { do { if (0) printf ("Using default thread stack size"); } while (0); _gf_log (this->name, "index.c", __FUNCTION__, 1073 , GF_LOG_WARNING, "Using default thread stack size"); } while (0); |
1074 | } |
1075 | GF_OPTION_INIT ("index-base", priv->index_basepath, path, out)do { int val_ret = 0; val_ret = xlator_option_init_path ((*__glusterfs_this_location ()), (*__glusterfs_this_location())->options, "index-base" , &(priv->index_basepath)); if (val_ret) goto out; } while (0); |
1076 | uuid_generate (priv->index); |
1077 | uuid_generate (priv->xattrop_vgfid); |
1078 | INIT_LIST_HEAD (&priv->callstubs)do { (&priv->callstubs)->next = (&priv->callstubs )->prev = &priv->callstubs; } while (0); |
1079 | |
1080 | this->private = priv; |
1081 | ret = pthread_create (&thread, &w_attr, index_worker, this); |
1082 | if (ret) { |
1083 | gf_log (this->name, GF_LOG_WARNING, "Failed to create "do { do { if (0) printf ("Failed to create " "worker thread, aborting" ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1084, GF_LOG_WARNING, "Failed to create " "worker thread, aborting" ); } while (0) |
1084 | "worker thread, aborting")do { do { if (0) printf ("Failed to create " "worker thread, aborting" ); } while (0); _gf_log (this->name, "index.c", __FUNCTION__ , 1084, GF_LOG_WARNING, "Failed to create " "worker thread, aborting" ); } while (0); |
1085 | goto out; |
1086 | } |
1087 | ret = 0; |
1088 | out: |
1089 | if (ret) { |
1090 | if (cond_inited) |
1091 | pthread_cond_destroy (&priv->cond); |
1092 | if (mutex_inited) |
1093 | pthread_mutex_destroy (&priv->mutex); |
1094 | if (priv) |
1095 | GF_FREE (priv)__gf_free (priv); |
1096 | this->private = NULL((void*)0); |
1097 | } |
1098 | if (attr_inited) |
1099 | pthread_attr_destroy (&w_attr); |
1100 | return ret; |
1101 | } |
1102 | |
1103 | void |
1104 | fini (xlator_t *this) |
1105 | { |
1106 | index_priv_t *priv = NULL((void*)0); |
1107 | |
1108 | priv = this->private; |
1109 | if (!priv) |
1110 | goto out; |
1111 | this->private = NULL((void*)0); |
1112 | LOCK_DESTROY (&priv->lock)pthread_spin_destroy (&priv->lock); |
1113 | pthread_cond_destroy (&priv->cond); |
1114 | pthread_mutex_destroy (&priv->mutex); |
1115 | GF_FREE (priv)__gf_free (priv); |
1116 | out: |
1117 | return; |
1118 | } |
1119 | |
1120 | int |
1121 | index_forget (xlator_t *this, inode_t *inode) |
1122 | { |
1123 | uint64_t tmp_cache = 0; |
1124 | if (!inode_ctx_del (inode, this, &tmp_cache)inode_ctx_del2(inode,this,&tmp_cache,0)) |
1125 | GF_FREE ((index_inode_ctx_t*) (long)tmp_cache)__gf_free ((index_inode_ctx_t*) (long)tmp_cache); |
1126 | |
1127 | return 0; |
1128 | } |
1129 | |
1130 | int32_t |
1131 | index_releasedir (xlator_t *this, fd_t *fd) |
1132 | { |
1133 | index_fd_ctx_t *fctx = NULL((void*)0); |
1134 | uint64_t ctx = 0; |
1135 | int ret = 0; |
1136 | |
1137 | ret = fd_ctx_del (fd, this, &ctx); |
1138 | if (ret < 0) |
1139 | goto out; |
1140 | |
1141 | fctx = (index_fd_ctx_t*) (long) ctx; |
1142 | if (fctx->dir) |
1143 | closedir (fctx->dir); |
1144 | |
1145 | GF_FREE (fctx)__gf_free (fctx); |
1146 | out: |
1147 | return 0; |
1148 | } |
1149 | |
1150 | int32_t |
1151 | index_release (xlator_t *this, fd_t *fd) |
1152 | { |
1153 | index_fd_ctx_t *fctx = NULL((void*)0); |
1154 | uint64_t ctx = 0; |
1155 | int ret = 0; |
1156 | |
1157 | ret = fd_ctx_del (fd, this, &ctx); |
1158 | if (ret < 0) |
1159 | goto out; |
1160 | |
1161 | fctx = (index_fd_ctx_t*) (long) ctx; |
1162 | GF_FREE (fctx)__gf_free (fctx); |
1163 | out: |
1164 | return 0; |
1165 | } |
1166 | |
1167 | int |
1168 | notify (xlator_t *this, int event, void *data, ...) |
1169 | { |
1170 | int ret = 0; |
1171 | ret = default_notify (this, event, data); |
1172 | return ret; |
1173 | } |
1174 | |
1175 | struct xlator_fops fops = { |
1176 | .xattrop = index_xattrop, |
1177 | .fxattrop = index_fxattrop, |
1178 | |
1179 | //interface functions follow |
1180 | .getxattr = index_getxattr, |
1181 | .lookup = index_lookup, |
1182 | .readdir = index_readdir, |
1183 | .unlink = index_unlink |
1184 | }; |
1185 | |
1186 | struct xlator_dumpops dumpops; |
1187 | |
1188 | struct xlator_cbks cbks = { |
1189 | .forget = index_forget, |
1190 | .release = index_release, |
1191 | .releasedir = index_releasedir |
1192 | }; |
1193 | |
1194 | struct volume_options options[] = { |
1195 | { .key = {"index-base" }, |
1196 | .type = GF_OPTION_TYPE_PATH, |
1197 | .description = "path where the index files need to be stored", |
1198 | }, |
1199 | { .key = {NULL((void*)0)} }, |
1200 | }; |