Bug Summary

File:xlators/features/marker/src/marker-quota.c
Location:line 1383, column 17
Description:Access to field 'name' results in a dereference of a null pointer (loaded from variable 'this')

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#ifndef _CONFIG_H
11#define _CONFIG_H
12#include "config.h"
13#endif
14
15#include "dict.h"
16#include "xlator.h"
17#include "defaults.h"
18#include "libxlator.h"
19#include "common-utils.h"
20#include "byte-order.h"
21#include "marker-quota.h"
22#include "marker-quota-helper.h"
23
24int
25mq_loc_copy (loc_t *dst, loc_t *src)
26{
27 int ret = -1;
28
29 GF_VALIDATE_OR_GOTO ("marker", dst, out)do { if (!dst) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "dst"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 29, GF_LOG_ERROR,
"invalid argument: " "dst"); } while (0); goto out; } } while
(0)
;
30 GF_VALIDATE_OR_GOTO ("marker", src, out)do { if (!src) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "src"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 30, GF_LOG_ERROR,
"invalid argument: " "src"); } while (0); goto out; } } while
(0)
;
31
32 if (src->inode == NULL((void*)0) ||
33 src->path == NULL((void*)0)) {
34 gf_log ("marker", GF_LOG_WARNING,do { do { if (0) printf ("src loc is not valid"); } while (0)
; _gf_log ("marker", "marker-quota.c", __FUNCTION__, 35, GF_LOG_WARNING
, "src loc is not valid"); } while (0)
35 "src loc is not valid")do { do { if (0) printf ("src loc is not valid"); } while (0)
; _gf_log ("marker", "marker-quota.c", __FUNCTION__, 35, GF_LOG_WARNING
, "src loc is not valid"); } while (0)
;
36 goto out;
37 }
38
39 ret = loc_copy (dst, src);
40out:
41 return ret;
42}
43
44int32_t
45mq_get_local_err (quota_local_tmarker_local_t *local,
46 int32_t *val)
47{
48 int32_t ret = -1;
49
50 GF_VALIDATE_OR_GOTO ("marker", local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 50, GF_LOG_ERROR,
"invalid argument: " "local"); } while (0); goto out; } } while
(0)
;
51 GF_VALIDATE_OR_GOTO ("marker", val, out)do { if (!val) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "val"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 51, GF_LOG_ERROR,
"invalid argument: " "val"); } while (0); goto out; } } while
(0)
;
52
53 LOCK (&local->lock)pthread_spin_lock (&local->lock);
54 {
55 *val = local->err;
56 }
57 UNLOCK (&local->lock)pthread_spin_unlock (&local->lock);
58
59 ret = 0;
60out:
61 return ret;
62}
63
64int32_t
65mq_get_ctx_updation_status (quota_inode_ctx_t *ctx,
66 gf_boolean_t *status)
67{
68 int32_t ret = -1;
69
70 GF_VALIDATE_OR_GOTO ("marker", ctx, out)do { if (!ctx) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "ctx"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 70, GF_LOG_ERROR,
"invalid argument: " "ctx"); } while (0); goto out; } } while
(0)
;
71 GF_VALIDATE_OR_GOTO ("marker", status, out)do { if (!status) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "status"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 71, GF_LOG_ERROR,
"invalid argument: " "status"); } while (0); goto out; } } while
(0)
;
72
73 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
74 {
75 *status = ctx->updation_status;
76 }
77 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
78
79 ret = 0;
80out:
81 return ret;
82}
83
84
85int32_t
86mq_set_ctx_updation_status (quota_inode_ctx_t *ctx,
87 gf_boolean_t status)
88{
89 int32_t ret = -1;
90
91 if (ctx == NULL((void*)0))
92 goto out;
93
94 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
95 {
96 ctx->updation_status = status;
97 }
98 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
99
100 ret = 0;
101out:
102 return ret;
103}
104
105int32_t
106mq_test_and_set_ctx_updation_status (quota_inode_ctx_t *ctx,
107 gf_boolean_t *status)
108{
109 int32_t ret = -1;
110 gf_boolean_t temp = _gf_false;
111
112 GF_VALIDATE_OR_GOTO ("marker", ctx, out)do { if (!ctx) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "ctx"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 112, GF_LOG_ERROR
, "invalid argument: " "ctx"); } while (0); goto out; } } while
(0)
;
113 GF_VALIDATE_OR_GOTO ("marker", status, out)do { if (!status) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "status"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 113, GF_LOG_ERROR
, "invalid argument: " "status"); } while (0); goto out; } } while
(0)
;
114
115 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
116 {
117 temp = *status;
118 *status = ctx->updation_status;
119 ctx->updation_status = temp;
120 }
121 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
122
123 ret = 0;
124out:
125 return ret;
126}
127
128void
129mq_assign_lk_owner (xlator_t *this, call_frame_t *frame)
130{
131 marker_conf_t *conf = NULL((void*)0);
132 uint64_t lk_owner = 0;
133
134 conf = this->private;
135
136 LOCK (&conf->lock)pthread_spin_lock (&conf->lock);
137 {
138 if (++conf->quota_lk_owner == 0) {
139 ++conf->quota_lk_owner;
140 }
141
142 lk_owner = conf->quota_lk_owner;
143 }
144 UNLOCK (&conf->lock)pthread_spin_unlock (&conf->lock);
145
146 set_lk_owner_from_uint64 (&frame->root->lk_owner, lk_owner);
147
148 return;
149}
150
151
152int32_t
153mq_loc_fill_from_name (xlator_t *this, loc_t *newloc, loc_t *oldloc,
154 uint64_t ino, char *name)
155{
156 int32_t ret = -1;
157 int32_t len = 0;
158 char *path = NULL((void*)0);
159
160 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 160, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
161 GF_VALIDATE_OR_GOTO ("marker", newloc, out)do { if (!newloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "newloc"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 161, GF_LOG_ERROR
, "invalid argument: " "newloc"); } while (0); goto out; } } while
(0)
;
162 GF_VALIDATE_OR_GOTO ("marker", oldloc, out)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 162, GF_LOG_ERROR
, "invalid argument: " "oldloc"); } while (0); goto out; } } while
(0)
;
163 GF_VALIDATE_OR_GOTO ("marker", name, out)do { if (!name) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "name"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 163, GF_LOG_ERROR
, "invalid argument: " "name"); } while (0); goto out; } } while
(0)
;
164
165 newloc->inode = inode_new (oldloc->inode->table);
166
167 if (!newloc->inode) {
168 ret = -1;
169 goto out;
170 }
171
172 newloc->parent = inode_ref (oldloc->inode);
173 uuid_copy (newloc->pargfid, oldloc->inode->gfid);
174
175 len = strlen (oldloc->path);
176
177 if (oldloc->path [len - 1] == '/')
178 ret = gf_asprintf ((char **) &path, "%s%s",
179 oldloc->path, name);
180 else
181 ret = gf_asprintf ((char **) &path, "%s/%s",
182 oldloc->path, name);
183
184 if (ret < 0)
185 goto out;
186
187 newloc->path = path;
188
189 newloc->name = strrchr (newloc->path, '/');
190
191 if (newloc->name)
192 newloc->name++;
193
194 gf_log (this->name, GF_LOG_DEBUG, "path = %s name =%s",do { do { if (0) printf ("path = %s name =%s", newloc->path
, newloc->name); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 195, GF_LOG_DEBUG, "path = %s name =%s", newloc
->path, newloc->name); } while (0)
195 newloc->path, newloc->name)do { do { if (0) printf ("path = %s name =%s", newloc->path
, newloc->name); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 195, GF_LOG_DEBUG, "path = %s name =%s", newloc
->path, newloc->name); } while (0)
;
196out:
197 return ret;
198}
199
200int32_t
201mq_dirty_inode_updation_done (call_frame_t *frame, void *cookie, xlator_t *this,
202 int32_t op_ret, int32_t op_errno, dict_t *xdata)
203{
204 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
205
206 return 0;
207}
208
209int32_t
210mq_release_lock_on_dirty_inode (call_frame_t *frame, void *cookie, xlator_t *this,
211 int32_t op_ret, int32_t op_errno, dict_t *xdata)
212{
213 struct gf_flock lock = {0, };
214 quota_local_tmarker_local_t *local = NULL((void*)0);
215 loc_t loc = {0, };
216 int ret = -1;
217
218 local = frame->local;
219
220 if (op_ret == -1) {
221 local->err = -1;
222
223 mq_dirty_inode_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
224
225 return 0;
226 }
227
228 if (op_ret == 0)
229 local->ctx->dirty = 0;
230
231 lock.l_type = F_UNLCK2;
232 lock.l_whence = SEEK_SET0;
233 lock.l_start = 0;
234 lock.l_len = 0;
235 lock.l_pid = 0;
236
237 ret = loc_copy (&loc, &local->loc);
238 if (ret == -1) {
239 local->err = -1;
240 frame->local = NULL((void*)0);
241 mq_dirty_inode_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
242 return 0;
243 }
244
245 if (local->loc.inode == NULL((void*)0)) {
246 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Inode is NULL, so can't stackwind."
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 247, GF_LOG_WARNING, "Inode is NULL, so can't stackwind.");
} while (0)
247 "Inode is NULL, so can't stackwind.")do { do { if (0) printf ("Inode is NULL, so can't stackwind."
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 247, GF_LOG_WARNING, "Inode is NULL, so can't stackwind.");
} while (0)
;
248 goto out;
249 }
250
251 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 255, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_dirty_inode_updation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_dirty_inode_updation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
252 mq_dirty_inode_updation_done,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", "marker-quota.c", __FUNCTION__, 255, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_dirty_inode_updation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_dirty_inode_updation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
253 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 255, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_dirty_inode_updation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_dirty_inode_updation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
254 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 255, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_dirty_inode_updation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_dirty_inode_updation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
255 this->name, &loc, F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 255, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_dirty_inode_updation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_dirty_inode_updation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
256
257 loc_wipe (&loc);
258
259 return 0;
260out:
261 mq_dirty_inode_updation_done (frame, NULL((void*)0), this, -1, 0, NULL((void*)0));
262
263 return 0;
264}
265
266int32_t
267mq_mark_inode_undirty (call_frame_t *frame, void *cookie, xlator_t *this,
268 int32_t op_ret, int32_t op_errno, dict_t *dict,
269 dict_t *xdata)
270{
271 int32_t ret = -1;
272 int64_t *size = NULL((void*)0);
273 dict_t *newdict = NULL((void*)0);
274 quota_local_tmarker_local_t *local = NULL((void*)0);
275
276 local = (quota_local_tmarker_local_t *) frame->local;
277
278 if (op_ret == -1)
279 goto err;
280
281 if (!dict)
282 goto wind;
283
284 ret = dict_get_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", (void **) &size);
285 if (ret)
286 goto wind;
287
288 LOCK (&local->ctx->lock)pthread_spin_lock (&local->ctx->lock);
289 {
290 local->ctx->size = ntoh64hton64 (*size);
291 }
292 UNLOCK (&local->ctx->lock)pthread_spin_unlock (&local->ctx->lock);
293
294wind:
295 newdict = dict_new ();
296 if (!newdict)
297 goto err;
298
299 ret = dict_set_int8 (newdict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", 0);
300 if (ret)
301 goto err;
302
303 if (uuid_is_null (local->loc.gfid))
304 uuid_copy (local->loc.gfid, local->loc.inode->gfid);
305
306 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 306, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\""); }
while (0); } } while (0);
;
307 STACK_WIND (frame, mq_release_lock_on_dirty_inode,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", "marker-quota.c", __FUNCTION__, 310, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_release_lock_on_dirty_inode
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_lock_on_dirty_inode"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
308 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 310, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_release_lock_on_dirty_inode
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_lock_on_dirty_inode"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
309 FIRST_CHILD(this)->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 310, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_release_lock_on_dirty_inode
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_lock_on_dirty_inode"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
310 &local->loc, newdict, 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", "marker-quota.c", __FUNCTION__, 310, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_release_lock_on_dirty_inode
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_lock_on_dirty_inode"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
311 ret = 0;
312
313err:
314 if (op_ret == -1 || ret == -1) {
315 local->err = -1;
316
317 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
318 }
319
320 if (newdict)
321 dict_unref (newdict);
322
323 return 0;
324}
325
326int32_t
327mq_update_size_xattr (call_frame_t *frame, void *cookie, xlator_t *this,
328 int32_t op_ret, int32_t op_errno, inode_t *inode,
329 struct iatt *buf, dict_t *dict, struct iatt *postparent)
330{
331 int32_t ret = -1;
332 dict_t *new_dict = NULL((void*)0);
333 int64_t *size = NULL((void*)0);
334 int64_t *delta = NULL((void*)0);
335 quota_local_tmarker_local_t *local = NULL((void*)0);
336
337 local = frame->local;
338
339 if (op_ret == -1)
340 goto err;
341
342 if (dict == NULL((void*)0)) {
343 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Dict is null while updating the size xattr %s"
, local->loc.path?local->loc.path:""); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 345, GF_LOG_WARNING
, "Dict is null while updating the size xattr %s", local->
loc.path?local->loc.path:""); } while (0)
344 "Dict is null while updating the size xattr %s",do { do { if (0) printf ("Dict is null while updating the size xattr %s"
, local->loc.path?local->loc.path:""); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 345, GF_LOG_WARNING
, "Dict is null while updating the size xattr %s", local->
loc.path?local->loc.path:""); } while (0)
345 local->loc.path?local->loc.path:"")do { do { if (0) printf ("Dict is null while updating the size xattr %s"
, local->loc.path?local->loc.path:""); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 345, GF_LOG_WARNING
, "Dict is null while updating the size xattr %s", local->
loc.path?local->loc.path:""); } while (0)
;
346 goto err;
347 }
348
349 ret = dict_get_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", (void **) &size);
350 if (!size) {
351 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to get the size, %s", local->
loc.path?local->loc.path:""); } while (0); _gf_log (this->
name, "marker-quota.c", __FUNCTION__, 353, GF_LOG_WARNING, "failed to get the size, %s"
, local->loc.path?local->loc.path:""); } while (0)
352 "failed to get the size, %s",do { do { if (0) printf ("failed to get the size, %s", local->
loc.path?local->loc.path:""); } while (0); _gf_log (this->
name, "marker-quota.c", __FUNCTION__, 353, GF_LOG_WARNING, "failed to get the size, %s"
, local->loc.path?local->loc.path:""); } while (0)
353 local->loc.path?local->loc.path:"")do { do { if (0) printf ("failed to get the size, %s", local->
loc.path?local->loc.path:""); } while (0); _gf_log (this->
name, "marker-quota.c", __FUNCTION__, 353, GF_LOG_WARNING, "failed to get the size, %s"
, local->loc.path?local->loc.path:""); } while (0)
;
354 goto err;
355 }
356
357 QUOTA_ALLOC_OR_GOTO (delta, int64_t, ret, err)do { delta = __gf_calloc (sizeof (int64_t), 1, gf_marker_mt_int64_t
); if (!delta) { do { do { if (0) printf ("out of memory"); }
while (0); _gf_log ("", "marker-quota.c", __FUNCTION__, 357,
GF_LOG_ERROR, "out of memory"); } while (0); ret = -1; goto err
; } ret = 0; } while (0);
;
358
359 *delta = hton64 (local->sum - ntoh64hton64 (*size));
360
361 gf_log (this->name, GF_LOG_DEBUG, "calculated size = %"PRId64", "do { do { if (0) printf ("calculated size = %""ll" "d"", " "original size = %"
"ll" "u" " path = %s diff = %""ll" "u", local->sum, hton64
(*size), local->loc.path, hton64 (*delta)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 364, GF_LOG_DEBUG
, "calculated size = %""ll" "d"", " "original size = %""ll" "u"
" path = %s diff = %""ll" "u", local->sum, hton64 (*size)
, local->loc.path, hton64 (*delta)); } while (0)
362 "original size = %"PRIu64do { do { if (0) printf ("calculated size = %""ll" "d"", " "original size = %"
"ll" "u" " path = %s diff = %""ll" "u", local->sum, hton64
(*size), local->loc.path, hton64 (*delta)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 364, GF_LOG_DEBUG
, "calculated size = %""ll" "d"", " "original size = %""ll" "u"
" path = %s diff = %""ll" "u", local->sum, hton64 (*size)
, local->loc.path, hton64 (*delta)); } while (0)
363 " path = %s diff = %"PRIu64, local->sum, ntoh64 (*size),do { do { if (0) printf ("calculated size = %""ll" "d"", " "original size = %"
"ll" "u" " path = %s diff = %""ll" "u", local->sum, hton64
(*size), local->loc.path, hton64 (*delta)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 364, GF_LOG_DEBUG
, "calculated size = %""ll" "d"", " "original size = %""ll" "u"
" path = %s diff = %""ll" "u", local->sum, hton64 (*size)
, local->loc.path, hton64 (*delta)); } while (0)
364 local->loc.path, ntoh64 (*delta))do { do { if (0) printf ("calculated size = %""ll" "d"", " "original size = %"
"ll" "u" " path = %s diff = %""ll" "u", local->sum, hton64
(*size), local->loc.path, hton64 (*delta)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 364, GF_LOG_DEBUG
, "calculated size = %""ll" "d"", " "original size = %""ll" "u"
" path = %s diff = %""ll" "u", local->sum, hton64 (*size)
, local->loc.path, hton64 (*delta)); } while (0)
;
365
366 new_dict = dict_new ();
367 if (!new_dict);
368
369 ret = dict_set_bin (new_dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", delta, 8);
370 if (ret)
371 goto err;
372
373 if (uuid_is_null (local->loc.gfid))
374 uuid_copy (local->loc.gfid, buf->ia_gfid);
375
376 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 376, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\""); }
while (0); } } while (0);
;
377
378 STACK_WIND (frame, mq_mark_inode_undirty, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 380, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->xattrop_cbk) tmp_cbk = mq_mark_inode_undirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_inode_undirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, new_dict, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
379 FIRST_CHILD(this)->fops->xattrop, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 380, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->xattrop_cbk) tmp_cbk = mq_mark_inode_undirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_inode_undirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, new_dict, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
380 GF_XATTROP_ADD_ARRAY64, new_dict, 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", "marker-quota.c", __FUNCTION__, 380, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->xattrop_cbk) tmp_cbk = mq_mark_inode_undirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_inode_undirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, new_dict, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
381
382 ret = 0;
383
384err:
385 if (op_ret == -1 || ret == -1) {
386 local->err = -1;
387
388 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
389 }
390
391 if (new_dict)
392 dict_unref (new_dict);
393
394 return 0;
395}
396
397int32_t
398mq_test_and_set_local_err(quota_local_tmarker_local_t *local,
399 int32_t *val)
400{
401 int tmp = 0;
402 int32_t ret = -1;
403
404 GF_VALIDATE_OR_GOTO ("marker", local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 404, GF_LOG_ERROR
, "invalid argument: " "local"); } while (0); goto out; } } while
(0)
;
405 GF_VALIDATE_OR_GOTO ("marker", val, out)do { if (!val) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "val"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 405, GF_LOG_ERROR
, "invalid argument: " "val"); } while (0); goto out; } } while
(0)
;
406
407 LOCK (&local->lock)pthread_spin_lock (&local->lock);
408 {
409 tmp = local->err;
410 local->err = *val;
411 *val = tmp;
412 }
413 UNLOCK (&local->lock)pthread_spin_unlock (&local->lock);
414
415 ret = 0;
416out:
417 return ret;
418}
419
420int32_t
421mq_get_dirty_inode_size (call_frame_t *frame, xlator_t *this)
422{
423 int32_t ret = -1;
424 dict_t *dict = NULL((void*)0);
425 quota_local_tmarker_local_t *local = NULL((void*)0);
426
427 local = (quota_local_tmarker_local_t *) frame->local;
428
429 dict = dict_new ();
430 if (!dict) {
431 ret = -1;
432 goto err;
433 }
434
435 ret = dict_set_int64 (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", 0);
436 if (ret)
437 goto err;
438
439 if (uuid_is_null (local->loc.gfid))
440 uuid_copy (local->loc.gfid, local->loc.inode->gfid);
441
442 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 442, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\""); }
while (0); } } while (0);
;
443
444 STACK_WIND (frame, mq_update_size_xattr, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 445, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_update_size_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_update_size_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, dict); (*__glusterfs_this_location()) = old_THIS
; } while (0)
445 FIRST_CHILD(this)->fops->lookup, &local->loc, dict)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 445, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_update_size_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_update_size_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, dict); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
446 ret =0;
447
448err:
449 if (ret) {
450 local->err = -1;
451
452 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
453 }
454
455 if (dict)
456 dict_unref (dict);
457
458 return 0;
459}
460
461int32_t
462mq_get_child_contribution (call_frame_t *frame,
463 void *cookie,
464 xlator_t *this,
465 int32_t op_ret,
466 int32_t op_errno,
467 inode_t *inode,
468 struct iatt *buf,
469 dict_t *dict,
470 struct iatt *postparent)
471{
472 int32_t ret = -1;
473 int32_t val = 0;
474 char contri_key [512] = {0, };
475 int64_t *contri = NULL((void*)0);
476 quota_local_tmarker_local_t *local = NULL((void*)0);
477
478 local = frame->local;
479
480 frame->local = NULL((void*)0);
481
482 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
483
484 if (op_ret == -1) {
485 gf_log (this->name, GF_LOG_ERROR, "%s",do { do { if (0) printf ("%s", strerror (op_errno)); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 486
, GF_LOG_ERROR, "%s", strerror (op_errno)); } while (0)
486 strerror (op_errno))do { do { if (0) printf ("%s", strerror (op_errno)); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 486
, GF_LOG_ERROR, "%s", strerror (op_errno)); } while (0)
;
487 val = -2;
488 if (!mq_test_and_set_local_err (local, &val) &&
489 val != -2)
490 mq_release_lock_on_dirty_inode (local->frame, NULL((void*)0),
491 this, 0, 0, NULL((void*)0));
492
493 goto exit;
494 }
495
496 ret = mq_get_local_err (local, &val);
497 if (!ret && val == -2)
498 goto exit;
499
500 GET_CONTRI_KEY (contri_key, local->loc.inode->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (local->loc.inode
->gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
501 if (ret < 0)
502 goto out;
503
504 if (!dict)
505 goto out;
506
507 if (dict_get_bin (dict, contri_key, (void **) &contri) == 0)
508 local->sum += ntoh64hton64 (*contri);
509
510out:
511 LOCK (&local->lock)pthread_spin_lock (&local->lock);
512 {
513 val = --local->dentry_child_count;
514 }
515 UNLOCK (&local->lock)pthread_spin_unlock (&local->lock);
516
517 if (val == 0) {
518 mq_dirty_inode_readdir (local->frame, NULL((void*)0), this,
519 0, 0, NULL((void*)0), NULL((void*)0));
520 }
521 mq_local_unref (this, local);
522
523 return 0;
524exit:
525 mq_local_unref (this, local);
526 return 0;
527}
528
529int32_t
530mq_readdir_cbk (call_frame_t *frame,
531 void *cookie,
532 xlator_t *this,
533 int32_t op_ret,
534 int32_t op_errno,
535 gf_dirent_t *entries, dict_t *xdata)
536{
537 char contri_key [512] = {0, };
538 int32_t ret = 0;
539 int32_t val = 0;
540 off_t offset = 0;
541 int32_t count = 0;
542 dict_t *dict = NULL((void*)0);
543 quota_local_tmarker_local_t *local = NULL((void*)0);
544 gf_dirent_t *entry = NULL((void*)0);
545 call_frame_t *newframe = NULL((void*)0);
546 loc_t loc = {0, };
547
548 local = mq_local_ref (frame->local);
549
550 if (op_ret == -1) {
551 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("readdir failed %s", strerror (op_errno
)); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 552, GF_LOG_DEBUG, "readdir failed %s", strerror (op_errno)
); } while (0)
552 "readdir failed %s", strerror (op_errno))do { do { if (0) printf ("readdir failed %s", strerror (op_errno
)); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 552, GF_LOG_DEBUG, "readdir failed %s", strerror (op_errno)
); } while (0)
;
553 local->err = -1;
554
555 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
556
557 goto end;
558 } else if (op_ret == 0) {
559 mq_get_dirty_inode_size (frame, this);
560
561 goto end;
562 }
563
564 local->dentry_child_count = 0;
565
566 list_for_each_entry (entry, (&entries->list), list)for (entry = ((typeof(*entry) *)((char *)(((&entries->
list))->next)-(unsigned long)(&((typeof(*entry) *)0)->
list))); &entry->list != ((&entries->list)); entry
= ((typeof(*entry) *)((char *)(entry->list.next)-(unsigned
long)(&((typeof(*entry) *)0)->list))))
{
567 gf_log (this->name, GF_LOG_DEBUG, "entry = %s", entry->d_name)do { do { if (0) printf ("entry = %s", entry->d_name); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
567, GF_LOG_DEBUG, "entry = %s", entry->d_name); } while
(0)
;
568
569 if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name,
570 ".."))) {
571 gf_log (this->name, GF_LOG_DEBUG, "entry = %s",do { do { if (0) printf ("entry = %s", entry->d_name); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
572, GF_LOG_DEBUG, "entry = %s", entry->d_name); } while
(0)
572 entry->d_name)do { do { if (0) printf ("entry = %s", entry->d_name); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
572, GF_LOG_DEBUG, "entry = %s", entry->d_name); } while
(0)
;
573 continue;
574 }
575
576 offset = entry->d_off;
577 count++;
578 }
579
580 if (count == 0) {
581 mq_get_dirty_inode_size (frame, this);
582 goto end;
583
584 }
585
586 local->frame = frame;
587
588 LOCK (&local->lock)pthread_spin_lock (&local->lock);
589 {
590 local->dentry_child_count = count;
591 local->d_off = offset;
592 }
593 UNLOCK (&local->lock)pthread_spin_unlock (&local->lock);
594
595
596 list_for_each_entry (entry, (&entries->list), list)for (entry = ((typeof(*entry) *)((char *)(((&entries->
list))->next)-(unsigned long)(&((typeof(*entry) *)0)->
list))); &entry->list != ((&entries->list)); entry
= ((typeof(*entry) *)((char *)(entry->list.next)-(unsigned
long)(&((typeof(*entry) *)0)->list))))
{
597 gf_log (this->name, GF_LOG_DEBUG, "entry = %s", entry->d_name)do { do { if (0) printf ("entry = %s", entry->d_name); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
597, GF_LOG_DEBUG, "entry = %s", entry->d_name); } while
(0)
;
598
599 if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name,
600 ".."))) {
601 gf_log (this->name, GF_LOG_DEBUG, "entry = %s",do { do { if (0) printf ("entry = %s", entry->d_name); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
602, GF_LOG_DEBUG, "entry = %s", entry->d_name); } while
(0)
602 entry->d_name)do { do { if (0) printf ("entry = %s", entry->d_name); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
602, GF_LOG_DEBUG, "entry = %s", entry->d_name); } while
(0)
;
603 continue;
604 }
605
606 ret = mq_loc_fill_from_name (this, &loc, &local->loc,
607 entry->d_ino, entry->d_name);
608 if (ret < 0)
609 goto out;
610
611 ret = 0;
612
613 LOCK (&local->lock)pthread_spin_lock (&local->lock);
614 {
615 if (local->err != -2) {
616 newframe = copy_frame (frame);
617 if (!newframe) {
618 ret = -1;
619 }
620 } else
621 ret = -1;
622 }
623 UNLOCK (&local->lock)pthread_spin_unlock (&local->lock);
624
625 if (ret == -1)
626 goto out;
627
628 newframe->local = mq_local_ref (local);
629
630 dict = dict_new ();
631 if (!dict) {
632 ret = -1;
633 goto out;
634 }
635
636 GET_CONTRI_KEY (contri_key, local->loc.inode->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (local->loc.inode
->gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
637 if (ret < 0)
638 goto out;
639
640 ret = dict_set_int64 (dict, contri_key, 0);
641 if (ret)
642 goto out;
643
644 STACK_WIND (newframe,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 648, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_get_child_contribution
; _new->root = newframe->root; _new->this = (this->
children->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new
->parent = newframe; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"
; _new->unwind_to = "mq_get_child_contribution"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { _new->next = newframe->root->
frames.next; _new->prev = &newframe->root->frames
; if (newframe->root->frames.next) newframe->root->
frames.next->prev = _new; newframe->root->frames.next
= _new; newframe->ref_count++; } pthread_spin_unlock (&
newframe->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (newframe->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &loc, dict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
645 mq_get_child_contribution,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 648, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_get_child_contribution
; _new->root = newframe->root; _new->this = (this->
children->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new
->parent = newframe; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"
; _new->unwind_to = "mq_get_child_contribution"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { _new->next = newframe->root->
frames.next; _new->prev = &newframe->root->frames
; if (newframe->root->frames.next) newframe->root->
frames.next->prev = _new; newframe->root->frames.next
= _new; newframe->ref_count++; } pthread_spin_unlock (&
newframe->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (newframe->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &loc, dict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
646 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 648, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_get_child_contribution
; _new->root = newframe->root; _new->this = (this->
children->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new
->parent = newframe; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"
; _new->unwind_to = "mq_get_child_contribution"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { _new->next = newframe->root->
frames.next; _new->prev = &newframe->root->frames
; if (newframe->root->frames.next) newframe->root->
frames.next->prev = _new; newframe->root->frames.next
= _new; newframe->ref_count++; } pthread_spin_unlock (&
newframe->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (newframe->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &loc, dict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
647 FIRST_CHILD(this)->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 648, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_get_child_contribution
; _new->root = newframe->root; _new->this = (this->
children->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new
->parent = newframe; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"
; _new->unwind_to = "mq_get_child_contribution"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { _new->next = newframe->root->
frames.next; _new->prev = &newframe->root->frames
; if (newframe->root->frames.next) newframe->root->
frames.next->prev = _new; newframe->root->frames.next
= _new; newframe->ref_count++; } pthread_spin_unlock (&
newframe->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (newframe->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &loc, dict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
648 &loc, dict)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (newframe->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 648, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_get_child_contribution
; _new->root = newframe->root; _new->this = (this->
children->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new
->parent = newframe; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->lookup"
; _new->unwind_to = "mq_get_child_contribution"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&newframe->
root->stack_lock); { _new->next = newframe->root->
frames.next; _new->prev = &newframe->root->frames
; if (newframe->root->frames.next) newframe->root->
frames.next->prev = _new; newframe->root->frames.next
= _new; newframe->ref_count++; } pthread_spin_unlock (&
newframe->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (newframe->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &loc, dict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
649
650 offset = entry->d_off;
651
652 loc_wipe (&loc);
653
654 newframe = NULL((void*)0);
655
656 out:
657 if (dict) {
658 dict_unref (dict);
659 dict = NULL((void*)0);
660 }
661
662 if (ret) {
663 val = -2;
664 mq_test_and_set_local_err (local, &val);
665
666 if (newframe) {
667 newframe->local = NULL((void*)0);
668 mq_local_unref(this, local);
669 QUOTA_STACK_DESTROY (newframe, this)do { marker_local_t *_local = ((void*)0); _local = newframe->
local; newframe->local = ((void*)0); STACK_DESTROY (newframe
->root); mq_local_unref (this, _local); } while (0)
;
670 }
671
672 break;
673 }
674 }
675
676 if (ret && val != -2) {
677 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
678 }
679end:
680 mq_local_unref (this, local);
681
682 return 0;
683}
684
685int32_t
686mq_dirty_inode_readdir (call_frame_t *frame,
687 void *cookie,
688 xlator_t *this,
689 int32_t op_ret,
690 int32_t op_errno,
691 fd_t *fd, dict_t *xdata)
692{
693 quota_local_tmarker_local_t *local = NULL((void*)0);
694
695 local = frame->local;
696
697 if (op_ret == -1) {
698 local->err = -1;
699 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
700 return 0;
701 }
702
703 if (local->fd == NULL((void*)0))
704 local->fd = fd_ref (fd);
705
706 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 710, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->readdir_cbk) tmp_cbk = mq_readdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->readdir"
; _new->unwind_to = "mq_readdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->readdir); (this->children->xlator
)->fops->readdir (_new, (this->children->xlator),
local->fd, 4096, local->d_off, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
707 mq_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", "marker-quota.c", __FUNCTION__, 710, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->readdir_cbk) tmp_cbk = mq_readdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->readdir"
; _new->unwind_to = "mq_readdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->readdir); (this->children->xlator
)->fops->readdir (_new, (this->children->xlator),
local->fd, 4096, local->d_off, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
708 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 710, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->readdir_cbk) tmp_cbk = mq_readdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->readdir"
; _new->unwind_to = "mq_readdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->readdir); (this->children->xlator
)->fops->readdir (_new, (this->children->xlator),
local->fd, 4096, local->d_off, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
709 FIRST_CHILD(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", "marker-quota.c", __FUNCTION__, 710, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->readdir_cbk) tmp_cbk = mq_readdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->readdir"
; _new->unwind_to = "mq_readdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->readdir); (this->children->xlator
)->fops->readdir (_new, (this->children->xlator),
local->fd, 4096, local->d_off, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
710 local->fd, READDIR_BUF, local->d_off, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 710, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->readdir_cbk) tmp_cbk = mq_readdir_cbk
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->readdir"
; _new->unwind_to = "mq_readdir_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->readdir); (this->children->xlator
)->fops->readdir (_new, (this->children->xlator),
local->fd, 4096, local->d_off, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
711
712 return 0;
713}
714
715int32_t
716mq_check_if_still_dirty (call_frame_t *frame,
717 void *cookie,
718 xlator_t *this,
719 int32_t op_ret,
720 int32_t op_errno,
721 inode_t *inode,
722 struct iatt *buf,
723 dict_t *dict,
724 struct iatt *postparent)
725{
726 int8_t dirty = -1;
727 int32_t ret = -1;
728 fd_t *fd = NULL((void*)0);
729 quota_local_tmarker_local_t *local = NULL((void*)0);
730
731 local = frame->local;
732
733 if (op_ret == -1) {
734 gf_log (this->name, GF_LOG_ERROR, "failed to get "do { do { if (0) printf ("failed to get " "the dirty xattr for %s"
, local->loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 735, GF_LOG_ERROR, "failed to get " "the dirty xattr for %s"
, local->loc.path); } while (0)
735 "the dirty xattr for %s", local->loc.path)do { do { if (0) printf ("failed to get " "the dirty xattr for %s"
, local->loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 735, GF_LOG_ERROR, "failed to get " "the dirty xattr for %s"
, local->loc.path); } while (0)
;
736 goto err;
737 }
738
739 if (!dict) {
740 ret = -1;
741 goto err;
742 }
743
744 ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", &dirty);
745 if (ret)
746 goto err;
747
748 //the inode is not dirty anymore
749 if (dirty == 0) {
750 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
751
752 return 0;
753 }
754
755 fd = fd_create (local->loc.inode, frame->root->pid);
756
757 local->d_off = 0;
758
759 if (uuid_is_null (local->loc.gfid))
760 uuid_copy (local->loc.gfid, buf->ia_gfid);
761
762 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 762, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\""); }
while (0); } } while (0);
;
763 STACK_WIND(frame,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", "marker-quota.c", __FUNCTION__, 767, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->opendir_cbk) tmp_cbk = mq_dirty_inode_readdir
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->opendir"
; _new->unwind_to = "mq_dirty_inode_readdir"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->opendir); (this->children->xlator
)->fops->opendir (_new, (this->children->xlator),
&local->loc, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
764 mq_dirty_inode_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", "marker-quota.c", __FUNCTION__, 767, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->opendir_cbk) tmp_cbk = mq_dirty_inode_readdir
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->opendir"
; _new->unwind_to = "mq_dirty_inode_readdir"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->opendir); (this->children->xlator
)->fops->opendir (_new, (this->children->xlator),
&local->loc, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
765 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 767, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->opendir_cbk) tmp_cbk = mq_dirty_inode_readdir
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->opendir"
; _new->unwind_to = "mq_dirty_inode_readdir"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->opendir); (this->children->xlator
)->fops->opendir (_new, (this->children->xlator),
&local->loc, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
766 FIRST_CHILD(this)->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", "marker-quota.c", __FUNCTION__, 767, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->opendir_cbk) tmp_cbk = mq_dirty_inode_readdir
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->opendir"
; _new->unwind_to = "mq_dirty_inode_readdir"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->opendir); (this->children->xlator
)->fops->opendir (_new, (this->children->xlator),
&local->loc, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
767 &local->loc, 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", "marker-quota.c", __FUNCTION__, 767, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->opendir_cbk) tmp_cbk = mq_dirty_inode_readdir
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->opendir"
; _new->unwind_to = "mq_dirty_inode_readdir"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->opendir); (this->children->xlator
)->fops->opendir (_new, (this->children->xlator),
&local->loc, fd, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
768
769 ret = 0;
770
771err:
772 if (op_ret == -1 || ret == -1) {
773 local->err = -1;
774 mq_release_lock_on_dirty_inode (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
775 }
776
777 if (fd != NULL((void*)0)) {
778 fd_unref (fd);
779 }
780
781 return 0;
782}
783
784int32_t
785mq_get_dirty_xattr (call_frame_t *frame, void *cookie, xlator_t *this,
786 int32_t op_ret, int32_t op_errno, dict_t *xdata)
787{
788 int32_t ret = -1;
789 dict_t *xattr_req = NULL((void*)0);
790 quota_local_tmarker_local_t *local = NULL((void*)0);
791
792 if (op_ret == -1) {
793 mq_dirty_inode_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
794 return 0;
795 }
796
797 local = frame->local;
798
799 xattr_req = dict_new ();
800 if (xattr_req == NULL((void*)0)) {
801 ret = -1;
802 goto err;
803 }
804
805 ret = dict_set_int8 (xattr_req, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", 0);
806 if (ret)
807 goto err;
808
809 if (uuid_is_null (local->loc.gfid))
810 uuid_copy (local->loc.gfid, local->loc.inode->gfid);
811
812 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 812, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\""); }
while (0); } } while (0);
;
813
814 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 819, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_check_if_still_dirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_check_if_still_dirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, xattr_req); (*__glusterfs_this_location()) = old_THIS
; } while (0)
815 mq_check_if_still_dirty,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", "marker-quota.c", __FUNCTION__, 819, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_check_if_still_dirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_check_if_still_dirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, xattr_req); (*__glusterfs_this_location()) = old_THIS
; } while (0)
816 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 819, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_check_if_still_dirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_check_if_still_dirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, xattr_req); (*__glusterfs_this_location()) = old_THIS
; } while (0)
817 FIRST_CHILD(this)->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 819, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_check_if_still_dirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_check_if_still_dirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, xattr_req); (*__glusterfs_this_location()) = old_THIS
; } while (0)
818 &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 819, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_check_if_still_dirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_check_if_still_dirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, xattr_req); (*__glusterfs_this_location()) = old_THIS
; } while (0)
819 xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 819, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->lookup_cbk) tmp_cbk = mq_check_if_still_dirty
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->lookup";
_new->unwind_to = "mq_check_if_still_dirty"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->lookup); (this->children->xlator
)->fops->lookup (_new, (this->children->xlator), &
local->loc, xattr_req); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
820 ret = 0;
821
822err:
823 if (ret) {
824 local->err = -1;
825 mq_release_lock_on_dirty_inode(frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
826 }
827
828 if (xattr_req)
829 dict_unref (xattr_req);
830
831 return 0;
832}
833
834/* return 1 when dirty updation started
835 * 0 other wise
836 */
837int32_t
838mq_update_dirty_inode (xlator_t *this,
839 loc_t *loc,
840 quota_inode_ctx_t *ctx,
841 inode_contribution_t *contribution)
842{
843 int32_t ret = -1;
844 quota_local_tmarker_local_t *local = NULL((void*)0);
845 gf_boolean_t status = _gf_false;
846 struct gf_flock lock = {0, };
847 call_frame_t *frame = NULL((void*)0);
848
849 ret = mq_get_ctx_updation_status (ctx, &status);
850 if (ret == -1 || status == _gf_true) {
851 ret = 0;
852 goto out;
853 }
854
855 frame = create_frame (this, this->ctx->pool);
856 if (frame == NULL((void*)0)) {
857 ret = -1;
858 goto out;
859 }
860
861 mq_assign_lk_owner (this, frame);
862
863 local = mq_local_new ();
864 if (local == NULL((void*)0))
865 goto fr_destroy;
866
867 frame->local = local;
868 ret = mq_loc_copy (&local->loc, loc);
869 if (ret < 0)
870 goto fr_destroy;
871
872 local->ctx = ctx;
873
874 local->contri = contribution;
875
876 lock.l_type = F_WRLCK1;
877 lock.l_whence = SEEK_SET0;
878 lock.l_start = 0;
879 lock.l_len = 0;
880
881 if (local->loc.inode == NULL((void*)0)) {
882 ret = -1;
883 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Inode is NULL, so can't stackwind."
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 884, GF_LOG_WARNING, "Inode is NULL, so can't stackwind.");
} while (0)
884 "Inode is NULL, so can't stackwind.")do { do { if (0) printf ("Inode is NULL, so can't stackwind."
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 884, GF_LOG_WARNING, "Inode is NULL, so can't stackwind.");
} while (0)
;
885 goto fr_destroy;
886 }
887
888 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_get_dirty_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
889 mq_get_dirty_xattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_get_dirty_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
890 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_get_dirty_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
891 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_get_dirty_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
892 this->name, &local->loc, F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 892, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_get_dirty_xattr
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
893 return 1;
894
895fr_destroy:
896 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
897out:
898
899 return 0;
900}
901
902
903int32_t
904mq_inode_creation_done (call_frame_t *frame, void *cookie, xlator_t *this,
905 int32_t op_ret, int32_t op_errno, dict_t *xdata)
906{
907 quota_local_tmarker_local_t *local = NULL((void*)0);
908
909 if (frame == NULL((void*)0))
910 return 0;
911
912 local = frame->local;
913
914 if (local != NULL((void*)0)) {
915 mq_initiate_quota_txn (this, &local->loc);
916 }
917
918 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
919
920 return 0;
921}
922
923
924int32_t
925mq_xattr_creation_release_lock (call_frame_t *frame, void *cookie,
926 xlator_t *this, int32_t op_ret,
927 int32_t op_errno, dict_t *xdata)
928{
929 struct gf_flock lock = {0, };
930 quota_local_tmarker_local_t *local = NULL((void*)0);
931
932 local = frame->local;
933
934 lock.l_type = F_UNLCK2;
935 lock.l_whence = SEEK_SET0;
936 lock.l_start = 0;
937 lock.l_len = 0;
938 lock.l_pid = 0;
939
940 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 945, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_inode_creation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inode_creation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
941 mq_inode_creation_done,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", "marker-quota.c", __FUNCTION__, 945, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_inode_creation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inode_creation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
942 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 945, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_inode_creation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inode_creation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
943 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 945, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_inode_creation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inode_creation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
944 this->name, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 945, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_inode_creation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inode_creation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
945 F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 945, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->inodelk_cbk) tmp_cbk = mq_inode_creation_done
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inode_creation_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
946
947 return 0;
948}
949
950
951int32_t
952mq_create_dirty_xattr (call_frame_t *frame, void *cookie, xlator_t *this,
953 int32_t op_ret, int32_t op_errno, dict_t *dict,
954 dict_t *xdata)
955{
956 int32_t ret = -1;
957 dict_t *newdict = NULL((void*)0);
958 quota_local_tmarker_local_t *local = NULL((void*)0);
959
960 if (op_ret < 0) {
961 goto err;
962 }
963
964 local = frame->local;
965
966 if (local->loc.inode->ia_type == IA_IFDIR) {
967 newdict = dict_new ();
968 if (!newdict) {
969 goto err;
970 }
971
972 ret = dict_set_int8 (newdict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", 0);
973 if (ret == -1) {
974 goto err;
975 }
976
977 uuid_copy (local->loc.gfid, local->loc.inode->gfid);
978 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 978, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\""); }
while (0); } } while (0);
;
979
980 STACK_WIND (frame, mq_xattr_creation_release_lock,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", "marker-quota.c", __FUNCTION__, 983, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_xattr_creation_release_lock
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_xattr_creation_release_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
981 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 983, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_xattr_creation_release_lock
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_xattr_creation_release_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
982 FIRST_CHILD(this)->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 983, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_xattr_creation_release_lock
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_xattr_creation_release_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
983 &local->loc, newdict, 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", "marker-quota.c", __FUNCTION__, 983, GF_LOG_ERROR
, "alloc failed"); } while (0); break; } typeof( (this->children
->xlator)->fops->setxattr_cbk) tmp_cbk = mq_xattr_creation_release_lock
; _new->root = frame->root; _new->this = (this->children
->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent
= frame; _new->cookie = _new; _new->wind_from = __FUNCTION__
; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_xattr_creation_release_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
984 } else {
985 mq_xattr_creation_release_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
986 }
987
988 ret = 0;
989
990err:
991 if (ret < 0) {
992 mq_xattr_creation_release_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
993 }
994
995 if (newdict != NULL((void*)0))
996 dict_unref (newdict);
997
998 return 0;
999}
1000
1001
1002int32_t
1003mq_create_xattr (xlator_t *this, call_frame_t *frame)
1004{
1005 int32_t ret = 0;
1006 int64_t *value = NULL((void*)0);
1007 int64_t *size = NULL((void*)0);
1008 dict_t *dict = NULL((void*)0);
1009 char key[512] = {0, };
1010 quota_local_tmarker_local_t *local = NULL((void*)0);
1011 quota_inode_ctx_t *ctx = NULL((void*)0);
1012 inode_contribution_t *contri = NULL((void*)0);
1013
1014 if (frame == NULL((void*)0) || this == NULL((void*)0))
1015 return 0;
1016
1017 local = frame->local;
1018
1019 ret = mq_inode_ctx_get (local->loc.inode, this, &ctx);
1020 if (ret < 0) {
1021 ctx = mq_inode_ctx_new (local->loc.inode, this);
1022 if (ctx == NULL((void*)0)) {
1023 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("mq_inode_ctx_new failed"); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1024
, GF_LOG_WARNING, "mq_inode_ctx_new failed"); } while (0)
1024 "mq_inode_ctx_new failed")do { do { if (0) printf ("mq_inode_ctx_new failed"); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1024
, GF_LOG_WARNING, "mq_inode_ctx_new failed"); } while (0)
;
1025 ret = -1;
1026 goto out;
1027 }
1028 }
1029
1030 dict = dict_new ();
1031 if (!dict)
1032 goto out;
1033
1034 if (local->loc.inode->ia_type == IA_IFDIR) {
1035 QUOTA_ALLOC_OR_GOTO (size, int64_t, ret, err)do { size = __gf_calloc (sizeof (int64_t), 1, gf_marker_mt_int64_t
); if (!size) { do { do { if (0) printf ("out of memory"); } while
(0); _gf_log ("", "marker-quota.c", __FUNCTION__, 1035, GF_LOG_ERROR
, "out of memory"); } while (0); ret = -1; goto err; } ret = 0
; } while (0);
;
1036 ret = dict_set_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", size, 8);
1037 if (ret < 0)
1038 goto free_size;
1039 }
1040
1041 if (strcmp (local->loc.path, "/") != 0) {
1042 contri = mq_add_new_contribution_node (this, ctx, &local->loc);
1043 if (contri == NULL((void*)0))
1044 goto err;
1045
1046 QUOTA_ALLOC_OR_GOTO (value, int64_t, ret, err)do { value = __gf_calloc (sizeof (int64_t), 1, gf_marker_mt_int64_t
); if (!value) { do { do { if (0) printf ("out of memory"); }
while (0); _gf_log ("", "marker-quota.c", __FUNCTION__, 1046
, GF_LOG_ERROR, "out of memory"); } while (0); ret = -1; goto
err; } ret = 0; } while (0);
;
1047 GET_CONTRI_KEY (key, local->loc.parent->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (local->loc.parent
->gfid, _gfid_unparsed); ret = snprintf (key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
1048
1049 ret = dict_set_bin (dict, key, value, 8);
1050 if (ret < 0)
1051 goto free_value;
1052 }
1053
1054 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1054, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1055
1056 STACK_WIND (frame, mq_create_dirty_xattr, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1058,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_create_dirty_xattr; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_create_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, dict, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
1057 FIRST_CHILD(this)->fops->xattrop, &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1058,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_create_dirty_xattr; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_create_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, dict, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
1058 GF_XATTROP_ADD_ARRAY64, dict, 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", "marker-quota.c", __FUNCTION__, 1058,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_create_dirty_xattr; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_create_dirty_xattr"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, dict, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1059 ret = 0;
1060
1061free_size:
1062 if (ret < 0) {
1063 GF_FREE (size)__gf_free (size);
1064 }
1065
1066free_value:
1067 if (ret < 0) {
1068 GF_FREE (value)__gf_free (value);
1069 }
1070
1071err:
1072 dict_unref (dict);
1073
1074out:
1075 if (ret < 0) {
1076 mq_xattr_creation_release_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1077 }
1078
1079 return 0;
1080}
1081
1082
1083int32_t
1084mq_check_n_set_inode_xattr (call_frame_t *frame, void *cookie,
1085 xlator_t *this, int32_t op_ret, int32_t op_errno,
1086 inode_t *inode, struct iatt *buf, dict_t *dict,
1087 struct iatt *postparent)
1088{
1089 quota_local_tmarker_local_t *local = NULL((void*)0);
1090 int64_t *size = NULL((void*)0), *contri = NULL((void*)0);
1091 int8_t dirty = 0;
1092 int32_t ret = 0;
1093 char contri_key[512] = {0, };
1094
1095 if (op_ret < 0) {
1096 goto out;
1097 }
1098
1099 local = frame->local;
1100
1101 ret = dict_get_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", (void **) &size);
1102 if (ret < 0)
1103 goto create_xattr;
1104
1105 ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", &dirty);
1106 if (ret < 0)
1107 goto create_xattr;
1108
1109 //check contribution xattr if not root
1110 if (strcmp (local->loc.path, "/") != 0) {
1111 GET_CONTRI_KEY (contri_key, local->loc.parent->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (local->loc.parent
->gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
1112 if (ret < 0)
1113 goto out;
1114
1115 ret = dict_get_bin (dict, contri_key, (void **) &contri);
1116 if (ret < 0)
1117 goto create_xattr;
1118 }
1119
1120out:
1121 mq_xattr_creation_release_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1122 return 0;
1123
1124create_xattr:
1125 if (uuid_is_null (local->loc.gfid)) {
1126 uuid_copy (local->loc.gfid, buf->ia_gfid);
1127 }
1128
1129 mq_create_xattr (this, frame);
1130 return 0;
1131}
1132
1133
1134int32_t
1135mq_get_xattr (call_frame_t *frame, void *cookie, xlator_t *this,
1136 int32_t op_ret, int32_t op_errno, dict_t *xdata)
1137{
1138 dict_t *xattr_req = NULL((void*)0);
1139 quota_local_tmarker_local_t *local = NULL((void*)0);
1140 int32_t ret = 0;
1141
1142 if (op_ret < 0) {
1143 goto lock_err;
1144 }
1145
1146 local = frame->local;
1147
1148 xattr_req = dict_new ();
1149 if (xattr_req == NULL((void*)0)) {
1150 goto err;
1151 }
1152
1153 ret = mq_req_xattr (this, &local->loc, xattr_req);
1154 if (ret < 0) {
1155 gf_log (this->name, GF_LOG_WARNING, "cannot request xattr")do { do { if (0) printf ("cannot request xattr"); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1155
, GF_LOG_WARNING, "cannot request xattr"); } while (0)
;
1156 goto err;
1157 }
1158
1159 if (uuid_is_null (local->loc.gfid))
1160 uuid_copy (local->loc.gfid, local->loc.inode->gfid);
1161
1162 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1162, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1163
1164 STACK_WIND (frame, mq_check_n_set_inode_xattr, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1165,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->lookup_cbk) tmp_cbk
= mq_check_n_set_inode_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->lookup"; _new->unwind_to =
"mq_check_n_set_inode_xattr"; pthread_spin_init (&_new->
lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &local->loc, xattr_req); (*
__glusterfs_this_location()) = old_THIS; } while (0)
1165 FIRST_CHILD(this)->fops->lookup, &local->loc, xattr_req)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1165,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->lookup_cbk) tmp_cbk
= mq_check_n_set_inode_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->lookup"; _new->unwind_to =
"mq_check_n_set_inode_xattr"; pthread_spin_init (&_new->
lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &local->loc, xattr_req); (*
__glusterfs_this_location()) = old_THIS; } while (0)
;
1166
1167 dict_unref (xattr_req);
1168
1169 return 0;
1170
1171err:
1172 mq_xattr_creation_release_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1173
1174 if (xattr_req)
1175 dict_unref (xattr_req);
1176 return 0;
1177
1178lock_err:
1179 mq_inode_creation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1180 return 0;
1181}
1182
1183
1184int32_t
1185mq_set_inode_xattr (xlator_t *this, loc_t *loc)
1186{
1187 struct gf_flock lock = {0, };
1188 quota_local_tmarker_local_t *local = NULL((void*)0);
1189 int32_t ret = 0;
1190 call_frame_t *frame = NULL((void*)0);
1191
1192 frame = create_frame (this, this->ctx->pool);
1193 if (!frame) {
1194 ret = -1;
1195 goto err;
1196 }
1197
1198 local = mq_local_new ();
1199 if (local == NULL((void*)0)) {
1200 goto err;
1201 }
1202
1203 frame->local = local;
1204
1205 ret = loc_copy (&local->loc, loc);
1206 if (ret < 0) {
1207 goto err;
1208 }
1209
1210 frame->local = local;
1211
1212 lock.l_len = 0;
1213 lock.l_start = 0;
1214 lock.l_type = F_WRLCK1;
1215 lock.l_whence = SEEK_SET0;
1216
1217 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 1221,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_get_xattr; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_xattr"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
1218 mq_get_xattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1221,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_get_xattr; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_xattr"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
1219 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1221,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_get_xattr; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_xattr"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
1220 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 1221,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_get_xattr; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_xattr"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
1221 this->name, &local->loc, F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 1221,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_get_xattr; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_get_xattr"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->loc, 14, &lock, ((void*)0)
); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1222
1223 return 0;
1224
1225err:
1226 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
1227
1228 return 0;
1229}
1230
1231
1232int32_t
1233mq_get_parent_inode_local (xlator_t *this, quota_local_tmarker_local_t *local)
1234{
1235 int32_t ret = -1;
1236 quota_inode_ctx_t *ctx = NULL((void*)0);
1237
1238 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 1238, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
1239 GF_VALIDATE_OR_GOTO ("marker", local, out)do { if (!local) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "local"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 1239, GF_LOG_ERROR
, "invalid argument: " "local"); } while (0); goto out; } } while
(0)
;
1240
1241 local->contri = NULL((void*)0);
1242
1243 loc_wipe (&local->loc);
1244
1245 ret = mq_loc_copy (&local->loc, &local->parent_loc);
1246 if (ret < 0) {
1247 gf_log_callingfn (this->name, GF_LOG_WARNING,do { do { if (0) printf ("loc copy failed"); } while (0); _gf_log_callingfn
(this->name, "marker-quota.c", __FUNCTION__, 1248, GF_LOG_WARNING
, "loc copy failed"); } while (0)
1248 "loc copy failed")do { do { if (0) printf ("loc copy failed"); } while (0); _gf_log_callingfn
(this->name, "marker-quota.c", __FUNCTION__, 1248, GF_LOG_WARNING
, "loc copy failed"); } while (0)
;
1249 goto out;
1250 }
1251
1252 loc_wipe (&local->parent_loc);
1253
1254 ret = mq_inode_loc_fill (NULL((void*)0), local->loc.parent,
1255 &local->parent_loc);
1256 if (ret < 0) {
1257 gf_log_callingfn (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to build parent loc of %s", local
->loc.path); } while (0); _gf_log_callingfn (this->name
, "marker-quota.c", __FUNCTION__, 1259, GF_LOG_WARNING, "failed to build parent loc of %s"
, local->loc.path); } while (0)
1258 "failed to build parent loc of %s",do { do { if (0) printf ("failed to build parent loc of %s", local
->loc.path); } while (0); _gf_log_callingfn (this->name
, "marker-quota.c", __FUNCTION__, 1259, GF_LOG_WARNING, "failed to build parent loc of %s"
, local->loc.path); } while (0)
1259 local->loc.path)do { do { if (0) printf ("failed to build parent loc of %s", local
->loc.path); } while (0); _gf_log_callingfn (this->name
, "marker-quota.c", __FUNCTION__, 1259, GF_LOG_WARNING, "failed to build parent loc of %s"
, local->loc.path); } while (0)
;
1260 goto out;
1261 }
1262
1263 ret = mq_inode_ctx_get (local->loc.inode, this, &ctx);
1264 if (ret < 0) {
1265 gf_log_callingfn (this->name, GF_LOG_WARNING,do { do { if (0) printf ("inode ctx get failed"); } while (0)
; _gf_log_callingfn (this->name, "marker-quota.c", __FUNCTION__
, 1266, GF_LOG_WARNING, "inode ctx get failed"); } while (0)
1266 "inode ctx get failed")do { do { if (0) printf ("inode ctx get failed"); } while (0)
; _gf_log_callingfn (this->name, "marker-quota.c", __FUNCTION__
, 1266, GF_LOG_WARNING, "inode ctx get failed"); } while (0)
;
1267 goto out;
1268 }
1269
1270 local->ctx = ctx;
1271
1272 if (list_empty (&ctx->contribution_head)) {
1273 gf_log_callingfn (this->name, GF_LOG_WARNING,do { do { if (0) printf ("contribution node list is empty which "
"is an error"); } while (0); _gf_log_callingfn (this->name
, "marker-quota.c", __FUNCTION__, 1275, GF_LOG_WARNING, "contribution node list is empty which "
"is an error"); } while (0)
1274 "contribution node list is empty which "do { do { if (0) printf ("contribution node list is empty which "
"is an error"); } while (0); _gf_log_callingfn (this->name
, "marker-quota.c", __FUNCTION__, 1275, GF_LOG_WARNING, "contribution node list is empty which "
"is an error"); } while (0)
1275 "is an error")do { do { if (0) printf ("contribution node list is empty which "
"is an error"); } while (0); _gf_log_callingfn (this->name
, "marker-quota.c", __FUNCTION__, 1275, GF_LOG_WARNING, "contribution node list is empty which "
"is an error"); } while (0)
;
1276 ret = -1;
1277 goto out;
1278 }
1279
1280 local->contri = (inode_contribution_t *) ctx->contribution_head.next;
1281
1282 ret = 0;
1283out:
1284 return ret;
1285}
1286
1287
1288int32_t
1289mq_xattr_updation_done (call_frame_t *frame,
1290 void *cookie,
1291 xlator_t *this,
1292 int32_t op_ret,
1293 int32_t op_errno,
1294 dict_t *dict, dict_t *xdata)
1295{
1296 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
1297 return 0;
1298}
1299
1300
1301int32_t
1302mq_inodelk_cbk (call_frame_t *frame, void *cookie,
1303 xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata)
1304{
1305 int32_t ret = 0;
1306 gf_boolean_t status = _gf_false;
1307 quota_local_tmarker_local_t *local = NULL((void*)0);
1308
1309 local = frame->local;
1310
1311 if (op_ret == -1 || local->err) {
1312 if (op_ret == -1) {
1313 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("unlocking failed on path (%s)(%s)",
local->parent_loc.path, strerror (op_errno)); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1315
, GF_LOG_DEBUG, "unlocking failed on path (%s)(%s)", local->
parent_loc.path, strerror (op_errno)); } while (0)
1314 "unlocking failed on path (%s)(%s)",do { do { if (0) printf ("unlocking failed on path (%s)(%s)",
local->parent_loc.path, strerror (op_errno)); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1315
, GF_LOG_DEBUG, "unlocking failed on path (%s)(%s)", local->
parent_loc.path, strerror (op_errno)); } while (0)
1315 local->parent_loc.path, strerror (op_errno))do { do { if (0) printf ("unlocking failed on path (%s)(%s)",
local->parent_loc.path, strerror (op_errno)); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1315
, GF_LOG_DEBUG, "unlocking failed on path (%s)(%s)", local->
parent_loc.path, strerror (op_errno)); } while (0)
;
1316 }
1317 mq_xattr_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0), NULL((void*)0));
1318
1319 return 0;
1320 }
1321
1322 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("inodelk released on %s", local->
parent_loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1323, GF_LOG_DEBUG, "inodelk released on %s",
local->parent_loc.path); } while (0)
1323 "inodelk released on %s", local->parent_loc.path)do { do { if (0) printf ("inodelk released on %s", local->
parent_loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1323, GF_LOG_DEBUG, "inodelk released on %s",
local->parent_loc.path); } while (0)
;
1324
1325 if ((strcmp (local->parent_loc.path, "/") == 0)
1326 || (local->delta == 0)) {
1327 mq_xattr_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0), NULL((void*)0));
1328 } else {
1329 ret = mq_get_parent_inode_local (this, local);
1330 if (ret < 0) {
1331 mq_xattr_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0),
1332 NULL((void*)0));
1333 goto out;
1334 }
1335 status = _gf_true;
1336
1337 ret = mq_test_and_set_ctx_updation_status (local->ctx, &status);
1338 if (ret == 0 && status == _gf_false) {
1339 mq_get_lock_on_parent (frame, this);
1340 } else {
1341 mq_xattr_updation_done (frame, NULL((void*)0), this, 0, 0, NULL((void*)0),
1342 NULL((void*)0));
1343 }
1344 }
1345out:
1346 return 0;
1347}
1348
1349
1350//now release lock on the parent inode
1351int32_t
1352mq_release_parent_lock (call_frame_t *frame, void *cookie,
1353 xlator_t *this, int32_t op_ret,
1354 int32_t op_errno, dict_t *xdata)
1355{
1356 int32_t ret = 0;
1357 quota_local_tmarker_local_t *local = NULL((void*)0);
1358 quota_inode_ctx_t *ctx = NULL((void*)0);
1359 struct gf_flock lock = {0, };
1360
1361 local = frame->local;
1362
1363 if (local->err != 0) {
6
Taking false branch
1364 gf_log_callingfn (this->name,do { do { if (0) printf ("An operation during quota updation "
"of path (%s) failed (%s)", local->loc.path, strerror (local
->err)); } while (0); _gf_log_callingfn (this->name, "marker-quota.c"
, __FUNCTION__, 1369, (local->err == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
, "An operation during quota updation " "of path (%s) failed (%s)"
, local->loc.path, strerror (local->err)); } while (0)
1365 (local->err == ENOENT) ? GF_LOG_DEBUGdo { do { if (0) printf ("An operation during quota updation "
"of path (%s) failed (%s)", local->loc.path, strerror (local
->err)); } while (0); _gf_log_callingfn (this->name, "marker-quota.c"
, __FUNCTION__, 1369, (local->err == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
, "An operation during quota updation " "of path (%s) failed (%s)"
, local->loc.path, strerror (local->err)); } while (0)
1366 : GF_LOG_WARNING,do { do { if (0) printf ("An operation during quota updation "
"of path (%s) failed (%s)", local->loc.path, strerror (local
->err)); } while (0); _gf_log_callingfn (this->name, "marker-quota.c"
, __FUNCTION__, 1369, (local->err == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
, "An operation during quota updation " "of path (%s) failed (%s)"
, local->loc.path, strerror (local->err)); } while (0)
1367 "An operation during quota updation "do { do { if (0) printf ("An operation during quota updation "
"of path (%s) failed (%s)", local->loc.path, strerror (local
->err)); } while (0); _gf_log_callingfn (this->name, "marker-quota.c"
, __FUNCTION__, 1369, (local->err == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
, "An operation during quota updation " "of path (%s) failed (%s)"
, local->loc.path, strerror (local->err)); } while (0)
1368 "of path (%s) failed (%s)", local->loc.path,do { do { if (0) printf ("An operation during quota updation "
"of path (%s) failed (%s)", local->loc.path, strerror (local
->err)); } while (0); _gf_log_callingfn (this->name, "marker-quota.c"
, __FUNCTION__, 1369, (local->err == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
, "An operation during quota updation " "of path (%s) failed (%s)"
, local->loc.path, strerror (local->err)); } while (0)
1369 strerror (local->err))do { do { if (0) printf ("An operation during quota updation "
"of path (%s) failed (%s)", local->loc.path, strerror (local
->err)); } while (0); _gf_log_callingfn (this->name, "marker-quota.c"
, __FUNCTION__, 1369, (local->err == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
, "An operation during quota updation " "of path (%s) failed (%s)"
, local->loc.path, strerror (local->err)); } while (0)
;
1370 }
1371
1372 ret = mq_inode_ctx_get (local->parent_loc.inode, this, &ctx);
1373 if (ret < 0)
7
Assuming 'ret' is >= 0
8
Taking false branch
1374 goto wind;
1375
1376 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
1377 {
1378 ctx->dirty = 0;
1379 }
1380 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
1381
1382 if (local->parent_loc.inode == NULL((void*)0)) {
9
Taking true branch
1383 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Invalid parent inode."); } while (0
); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1384
, GF_LOG_DEBUG, "Invalid parent inode."); } while (0)
10
Within the expansion of the macro 'gf_log':
a
Access to field 'name' results in a dereference of a null pointer (loaded from variable 'this')
1384 "Invalid parent inode.")do { do { if (0) printf ("Invalid parent inode."); } while (0
); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1384
, GF_LOG_DEBUG, "Invalid parent inode."); } while (0)
;
1385 goto err;
1386 }
1387
1388wind:
1389 lock.l_type = F_UNLCK2;
1390 lock.l_whence = SEEK_SET0;
1391 lock.l_start = 0;
1392 lock.l_len = 0;
1393 lock.l_pid = 0;
1394
1395 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 1400,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_inodelk_cbk; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1396 mq_inodelk_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", "marker-quota.c", __FUNCTION__, 1400,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_inodelk_cbk; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1397 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1400,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_inodelk_cbk; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1398 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 1400,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_inodelk_cbk; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1399 this->name, &local->parent_loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1400,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_inodelk_cbk; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1400 F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 1400,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_inodelk_cbk; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_inodelk_cbk"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1401
1402 return 0;
1403err:
1404 mq_xattr_updation_done (frame, NULL((void*)0), this,
1405 0, 0 , NULL((void*)0), NULL((void*)0));
1406 return 0;
1407}
1408
1409
1410int32_t
1411mq_mark_undirty (call_frame_t *frame,
1412 void *cookie,
1413 xlator_t *this,
1414 int32_t op_ret,
1415 int32_t op_errno,
1416 dict_t *dict, dict_t *xdata)
1417{
1418 int32_t ret = -1;
1419 int64_t *size = NULL((void*)0);
1420 dict_t *newdict = NULL((void*)0);
1421 quota_local_tmarker_local_t *local = NULL((void*)0);
1422 quota_inode_ctx_t *ctx = NULL((void*)0);
1423
1424 local = frame->local;
1425
1426 if (op_ret == -1) {
1427 gf_log (this->name, GF_LOG_WARNING, "%s occurred while"do { do { if (0) printf ("%s occurred while" " updating the size of %s"
, strerror (op_errno), local->parent_loc.path); } while (0
); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1429
, GF_LOG_WARNING, "%s occurred while" " updating the size of %s"
, strerror (op_errno), local->parent_loc.path); } while (0
)
1428 " updating the size of %s", strerror (op_errno),do { do { if (0) printf ("%s occurred while" " updating the size of %s"
, strerror (op_errno), local->parent_loc.path); } while (0
); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1429
, GF_LOG_WARNING, "%s occurred while" " updating the size of %s"
, strerror (op_errno), local->parent_loc.path); } while (0
)
1429 local->parent_loc.path)do { do { if (0) printf ("%s occurred while" " updating the size of %s"
, strerror (op_errno), local->parent_loc.path); } while (0
); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1429
, GF_LOG_WARNING, "%s occurred while" " updating the size of %s"
, strerror (op_errno), local->parent_loc.path); } while (0
)
;
1430
1431 goto err;
1432 }
1433
1434 //update the size of the parent inode
1435 if (dict != NULL((void*)0)) {
1436 ret = mq_inode_ctx_get (local->parent_loc.inode, this, &ctx);
1437 if (ret < 0) {
1438 op_errno = EINVAL22;
1439 goto err;
1440 }
1441
1442 ret = dict_get_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", (void **) &size);
1443 if (ret < 0) {
1444 op_errno = EINVAL22;
1445 goto err;
1446 }
1447
1448 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
1449 {
1450 if (size)
1451 ctx->size = ntoh64hton64 (*size);
1452 gf_log (this->name, GF_LOG_DEBUG, "%s %"PRId64,do { do { if (0) printf ("%s %""ll" "d", local->parent_loc
.path, ctx->size); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1453, GF_LOG_DEBUG, "%s %""ll" "d", local->
parent_loc.path, ctx->size); } while (0)
1453 local->parent_loc.path, ctx->size)do { do { if (0) printf ("%s %""ll" "d", local->parent_loc
.path, ctx->size); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1453, GF_LOG_DEBUG, "%s %""ll" "d", local->
parent_loc.path, ctx->size); } while (0)
;
1454 }
1455 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
1456 }
1457
1458 newdict = dict_new ();
1459 if (!newdict) {
1460 op_errno = ENOMEM12;
1461 goto err;
1462 }
1463
1464 ret = dict_set_int8 (newdict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", 0);
1465
1466 if (ret == -1) {
1467 op_errno = -ret;
1468 goto err;
1469 }
1470
1471 uuid_copy (local->parent_loc.gfid, local->parent_loc.inode->gfid);
1472 GF_UUID_ASSERT (local->parent_loc.gfid)if (uuid_is_null (local->parent_loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1472, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1473
1474 STACK_WIND (frame, mq_release_parent_lock,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", "marker-quota.c", __FUNCTION__, 1477,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_release_parent_lock; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_parent_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1475 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1477,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_release_parent_lock; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_parent_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1476 FIRST_CHILD(this)->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1477,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_release_parent_lock; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_parent_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1477 &local->parent_loc, newdict, 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", "marker-quota.c", __FUNCTION__, 1477,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_release_parent_lock; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr"
; _new->unwind_to = "mq_release_parent_lock"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, newdict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1478
1479 ret = 0;
1480err:
1481 if (op_ret == -1 || ret == -1) {
1482 local->err = op_errno;
1483
1484 mq_release_parent_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1485 }
1486
1487 if (newdict)
1488 dict_unref (newdict);
1489
1490 return 0;
1491}
1492
1493
1494int32_t
1495mq_update_parent_size (call_frame_t *frame,
1496 void *cookie,
1497 xlator_t *this,
1498 int32_t op_ret,
1499 int32_t op_errno,
1500 dict_t *dict, dict_t *xdata)
1501{
1502 int64_t *size = NULL((void*)0);
1503 int32_t ret = -1;
1504 dict_t *newdict = NULL((void*)0);
1505 quota_local_tmarker_local_t *local = NULL((void*)0);
1506 quota_inode_ctx_t *ctx = NULL((void*)0);
1507
1508 local = frame->local;
1509
1510 if (op_ret == -1) {
1511 gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG :do { do { if (0) printf ("xattrop call failed: %s", strerror (
op_errno)); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1513, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
), "xattrop call failed: %s", strerror (op_errno)); } while (
0)
1512 GF_LOG_WARNING),do { do { if (0) printf ("xattrop call failed: %s", strerror (
op_errno)); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1513, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
), "xattrop call failed: %s", strerror (op_errno)); } while (
0)
1513 "xattrop call failed: %s", strerror (op_errno))do { do { if (0) printf ("xattrop call failed: %s", strerror (
op_errno)); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1513, ((op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING
), "xattrop call failed: %s", strerror (op_errno)); } while (
0)
;
1514
1515 goto err;
1516 }
1517
1518 LOCK (&local->contri->lock)pthread_spin_lock (&local->contri->lock);
1519 {
1520 local->contri->contribution += local->delta;
1521 }
1522 UNLOCK (&local->contri->lock)pthread_spin_unlock (&local->contri->lock);
1523
1524 gf_log (this->name, GF_LOG_DEBUG, "%s %"PRId64 "%"PRId64,do { do { if (0) printf ("%s %""ll" "d" "%""ll" "d", local->
loc.path, local->ctx->size, local->contri->contribution
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 1526, GF_LOG_DEBUG, "%s %""ll" "d" "%""ll" "d", local->loc
.path, local->ctx->size, local->contri->contribution
); } while (0)
1525 local->loc.path, local->ctx->size,do { do { if (0) printf ("%s %""ll" "d" "%""ll" "d", local->
loc.path, local->ctx->size, local->contri->contribution
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 1526, GF_LOG_DEBUG, "%s %""ll" "d" "%""ll" "d", local->loc
.path, local->ctx->size, local->contri->contribution
); } while (0)
1526 local->contri->contribution)do { do { if (0) printf ("%s %""ll" "d" "%""ll" "d", local->
loc.path, local->ctx->size, local->contri->contribution
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 1526, GF_LOG_DEBUG, "%s %""ll" "d" "%""ll" "d", local->loc
.path, local->ctx->size, local->contri->contribution
); } while (0)
;
1527
1528 if (dict == NULL((void*)0)) {
1529 op_errno = EINVAL22;
1530 goto err;
1531 }
1532
1533 ret = mq_inode_ctx_get (local->parent_loc.inode, this, &ctx);
1534 if (ret < 0) {
1535 op_errno = EINVAL22;
1536 goto err;
1537 }
1538
1539 newdict = dict_new ();
1540 if (!newdict) {
1541 op_errno = ENOMEM12;
1542 ret = -1;
1543 goto err;
1544 }
1545
1546 QUOTA_ALLOC_OR_GOTO (size, int64_t, ret, err)do { size = __gf_calloc (sizeof (int64_t), 1, gf_marker_mt_int64_t
); if (!size) { do { do { if (0) printf ("out of memory"); } while
(0); _gf_log ("", "marker-quota.c", __FUNCTION__, 1546, GF_LOG_ERROR
, "out of memory"); } while (0); ret = -1; goto err; } ret = 0
; } while (0);
;
1547
1548 *size = hton64 (local->delta);
1549
1550 ret = dict_set_bin (newdict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", size, 8);
1551 if (ret < 0) {
1552 op_errno = -ret;
1553 goto err;
1554 }
1555
1556 if (uuid_is_null (local->parent_loc.gfid))
1557 uuid_copy (local->parent_loc.gfid,
1558 local->parent_loc.inode->gfid);
1559 GF_UUID_ASSERT (local->parent_loc.gfid)if (uuid_is_null (local->parent_loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1559, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1560
1561 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1562 mq_mark_undirty,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", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1563 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1564 FIRST_CHILD(this)->fops->xattrop,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", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1565 &local->parent_loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1566 GF_XATTROP_ADD_ARRAY64,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", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
1567 newdict, 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", "marker-quota.c", __FUNCTION__, 1567,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_mark_undirty; _new->root = frame->root; _new->
this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_mark_undirty"; pthread_spin_init (
&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, newdict, (
(void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
1568 ret = 0;
1569err:
1570 if (op_ret == -1 || ret < 0) {
1571 local->err = op_errno;
1572 mq_release_parent_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1573 }
1574
1575 if (newdict)
1576 dict_unref (newdict);
1577
1578 return 0;
1579}
1580
1581int32_t
1582mq_update_inode_contribution (call_frame_t *frame, void *cookie,
1583 xlator_t *this, int32_t op_ret,
1584 int32_t op_errno, inode_t *inode,
1585 struct iatt *buf, dict_t *dict,
1586 struct iatt *postparent)
1587{
1588 int32_t ret = -1;
1589 int64_t *size = NULL((void*)0), size_int = 0, contri_int = 0;
1590 int64_t *contri = NULL((void*)0);
1591 int64_t *delta = NULL((void*)0);
1592 char contri_key [512] = {0, };
1593 dict_t *newdict = NULL((void*)0);
1594 quota_local_tmarker_local_t *local = NULL((void*)0);
1595 quota_inode_ctx_t *ctx = NULL((void*)0);
1596 inode_contribution_t *contribution = NULL((void*)0);
1597
1598 local = frame->local;
1599
1600 if (op_ret == -1) {
1601 gf_log (this->name, ((op_errno == ENOENT) ? GF_LOG_DEBUG :do { do { if (0) printf ("failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1604, ((op_errno
== 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0)
1602 GF_LOG_WARNING),do { do { if (0) printf ("failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1604, ((op_errno
== 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0)
1603 "failed to get size and contribution of path (%s)(%s)",do { do { if (0) printf ("failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1604, ((op_errno
== 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0)
1604 local->loc.path, strerror (op_errno))do { do { if (0) printf ("failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1604, ((op_errno
== 2) ? GF_LOG_DEBUG : GF_LOG_WARNING), "failed to get size and contribution of path (%s)(%s)"
, local->loc.path, strerror (op_errno)); } while (0)
;
1605 goto err;
1606 }
1607
1608 ctx = local->ctx;
1609 contribution = local->contri;
1610
1611 //prepare to update size & contribution of the inode
1612 GET_CONTRI_KEY (contri_key, contribution->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (contribution->
gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
1613 if (ret == -1) {
1614 op_errno = ENOMEM12;
1615 goto err;
1616 }
1617
1618 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
1619 {
1620 if (local->loc.inode->ia_type == IA_IFDIR ) {
1621 ret = dict_get_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size",
1622 (void **) &size);
1623 if (ret < 0) {
1624 op_errno = EINVAL22;
1625 goto unlock;
1626 }
1627
1628 ctx->size = ntoh64hton64 (*size);
1629 } else
1630 ctx->size = buf->ia_blocks * 512;
1631
1632 size_int = ctx->size;
1633 }
1634unlock:
1635 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
1636
1637 if (ret < 0) {
1638 goto err;
1639 }
1640
1641 ret = dict_get_bin (dict, contri_key, (void **) &contri);
1642
1643 LOCK (&contribution->lock)pthread_spin_lock (&contribution->lock);
1644 {
1645 if (ret < 0)
1646 contribution->contribution = 0;
1647 else
1648 contribution->contribution = ntoh64hton64 (*contri);
1649
1650 contri_int = contribution->contribution;
1651 }
1652 UNLOCK (&contribution->lock)pthread_spin_unlock (&contribution->lock);
1653
1654 gf_log (this->name, GF_LOG_DEBUG, "%s %"PRId64 "%"PRId64,do { do { if (0) printf ("%s %""ll" "d" "%""ll" "d", local->
loc.path, size_int, contri_int); } while (0); _gf_log (this->
name, "marker-quota.c", __FUNCTION__, 1655, GF_LOG_DEBUG, "%s %"
"ll" "d" "%""ll" "d", local->loc.path, size_int, contri_int
); } while (0)
1655 local->loc.path, size_int, contri_int)do { do { if (0) printf ("%s %""ll" "d" "%""ll" "d", local->
loc.path, size_int, contri_int); } while (0); _gf_log (this->
name, "marker-quota.c", __FUNCTION__, 1655, GF_LOG_DEBUG, "%s %"
"ll" "d" "%""ll" "d", local->loc.path, size_int, contri_int
); } while (0)
;
1656
1657 local->delta = size_int - contri_int;
1658
1659 if (local->delta == 0) {
1660 mq_mark_undirty (frame, NULL((void*)0), this, 0, 0, NULL((void*)0), NULL((void*)0));
1661 return 0;
1662 }
1663
1664 newdict = dict_new ();
1665 if (newdict == NULL((void*)0)) {
1666 op_errno = ENOMEM12;
1667 ret = -1;
1668 goto err;
1669 }
1670
1671 QUOTA_ALLOC_OR_GOTO (delta, int64_t, ret, err)do { delta = __gf_calloc (sizeof (int64_t), 1, gf_marker_mt_int64_t
); if (!delta) { do { do { if (0) printf ("out of memory"); }
while (0); _gf_log ("", "marker-quota.c", __FUNCTION__, 1671
, GF_LOG_ERROR, "out of memory"); } while (0); ret = -1; goto
err; } ret = 0; } while (0);
;
1672
1673 *delta = hton64 (local->delta);
1674
1675 ret = dict_set_bin (newdict, contri_key, delta, 8);
1676 if (ret < 0) {
1677 op_errno = -ret;
1678 ret = -1;
1679 goto err;
1680 }
1681
1682 if (uuid_is_null (local->loc.gfid))
1683 uuid_copy (local->loc.gfid, buf->ia_gfid);
1684
1685 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1685, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1686
1687 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1688 mq_update_parent_size,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", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1689 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1690 FIRST_CHILD(this)->fops->xattrop,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", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1691 &local->loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1692 GF_XATTROP_ADD_ARRAY64,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", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1693 newdict, 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", "marker-quota.c", __FUNCTION__, 1693,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_update_parent_size; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_update_parent_size"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->loc, GF_XATTROP_ADD_ARRAY64, newdict, ((void*
)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1694 ret = 0;
1695
1696err:
1697 if (op_ret == -1 || ret < 0) {
1698 local->err = op_errno;
1699
1700 mq_release_parent_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1701 }
1702
1703 if (newdict)
1704 dict_unref (newdict);
1705
1706 return 0;
1707}
1708
1709int32_t
1710mq_fetch_child_size_and_contri (call_frame_t *frame, void *cookie,
1711 xlator_t *this, int32_t op_ret,
1712 int32_t op_errno, dict_t *xdata)
1713{
1714 int32_t ret = -1;
1715 char contri_key [512] = {0, };
1716 dict_t *newdict = NULL((void*)0);
1717 quota_local_tmarker_local_t *local = NULL((void*)0);
1718 quota_inode_ctx_t *ctx = NULL((void*)0);
1719
1720 local = frame->local;
1721
1722 if (op_ret == -1) {
1
Taking false branch
1723 gf_log (this->name, (op_errno == ENOENT) ? GF_LOG_DEBUGdo { do { if (0) printf ("couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
1726, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0)
1724 : GF_LOG_WARNING,do { do { if (0) printf ("couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
1726, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0)
1725 "couldnt mark inode corresponding to path (%s) dirty "do { do { if (0) printf ("couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
1726, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0)
1726 "(%s)", local->parent_loc.path, strerror (op_errno))do { do { if (0) printf ("couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0); _gf_log (this->name, "marker-quota.c", __FUNCTION__,
1726, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "couldnt mark inode corresponding to path (%s) dirty "
"(%s)", local->parent_loc.path, strerror (op_errno)); } while
(0)
;
1727 goto err;
1728 }
1729
1730 VALIDATE_OR_GOTO (local->ctx, err)do { if (!local->ctx) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "local->ctx"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "marker-quota.c", __FUNCTION__, 1730, GF_LOG_WARNING, "invalid argument: "
"local->ctx"); } while (0); goto err; } } while (0)
;
2
Within the expansion of the macro 'VALIDATE_OR_GOTO':
a
Assuming 'this' is null
1731 VALIDATE_OR_GOTO (local->contri, err)do { if (!local->contri) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "local->contri"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "marker-quota.c", __FUNCTION__, 1731, GF_LOG_WARNING, "invalid argument: "
"local->contri"); } while (0); goto err; } } while (0)
;
1732
1733 gf_log (this->name, GF_LOG_DEBUG, "%s marked dirty", local->parent_loc.path)do { do { if (0) printf ("%s marked dirty", local->parent_loc
.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1733, GF_LOG_DEBUG, "%s marked dirty", local->
parent_loc.path); } while (0)
;
1734
1735 //update parent ctx
1736 ret = mq_inode_ctx_get (local->parent_loc.inode, this, &ctx);
1737 if (ret == -1) {
1738 op_errno = EINVAL22;
1739 goto err;
1740 }
1741
1742 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
1743 {
1744 ctx->dirty = 1;
1745 }
1746 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
1747
1748 newdict = dict_new ();
1749 if (newdict == NULL((void*)0)) {
1750 op_errno = ENOMEM12;
1751 goto err;
1752 }
1753
1754 if (local->loc.inode->ia_type == IA_IFDIR) {
1755 ret = dict_set_int64 (newdict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", 0);
1756 if (ret < 0) {
1757 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dict_set failed."); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1758, GF_LOG_WARNING
, "dict_set failed."); } while (0)
1758 "dict_set failed.")do { do { if (0) printf ("dict_set failed."); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1758, GF_LOG_WARNING
, "dict_set failed."); } while (0)
;
1759 goto err;
1760 }
1761 }
1762
1763 GET_CONTRI_KEY (contri_key, local->contri->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (local->contri->
gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
1764 if (ret < 0) {
1765 op_errno = ENOMEM12;
1766 goto err;
1767 }
1768
1769 ret = dict_set_int64 (newdict, contri_key, 0);
1770 if (ret < 0) {
1771 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dict_set failed."); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1772, GF_LOG_WARNING
, "dict_set failed."); } while (0)
1772 "dict_set failed.")do { do { if (0) printf ("dict_set failed."); } while (0); _gf_log
(this->name, "marker-quota.c", __FUNCTION__, 1772, GF_LOG_WARNING
, "dict_set failed."); } while (0)
;
1773 goto err;
1774 }
1775
1776 mq_set_ctx_updation_status (local->ctx, _gf_false);
1777
1778 if (uuid_is_null (local->loc.gfid))
1779 uuid_copy (local->loc.gfid, local->loc.inode->gfid);
1780
1781 GF_UUID_ASSERT (local->loc.gfid)if (uuid_is_null (local->loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1781, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1782
1783 STACK_WIND (frame, mq_update_inode_contribution, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1784,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->lookup_cbk) tmp_cbk
= mq_update_inode_contribution; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->lookup"; _new->unwind_to =
"mq_update_inode_contribution"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &local->loc, newdict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1784 FIRST_CHILD(this)->fops->lookup, &local->loc, newdict)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", "marker-quota.c", __FUNCTION__, 1784,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->lookup_cbk) tmp_cbk
= mq_update_inode_contribution; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->lookup"; _new->unwind_to =
"mq_update_inode_contribution"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->lookup); (
this->children->xlator)->fops->lookup (_new, (this
->children->xlator), &local->loc, newdict); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1785
1786 ret = 0;
1787
1788err:
1789 if ((op_ret == -1) || (ret < 0)) {
3
Taking true branch
1790 local->err = op_errno;
1791
1792 mq_set_ctx_updation_status (local->ctx, _gf_false);
1793
1794 mq_release_parent_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
4
Passing null pointer value via 3rd parameter 'this'
5
Calling 'mq_release_parent_lock'
1795 }
1796
1797 if (newdict)
1798 dict_unref (newdict);
1799
1800 return 0;
1801}
1802
1803int32_t
1804mq_markdirty (call_frame_t *frame, void *cookie,
1805 xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata)
1806{
1807 int32_t ret = -1;
1808 dict_t *dict = NULL((void*)0);
1809 quota_local_tmarker_local_t *local = NULL((void*)0);
1810
1811 local = frame->local;
1812
1813 if (op_ret == -1){
1814 gf_log (this->name, (op_errno == ENOENT) ? GF_LOG_DEBUGdo { do { if (0) printf ("acquiring locks failed on %s (%s)",
local->parent_loc.path, strerror (op_errno)); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1816
, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "acquiring locks failed on %s (%s)"
, local->parent_loc.path, strerror (op_errno)); } while (0
)
1815 : GF_LOG_WARNING, "acquiring locks failed on %s (%s)",do { do { if (0) printf ("acquiring locks failed on %s (%s)",
local->parent_loc.path, strerror (op_errno)); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1816
, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "acquiring locks failed on %s (%s)"
, local->parent_loc.path, strerror (op_errno)); } while (0
)
1816 local->parent_loc.path, strerror (op_errno))do { do { if (0) printf ("acquiring locks failed on %s (%s)",
local->parent_loc.path, strerror (op_errno)); } while (0)
; _gf_log (this->name, "marker-quota.c", __FUNCTION__, 1816
, (op_errno == 2) ? GF_LOG_DEBUG : GF_LOG_WARNING, "acquiring locks failed on %s (%s)"
, local->parent_loc.path, strerror (op_errno)); } while (0
)
;
1817
1818 local->err = op_errno;
1819
1820 mq_set_ctx_updation_status (local->ctx, _gf_false);
1821
1822 mq_inodelk_cbk (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1823
1824 return 0;
1825 }
1826
1827 gf_log (this->name, GF_LOG_TRACE,do { do { if (0) printf ("inodelk succeeded on %s", local->
parent_loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1828, GF_LOG_TRACE, "inodelk succeeded on %s"
, local->parent_loc.path); } while (0)
1828 "inodelk succeeded on %s", local->parent_loc.path)do { do { if (0) printf ("inodelk succeeded on %s", local->
parent_loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1828, GF_LOG_TRACE, "inodelk succeeded on %s"
, local->parent_loc.path); } while (0)
;
1829
1830 dict = dict_new ();
1831 if (!dict) {
1832 ret = -1;
1833 goto err;
1834 }
1835
1836 ret = dict_set_int8 (dict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", 1);
1837 if (ret == -1)
1838 goto err;
1839
1840 uuid_copy (local->parent_loc.gfid,
1841 local->parent_loc.inode->gfid);
1842 GF_UUID_ASSERT (local->parent_loc.gfid)if (uuid_is_null (local->parent_loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 1842, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
1843
1844 STACK_WIND (frame, mq_fetch_child_size_and_contri,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", "marker-quota.c", __FUNCTION__, 1847,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_fetch_child_size_and_contri; _new->root = frame->
root; _new->this = (this->children->xlator); _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->setxattr"; _new->unwind_to
= "mq_fetch_child_size_and_contri"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, dict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1845 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1847,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_fetch_child_size_and_contri; _new->root = frame->
root; _new->this = (this->children->xlator); _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->setxattr"; _new->unwind_to
= "mq_fetch_child_size_and_contri"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, dict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1846 FIRST_CHILD(this)->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1847,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_fetch_child_size_and_contri; _new->root = frame->
root; _new->this = (this->children->xlator); _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->setxattr"; _new->unwind_to
= "mq_fetch_child_size_and_contri"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, dict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1847 &local->parent_loc, dict, 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", "marker-quota.c", __FUNCTION__, 1847,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->setxattr_cbk) tmp_cbk
= mq_fetch_child_size_and_contri; _new->root = frame->
root; _new->this = (this->children->xlator); _new->
ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->setxattr"; _new->unwind_to
= "mq_fetch_child_size_and_contri"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->setxattr); (this->children->xlator
)->fops->setxattr (_new, (this->children->xlator)
, &local->parent_loc, dict, 0, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1848
1849 ret = 0;
1850err:
1851 if (ret == -1) {
1852 local->err = 1;
1853
1854 mq_set_ctx_updation_status (local->ctx, _gf_false);
1855
1856 mq_release_parent_lock (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
1857 }
1858
1859 if (dict)
1860 dict_unref (dict);
1861
1862 return 0;
1863}
1864
1865
1866int32_t
1867mq_get_lock_on_parent (call_frame_t *frame, xlator_t *this)
1868{
1869 struct gf_flock lock = {0, };
1870 quota_local_tmarker_local_t *local = NULL((void*)0);
1871
1872 GF_VALIDATE_OR_GOTO ("marker", frame, fr_destroy)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 1872, GF_LOG_ERROR
, "invalid argument: " "frame"); } while (0); goto fr_destroy
; } } while (0)
;
1873
1874 local = frame->local;
1875 gf_log (this->name, GF_LOG_DEBUG, "taking lock on %s",do { do { if (0) printf ("taking lock on %s", local->parent_loc
.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1876, GF_LOG_DEBUG, "taking lock on %s", local
->parent_loc.path); } while (0)
1876 local->parent_loc.path)do { do { if (0) printf ("taking lock on %s", local->parent_loc
.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1876, GF_LOG_DEBUG, "taking lock on %s", local
->parent_loc.path); } while (0)
;
1877
1878 if (local->parent_loc.inode == NULL((void*)0)) {
1879 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("parent inode is not valid, aborting "
"transaction."); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1881, GF_LOG_DEBUG, "parent inode is not valid, aborting "
"transaction."); } while (0)
1880 "parent inode is not valid, aborting "do { do { if (0) printf ("parent inode is not valid, aborting "
"transaction."); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1881, GF_LOG_DEBUG, "parent inode is not valid, aborting "
"transaction."); } while (0)
1881 "transaction.")do { do { if (0) printf ("parent inode is not valid, aborting "
"transaction."); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 1881, GF_LOG_DEBUG, "parent inode is not valid, aborting "
"transaction."); } while (0)
;
1882 goto fr_destroy;
1883 }
1884
1885 lock.l_len = 0;
1886 lock.l_start = 0;
1887 lock.l_type = F_WRLCK1;
1888 lock.l_whence = SEEK_SET0;
1889
1890 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 1894,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_markdirty; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_markdirty"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1891 mq_markdirty,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", "marker-quota.c", __FUNCTION__, 1894,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_markdirty; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_markdirty"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1892 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 1894,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_markdirty; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_markdirty"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1893 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 1894,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_markdirty; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_markdirty"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
1894 this->name, &local->parent_loc, F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 1894,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_markdirty; _new->root = frame->root; _new->this
= (this->children->xlator); _new->ret = (ret_fn_t) tmp_cbk
; _new->parent = frame; _new->cookie = _new; _new->wind_from
= __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "mq_markdirty"; pthread_spin_init (&
_new->lock, 0); pthread_spin_lock (&frame->root->
stack_lock); { _new->next = frame->root->frames.next
; _new->prev = &frame->root->frames; if (frame->
root->frames.next) frame->root->frames.next->prev
= _new; frame->root->frames.next = _new; frame->ref_count
++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
1895
1896 return 0;
1897
1898fr_destroy:
1899 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
1900
1901 return -1;
1902}
1903
1904
1905int
1906mq_start_quota_txn (xlator_t *this, loc_t *loc,
1907 quota_inode_ctx_t *ctx,
1908 inode_contribution_t *contri)
1909{
1910 int32_t ret = -1;
1911 call_frame_t *frame = NULL((void*)0);
1912 quota_local_tmarker_local_t *local = NULL((void*)0);
1913
1914 frame = create_frame (this, this->ctx->pool);
1915 if (frame == NULL((void*)0))
1916 goto err;
1917
1918 mq_assign_lk_owner (this, frame);
1919
1920 local = mq_local_new ();
1921 if (local == NULL((void*)0))
1922 goto fr_destroy;
1923
1924 frame->local = local;
1925
1926 ret = mq_loc_copy (&local->loc, loc);
1927 if (ret < 0)
1928 goto fr_destroy;
1929
1930 ret = mq_inode_loc_fill (NULL((void*)0), local->loc.parent,
1931 &local->parent_loc);
1932 if (ret < 0)
1933 goto fr_destroy;
1934
1935 local->ctx = ctx;
1936 local->contri = contri;
1937
1938 ret = mq_get_lock_on_parent (frame, this);
1939 if (ret == -1)
1940 goto err;
1941
1942 return 0;
1943
1944fr_destroy:
1945 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
1946err:
1947 mq_set_ctx_updation_status (ctx, _gf_false);
1948
1949 return -1;
1950}
1951
1952
1953int
1954mq_initiate_quota_txn (xlator_t *this, loc_t *loc)
1955{
1956 int32_t ret = -1;
1957 gf_boolean_t status = _gf_false;
1958 quota_inode_ctx_t *ctx = NULL((void*)0);
1959 inode_contribution_t *contribution = NULL((void*)0);
1960
1961 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 1961, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
1962 GF_VALIDATE_OR_GOTO ("marker", loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 1962, GF_LOG_ERROR
, "invalid argument: " "loc"); } while (0); goto out; } } while
(0)
;
1963 GF_VALIDATE_OR_GOTO ("marker", loc->inode, out)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ("marker", "marker-quota.c", __FUNCTION__
, 1963, GF_LOG_ERROR, "invalid argument: " "loc->inode"); }
while (0); goto out; } } while (0)
;
1964
1965 ret = mq_inode_ctx_get (loc->inode, this, &ctx);
1966 if (ret == -1) {
1967 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("inode ctx get failed, aborting quota txn"
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 1968, GF_LOG_WARNING, "inode ctx get failed, aborting quota txn"
); } while (0)
1968 "inode ctx get failed, aborting quota txn")do { do { if (0) printf ("inode ctx get failed, aborting quota txn"
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 1968, GF_LOG_WARNING, "inode ctx get failed, aborting quota txn"
); } while (0)
;
1969 ret = -1;
1970 goto out;
1971 }
1972
1973 contribution = mq_get_contribution_node (loc->parent, ctx);
1974 if (contribution == NULL((void*)0))
1975 goto out;
1976
1977 /* To improve performance, donot start another transaction
1978 * if one is already in progress for same inode
1979 */
1980 status = _gf_true;
1981
1982 ret = mq_test_and_set_ctx_updation_status (ctx, &status);
1983 if (ret < 0)
1984 goto out;
1985
1986 if (status == _gf_false) {
1987 mq_start_quota_txn (this, loc, ctx, contribution);
1988 }
1989
1990 ret = 0;
1991out:
1992 return ret;
1993}
1994
1995
1996/* int32_t */
1997/* validate_inode_size_contribution (xlator_t *this, loc_t *loc, int64_t size, */
1998/* int64_t contribution) */
1999/* { */
2000/* if (size != contribution) { */
2001/* mq_initiate_quota_txn (this, loc); */
2002/* } */
2003
2004/* return 0; */
2005/* } */
2006
2007
2008int32_t
2009mq_inspect_directory_xattr (xlator_t *this,
2010 loc_t *loc,
2011 dict_t *dict,
2012 struct iatt buf)
2013{
2014 int32_t ret = 0;
2015 int8_t dirty = -1;
2016 int64_t *size = NULL((void*)0), size_int = 0;
2017 int64_t *contri = NULL((void*)0), contri_int = 0;
2018 char contri_key [512] = {0, };
2019 gf_boolean_t not_root = _gf_false;
2020 quota_inode_ctx_t *ctx = NULL((void*)0);
2021 inode_contribution_t *contribution = NULL((void*)0);
2022
2023 ret = mq_inode_ctx_get (loc->inode, this, &ctx);
2024 if (ret < 0) {
2025 ctx = mq_inode_ctx_new (loc->inode, this);
2026 if (ctx == NULL((void*)0)) {
2027 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("mq_inode_ctx_new failed"); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 2028
, GF_LOG_WARNING, "mq_inode_ctx_new failed"); } while (0)
2028 "mq_inode_ctx_new failed")do { do { if (0) printf ("mq_inode_ctx_new failed"); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 2028
, GF_LOG_WARNING, "mq_inode_ctx_new failed"); } while (0)
;
2029 ret = -1;
2030 goto err;
2031 }
2032 }
2033
2034 if (strcmp (loc->path, "/") != 0) {
2035 contribution = mq_add_new_contribution_node (this, ctx, loc);
2036 if (contribution == NULL((void*)0)) {
2037 if (!uuid_is_null (loc->inode->gfid))
2038 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("cannot add a new contribution node"
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 2039, GF_LOG_WARNING, "cannot add a new contribution node")
; } while (0)
2039 "cannot add a new contribution node")do { do { if (0) printf ("cannot add a new contribution node"
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 2039, GF_LOG_WARNING, "cannot add a new contribution node")
; } while (0)
;
2040 ret = -1;
2041 goto err;
2042 }
2043 }
2044
2045 ret = dict_get_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", (void **) &size);
2046 if (ret < 0)
2047 goto out;
2048
2049 ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", &dirty);
2050 if (ret < 0)
2051 goto out;
2052
2053 if (strcmp (loc->path, "/") != 0) {
2054 not_root = _gf_true;
2055
2056 GET_CONTRI_KEY (contri_key, contribution->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (contribution->
gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
2057 if (ret < 0)
2058 goto out;
2059
2060 ret = dict_get_bin (dict, contri_key, (void **) &contri);
2061 if (ret < 0)
2062 goto out;
2063
2064 LOCK (&contribution->lock)pthread_spin_lock (&contribution->lock);
2065 {
2066 contribution->contribution = ntoh64hton64 (*contri);
2067 contri_int = contribution->contribution;
2068 }
2069 UNLOCK (&contribution->lock)pthread_spin_unlock (&contribution->lock);
2070 }
2071
2072 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
2073 {
2074 ctx->size = ntoh64hton64 (*size);
2075 ctx->dirty = dirty;
2076 size_int = ctx->size;
2077 }
2078 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
2079
2080 gf_log (this->name, GF_LOG_DEBUG, "size=%"PRId64do { do { if (0) printf ("size=%""ll" "d" " contri=%""ll" "d"
, size_int, contri_int); } while (0); _gf_log (this->name,
"marker-quota.c", __FUNCTION__, 2081, GF_LOG_DEBUG, "size=%"
"ll" "d" " contri=%""ll" "d", size_int, contri_int); } while (
0)
2081 " contri=%"PRId64, size_int, contri_int)do { do { if (0) printf ("size=%""ll" "d" " contri=%""ll" "d"
, size_int, contri_int); } while (0); _gf_log (this->name,
"marker-quota.c", __FUNCTION__, 2081, GF_LOG_DEBUG, "size=%"
"ll" "d" " contri=%""ll" "d", size_int, contri_int); } while (
0)
;
2082
2083 if (dirty) {
2084 ret = mq_update_dirty_inode (this, loc, ctx, contribution);
2085 }
2086
2087 if ((!dirty || ret == 0) && (not_root == _gf_true) &&
2088 (size_int != contri_int)) {
2089 mq_initiate_quota_txn (this, loc);
2090 }
2091
2092 ret = 0;
2093out:
2094 if (ret)
2095 mq_set_inode_xattr (this, loc);
2096err:
2097 return ret;
2098}
2099
2100int32_t
2101mq_inspect_file_xattr (xlator_t *this,
2102 loc_t *loc,
2103 dict_t *dict,
2104 struct iatt buf)
2105{
2106 int32_t ret = -1;
2107 uint64_t contri_int = 0, size = 0;
2108 int64_t *contri_ptr = NULL((void*)0);
2109 char contri_key [512] = {0, };
2110 quota_inode_ctx_t *ctx = NULL((void*)0);
2111 inode_contribution_t *contribution = NULL((void*)0);
2112
2113 ret = mq_inode_ctx_get (loc->inode, this, &ctx);
2114 if (ret < 0) {
2115 ctx = mq_inode_ctx_new (loc->inode, this);
2116 if (ctx == NULL((void*)0)) {
2117 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("mq_inode_ctx_new failed"); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 2118
, GF_LOG_WARNING, "mq_inode_ctx_new failed"); } while (0)
2118 "mq_inode_ctx_new failed")do { do { if (0) printf ("mq_inode_ctx_new failed"); } while (
0); _gf_log (this->name, "marker-quota.c", __FUNCTION__, 2118
, GF_LOG_WARNING, "mq_inode_ctx_new failed"); } while (0)
;
2119 ret = -1;
2120 goto out;
2121 }
2122 }
2123
2124 contribution = mq_add_new_contribution_node (this, ctx, loc);
2125 if (contribution == NULL((void*)0))
2126 goto out;
2127
2128 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
2129 {
2130 ctx->size = 512 * buf.ia_blocks;
2131 size = ctx->size;
2132 }
2133 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
2134
2135 list_for_each_entry (contribution, &ctx->contribution_head,for (contribution = ((typeof(*contribution) *)((char *)((&
ctx->contribution_head)->next)-(unsigned long)(&((typeof
(*contribution) *)0)->contri_list))); &contribution->
contri_list != (&ctx->contribution_head); contribution
= ((typeof(*contribution) *)((char *)(contribution->contri_list
.next)-(unsigned long)(&((typeof(*contribution) *)0)->
contri_list))))
2136 contri_list)for (contribution = ((typeof(*contribution) *)((char *)((&
ctx->contribution_head)->next)-(unsigned long)(&((typeof
(*contribution) *)0)->contri_list))); &contribution->
contri_list != (&ctx->contribution_head); contribution
= ((typeof(*contribution) *)((char *)(contribution->contri_list
.next)-(unsigned long)(&((typeof(*contribution) *)0)->
contri_list))))
{
2137 GET_CONTRI_KEY (contri_key, contribution->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (contribution->
gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
2138 if (ret < 0)
2139 continue;
2140
2141 ret = dict_get_bin (dict, contri_key, (void **) &contri_int);
2142 if (ret == 0) {
2143 contri_ptr = (int64_t *)(unsigned long)contri_int;
2144
2145 LOCK (&contribution->lock)pthread_spin_lock (&contribution->lock);
2146 {
2147 contribution->contribution = ntoh64hton64 (*contri_ptr);
2148 contri_int = contribution->contribution;
2149 }
2150 UNLOCK (&contribution->lock)pthread_spin_unlock (&contribution->lock);
2151
2152 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("size=%""ll" "d" " contri=%""ll" "d"
, size, contri_int); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 2153, GF_LOG_DEBUG, "size=%""ll" "d" " contri=%"
"ll" "d", size, contri_int); } while (0)
2153 "size=%"PRId64 " contri=%"PRId64, size, contri_int)do { do { if (0) printf ("size=%""ll" "d" " contri=%""ll" "d"
, size, contri_int); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 2153, GF_LOG_DEBUG, "size=%""ll" "d" " contri=%"
"ll" "d", size, contri_int); } while (0)
;
2154
2155 if (size != contri_int) {
2156 mq_initiate_quota_txn (this, loc);
2157 }
2158 } else
2159 mq_initiate_quota_txn (this, loc);
2160 }
2161
2162out:
2163 return ret;
2164}
2165
2166int32_t
2167mq_xattr_state (xlator_t *this,
2168 loc_t *loc,
2169 dict_t *dict,
2170 struct iatt buf)
2171{
2172 if (buf.ia_type == IA_IFREG ||
2173 buf.ia_type == IA_IFLNK) {
2174 mq_inspect_file_xattr (this, loc, dict, buf);
2175 } else if (buf.ia_type == IA_IFDIR)
2176 mq_inspect_directory_xattr (this, loc, dict, buf);
2177
2178 return 0;
2179}
2180
2181int32_t
2182mq_req_xattr (xlator_t *this,
2183 loc_t *loc,
2184 dict_t *dict)
2185{
2186 int32_t ret = -1;
2187
2188 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2188, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
2189 GF_VALIDATE_OR_GOTO ("marker", dict, out)do { if (!dict) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "dict"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2189, GF_LOG_ERROR
, "invalid argument: " "dict"); } while (0); goto out; } } while
(0)
;
2190
2191 if (!loc)
2192 goto set_size;
2193
2194 //if not "/" then request contribution
2195 if (strcmp (loc->path, "/") == 0)
2196 goto set_size;
2197
2198 ret = mq_dict_set_contribution (this, dict, loc);
2199 if (ret == -1)
2200 goto out;
2201
2202set_size:
2203 ret = dict_set_uint64 (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", 0);
2204 if (ret < 0) {
2205 ret = -1;
2206 goto out;
2207 }
2208
2209 ret = dict_set_int8 (dict, QUOTA_DIRTY_KEY"trusted.glusterfs.quota.dirty", 0);
2210 if (ret < 0) {
2211 ret = -1;
2212 goto out;
2213 }
2214
2215 ret = 0;
2216
2217out:
2218 return ret;
2219}
2220
2221
2222int32_t
2223mq_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2224 int32_t op_ret, int32_t op_errno, dict_t *xdata)
2225{
2226 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
2227
2228 return 0;
2229}
2230
2231int32_t
2232_mq_inode_remove_done (call_frame_t *frame, void *cookie, xlator_t *this,
2233 int32_t op_ret, int32_t op_errno, dict_t *xdata)
2234{
2235 int32_t ret = 0;
2236 char contri_key [512] = {0, };
2237 quota_local_tmarker_local_t *local = NULL((void*)0);
2238
2239 local = (quota_local_tmarker_local_t *) frame->local;
2240
2241 if (op_ret == -1 || local->err == -1) {
2242 mq_removexattr_cbk (frame, NULL((void*)0), this, -1, 0, NULL((void*)0));
2243 return 0;
2244 }
2245
2246 frame->local = NULL((void*)0);
2247
2248 if (local->hl_count > 1) {
2249 GET_CONTRI_KEY (contri_key, local->contri->gfid, ret)do { char _gfid_unparsed[40]; uuid_unparse (local->contri->
gfid, _gfid_unparsed); ret = snprintf (contri_key, 512, "trusted.glusterfs"
".%s.%s." "contri", "quota", _gfid_unparsed); } while (0);
;
2250
2251 STACK_WIND (frame, mq_removexattr_cbk, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2253,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->removexattr_cbk)
tmp_cbk = mq_removexattr_cbk; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->removexattr"; _new->unwind_to
= "mq_removexattr_cbk"; pthread_spin_init (&_new->lock
, 0); pthread_spin_lock (&frame->root->stack_lock);
{ _new->next = frame->root->frames.next; _new->prev
= &frame->root->frames; if (frame->root->frames
.next) frame->root->frames.next->prev = _new; frame->
root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->removexattr
); (this->children->xlator)->fops->removexattr (_new
, (this->children->xlator), &local->loc, contri_key
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
2252 FIRST_CHILD(this)->fops->removexattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2253,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->removexattr_cbk)
tmp_cbk = mq_removexattr_cbk; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->removexattr"; _new->unwind_to
= "mq_removexattr_cbk"; pthread_spin_init (&_new->lock
, 0); pthread_spin_lock (&frame->root->stack_lock);
{ _new->next = frame->root->frames.next; _new->prev
= &frame->root->frames; if (frame->root->frames
.next) frame->root->frames.next->prev = _new; frame->
root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->removexattr
); (this->children->xlator)->fops->removexattr (_new
, (this->children->xlator), &local->loc, contri_key
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
2253 &local->loc, contri_key, NULL)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2253,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->removexattr_cbk)
tmp_cbk = mq_removexattr_cbk; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->removexattr"; _new->unwind_to
= "mq_removexattr_cbk"; pthread_spin_init (&_new->lock
, 0); pthread_spin_lock (&frame->root->stack_lock);
{ _new->next = frame->root->frames.next; _new->prev
= &frame->root->frames; if (frame->root->frames
.next) frame->root->frames.next->prev = _new; frame->
root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->removexattr
); (this->children->xlator)->fops->removexattr (_new
, (this->children->xlator), &local->loc, contri_key
, ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
2254 ret = 0;
2255 } else {
2256 mq_removexattr_cbk (frame, NULL((void*)0), this, 0, 0, NULL((void*)0));
2257 }
2258
2259 if (strcmp (local->parent_loc.path, "/") != 0) {
2260 ret = mq_get_parent_inode_local (this, local);
2261 if (ret < 0)
2262 goto out;
2263
2264 mq_start_quota_txn (this, &local->loc, local->ctx, local->contri);
2265 }
2266out:
2267 mq_local_unref (this, local);
2268
2269 return 0;
2270}
2271
2272int32_t
2273mq_inode_remove_done (call_frame_t *frame, void *cookie, xlator_t *this,
2274 int32_t op_ret, int32_t op_errno, dict_t *dict,
2275 dict_t *xdata)
2276{
2277 int32_t ret = -1;
2278 struct gf_flock lock = {0, };
2279 quota_inode_ctx_t *ctx = NULL((void*)0);
2280 quota_local_tmarker_local_t *local = NULL((void*)0);
2281 int64_t contribution = 0;
2282
2283 local = frame->local;
2284 if (op_ret == -1)
2285 local->err = -1;
2286
2287 ret = mq_inode_ctx_get (local->parent_loc.inode, this, &ctx);
2288
2289 LOCK (&local->contri->lock)pthread_spin_lock (&local->contri->lock);
2290 {
2291 contribution = local->contri->contribution;
2292 }
2293 UNLOCK (&local->contri->lock)pthread_spin_unlock (&local->contri->lock);
2294
2295 if (contribution == local->size) {
2296 if (ret == 0) {
2297 LOCK (&ctx->lock)pthread_spin_lock (&ctx->lock);
2298 {
2299 ctx->size -= contribution;
2300 }
2301 UNLOCK (&ctx->lock)pthread_spin_unlock (&ctx->lock);
2302
2303 LOCK (&local->contri->lock)pthread_spin_lock (&local->contri->lock);
2304 {
2305 local->contri->contribution = 0;
2306 }
2307 UNLOCK (&local->contri->lock)pthread_spin_unlock (&local->contri->lock);
2308 }
2309 }
2310
2311 lock.l_type = F_UNLCK2;
2312 lock.l_whence = SEEK_SET0;
2313 lock.l_start = 0;
2314 lock.l_len = 0;
2315 lock.l_pid = 0;
2316
2317 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 2322,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= _mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "_mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2318 _mq_inode_remove_done,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", "marker-quota.c", __FUNCTION__, 2322,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= _mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "_mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2319 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2322,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= _mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "_mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2320 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 2322,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= _mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "_mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2321 this->name, &local->parent_loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2322,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= _mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "_mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2322 F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 2322,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= _mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->inodelk"
; _new->unwind_to = "_mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->inodelk); (this->children->xlator
)->fops->inodelk (_new, (this->children->xlator),
this->name, &local->parent_loc, 14, &lock, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
2323 return 0;
2324}
2325
2326int32_t
2327mq_reduce_parent_size_xattr (call_frame_t *frame, void *cookie, xlator_t *this,
2328 int32_t op_ret, int32_t op_errno, dict_t *xdata)
2329{
2330 int32_t ret = -1;
2331 int64_t *size = NULL((void*)0);
2332 dict_t *dict = NULL((void*)0);
2333 quota_local_tmarker_local_t *local = NULL((void*)0);
2334
2335 local = frame->local;
2336 if (op_ret == -1) {
2337 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("inodelk set failed on %s", local->
parent_loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 2338, GF_LOG_WARNING, "inodelk set failed on %s"
, local->parent_loc.path); } while (0)
2338 "inodelk set failed on %s", local->parent_loc.path)do { do { if (0) printf ("inodelk set failed on %s", local->
parent_loc.path); } while (0); _gf_log (this->name, "marker-quota.c"
, __FUNCTION__, 2338, GF_LOG_WARNING, "inodelk set failed on %s"
, local->parent_loc.path); } while (0)
;
2339 QUOTA_STACK_DESTROY (frame, this)do { marker_local_t *_local = ((void*)0); _local = frame->
local; frame->local = ((void*)0); STACK_DESTROY (frame->
root); mq_local_unref (this, _local); } while (0)
;
2340 return 0;
2341 }
2342
2343 VALIDATE_OR_GOTO (local->contri, err)do { if (!local->contri) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "local->contri"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "marker-quota.c", __FUNCTION__, 2343, GF_LOG_WARNING, "invalid argument: "
"local->contri"); } while (0); goto err; } } while (0)
;
2344
2345 dict = dict_new ();
2346 if (dict == NULL((void*)0)) {
2347 ret = -1;
2348 goto err;
2349 }
2350
2351 QUOTA_ALLOC_OR_GOTO (size, int64_t, ret, err)do { size = __gf_calloc (sizeof (int64_t), 1, gf_marker_mt_int64_t
); if (!size) { do { do { if (0) printf ("out of memory"); } while
(0); _gf_log ("", "marker-quota.c", __FUNCTION__, 2351, GF_LOG_ERROR
, "out of memory"); } while (0); ret = -1; goto err; } ret = 0
; } while (0);
;
2352
2353 *size = hton64 (-local->size);
2354
2355 ret = dict_set_bin (dict, QUOTA_SIZE_KEY"trusted.glusterfs.quota.size", size, 8);
2356 if (ret < 0)
2357 goto err;
2358
2359 uuid_copy (local->parent_loc.gfid,
2360 local->parent_loc.inode->gfid);
2361 GF_UUID_ASSERT (local->parent_loc.gfid)if (uuid_is_null (local->parent_loc.gfid)) do { if (!(!"uuid null"
)) { do { do { if (0) printf ("Assertion failed: " "!\"uuid null\""
); } while (0); _gf_log_callingfn ("", "marker-quota.c", __FUNCTION__
, 2361, GF_LOG_ERROR, "Assertion failed: " "!\"uuid null\"");
} while (0); } } while (0);
;
2362
2363 STACK_WIND (frame, mq_inode_remove_done, FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2365,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, dict, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2364 FIRST_CHILD(this)->fops->xattrop, &local->parent_loc,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2365,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, dict, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
2365 GF_XATTROP_ADD_ARRAY64, dict, 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", "marker-quota.c", __FUNCTION__, 2365,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->xattrop_cbk) tmp_cbk
= mq_inode_remove_done; _new->root = frame->root; _new
->this = (this->children->xlator); _new->ret = (ret_fn_t
) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new
->wind_from = __FUNCTION__; _new->wind_to = "FIRST_CHILD(this)->fops->xattrop"
; _new->unwind_to = "mq_inode_remove_done"; pthread_spin_init
(&_new->lock, 0); pthread_spin_lock (&frame->root
->stack_lock); { _new->next = frame->root->frames
.next; _new->prev = &frame->root->frames; if (frame
->root->frames.next) frame->root->frames.next->
prev = _new; frame->root->frames.next = _new; frame->
ref_count++; } pthread_spin_unlock (&frame->root->stack_lock
); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location
()) = (this->children->xlator); if (frame->this->
ctx->measure_latency) gf_latency_begin (_new, (this->children
->xlator)->fops->xattrop); (this->children->xlator
)->fops->xattrop (_new, (this->children->xlator),
&local->parent_loc, GF_XATTROP_ADD_ARRAY64, dict, ((void
*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0)
;
2366 dict_unref (dict);
2367 return 0;
2368
2369err:
2370 local->err = 1;
2371 mq_inode_remove_done (frame, NULL((void*)0), this, -1, 0, NULL((void*)0), NULL((void*)0));
2372 if (dict)
2373 dict_unref (dict);
2374 return 0;
2375}
2376
2377int32_t
2378mq_reduce_parent_size (xlator_t *this, loc_t *loc, int64_t contri)
2379{
2380 int32_t ret = -1;
2381 struct gf_flock lock = {0,};
2382 call_frame_t *frame = NULL((void*)0);
2383 quota_local_tmarker_local_t *local = NULL((void*)0);
2384 quota_inode_ctx_t *ctx = NULL((void*)0);
2385 inode_contribution_t *contribution = NULL((void*)0);
2386
2387 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2387, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
2388 GF_VALIDATE_OR_GOTO ("marker", loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2388, GF_LOG_ERROR
, "invalid argument: " "loc"); } while (0); goto out; } } while
(0)
;
2389
2390 ret = mq_inode_ctx_get (loc->inode, this, &ctx);
2391 if (ret < 0)
2392 goto out;
2393
2394 contribution = mq_get_contribution_node (loc->parent, ctx);
2395 if (contribution == NULL((void*)0))
2396 goto out;
2397
2398 local = mq_local_new ();
2399 if (local == NULL((void*)0)) {
2400 ret = -1;
2401 goto out;
2402 }
2403
2404 if (contri >= 0) {
2405 local->size = contri;
2406 } else {
2407 LOCK (&contribution->lock)pthread_spin_lock (&contribution->lock);
2408 {
2409 local->size = contribution->contribution;
2410 }
2411 UNLOCK (&contribution->lock)pthread_spin_unlock (&contribution->lock);
2412 }
2413
2414 if (local->size == 0) {
2415 ret = 0;
2416 goto out;
2417 }
2418
2419 ret = mq_loc_copy (&local->loc, loc);
2420 if (ret < 0)
2421 goto out;
2422
2423 local->ctx = ctx;
2424 local->contri = contribution;
2425
2426 ret = mq_inode_loc_fill (NULL((void*)0), loc->parent, &local->parent_loc);
2427 if (ret < 0)
2428 goto out;
2429
2430 frame = create_frame (this, this->ctx->pool);
2431 if (!frame) {
2432 ret = -1;
2433 goto out;
2434 }
2435
2436 mq_assign_lk_owner (this, frame);
2437
2438 frame->local = local;
2439
2440 lock.l_len = 0;
2441 lock.l_start = 0;
2442 lock.l_type = F_WRLCK1;
2443 lock.l_whence = SEEK_SET0;
2444
2445 if (local->parent_loc.inode == NULL((void*)0)) {
2446 ret = -1;
2447 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Inode is NULL, so can't stackwind."
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 2448, GF_LOG_DEBUG, "Inode is NULL, so can't stackwind."); }
while (0)
2448 "Inode is NULL, so can't stackwind.")do { do { if (0) printf ("Inode is NULL, so can't stackwind."
); } while (0); _gf_log (this->name, "marker-quota.c", __FUNCTION__
, 2448, GF_LOG_DEBUG, "Inode is NULL, so can't stackwind."); }
while (0)
;
2449 goto out;
2450 }
2451
2452 STACK_WIND (frame,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", "marker-quota.c", __FUNCTION__, 2456,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_reduce_parent_size_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->inodelk"; _new->unwind_to
= "mq_reduce_parent_size_xattr"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->inodelk);
(this->children->xlator)->fops->inodelk (_new, (
this->children->xlator), this->name, &local->
parent_loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2453 mq_reduce_parent_size_xattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2456,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_reduce_parent_size_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->inodelk"; _new->unwind_to
= "mq_reduce_parent_size_xattr"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->inodelk);
(this->children->xlator)->fops->inodelk (_new, (
this->children->xlator), this->name, &local->
parent_loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2454 FIRST_CHILD(this),do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = ((
void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool
); if (!_new) { do { do { if (0) printf ("alloc failed"); } while
(0); _gf_log ("stack", "marker-quota.c", __FUNCTION__, 2456,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_reduce_parent_size_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->inodelk"; _new->unwind_to
= "mq_reduce_parent_size_xattr"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->inodelk);
(this->children->xlator)->fops->inodelk (_new, (
this->children->xlator), this->name, &local->
parent_loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2455 FIRST_CHILD(this)->fops->inodelk,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", "marker-quota.c", __FUNCTION__, 2456,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_reduce_parent_size_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->inodelk"; _new->unwind_to
= "mq_reduce_parent_size_xattr"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->inodelk);
(this->children->xlator)->fops->inodelk (_new, (
this->children->xlator), this->name, &local->
parent_loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2456 this->name, &local->parent_loc, F_SETLKW, &lock, 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", "marker-quota.c", __FUNCTION__, 2456,
GF_LOG_ERROR, "alloc failed"); } while (0); break; } typeof(
(this->children->xlator)->fops->inodelk_cbk) tmp_cbk
= mq_reduce_parent_size_xattr; _new->root = frame->root
; _new->this = (this->children->xlator); _new->ret
= (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie
= _new; _new->wind_from = __FUNCTION__; _new->wind_to =
"FIRST_CHILD(this)->fops->inodelk"; _new->unwind_to
= "mq_reduce_parent_size_xattr"; pthread_spin_init (&_new
->lock, 0); pthread_spin_lock (&frame->root->stack_lock
); { _new->next = frame->root->frames.next; _new->
prev = &frame->root->frames; if (frame->root->
frames.next) frame->root->frames.next->prev = _new; frame
->root->frames.next = _new; frame->ref_count++; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = (this->children->
xlator); if (frame->this->ctx->measure_latency) gf_latency_begin
(_new, (this->children->xlator)->fops->inodelk);
(this->children->xlator)->fops->inodelk (_new, (
this->children->xlator), this->name, &local->
parent_loc, 14, &lock, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2457 local = NULL((void*)0);
2458 ret = 0;
2459
2460out:
2461 if (local != NULL((void*)0))
2462 mq_local_unref (this, local);
2463
2464 return ret;
2465}
2466
2467
2468int32_t
2469init_quota_priv (xlator_t *this)
2470{
2471 return 0;
2472}
2473
2474
2475int32_t
2476mq_rename_update_newpath (xlator_t *this, loc_t *loc)
2477{
2478 int32_t ret = -1;
2479 quota_inode_ctx_t *ctx = NULL((void*)0);
2480 inode_contribution_t *contribution = NULL((void*)0);
2481
2482 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2482, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
2483 GF_VALIDATE_OR_GOTO ("marker", loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2483, GF_LOG_ERROR
, "invalid argument: " "loc"); } while (0); goto out; } } while
(0)
;
2484 GF_VALIDATE_OR_GOTO ("marker", loc->inode, out)do { if (!loc->inode) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->inode"); } while
(0); _gf_log_callingfn ("marker", "marker-quota.c", __FUNCTION__
, 2484, GF_LOG_ERROR, "invalid argument: " "loc->inode"); }
while (0); goto out; } } while (0)
;
2485
2486 ret = mq_inode_ctx_get (loc->inode, this, &ctx);
2487 if (ret < 0)
2488 goto out;
2489
2490 contribution = mq_add_new_contribution_node (this, ctx, loc);
2491 if (contribution == NULL((void*)0)) {
2492 ret = -1;
2493 goto out;
2494 }
2495
2496 mq_initiate_quota_txn (this, loc);
2497out:
2498 return ret;
2499}
2500
2501int32_t
2502mq_forget (xlator_t *this, quota_inode_ctx_t *ctx)
2503{
2504 inode_contribution_t *contri = NULL((void*)0);
2505 inode_contribution_t *next = NULL((void*)0);
2506
2507 GF_VALIDATE_OR_GOTO ("marker", this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2507, GF_LOG_ERROR
, "invalid argument: " "this"); } while (0); goto out; } } while
(0)
;
2508 GF_VALIDATE_OR_GOTO ("marker", ctx, out)do { if (!ctx) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "ctx"); } while (0); _gf_log_callingfn
("marker", "marker-quota.c", __FUNCTION__, 2508, GF_LOG_ERROR
, "invalid argument: " "ctx"); } while (0); goto out; } } while
(0)
;
2509
2510 list_for_each_entry_safe (contri, next, &ctx->contribution_head,for (contri = ((typeof(*contri) *)((char *)((&ctx->contribution_head
)->next)-(unsigned long)(&((typeof(*contri) *)0)->contri_list
))), next = ((typeof(*contri) *)((char *)(contri->contri_list
.next)-(unsigned long)(&((typeof(*contri) *)0)->contri_list
))); &contri->contri_list != (&ctx->contribution_head
); contri = next, next = ((typeof(*next) *)((char *)(next->
contri_list.next)-(unsigned long)(&((typeof(*next) *)0)->
contri_list))))
2511 contri_list)for (contri = ((typeof(*contri) *)((char *)((&ctx->contribution_head
)->next)-(unsigned long)(&((typeof(*contri) *)0)->contri_list
))), next = ((typeof(*contri) *)((char *)(contri->contri_list
.next)-(unsigned long)(&((typeof(*contri) *)0)->contri_list
))); &contri->contri_list != (&ctx->contribution_head
); contri = next, next = ((typeof(*next) *)((char *)(next->
contri_list.next)-(unsigned long)(&((typeof(*next) *)0)->
contri_list))))
{
2512 list_del (&contri->contri_list);
2513 GF_FREE (contri)__gf_free (contri);
2514 }
2515
2516 LOCK_DESTROY (&ctx->lock)pthread_spin_destroy (&ctx->lock);
2517 GF_FREE (ctx)__gf_free (ctx);
2518out:
2519 return 0;
2520}