Bug Summary

File:xlators/cluster/dht/src/dht-rename.c
Location:line 76, column 17
Description:Access to field 'op_ret' results in a dereference of a null pointer (loaded from variable 'local')

Annotated Source Code

1/*
2 Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
3 This file is part of GlusterFS.
4
5 This file is licensed to you under your choice of the GNU Lesser
6 General Public License, version 3 or any later version (LGPLv3 or
7 later), or the GNU General Public License, version 2 (GPLv2), in all
8 cases as published by the Free Software Foundation.
9*/
10
11/* TODO: link(oldpath, newpath) fails if newpath already exists. DHT should
12 * delete the newpath if it gets EEXISTS from link() call.
13 */
14#ifndef _CONFIG_H
15#define _CONFIG_H
16#include "config.h"
17#endif
18
19#include "glusterfs.h"
20#include "xlator.h"
21#include "dht-common.h"
22#include "defaults.h"
23
24
25int
26dht_rename_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
27 int32_t op_ret, int32_t op_errno, struct iatt *stbuf,
28 struct iatt *preoldparent, struct iatt *postoldparent,
29 struct iatt *prenewparent, struct iatt *postnewparent,
30 dict_t *xdata)
31{
32 dht_local_t *local = NULL((void*)0);
33 int this_call_cnt = 0;
34 call_frame_t *prev = NULL((void*)0);
35
36 local = frame->local;
1
Value assigned to 'local'
37 prev = cookie;
38
39 if (op_ret == -1) {
2
Taking false branch
40 /* TODO: undo the damage */
41
42 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 45, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
43 "rename %s -> %s on %s failed (%s)",do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 45, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
44 local->loc.path, local->loc2.path,do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 45, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
45 prev->this->name, strerror (op_errno))do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 45, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
;
46
47 local->op_ret = op_ret;
48 local->op_errno = op_errno;
49 goto unwind;
50 }
51 /* TODO: construct proper stbuf for dir */
52 /*
53 * FIXME: is this the correct way to build stbuf and
54 * parent bufs?
55 */
56 dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
57 dht_iatt_merge (this, &local->preoldparent, preoldparent,
58 prev->this);
59 dht_iatt_merge (this, &local->postoldparent, postoldparent,
60 prev->this);
61 dht_iatt_merge (this, &local->preparent, prenewparent,
62 prev->this);
63 dht_iatt_merge (this, &local->postparent, postnewparent,
64 prev->this);
65
66
67unwind:
68 this_call_cnt = dht_frame_return (frame);
69 if (is_last_call (this_call_cnt)(this_call_cnt == 0)) {
3
Taking true branch
70 WIPE (&local->preoldparent)do { typeof(*&local->preoldparent) z = {0,}; if (&
local->preoldparent) *&local->preoldparent = z; } while
(0)
;
4
Within the expansion of the macro 'WIPE':
a
Assuming pointer value is null
71 WIPE (&local->postoldparent)do { typeof(*&local->postoldparent) z = {0,}; if (&
local->postoldparent) *&local->postoldparent = z; }
while (0)
;
72 WIPE (&local->preparent)do { typeof(*&local->preparent) z = {0,}; if (&local
->preparent) *&local->preparent = z; } while (0)
;
73 WIPE (&local->postparent)do { typeof(*&local->postparent) z = {0,}; if (&local
->postparent) *&local->postparent = z; } while (0)
;
74
75 DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local->
stbuf)->ia_type == IA_IFREG) && ((&local->stbuf
)->ia_prot.sticky == 1) && ((&local->stbuf)
->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot
.sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } }
while (0)
;
76 DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 79, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (
fop_rename_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, xdata)
; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe
(__xl, __local); } while (0)
5
Within the expansion of the macro 'DHT_STACK_UNWIND':
a
Access to field 'op_ret' results in a dereference of a null pointer (loaded from variable 'local')
77 &local->stbuf, &local->preoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 79, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (
fop_rename_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, xdata)
; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe
(__xl, __local); } while (0)
78 &local->postoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 79, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (
fop_rename_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, xdata)
; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe
(__xl, __local); } while (0)
79 &local->preparent, &local->postparent, xdata)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 79, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn = (
fop_rename_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock
(&frame->root->stack_lock); { _parent->ref_count
--; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, xdata)
; (*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe
(__xl, __local); } while (0)
;
80 }
81
82 return 0;
83}
84
85
86int
87dht_rename_hashed_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
88 int32_t op_ret, int32_t op_errno, struct iatt *stbuf,
89 struct iatt *preoldparent,
90 struct iatt *postoldparent,
91 struct iatt *prenewparent,
92 struct iatt *postnewparent, dict_t *xdata)
93{
94 dht_conf_t *conf = NULL((void*)0);
95 dht_local_t *local = NULL((void*)0);
96 int call_cnt = 0;
97 call_frame_t *prev = NULL((void*)0);
98 int i = 0;
99
100 conf = this->private;
101 local = frame->local;
102 prev = cookie;
103
104 if (op_ret == -1) {
105 /* TODO: undo the damage */
106
107 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 110, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
108 "rename %s -> %s on %s failed (%s)",do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 110, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
109 local->loc.path, local->loc2.path,do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 110, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
110 prev->this->name, strerror (op_errno))do { do { if (0) printf ("rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0); _gf_log (this->name
, "dht-rename.c", __FUNCTION__, 110, GF_LOG_INFO, "rename %s -> %s on %s failed (%s)"
, local->loc.path, local->loc2.path, prev->this->
name, strerror (op_errno)); } while (0)
;
111
112 local->op_ret = op_ret;
113 local->op_errno = op_errno;
114 goto unwind;
115 }
116 /* TODO: construct proper stbuf for dir */
117 /*
118 * FIXME: is this the correct way to build stbuf and
119 * parent bufs?
120 */
121 dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
122 dht_iatt_merge (this, &local->preoldparent, preoldparent,
123 prev->this);
124 dht_iatt_merge (this, &local->postoldparent, postoldparent,
125 prev->this);
126 dht_iatt_merge (this, &local->preparent, prenewparent,
127 prev->this);
128 dht_iatt_merge (this, &local->postparent, postnewparent,
129 prev->this);
130
131 call_cnt = local->call_cnt = conf->subvolume_cnt - 1;
132
133 if (!local->call_cnt)
134 goto unwind;
135
136 for (i = 0; i < conf->subvolume_cnt; i++) {
137 if (conf->subvolumes[i] == local->dst_hashed)
138 continue;
139 STACK_WIND (frame, dht_rename_dir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->rename_cbk) tmp_cbk = dht_rename_dir_cbk; _new
->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->rename"; _new
->unwind_to = "dht_rename_dir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->rename); conf->subvolumes[i]->fops->
rename (_new, conf->subvolumes[i], &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
140 conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->rename_cbk) tmp_cbk = dht_rename_dir_cbk; _new
->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->rename"; _new
->unwind_to = "dht_rename_dir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->rename); conf->subvolumes[i]->fops->
rename (_new, conf->subvolumes[i], &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
141 conf->subvolumes[i]->fops->rename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->rename_cbk) tmp_cbk = dht_rename_dir_cbk; _new
->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->rename"; _new
->unwind_to = "dht_rename_dir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->rename); conf->subvolumes[i]->fops->
rename (_new, conf->subvolumes[i], &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
142 &local->loc, &local->loc2, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 142, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->rename_cbk) tmp_cbk = dht_rename_dir_cbk; _new
->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->rename"; _new
->unwind_to = "dht_rename_dir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->rename); conf->subvolumes[i]->fops->
rename (_new, conf->subvolumes[i], &local->loc, &
local->loc2, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
143 if (!--call_cnt)
144 break;
145 }
146
147
148 return 0;
149unwind:
150 WIPE (&local->preoldparent)do { typeof(*&local->preoldparent) z = {0,}; if (&
local->preoldparent) *&local->preoldparent = z; } while
(0)
;
151 WIPE (&local->postoldparent)do { typeof(*&local->postoldparent) z = {0,}; if (&
local->postoldparent) *&local->postoldparent = z; }
while (0)
;
152 WIPE (&local->preparent)do { typeof(*&local->preparent) z = {0,}; if (&local
->preparent) *&local->preparent = z; } while (0)
;
153 WIPE (&local->postparent)do { typeof(*&local->postparent) z = {0,}; if (&local
->postparent) *&local->postparent = z; } while (0)
;
154
155 DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local->
stbuf)->ia_type == IA_IFREG) && ((&local->stbuf
)->ia_prot.sticky == 1) && ((&local->stbuf)
->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot
.sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } }
while (0)
;
156 DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 159, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
157 &local->stbuf, &local->preoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 159, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
158 &local->postoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 159, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
159 &local->preparent, &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 159, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
;
160
161 return 0;
162}
163
164
165int
166dht_rename_dir_do (call_frame_t *frame, xlator_t *this)
167{
168 dht_local_t *local = NULL((void*)0);
169
170 local = frame->local;
171
172 if (local->op_ret == -1)
173 goto err;
174
175 local->op_ret = 0;
176
177 STACK_WIND (frame, dht_rename_hashed_dir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 180, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( local->dst_hashed
->fops->rename_cbk) tmp_cbk = dht_rename_hashed_dir_cbk
; _new->root = frame->root; _new->this = local->dst_hashed
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "local->dst_hashed->fops->rename"; _new
->unwind_to = "dht_rename_hashed_dir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = local->dst_hashed; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, local->dst_hashed->fops->rename
); local->dst_hashed->fops->rename (_new, local->
dst_hashed, &local->loc, &local->loc2, ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
178 local->dst_hashed,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 180, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( local->dst_hashed
->fops->rename_cbk) tmp_cbk = dht_rename_hashed_dir_cbk
; _new->root = frame->root; _new->this = local->dst_hashed
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "local->dst_hashed->fops->rename"; _new
->unwind_to = "dht_rename_hashed_dir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = local->dst_hashed; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, local->dst_hashed->fops->rename
); local->dst_hashed->fops->rename (_new, local->
dst_hashed, &local->loc, &local->loc2, ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
179 local->dst_hashed->fops->rename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 180, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( local->dst_hashed
->fops->rename_cbk) tmp_cbk = dht_rename_hashed_dir_cbk
; _new->root = frame->root; _new->this = local->dst_hashed
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "local->dst_hashed->fops->rename"; _new
->unwind_to = "dht_rename_hashed_dir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = local->dst_hashed; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, local->dst_hashed->fops->rename
); local->dst_hashed->fops->rename (_new, local->
dst_hashed, &local->loc, &local->loc2, ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
180 &local->loc, &local->loc2, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 180, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( local->dst_hashed
->fops->rename_cbk) tmp_cbk = dht_rename_hashed_dir_cbk
; _new->root = frame->root; _new->this = local->dst_hashed
; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame;
_new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "local->dst_hashed->fops->rename"; _new
->unwind_to = "dht_rename_hashed_dir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = local->dst_hashed; if (frame->this->ctx->measure_latency
) gf_latency_begin (_new, local->dst_hashed->fops->rename
); local->dst_hashed->fops->rename (_new, local->
dst_hashed, &local->loc, &local->loc2, ((void*)
0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
181 return 0;
182
183err:
184 DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 185, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, ((void*)0), (
(void*)0), ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (
*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe
(__xl, __local); } while (0)
185 NULL, NULL, NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 185, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, ((void*)0), (
(void*)0), ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (
*__glusterfs_this_location()) = old_THIS; } while (0); dht_local_wipe
(__xl, __local); } while (0)
;
186 return 0;
187}
188
189
190int
191dht_rename_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
192 int op_ret, int op_errno, gf_dirent_t *entries,
193 dict_t *xdata)
194{
195 dht_local_t *local = NULL((void*)0);
196 int this_call_cnt = -1;
197 call_frame_t *prev = NULL((void*)0);
198
199 local = frame->local;
200 prev = cookie;
201
202 if (op_ret > 2) {
203 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("readdir on %s for %s returned %d entries"
, prev->this->name, local->loc.path, op_ret); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 205
, GF_LOG_TRACE, "readdir on %s for %s returned %d entries", prev
->this->name, local->loc.path, op_ret); } while (0)
204 "readdir on %s for %s returned %d entries",do { do { if (0) printf ("readdir on %s for %s returned %d entries"
, prev->this->name, local->loc.path, op_ret); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 205
, GF_LOG_TRACE, "readdir on %s for %s returned %d entries", prev
->this->name, local->loc.path, op_ret); } while (0)
205 prev->this->name, local->loc.path, op_ret)do { do { if (0) printf ("readdir on %s for %s returned %d entries"
, prev->this->name, local->loc.path, op_ret); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 205
, GF_LOG_TRACE, "readdir on %s for %s returned %d entries", prev
->this->name, local->loc.path, op_ret); } while (0)
;
206 local->op_ret = -1;
207 local->op_errno = ENOTEMPTY39;
208 }
209
210 this_call_cnt = dht_frame_return (frame);
211
212 if (is_last_call (this_call_cnt)(this_call_cnt == 0)) {
213 dht_rename_dir_do (frame, this);
214 }
215
216 return 0;
217}
218
219
220int
221dht_rename_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
222 int op_ret, int op_errno, fd_t *fd, dict_t *xdata)
223{
224 dht_local_t *local = NULL((void*)0);
225 int this_call_cnt = -1;
226 call_frame_t *prev = NULL((void*)0);
227
228
229 local = frame->local;
230 prev = cookie;
231
232 if (op_ret == -1) {
233 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev
->this->name, local->loc.path, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 236, GF_LOG_INFO, "opendir on %s for %s failed (%s)", prev->
this->name, local->loc.path, strerror (op_errno)); } while
(0)
234 "opendir on %s for %s failed (%s)",do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev
->this->name, local->loc.path, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 236, GF_LOG_INFO, "opendir on %s for %s failed (%s)", prev->
this->name, local->loc.path, strerror (op_errno)); } while
(0)
235 prev->this->name, local->loc.path,do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev
->this->name, local->loc.path, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 236, GF_LOG_INFO, "opendir on %s for %s failed (%s)", prev->
this->name, local->loc.path, strerror (op_errno)); } while
(0)
236 strerror (op_errno))do { do { if (0) printf ("opendir on %s for %s failed (%s)", prev
->this->name, local->loc.path, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 236, GF_LOG_INFO, "opendir on %s for %s failed (%s)", prev->
this->name, local->loc.path, strerror (op_errno)); } while
(0)
;
237 goto err;
238 }
239
240 STACK_WIND (frame, dht_rename_readdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 242, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( prev->this
->fops->readdir_cbk) tmp_cbk = dht_rename_readdir_cbk; _new
->root = frame->root; _new->this = prev->this; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "prev->this->fops->readdir"; _new->unwind_to =
"dht_rename_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()) = prev->this; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, prev->this->fops->readdir); prev->this->fops
->readdir (_new, prev->this, local->fd, 4096, 0, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
241 prev->this, prev->this->fops->readdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 242, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( prev->this
->fops->readdir_cbk) tmp_cbk = dht_rename_readdir_cbk; _new
->root = frame->root; _new->this = prev->this; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "prev->this->fops->readdir"; _new->unwind_to =
"dht_rename_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()) = prev->this; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, prev->this->fops->readdir); prev->this->fops
->readdir (_new, prev->this, local->fd, 4096, 0, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
242 local->fd, 4096, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 242, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( prev->this
->fops->readdir_cbk) tmp_cbk = dht_rename_readdir_cbk; _new
->root = frame->root; _new->this = prev->this; _new
->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->
cookie = _new; _new->wind_from = __FUNCTION__; _new->wind_to
= "prev->this->fops->readdir"; _new->unwind_to =
"dht_rename_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()) = prev->this; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, prev->this->fops->readdir); prev->this->fops
->readdir (_new, prev->this, local->fd, 4096, 0, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
243
244 return 0;
245
246err:
247 this_call_cnt = dht_frame_return (frame);
248
249 if (is_last_call (this_call_cnt)(this_call_cnt == 0)) {
250 dht_rename_dir_do (frame, this);
251 }
252
253 return 0;
254}
255
256
257int
258dht_rename_dir (call_frame_t *frame, xlator_t *this)
259{
260 dht_conf_t *conf = NULL((void*)0);
261 dht_local_t *local = NULL((void*)0);
262 int i = 0;
263 int op_errno = -1;
264
265
266 conf = frame->this->private;
267 local = frame->local;
268
269 local->call_cnt = conf->subvolume_cnt;
270
271 for (i = 0; i < conf->subvolume_cnt; i++) {
272 if (!conf->subvolume_status[i]) {
273 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("one of the subvolumes down (%s)", conf
->subvolumes[i]->name); } while (0); _gf_log (this->
name, "dht-rename.c", __FUNCTION__, 275, GF_LOG_INFO, "one of the subvolumes down (%s)"
, conf->subvolumes[i]->name); } while (0)
274 "one of the subvolumes down (%s)",do { do { if (0) printf ("one of the subvolumes down (%s)", conf
->subvolumes[i]->name); } while (0); _gf_log (this->
name, "dht-rename.c", __FUNCTION__, 275, GF_LOG_INFO, "one of the subvolumes down (%s)"
, conf->subvolumes[i]->name); } while (0)
275 conf->subvolumes[i]->name)do { do { if (0) printf ("one of the subvolumes down (%s)", conf
->subvolumes[i]->name); } while (0); _gf_log (this->
name, "dht-rename.c", __FUNCTION__, 275, GF_LOG_INFO, "one of the subvolumes down (%s)"
, conf->subvolumes[i]->name); } while (0)
;
276 op_errno = ENOTCONN107;
277 goto err;
278 }
279 }
280
281 local->fd = fd_create (local->loc.inode, frame->root->pid);
282 if (!local->fd) {
283 op_errno = ENOMEM12;
284 goto err;
285 }
286
287 local->op_ret = 0;
288
289 if (!local->dst_cached) {
290 dht_rename_dir_do (frame, this);
291 return 0;
292 }
293
294 for (i = 0; i < conf->subvolume_cnt; i++) {
295 STACK_WIND (frame, dht_rename_opendir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 298, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->opendir_cbk) tmp_cbk = dht_rename_opendir_cbk
; _new->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->opendir";
_new->unwind_to = "dht_rename_opendir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->opendir); conf->subvolumes[i]->fops->
opendir (_new, conf->subvolumes[i], &local->loc2, local
->fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
296 conf->subvolumes[i],do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 298, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->opendir_cbk) tmp_cbk = dht_rename_opendir_cbk
; _new->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->opendir";
_new->unwind_to = "dht_rename_opendir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->opendir); conf->subvolumes[i]->fops->
opendir (_new, conf->subvolumes[i], &local->loc2, local
->fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
297 conf->subvolumes[i]->fops->opendir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 298, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->opendir_cbk) tmp_cbk = dht_rename_opendir_cbk
; _new->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->opendir";
_new->unwind_to = "dht_rename_opendir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->opendir); conf->subvolumes[i]->fops->
opendir (_new, conf->subvolumes[i], &local->loc2, local
->fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
298 &local->loc2, local->fd, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 298, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( conf->subvolumes
[i]->fops->opendir_cbk) tmp_cbk = dht_rename_opendir_cbk
; _new->root = frame->root; _new->this = conf->subvolumes
[i]; _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame
; _new->cookie = _new; _new->wind_from = __FUNCTION__; _new
->wind_to = "conf->subvolumes[i]->fops->opendir";
_new->unwind_to = "dht_rename_opendir_cbk"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = conf->subvolumes[i]; if (frame->this->ctx->
measure_latency) gf_latency_begin (_new, conf->subvolumes[
i]->fops->opendir); conf->subvolumes[i]->fops->
opendir (_new, conf->subvolumes[i], &local->loc2, local
->fd, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
299 }
300
301 return 0;
302
303err:
304 op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno;
305 DHT_STACK_UNWIND (rename, frame, -1, op_errno, NULL, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 306, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), (
(void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); }
while (0)
306 NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 306, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), (
(void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); }
while (0)
;
307 return 0;
308}
309
310
311int
312dht_rename_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
313 int32_t op_ret, int32_t op_errno, struct iatt *preparent,
314 struct iatt *postparent, dict_t *xdata)
315{
316 dht_local_t *local = NULL((void*)0);
317 call_frame_t *prev = NULL((void*)0);
318 int this_call_cnt = 0;
319
320 local = frame->local;
321 prev = cookie;
322
323 if (!local) {
324 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("!local, should not happen"); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 325
, GF_LOG_ERROR, "!local, should not happen"); } while (0)
325 "!local, should not happen")do { do { if (0) printf ("!local, should not happen"); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 325
, GF_LOG_ERROR, "!local, should not happen"); } while (0)
;
326 goto out;
327 }
328
329 this_call_cnt = dht_frame_return (frame);
330
331 if (op_ret == -1) {
332 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: unlink on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 334, GF_LOG_WARNING, "%s: unlink on %s failed (%s)", local->
loc.path, prev->this->name, strerror (op_errno)); } while
(0)
333 "%s: unlink on %s failed (%s)",do { do { if (0) printf ("%s: unlink on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 334, GF_LOG_WARNING, "%s: unlink on %s failed (%s)", local->
loc.path, prev->this->name, strerror (op_errno)); } while
(0)
334 local->loc.path, prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s: unlink on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 334, GF_LOG_WARNING, "%s: unlink on %s failed (%s)", local->
loc.path, prev->this->name, strerror (op_errno)); } while
(0)
;
335 }
336
337 WIPE (&local->preoldparent)do { typeof(*&local->preoldparent) z = {0,}; if (&
local->preoldparent) *&local->preoldparent = z; } while
(0)
;
338 WIPE (&local->postoldparent)do { typeof(*&local->postoldparent) z = {0,}; if (&
local->postoldparent) *&local->postoldparent = z; }
while (0)
;
339 WIPE (&local->preparent)do { typeof(*&local->preparent) z = {0,}; if (&local
->preparent) *&local->preparent = z; } while (0)
;
340 WIPE (&local->postparent)do { typeof(*&local->postparent) z = {0,}; if (&local
->postparent) *&local->postparent = z; } while (0)
;
341
342 if (is_last_call (this_call_cnt)(this_call_cnt == 0)) {
343 DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local->
stbuf)->ia_type == IA_IFREG) && ((&local->stbuf
)->ia_prot.sticky == 1) && ((&local->stbuf)
->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot
.sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } }
while (0)
;
344 DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 347, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
345 &local->stbuf, &local->preoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 347, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
346 &local->postoldparent, &local->preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 347, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
347 &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 347, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
;
348 }
349
350out:
351 return 0;
352}
353
354
355int
356dht_rename_cleanup (call_frame_t *frame)
357{
358 dht_local_t *local = NULL((void*)0);
359 xlator_t *this = NULL((void*)0);
360 xlator_t *src_hashed = NULL((void*)0);
361 xlator_t *src_cached = NULL((void*)0);
362 xlator_t *dst_hashed = NULL((void*)0);
363 xlator_t *dst_cached = NULL((void*)0);
364 int call_cnt = 0;
365
366
367 local = frame->local;
368 this = frame->this;
369
370 src_hashed = local->src_hashed;
371 src_cached = local->src_cached;
372 dst_hashed = local->dst_hashed;
373 dst_cached = local->dst_cached;
374
375 if (src_cached == dst_cached)
376 goto nolinks;
377
378 if (dst_hashed != src_hashed && dst_hashed != src_cached)
379 call_cnt++;
380
381 if (src_cached != dst_hashed)
382 call_cnt++;
383
384 local->call_cnt = call_cnt;
385
386 if (!call_cnt)
387 goto nolinks;
388
389 if (dst_hashed != src_hashed && dst_hashed != src_cached) {
390 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("unlinking linkfile %s @ %s => %s"
, local->loc.path, dst_hashed->name, src_cached->name
); } while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 392, GF_LOG_TRACE, "unlinking linkfile %s @ %s => %s", local
->loc.path, dst_hashed->name, src_cached->name); } while
(0)
391 "unlinking linkfile %s @ %s => %s",do { do { if (0) printf ("unlinking linkfile %s @ %s => %s"
, local->loc.path, dst_hashed->name, src_cached->name
); } while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 392, GF_LOG_TRACE, "unlinking linkfile %s @ %s => %s", local
->loc.path, dst_hashed->name, src_cached->name); } while
(0)
392 local->loc.path, dst_hashed->name, src_cached->name)do { do { if (0) printf ("unlinking linkfile %s @ %s => %s"
, local->loc.path, dst_hashed->name, src_cached->name
); } while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 392, GF_LOG_TRACE, "unlinking linkfile %s @ %s => %s", local
->loc.path, dst_hashed->name, src_cached->name); } while
(0)
;
393 STACK_WIND (frame, dht_rename_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 395, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = dst_hashed; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_hashed->fops->unlink"; _new->unwind_to = "dht_rename_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()) = dst_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_hashed
->fops->unlink); dst_hashed->fops->unlink (_new, dst_hashed
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
394 dst_hashed, dst_hashed->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 395, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = dst_hashed; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_hashed->fops->unlink"; _new->unwind_to = "dht_rename_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()) = dst_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_hashed
->fops->unlink); dst_hashed->fops->unlink (_new, dst_hashed
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
395 &local->loc, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 395, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = dst_hashed; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_hashed->fops->unlink"; _new->unwind_to = "dht_rename_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()) = dst_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_hashed
->fops->unlink); dst_hashed->fops->unlink (_new, dst_hashed
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
396 }
397
398 if (src_cached != dst_hashed) {
399 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("unlinking link %s => %s (%s)", local
->loc.path, local->loc2.path, src_cached->name); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 401
, GF_LOG_TRACE, "unlinking link %s => %s (%s)", local->
loc.path, local->loc2.path, src_cached->name); } while (
0)
400 "unlinking link %s => %s (%s)", local->loc.path,do { do { if (0) printf ("unlinking link %s => %s (%s)", local
->loc.path, local->loc2.path, src_cached->name); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 401
, GF_LOG_TRACE, "unlinking link %s => %s (%s)", local->
loc.path, local->loc2.path, src_cached->name); } while (
0)
401 local->loc2.path, src_cached->name)do { do { if (0) printf ("unlinking link %s => %s (%s)", local
->loc.path, local->loc2.path, src_cached->name); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 401
, GF_LOG_TRACE, "unlinking link %s => %s (%s)", local->
loc.path, local->loc2.path, src_cached->name); } while (
0)
;
402 STACK_WIND (frame, dht_rename_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 404, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->unlink); src_cached->fops->unlink (_new, src_cached
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
403 src_cached, src_cached->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 404, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->unlink); src_cached->fops->unlink (_new, src_cached
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
404 &local->loc2, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 404, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->unlink); src_cached->fops->unlink (_new, src_cached
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
405 }
406
407 return 0;
408
409nolinks:
410 WIPE (&local->preoldparent)do { typeof(*&local->preoldparent) z = {0,}; if (&
local->preoldparent) *&local->preoldparent = z; } while
(0)
;
411 WIPE (&local->postoldparent)do { typeof(*&local->postoldparent) z = {0,}; if (&
local->postoldparent) *&local->postoldparent = z; }
while (0)
;
412 WIPE (&local->preparent)do { typeof(*&local->preparent) z = {0,}; if (&local
->preparent) *&local->preparent = z; } while (0)
;
413 WIPE (&local->postparent)do { typeof(*&local->postparent) z = {0,}; if (&local
->postparent) *&local->postparent = z; } while (0)
;
414
415 DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local->
stbuf)->ia_type == IA_IFREG) && ((&local->stbuf
)->ia_prot.sticky == 1) && ((&local->stbuf)
->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot
.sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } }
while (0)
;
416 DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 419, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
417 &local->stbuf, &local->preoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 419, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
418 &local->postoldparent, &local->preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 419, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
419 &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 419, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
;
420
421 return 0;
422}
423
424
425int
426dht_rename_links_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
427 int32_t op_ret, int32_t op_errno,
428 inode_t *inode, struct iatt *stbuf,
429 struct iatt *preparent, struct iatt *postparent,
430 dict_t *xdata)
431{
432 call_frame_t *prev = NULL((void*)0);
433 dht_local_t *local = NULL((void*)0);
434
435 prev = cookie;
436 local = frame->local;
437
438 if (op_ret == -1) {
439 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("link/file %s on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 441, GF_LOG_WARNING, "link/file %s on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0)
440 "link/file %s on %s failed (%s)",do { do { if (0) printf ("link/file %s on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 441, GF_LOG_WARNING, "link/file %s on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0)
441 local->loc.path, prev->this->name, strerror (op_errno))do { do { if (0) printf ("link/file %s on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 441, GF_LOG_WARNING, "link/file %s on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0)
;
442 }
443
444 if (local->linked == _gf_true) {
445 local->linked = _gf_false;
446 dht_linkfile_attr_heal (frame, this);
447 }
448 DHT_STACK_DESTROY (frame)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); __xl = frame->this; __local = frame->local; frame
->local = ((void*)0); STACK_DESTROY (frame->root); dht_local_wipe
(__xl, __local); } while (0)
;
449
450 return 0;
451}
452
453
454int
455dht_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
456 int32_t op_ret, int32_t op_errno, struct iatt *stbuf,
457 struct iatt *preoldparent, struct iatt *postoldparent,
458 struct iatt *prenewparent, struct iatt *postnewparent,
459 dict_t *xdata)
460{
461 dht_local_t *local = NULL((void*)0);
462 call_frame_t *prev = NULL((void*)0);
463 xlator_t *src_hashed = NULL((void*)0);
464 xlator_t *src_cached = NULL((void*)0);
465 xlator_t *dst_hashed = NULL((void*)0);
466 xlator_t *dst_cached = NULL((void*)0);
467 xlator_t *rename_subvol = NULL((void*)0);
468 call_frame_t *link_frame = NULL((void*)0);
469 dht_local_t *link_local = NULL((void*)0);
470
471 local = frame->local;
472 prev = cookie;
473
474 src_hashed = local->src_hashed;
475 src_cached = local->src_cached;
476 dst_hashed = local->dst_hashed;
477 dst_cached = local->dst_cached;
478
479 if (op_ret == -1) {
480 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: rename on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 482, GF_LOG_WARNING, "%s: rename on %s failed (%s)", local->
loc.path, prev->this->name, strerror (op_errno)); } while
(0)
481 "%s: rename on %s failed (%s)", local->loc.path,do { do { if (0) printf ("%s: rename on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 482, GF_LOG_WARNING, "%s: rename on %s failed (%s)", local->
loc.path, prev->this->name, strerror (op_errno)); } while
(0)
482 prev->this->name, strerror (op_errno))do { do { if (0) printf ("%s: rename on %s failed (%s)", local
->loc.path, prev->this->name, strerror (op_errno)); }
while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 482, GF_LOG_WARNING, "%s: rename on %s failed (%s)", local->
loc.path, prev->this->name, strerror (op_errno)); } while
(0)
;
483 local->op_ret = op_ret;
484 local->op_errno = op_errno;
485 goto cleanup;
486 }
487
488 if ((src_cached == dst_cached) && (dst_hashed != dst_cached)) {
489 link_frame = copy_frame (frame);
490 if (!link_frame) {
491 goto err;
492 }
493
494 /* fop value sent as maxvalue because it is not used
495 anywhere in this case */
496 link_local = dht_local_init (link_frame, &local->loc2, NULL((void*)0),
497 GF_FOP_MAXVALUE);
498 if (!link_local) {
499 goto err;
500 }
501
502 if (link_local->loc.inode)
503 inode_unref (link_local->loc.inode);
504 link_local->loc.inode = inode_ref (local->loc.inode);
505 uuid_copy (link_local->gfid, local->loc.inode->gfid);
506
507 dht_linkfile_create (link_frame, dht_rename_links_create_cbk,
508 this, src_cached, dst_hashed,
509 &link_local->loc);
510 }
511
512err:
513 dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
514 dht_iatt_merge (this, &local->preoldparent, preoldparent, prev->this);
515 dht_iatt_merge (this, &local->postoldparent, postoldparent, prev->this);
516 dht_iatt_merge (this, &local->preparent, prenewparent, prev->this);
517 dht_iatt_merge (this, &local->postparent, postnewparent, prev->this);
518
519 if (local->linked == _gf_true) {
520 local->linked = _gf_false;
521 dht_linkfile_attr_heal (frame, this);
522 }
523
524 /* NOTE: rename_subvol is the same subvolume from which dht_rename_cbk
525 * is called. since rename has already happened on rename_subvol,
526 * unlink should not be sent for oldpath (either linkfile or cached-file)
527 * on rename_subvol. */
528 if (src_cached == dst_cached)
529 rename_subvol = src_cached;
530 else
531 rename_subvol = dst_hashed;
532
533 /* TODO: delete files in background */
534
535 if (src_cached != dst_hashed && src_cached != dst_cached)
536 local->call_cnt++;
537
538 if (src_hashed != rename_subvol && src_hashed != src_cached)
539 local->call_cnt++;
540
541 if (dst_cached && dst_cached != dst_hashed && dst_cached != src_cached)
542 local->call_cnt++;
543
544 if (local->call_cnt == 0)
545 goto unwind;
546
547 if (src_cached != dst_hashed && src_cached != dst_cached) {
548 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("deleting old src datafile %s @ %s",
local->loc.path, src_cached->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 550, GF_LOG_TRACE
, "deleting old src datafile %s @ %s", local->loc.path, src_cached
->name); } while (0)
549 "deleting old src datafile %s @ %s",do { do { if (0) printf ("deleting old src datafile %s @ %s",
local->loc.path, src_cached->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 550, GF_LOG_TRACE
, "deleting old src datafile %s @ %s", local->loc.path, src_cached
->name); } while (0)
550 local->loc.path, src_cached->name)do { do { if (0) printf ("deleting old src datafile %s @ %s",
local->loc.path, src_cached->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 550, GF_LOG_TRACE
, "deleting old src datafile %s @ %s", local->loc.path, src_cached
->name); } while (0)
;
551
552 STACK_WIND (frame, dht_rename_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 554, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->unlink); src_cached->fops->unlink (_new, src_cached
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
553 src_cached, src_cached->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 554, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->unlink); src_cached->fops->unlink (_new, src_cached
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
554 &local->loc, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 554, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->unlink); src_cached->fops->unlink (_new, src_cached
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
555 }
556
557 if (src_hashed != rename_subvol && src_hashed != src_cached) {
558 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("deleting old src linkfile %s @ %s",
local->loc.path, src_hashed->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 560, GF_LOG_TRACE
, "deleting old src linkfile %s @ %s", local->loc.path, src_hashed
->name); } while (0)
559 "deleting old src linkfile %s @ %s",do { do { if (0) printf ("deleting old src linkfile %s @ %s",
local->loc.path, src_hashed->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 560, GF_LOG_TRACE
, "deleting old src linkfile %s @ %s", local->loc.path, src_hashed
->name); } while (0)
560 local->loc.path, src_hashed->name)do { do { if (0) printf ("deleting old src linkfile %s @ %s",
local->loc.path, src_hashed->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 560, GF_LOG_TRACE
, "deleting old src linkfile %s @ %s", local->loc.path, src_hashed
->name); } while (0)
;
561
562 STACK_WIND (frame, dht_rename_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 564, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_hashed; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_hashed->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_hashed
->fops->unlink); src_hashed->fops->unlink (_new, src_hashed
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
563 src_hashed, src_hashed->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 564, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_hashed; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_hashed->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_hashed
->fops->unlink); src_hashed->fops->unlink (_new, src_hashed
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
564 &local->loc, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 564, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = src_hashed; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_hashed->fops->unlink"; _new->unwind_to = "dht_rename_unlink_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_hashed
->fops->unlink); src_hashed->fops->unlink (_new, src_hashed
, &local->loc, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
565 }
566
567 if (dst_cached
568 && (dst_cached != dst_hashed)
569 && (dst_cached != src_cached)) {
570 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("deleting old dst datafile %s @ %s",
local->loc2.path, dst_cached->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 572, GF_LOG_TRACE
, "deleting old dst datafile %s @ %s", local->loc2.path, dst_cached
->name); } while (0)
571 "deleting old dst datafile %s @ %s",do { do { if (0) printf ("deleting old dst datafile %s @ %s",
local->loc2.path, dst_cached->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 572, GF_LOG_TRACE
, "deleting old dst datafile %s @ %s", local->loc2.path, dst_cached
->name); } while (0)
572 local->loc2.path, dst_cached->name)do { do { if (0) printf ("deleting old dst datafile %s @ %s",
local->loc2.path, dst_cached->name); } while (0); _gf_log
(this->name, "dht-rename.c", __FUNCTION__, 572, GF_LOG_TRACE
, "deleting old dst datafile %s @ %s", local->loc2.path, dst_cached
->name); } while (0)
;
573
574 STACK_WIND (frame, dht_rename_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 576, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = dst_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_cached->fops->unlink"; _new->unwind_to = "dht_rename_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()) = dst_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_cached
->fops->unlink); dst_cached->fops->unlink (_new, dst_cached
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
575 dst_cached, dst_cached->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 576, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = dst_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_cached->fops->unlink"; _new->unwind_to = "dht_rename_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()) = dst_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_cached
->fops->unlink); dst_cached->fops->unlink (_new, dst_cached
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
576 &local->loc2, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 576, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_cached->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_cbk; _new->
root = frame->root; _new->this = dst_cached; _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_cached->fops->unlink"; _new->unwind_to = "dht_rename_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()) = dst_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_cached
->fops->unlink); dst_cached->fops->unlink (_new, dst_cached
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
577 }
578 return 0;
579
580unwind:
581 WIPE (&local->preoldparent)do { typeof(*&local->preoldparent) z = {0,}; if (&
local->preoldparent) *&local->preoldparent = z; } while
(0)
;
582 WIPE (&local->postoldparent)do { typeof(*&local->postoldparent) z = {0,}; if (&
local->postoldparent) *&local->postoldparent = z; }
while (0)
;
583 WIPE (&local->preparent)do { typeof(*&local->preparent) z = {0,}; if (&local
->preparent) *&local->preparent = z; } while (0)
;
584 WIPE (&local->postparent)do { typeof(*&local->postparent) z = {0,}; if (&local
->postparent) *&local->postparent = z; } while (0)
;
585
586 DHT_STRIP_PHASE1_FLAGS (&local->stbuf)do { if ((&local->stbuf) && ( ((&local->
stbuf)->ia_type == IA_IFREG) && ((&local->stbuf
)->ia_prot.sticky == 1) && ((&local->stbuf)
->ia_prot.sgid == 1))) { (&local->stbuf)->ia_prot
.sticky = 0; (&local->stbuf)->ia_prot.sgid = 0; } }
while (0)
;
587 DHT_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 590, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
588 &local->stbuf, &local->preoldparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 590, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
589 &local->postoldparent, &local->preparent,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 590, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
590 &local->postparent, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 590, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, local->op_ret, local->op_errno, &local->
stbuf, &local->preoldparent, &local->postoldparent
, &local->preparent, &local->postparent, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
; dht_local_wipe (__xl, __local); } while (0)
;
591
592 return 0;
593
594cleanup:
595 dht_rename_cleanup (frame);
596
597 return 0;
598}
599
600
601int
602dht_do_rename (call_frame_t *frame)
603{
604 dht_local_t *local = NULL((void*)0);
605 xlator_t *dst_hashed = NULL((void*)0);
606 xlator_t *src_cached = NULL((void*)0);
607 xlator_t *dst_cached = NULL((void*)0);
608 xlator_t *this = NULL((void*)0);
609 xlator_t *rename_subvol = NULL((void*)0);
610
611
612 local = frame->local;
613 this = frame->this;
614
615 dst_hashed = local->dst_hashed;
616 dst_cached = local->dst_cached;
617 src_cached = local->src_cached;
618
619 if (src_cached == dst_cached)
620 rename_subvol = src_cached;
621 else
622 rename_subvol = dst_hashed;
623
624 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("renaming %s => %s (%s)", local->
loc.path, local->loc2.path, rename_subvol->name); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 626
, GF_LOG_TRACE, "renaming %s => %s (%s)", local->loc.path
, local->loc2.path, rename_subvol->name); } while (0)
625 "renaming %s => %s (%s)",do { do { if (0) printf ("renaming %s => %s (%s)", local->
loc.path, local->loc2.path, rename_subvol->name); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 626
, GF_LOG_TRACE, "renaming %s => %s (%s)", local->loc.path
, local->loc2.path, rename_subvol->name); } while (0)
626 local->loc.path, local->loc2.path, rename_subvol->name)do { do { if (0) printf ("renaming %s => %s (%s)", local->
loc.path, local->loc2.path, rename_subvol->name); } while
(0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 626
, GF_LOG_TRACE, "renaming %s => %s (%s)", local->loc.path
, local->loc2.path, rename_subvol->name); } while (0)
;
627
628 STACK_WIND (frame, dht_rename_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 630, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( rename_subvol
->fops->rename_cbk) tmp_cbk = dht_rename_cbk; _new->
root = frame->root; _new->this = rename_subvol; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"rename_subvol->fops->rename"; _new->unwind_to = "dht_rename_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()) = rename_subvol; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, rename_subvol->fops->rename); rename_subvol->fops->
rename (_new, rename_subvol, &local->loc, &local->
loc2, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
629 rename_subvol, rename_subvol->fops->rename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 630, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( rename_subvol
->fops->rename_cbk) tmp_cbk = dht_rename_cbk; _new->
root = frame->root; _new->this = rename_subvol; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"rename_subvol->fops->rename"; _new->unwind_to = "dht_rename_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()) = rename_subvol; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, rename_subvol->fops->rename); rename_subvol->fops->
rename (_new, rename_subvol, &local->loc, &local->
loc2, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
630 &local->loc, &local->loc2, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 630, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( rename_subvol
->fops->rename_cbk) tmp_cbk = dht_rename_cbk; _new->
root = frame->root; _new->this = rename_subvol; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"rename_subvol->fops->rename"; _new->unwind_to = "dht_rename_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()) = rename_subvol; if (frame
->this->ctx->measure_latency) gf_latency_begin (_new
, rename_subvol->fops->rename); rename_subvol->fops->
rename (_new, rename_subvol, &local->loc, &local->
loc2, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
;
631
632 return 0;
633}
634
635
636int
637dht_rename_links_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
638 int32_t op_ret, int32_t op_errno,
639 inode_t *inode, struct iatt *stbuf,
640 struct iatt *preparent, struct iatt *postparent,
641 dict_t *xdata)
642{
643 dht_local_t *local = NULL((void*)0);
644 call_frame_t *prev = NULL((void*)0);
645 int this_call_cnt = 0;
646
647
648 local = frame->local;
649 prev = cookie;
650
651 if (op_ret == -1) {
652 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("link/file on %s failed (%s)", prev->
this->name, strerror (op_errno)); } while (0); _gf_log (this
->name, "dht-rename.c", __FUNCTION__, 654, GF_LOG_DEBUG, "link/file on %s failed (%s)"
, prev->this->name, strerror (op_errno)); } while (0)
653 "link/file on %s failed (%s)",do { do { if (0) printf ("link/file on %s failed (%s)", prev->
this->name, strerror (op_errno)); } while (0); _gf_log (this
->name, "dht-rename.c", __FUNCTION__, 654, GF_LOG_DEBUG, "link/file on %s failed (%s)"
, prev->this->name, strerror (op_errno)); } while (0)
654 prev->this->name, strerror (op_errno))do { do { if (0) printf ("link/file on %s failed (%s)", prev->
this->name, strerror (op_errno)); } while (0); _gf_log (this
->name, "dht-rename.c", __FUNCTION__, 654, GF_LOG_DEBUG, "link/file on %s failed (%s)"
, prev->this->name, strerror (op_errno)); } while (0)
;
655 local->op_ret = -1;
656 if (op_errno != ENOENT2)
657 local->op_errno = op_errno;
658 } else {
659 dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
660 }
661
662 this_call_cnt = dht_frame_return (frame);
663 if (is_last_call (this_call_cnt)(this_call_cnt == 0)) {
664 if (local->op_ret == -1)
665 goto cleanup;
666
667 dht_do_rename (frame);
668 }
669
670 return 0;
671
672cleanup:
673 dht_rename_cleanup (frame);
674
675 return 0;
676}
677
678
679int
680dht_rename_unlink_links_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
681 int32_t op_ret, int32_t op_errno,
682 struct iatt *preparent, struct iatt *postparent,
683 dict_t *xdata)
684{
685 dht_local_t *local = NULL((void*)0);
686 call_frame_t *prev = NULL((void*)0);
687
688
689 local = frame->local;
690 prev = cookie;
691
692 if ((op_ret == -1) && (op_errno != ENOENT2)) {
693 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("unlink of %s on %s failed (%s)", local
->loc2.path, prev->this->name, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 696, GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->
loc2.path, prev->this->name, strerror (op_errno)); } while
(0)
694 "unlink of %s on %s failed (%s)",do { do { if (0) printf ("unlink of %s on %s failed (%s)", local
->loc2.path, prev->this->name, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 696, GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->
loc2.path, prev->this->name, strerror (op_errno)); } while
(0)
695 local->loc2.path, prev->this->name,do { do { if (0) printf ("unlink of %s on %s failed (%s)", local
->loc2.path, prev->this->name, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 696, GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->
loc2.path, prev->this->name, strerror (op_errno)); } while
(0)
696 strerror (op_errno))do { do { if (0) printf ("unlink of %s on %s failed (%s)", local
->loc2.path, prev->this->name, strerror (op_errno));
} while (0); _gf_log (this->name, "dht-rename.c", __FUNCTION__
, 696, GF_LOG_DEBUG, "unlink of %s on %s failed (%s)", local->
loc2.path, prev->this->name, strerror (op_errno)); } while
(0)
;
697 local->op_ret = -1;
698 local->op_errno = op_errno;
699 }
700
701 if (local->op_ret == -1)
702 goto cleanup;
703
704 dht_do_rename (frame);
705
706 return 0;
707
708cleanup:
709 dht_rename_cleanup (frame);
710
711 return 0;
712}
713
714
715int
716dht_rename_create_links (call_frame_t *frame)
717{
718 dht_local_t *local = NULL((void*)0);
719 xlator_t *this = NULL((void*)0);
720 xlator_t *src_hashed = NULL((void*)0);
721 xlator_t *src_cached = NULL((void*)0);
722 xlator_t *dst_hashed = NULL((void*)0);
723 xlator_t *dst_cached = NULL((void*)0);
724 int call_cnt = 0;
725
726
727 local = frame->local;
728 this = frame->this;
729
730 src_hashed = local->src_hashed;
731 src_cached = local->src_cached;
732 dst_hashed = local->dst_hashed;
733 dst_cached = local->dst_cached;
734
735
736 if (src_cached == dst_cached) {
737 if (dst_hashed == dst_cached)
738 goto nolinks;
739
740 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("unlinking dst linkfile %s @ %s", local
->loc2.path, dst_hashed->name); } while (0); _gf_log (this
->name, "dht-rename.c", __FUNCTION__, 742, GF_LOG_TRACE, "unlinking dst linkfile %s @ %s"
, local->loc2.path, dst_hashed->name); } while (0)
741 "unlinking dst linkfile %s @ %s",do { do { if (0) printf ("unlinking dst linkfile %s @ %s", local
->loc2.path, dst_hashed->name); } while (0); _gf_log (this
->name, "dht-rename.c", __FUNCTION__, 742, GF_LOG_TRACE, "unlinking dst linkfile %s @ %s"
, local->loc2.path, dst_hashed->name); } while (0)
742 local->loc2.path, dst_hashed->name)do { do { if (0) printf ("unlinking dst linkfile %s @ %s", local
->loc2.path, dst_hashed->name); } while (0); _gf_log (this
->name, "dht-rename.c", __FUNCTION__, 742, GF_LOG_TRACE, "unlinking dst linkfile %s @ %s"
, local->loc2.path, dst_hashed->name); } while (0)
;
743
744 STACK_WIND (frame, dht_rename_unlink_links_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 746, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_links_cbk; _new
->root = frame->root; _new->this = dst_hashed; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_hashed->fops->unlink"; _new->unwind_to = "dht_rename_unlink_links_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()) = dst_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_hashed
->fops->unlink); dst_hashed->fops->unlink (_new, dst_hashed
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
745 dst_hashed, dst_hashed->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 746, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_links_cbk; _new
->root = frame->root; _new->this = dst_hashed; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_hashed->fops->unlink"; _new->unwind_to = "dht_rename_unlink_links_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()) = dst_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_hashed
->fops->unlink); dst_hashed->fops->unlink (_new, dst_hashed
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
746 &local->loc2, 0, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 746, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( dst_hashed->
fops->unlink_cbk) tmp_cbk = dht_rename_unlink_links_cbk; _new
->root = frame->root; _new->this = dst_hashed; _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"dst_hashed->fops->unlink"; _new->unwind_to = "dht_rename_unlink_links_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()) = dst_hashed; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, dst_hashed
->fops->unlink); dst_hashed->fops->unlink (_new, dst_hashed
, &local->loc2, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
747 return 0;
748 }
749
750 if (dst_hashed != src_hashed && dst_hashed != src_cached)
751 call_cnt++;
752
753 if (src_cached != dst_hashed)
754 call_cnt++;
755
756 local->call_cnt = call_cnt;
757
758 if (dst_hashed != src_hashed && dst_hashed != src_cached) {
759 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("linkfile %s @ %s => %s", local->
loc.path, dst_hashed->name, src_cached->name); } while (
0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 761
, GF_LOG_TRACE, "linkfile %s @ %s => %s", local->loc.path
, dst_hashed->name, src_cached->name); } while (0)
760 "linkfile %s @ %s => %s",do { do { if (0) printf ("linkfile %s @ %s => %s", local->
loc.path, dst_hashed->name, src_cached->name); } while (
0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 761
, GF_LOG_TRACE, "linkfile %s @ %s => %s", local->loc.path
, dst_hashed->name, src_cached->name); } while (0)
761 local->loc.path, dst_hashed->name, src_cached->name)do { do { if (0) printf ("linkfile %s @ %s => %s", local->
loc.path, dst_hashed->name, src_cached->name); } while (
0); _gf_log (this->name, "dht-rename.c", __FUNCTION__, 761
, GF_LOG_TRACE, "linkfile %s @ %s => %s", local->loc.path
, dst_hashed->name, src_cached->name); } while (0)
;
762 memcpy (local->gfid, local->loc.inode->gfid, 16);
763 dht_linkfile_create (frame, dht_rename_links_cbk, this,
764 src_cached, dst_hashed, &local->loc);
765 }
766
767 if (src_cached != dst_hashed) {
768 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("link %s => %s (%s)", local->loc
.path, local->loc2.path, src_cached->name); } while (0)
; _gf_log (this->name, "dht-rename.c", __FUNCTION__, 770, GF_LOG_TRACE
, "link %s => %s (%s)", local->loc.path, local->loc2
.path, src_cached->name); } while (0)
769 "link %s => %s (%s)", local->loc.path,do { do { if (0) printf ("link %s => %s (%s)", local->loc
.path, local->loc2.path, src_cached->name); } while (0)
; _gf_log (this->name, "dht-rename.c", __FUNCTION__, 770, GF_LOG_TRACE
, "link %s => %s (%s)", local->loc.path, local->loc2
.path, src_cached->name); } while (0)
770 local->loc2.path, src_cached->name)do { do { if (0) printf ("link %s => %s (%s)", local->loc
.path, local->loc2.path, src_cached->name); } while (0)
; _gf_log (this->name, "dht-rename.c", __FUNCTION__, 770, GF_LOG_TRACE
, "link %s => %s (%s)", local->loc.path, local->loc2
.path, src_cached->name); } while (0)
;
771 STACK_WIND (frame, dht_rename_links_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 773, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->link_cbk) tmp_cbk = dht_rename_links_cbk; _new->root
= frame->root; _new->this = src_cached; _new->ret =
(ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->link"; _new->unwind_to = "dht_rename_links_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->link); src_cached->fops->link (_new, src_cached
, &local->loc, &local->loc2, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
772 src_cached, src_cached->fops->link,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 773, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->link_cbk) tmp_cbk = dht_rename_links_cbk; _new->root
= frame->root; _new->this = src_cached; _new->ret =
(ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->link"; _new->unwind_to = "dht_rename_links_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->link); src_cached->fops->link (_new, src_cached
, &local->loc, &local->loc2, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
773 &local->loc, &local->loc2, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "dht-rename.c", __FUNCTION__, 773, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( src_cached->
fops->link_cbk) tmp_cbk = dht_rename_links_cbk; _new->root
= frame->root; _new->this = src_cached; _new->ret =
(ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"src_cached->fops->link"; _new->unwind_to = "dht_rename_links_cbk"
; pthread_spin_init (&_new->lock, 0); pthread_spin_lock
(&frame->root->stack_lock); { _new->next = frame
->root->frames.next; _new->prev = &frame->root
->frames; if (frame->root->frames.next) frame->root
->frames.next->prev = _new; frame->root->frames.next
= _new; frame->ref_count++; } pthread_spin_unlock (&frame
->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = src_cached; if (frame->
this->ctx->measure_latency) gf_latency_begin (_new, src_cached
->fops->link); src_cached->fops->link (_new, src_cached
, &local->loc, &local->loc2, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
774 }
775
776nolinks:
777 if (!call_cnt) {
778 /* skip to next step */
779 dht_do_rename (frame);
780 }
781
782 return 0;
783}
784
785
786int
787dht_rename (call_frame_t *frame, xlator_t *this,
788 loc_t *oldloc, loc_t *newloc, dict_t *xdata)
789{
790 xlator_t *src_cached = NULL((void*)0);
791 xlator_t *src_hashed = NULL((void*)0);
792 xlator_t *dst_cached = NULL((void*)0);
793 xlator_t *dst_hashed = NULL((void*)0);
794 int op_errno = -1;
795 int ret = -1;
796 dht_local_t *local = NULL((void*)0);
797
798
799 VALIDATE_OR_GOTO (frame, err)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "dht-rename.c"
, __FUNCTION__, 799, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto err; } } while (0)
;
800 VALIDATE_OR_GOTO (this, err)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "dht-rename.c"
, __FUNCTION__, 800, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto err; } } while (0)
;
801 VALIDATE_OR_GOTO (oldloc, err)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "dht-rename.c"
, __FUNCTION__, 801, GF_LOG_WARNING, "invalid argument: " "oldloc"
); } while (0); goto err; } } while (0)
;
802 VALIDATE_OR_GOTO (newloc, err)do { if (!newloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "newloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "dht-rename.c"
, __FUNCTION__, 802, GF_LOG_WARNING, "invalid argument: " "newloc"
); } while (0); goto err; } } while (0)
;
803
804 src_hashed = dht_subvol_get_hashed (this, oldloc);
805 if (!src_hashed) {
806 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("no subvolume in layout for path=%s"
, oldloc->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 808, GF_LOG_INFO, "no subvolume in layout for path=%s"
, oldloc->path); } while (0)
807 "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s"
, oldloc->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 808, GF_LOG_INFO, "no subvolume in layout for path=%s"
, oldloc->path); } while (0)
808 oldloc->path)do { do { if (0) printf ("no subvolume in layout for path=%s"
, oldloc->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 808, GF_LOG_INFO, "no subvolume in layout for path=%s"
, oldloc->path); } while (0)
;
809 op_errno = EINVAL22;
810 goto err;
811 }
812
813 src_cached = dht_subvol_get_cached (this, oldloc->inode);
814 if (!src_cached) {
815 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("no cached subvolume for path=%s", oldloc
->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 816, GF_LOG_INFO, "no cached subvolume for path=%s"
, oldloc->path); } while (0)
816 "no cached subvolume for path=%s", oldloc->path)do { do { if (0) printf ("no cached subvolume for path=%s", oldloc
->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 816, GF_LOG_INFO, "no cached subvolume for path=%s"
, oldloc->path); } while (0)
;
817 op_errno = EINVAL22;
818 goto err;
819 }
820
821 dst_hashed = dht_subvol_get_hashed (this, newloc);
822 if (!dst_hashed) {
823 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("no subvolume in layout for path=%s"
, newloc->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 825, GF_LOG_INFO, "no subvolume in layout for path=%s"
, newloc->path); } while (0)
824 "no subvolume in layout for path=%s",do { do { if (0) printf ("no subvolume in layout for path=%s"
, newloc->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 825, GF_LOG_INFO, "no subvolume in layout for path=%s"
, newloc->path); } while (0)
825 newloc->path)do { do { if (0) printf ("no subvolume in layout for path=%s"
, newloc->path); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 825, GF_LOG_INFO, "no subvolume in layout for path=%s"
, newloc->path); } while (0)
;
826 op_errno = EINVAL22;
827 goto err;
828 }
829
830 if (newloc->inode)
831 dst_cached = dht_subvol_get_cached (this, newloc->inode);
832
833 local = dht_local_init (frame, oldloc, NULL((void*)0), GF_FOP_RENAME);
834 if (!local) {
835 op_errno = ENOMEM12;
836 goto err;
837 }
838 /* cached_subvol will be set from dht_local_init, reset it to NULL,
839 as the logic of handling rename is different */
840 local->cached_subvol = NULL((void*)0);
841
842 ret = loc_copy (&local->loc2, newloc);
843 if (ret == -1) {
844 op_errno = ENOMEM12;
845 goto err;
846 }
847
848 local->src_hashed = src_hashed;
849 local->src_cached = src_cached;
850 local->dst_hashed = dst_hashed;
851 local->dst_cached = dst_cached;
852
853 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 857, GF_LOG_TRACE, "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0)
854 "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)",do { do { if (0) printf ("renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 857, GF_LOG_TRACE, "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0)
855 oldloc->path, src_hashed->name, src_cached->name,do { do { if (0) printf ("renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 857, GF_LOG_TRACE, "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0)
856 newloc->path, dst_hashed->name,do { do { if (0) printf ("renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 857, GF_LOG_TRACE, "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0)
857 dst_cached ? dst_cached->name : "<nul>")do { do { if (0) printf ("renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0); _gf_log (this->name, "dht-rename.c"
, __FUNCTION__, 857, GF_LOG_TRACE, "renaming %s (hash=%s/cache=%s) => %s (hash=%s/cache=%s)"
, oldloc->path, src_hashed->name, src_cached->name, newloc
->path, dst_hashed->name, dst_cached ? dst_cached->name
: "<nul>"); } while (0)
;
858
859 if (IA_ISDIR (oldloc->inode->ia_type)(oldloc->inode->ia_type == IA_IFDIR)) {
860 dht_rename_dir (frame, this);
861 } else {
862 local->op_ret = 0;
863 dht_rename_create_links (frame);
864 }
865
866 return 0;
867
868err:
869 op_errno = (op_errno == -1) ? errno(*__errno_location ()) : op_errno;
870 DHT_STACK_UNWIND (rename, frame, -1, op_errno, NULL, NULL, NULL, NULL,do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 871, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), (
(void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); }
while (0)
871 NULL, NULL)do { dht_local_t *__local = ((void*)0); xlator_t *__xl = ((void
*)0); if (frame) { __xl = frame->this; __local = frame->
local; frame->local = ((void*)0); } do { fop_rename_cbk_t fn
= ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *
old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf (
"!frame"); } while (0); _gf_log ("stack", "dht-rename.c", __FUNCTION__
, 871, GF_LOG_CRITICAL, "!frame"); } while (0); break; } fn =
(fop_rename_cbk_t )frame->ret; _parent = frame->parent
; pthread_spin_lock (&frame->root->stack_lock); { _parent
->ref_count--; } pthread_spin_unlock (&frame->root->
stack_lock); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = _parent->this; frame->complete = _gf_true; frame->
unwind_from = __FUNCTION__; if (frame->this->ctx->measure_latency
) gf_latency_end (frame); fn (_parent, frame->cookie, _parent
->this, -1, op_errno, ((void*)0), ((void*)0), ((void*)0), (
(void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0); dht_local_wipe (__xl, __local); }
while (0)
;
872
873 return 0;
874}