Bug Summary

File:xlators/storage/posix/src/posix.c
Location:line 1164, column 26
Description:Null pointer passed as an argument to a 'nonnull' parameter

Annotated Source Code

1/*
2 Copyright (c) 2006-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#define __XOPEN_SOURCE500 500
16
17#include <openssl/md5.h>
18#include <stdint.h>
19#include <sys/time.h>
20#include <sys/resource.h>
21#include <errno(*__errno_location ()).h>
22#include <libgen.h>
23#include <pthread.h>
24#include <ftw.h>
25#include <sys/stat.h>
26
27#ifndef GF_BSD_HOST_OS
28#include <alloca.h>
29#endif /* GF_BSD_HOST_OS */
30
31#ifdef HAVE_LINKAT1
32#include <fcntl.h>
33#endif /* HAVE_LINKAT */
34
35#include "glusterfs.h"
36#include "checksum.h"
37#include "dict.h"
38#include "logging.h"
39#include "posix.h"
40#include "xlator.h"
41#include "defaults.h"
42#include "common-utils.h"
43#include "compat-errno.h"
44#include "compat.h"
45#include "byte-order.h"
46#include "syscall.h"
47#include "statedump.h"
48#include "locking.h"
49#include "timer.h"
50#include "glusterfs3-xdr.h"
51#include "hashfn.h"
52#include "posix-aio.h"
53
54extern char *marker_xattrs[];
55#define ALIGN_SIZE4096 4096
56
57#undef HAVE_SET_FSID
58#ifdef HAVE_SET_FSID
59
60#define DECLARE_OLD_FS_ID_VAR uid_t old_fsuid; gid_t old_fsgid;
61
62#define SET_FS_ID(uid, gid) do { \
63 old_fsuid = setfsuid (uid); \
64 old_fsgid = setfsgid (gid); \
65 } while (0)
66
67#define SET_TO_OLD_FS_ID() do { \
68 setfsuid (old_fsuid); \
69 setfsgid (old_fsgid); \
70 } while (0)
71
72#else
73
74#define DECLARE_OLD_FS_ID_VAR
75#define SET_FS_ID(uid, gid)
76#define SET_TO_OLD_FS_ID()
77
78#endif
79
80int
81posix_forget (xlator_t *this, inode_t *inode)
82{
83 uint64_t tmp_cache = 0;
84 if (!inode_ctx_del (inode, this, &tmp_cache)inode_ctx_del2(inode,this,&tmp_cache,0))
85 dict_destroy ((dict_t *)(long)tmp_cache);
86
87 return 0;
88}
89
90/* Regular fops */
91
92int32_t
93posix_lookup (call_frame_t *frame, xlator_t *this,
94 loc_t *loc, dict_t *xdata)
95{
96 struct iatt buf = {0, };
97 int32_t op_ret = -1;
98 int32_t entry_ret = 0;
99 int32_t op_errno = 0;
100 dict_t * xattr = NULL((void*)0);
101 char * real_path = NULL((void*)0);
102 char * par_path = NULL((void*)0);
103 struct iatt postparent = {0,};
104 int32_t gfidless = 0;
105
106 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 106, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
107 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 107, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
108 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 108, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
109
110 /* The Hidden directory should be for housekeeping purpose and it
111 should not get any gfid on it */
112 if (__is_root_gfid (loc->pargfid) &&
113 (strcmp (loc->name, GF_HIDDEN_PATH".glusterfs") == 0)) {
114 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Lookup issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 116, GF_LOG_WARNING, "Lookup issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
115 "Lookup issued on %s, which is not permitted",do { do { if (0) printf ("Lookup issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 116, GF_LOG_WARNING, "Lookup issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
116 GF_HIDDEN_PATH)do { do { if (0) printf ("Lookup issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 116, GF_LOG_WARNING, "Lookup issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
;
117 op_errno = EPERM1;
118 op_ret = -1;
119 goto out;
120 }
121
122 op_ret = dict_get_int32 (xdata, GF_GFIDLESS_LOOKUP"gfidless-lookup", &gfidless);
123 op_ret = -1;
124 if (uuid_is_null (loc->pargfid)) {
125 /* nameless lookup */
126 MAKE_INODE_HANDLE (real_path, this, loc, &buf)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 126, GF_LOG_ERROR, "null gfid for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); op_ret =
posix_pstat (this, loc->gfid, real_path, &buf); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, loc
->gfid, ((void*)0), &buf); if ((*__errno_location ()) !=
40) { do { int __len; __len = posix_handle_path (this, loc->
gfid, ((void*)0), ((void*)0), 0); if (__len <= 0) break; real_path
= __builtin_alloca (__len); __len = posix_handle_path (this,
loc->gfid, ((void*)0), real_path, __len); } while (0); break
; } } while (0)
;
127 } else {
128 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &buf)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 128, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &buf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &buf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
129
130 if (uuid_is_null (loc->inode->gfid)) {
131 posix_gfid_set (this, real_path, loc, xdata);
132 MAKE_ENTRY_HANDLE (real_path, par_path, this,do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 133, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &buf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &buf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
133 loc, &buf)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 133, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &buf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &buf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
134 }
135 }
136
137 op_errno = errno(*__errno_location ());
138
139 if (op_ret == -1) {
140 if (op_errno != ENOENT2) {
141 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 143, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
142 "lstat on %s failed: %s",do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 143, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
143 real_path, strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 143, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
144 }
145
146 entry_ret = -1;
147 goto parent;
148 }
149
150 if (xdata && (op_ret == 0)) {
151 xattr = posix_lookup_xattr_fill (this, real_path, loc,
152 xdata, &buf);
153 }
154
155parent:
156 if (par_path) {
157 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
158 if (op_ret == -1) {
159 op_errno = errno(*__errno_location ());
160 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 162, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
161 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 162, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
162 par_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 162, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
163 goto out;
164 }
165 }
166
167 op_ret = entry_ret;
168out:
169 if (xattr)
170 dict_ref (xattr);
171
172 if (!op_ret && !gfidless && uuid_is_null (buf.ia_gfid)) {
173 gf_log (this->name, GF_LOG_ERROR, "buf->ia_gfid is null for "do { do { if (0) printf ("buf->ia_gfid is null for " "%s",
(real_path) ? real_path: ""); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 174, GF_LOG_ERROR, "buf->ia_gfid is null for "
"%s", (real_path) ? real_path: ""); } while (0)
174 "%s", (real_path) ? real_path: "")do { do { if (0) printf ("buf->ia_gfid is null for " "%s",
(real_path) ? real_path: ""); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 174, GF_LOG_ERROR, "buf->ia_gfid is null for "
"%s", (real_path) ? real_path: ""); } while (0)
;
175 op_ret = -1;
176 op_errno = ENODATA61;
177 }
178 STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 179, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &buf, xattr, &
postparent); (*__glusterfs_this_location()) = old_THIS; } while
(0)
179 (loc)?loc->inode:NULL, &buf, xattr, &postparent)do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 179, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_lookup_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &buf, xattr, &
postparent); (*__glusterfs_this_location()) = old_THIS; } while
(0)
;
180
181 if (xattr)
182 dict_unref (xattr);
183
184 return 0;
185}
186
187
188int32_t
189posix_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
190{
191 struct iatt buf = {0,};
192 int32_t op_ret = -1;
193 int32_t op_errno = 0;
194 struct posix_private *priv = NULL((void*)0);
195 char *real_path = NULL((void*)0);
196
197 DECLARE_OLD_FS_ID_VAR;
198
199 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 199, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
200 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 200, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
201 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 201, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
202
203 priv = this->private;
204 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 204, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
205
206 SET_FS_ID (frame->root->uid, frame->root->gid);
207
208 MAKE_INODE_HANDLE (real_path, this, loc, &buf)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 208, GF_LOG_ERROR, "null gfid for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); op_ret =
posix_pstat (this, loc->gfid, real_path, &buf); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, loc
->gfid, ((void*)0), &buf); if ((*__errno_location ()) !=
40) { do { int __len; __len = posix_handle_path (this, loc->
gfid, ((void*)0), ((void*)0), 0); if (__len <= 0) break; real_path
= __builtin_alloca (__len); __len = posix_handle_path (this,
loc->gfid, ((void*)0), real_path, __len); } while (0); break
; } } while (0)
;
209
210 if (op_ret == -1) {
211 op_errno = errno(*__errno_location ());
212 gf_log (this->name, (op_errno == ENOENT)?do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 215, (op_errno == 2)? GF_LOG_DEBUG:GF_LOG_ERROR
, "lstat on %s failed: %s", real_path, strerror (op_errno)); }
while (0)
213 GF_LOG_DEBUG:GF_LOG_ERROR,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 215, (op_errno == 2)? GF_LOG_DEBUG:GF_LOG_ERROR
, "lstat on %s failed: %s", real_path, strerror (op_errno)); }
while (0)
214 "lstat on %s failed: %s", real_path,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 215, (op_errno == 2)? GF_LOG_DEBUG:GF_LOG_ERROR
, "lstat on %s failed: %s", real_path, strerror (op_errno)); }
while (0)
215 strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 215, (op_errno == 2)? GF_LOG_DEBUG:GF_LOG_ERROR
, "lstat on %s failed: %s", real_path, strerror (op_errno)); }
while (0)
;
216 goto out;
217 }
218
219 op_ret = 0;
220
221out:
222 SET_TO_OLD_FS_ID();
223 STACK_UNWIND_STRICT (stat, frame, op_ret, op_errno, &buf, NULL)do { fop_stat_cbk_t fn = ((void*)0); call_frame_t *_parent = (
(void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do {
do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 223, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_stat_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
224
225 return 0;
226}
227
228static int
229posix_do_chmod (xlator_t *this, const char *path, struct iatt *stbuf)
230{
231 int32_t ret = -1;
232 mode_t mode = 0;
233 struct stat stat;
234 int is_symlink = 0;
235
236 ret = sys_lstat (path, &stat);
237 if (ret != 0) {
238 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("lstat failed: %s (%s)", path, strerror
((*__errno_location ()))); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 239, GF_LOG_WARNING, "lstat failed: %s (%s)"
, path, strerror ((*__errno_location ()))); } while (0)
239 "lstat failed: %s (%s)", path, strerror (errno))do { do { if (0) printf ("lstat failed: %s (%s)", path, strerror
((*__errno_location ()))); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 239, GF_LOG_WARNING, "lstat failed: %s (%s)"
, path, strerror ((*__errno_location ()))); } while (0)
;
240 goto out;
241 }
242
243 if (S_ISLNK (stat.st_mode)((((stat.st_mode)) & 0170000) == (0120000)))
244 is_symlink = 1;
245
246 mode = st_mode_from_ia (stbuf->ia_prot, stbuf->ia_type);
247 ret = lchmod (path, mode);
248 if ((ret == -1) && (errno(*__errno_location ()) == ENOSYS38)) {
249 /* in Linux symlinks are always in mode 0777 and no
250 such call as lchmod exists.
251 */
252 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s (%s)", path, strerror ((*__errno_location
()))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 253, GF_LOG_DEBUG, "%s (%s)", path, strerror ((*__errno_location
()))); } while (0)
253 "%s (%s)", path, strerror (errno))do { do { if (0) printf ("%s (%s)", path, strerror ((*__errno_location
()))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 253, GF_LOG_DEBUG, "%s (%s)", path, strerror ((*__errno_location
()))); } while (0)
;
254 if (is_symlink) {
255 ret = 0;
256 goto out;
257 }
258
259 ret = chmod (path, mode);
260 }
261out:
262 return ret;
263}
264
265static int
266posix_do_chown (xlator_t *this,
267 const char *path,
268 struct iatt *stbuf,
269 int32_t valid)
270{
271 int32_t ret = -1;
272 uid_t uid = -1;
273 gid_t gid = -1;
274
275 if (valid & GF_SET_ATTR_UID0x2)
276 uid = stbuf->ia_uid;
277
278 if (valid & GF_SET_ATTR_GID0x4)
279 gid = stbuf->ia_gid;
280
281 ret = lchown (path, uid, gid);
282
283 return ret;
284}
285
286static int
287posix_do_utimes (xlator_t *this,
288 const char *path,
289 struct iatt *stbuf)
290{
291 int32_t ret = -1;
292 struct timeval tv[2] = {{0,},{0,}};
293 struct stat stat;
294 int is_symlink = 0;
295
296 ret = sys_lstat (path, &stat);
297 if (ret != 0) {
298 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s (%s)", path, strerror ((*__errno_location
()))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 299, GF_LOG_WARNING, "%s (%s)", path, strerror ((*__errno_location
()))); } while (0)
299 "%s (%s)", path, strerror (errno))do { do { if (0) printf ("%s (%s)", path, strerror ((*__errno_location
()))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 299, GF_LOG_WARNING, "%s (%s)", path, strerror ((*__errno_location
()))); } while (0)
;
300 goto out;
301 }
302
303 if (S_ISLNK (stat.st_mode)((((stat.st_mode)) & 0170000) == (0120000)))
304 is_symlink = 1;
305
306 tv[0].tv_sec = stbuf->ia_atime;
307 tv[0].tv_usec = stbuf->ia_atime_nsec / 1000;
308 tv[1].tv_sec = stbuf->ia_mtime;
309 tv[1].tv_usec = stbuf->ia_mtime_nsec / 1000;
310
311 ret = lutimes (path, tv);
312 if ((ret == -1) && (errno(*__errno_location ()) == ENOSYS38)) {
313 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("%s (%s)", path, strerror ((*__errno_location
()))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 314, GF_LOG_DEBUG, "%s (%s)", path, strerror ((*__errno_location
()))); } while (0)
314 "%s (%s)", path, strerror (errno))do { do { if (0) printf ("%s (%s)", path, strerror ((*__errno_location
()))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 314, GF_LOG_DEBUG, "%s (%s)", path, strerror ((*__errno_location
()))); } while (0)
;
315 if (is_symlink) {
316 ret = 0;
317 goto out;
318 }
319
320 ret = utimes (path, tv);
321 }
322
323out:
324 return ret;
325}
326
327int
328posix_setattr (call_frame_t *frame, xlator_t *this,
329 loc_t *loc, struct iatt *stbuf, int32_t valid, dict_t *xdata)
330{
331 int32_t op_ret = -1;
332 int32_t op_errno = 0;
333 char * real_path = 0;
334 struct iatt statpre = {0,};
335 struct iatt statpost = {0,};
336
337 DECLARE_OLD_FS_ID_VAR;
338
339 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 339, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
340 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 340, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
341 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 341, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
342
343 SET_FS_ID (frame->root->uid, frame->root->gid);
344 MAKE_INODE_HANDLE (real_path, this, loc, &statpre)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 344, GF_LOG_ERROR, "null gfid for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); op_ret =
posix_pstat (this, loc->gfid, real_path, &statpre); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, loc
->gfid, ((void*)0), &statpre); if ((*__errno_location (
)) != 40) { do { int __len; __len = posix_handle_path (this, loc
->gfid, ((void*)0), ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->gfid, ((void*)0), real_path, __len); } while (
0); break; } } while (0)
;
345
346 if (op_ret == -1) {
347 op_errno = errno(*__errno_location ());
348 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setattr (lstat) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 350, GF_LOG_ERROR, "setattr (lstat) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
349 "setattr (lstat) on %s failed: %s", real_path,do { do { if (0) printf ("setattr (lstat) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 350, GF_LOG_ERROR, "setattr (lstat) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
350 strerror (op_errno))do { do { if (0) printf ("setattr (lstat) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 350, GF_LOG_ERROR, "setattr (lstat) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
351 goto out;
352 }
353
354 if (valid & GF_SET_ATTR_MODE0x1) {
355 op_ret = posix_do_chmod (this, real_path, stbuf);
356 if (op_ret == -1) {
357 op_errno = errno(*__errno_location ());
358 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setattr (chmod) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 360, GF_LOG_ERROR, "setattr (chmod) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
359 "setattr (chmod) on %s failed: %s", real_path,do { do { if (0) printf ("setattr (chmod) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 360, GF_LOG_ERROR, "setattr (chmod) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
360 strerror (op_errno))do { do { if (0) printf ("setattr (chmod) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 360, GF_LOG_ERROR, "setattr (chmod) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
361 goto out;
362 }
363 }
364
365 if (valid & (GF_SET_ATTR_UID0x2 | GF_SET_ATTR_GID0x4)){
366 op_ret = posix_do_chown (this, real_path, stbuf, valid);
367 if (op_ret == -1) {
368 op_errno = errno(*__errno_location ());
369 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setattr (chown) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 371, GF_LOG_ERROR, "setattr (chown) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
370 "setattr (chown) on %s failed: %s", real_path,do { do { if (0) printf ("setattr (chown) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 371, GF_LOG_ERROR, "setattr (chown) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
371 strerror (op_errno))do { do { if (0) printf ("setattr (chown) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 371, GF_LOG_ERROR, "setattr (chown) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
372 goto out;
373 }
374 }
375
376 if (valid & (GF_SET_ATTR_ATIME0x10 | GF_SET_ATTR_MTIME0x20)) {
377 op_ret = posix_do_utimes (this, real_path, stbuf);
378 if (op_ret == -1) {
379 op_errno = errno(*__errno_location ());
380 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setattr (utimes) on %s failed: %s",
real_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 382, GF_LOG_ERROR, "setattr (utimes) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
381 "setattr (utimes) on %s failed: %s", real_path,do { do { if (0) printf ("setattr (utimes) on %s failed: %s",
real_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 382, GF_LOG_ERROR, "setattr (utimes) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
382 strerror (op_errno))do { do { if (0) printf ("setattr (utimes) on %s failed: %s",
real_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 382, GF_LOG_ERROR, "setattr (utimes) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
383 goto out;
384 }
385 }
386
387 if (!valid) {
388 op_ret = lchown (real_path, -1, -1);
389 if (op_ret == -1) {
390 op_errno = errno(*__errno_location ());
391 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lchown (%s, -1, -1) failed => (%s)"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 393, GF_LOG_ERROR, "lchown (%s, -1, -1) failed => (%s)"
, real_path, strerror (op_errno)); } while (0)
392 "lchown (%s, -1, -1) failed => (%s)",do { do { if (0) printf ("lchown (%s, -1, -1) failed => (%s)"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 393, GF_LOG_ERROR, "lchown (%s, -1, -1) failed => (%s)"
, real_path, strerror (op_errno)); } while (0)
393 real_path, strerror (op_errno))do { do { if (0) printf ("lchown (%s, -1, -1) failed => (%s)"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 393, GF_LOG_ERROR, "lchown (%s, -1, -1) failed => (%s)"
, real_path, strerror (op_errno)); } while (0)
;
394
395 goto out;
396 }
397 }
398
399 op_ret = posix_pstat (this, loc->gfid, real_path, &statpost);
400 if (op_ret == -1) {
401 op_errno = errno(*__errno_location ());
402 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setattr (lstat) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 404, GF_LOG_ERROR, "setattr (lstat) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
403 "setattr (lstat) on %s failed: %s", real_path,do { do { if (0) printf ("setattr (lstat) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 404, GF_LOG_ERROR, "setattr (lstat) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
404 strerror (op_errno))do { do { if (0) printf ("setattr (lstat) on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 404, GF_LOG_ERROR, "setattr (lstat) on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
405 goto out;
406 }
407
408 op_ret = 0;
409
410out:
411 SET_TO_OLD_FS_ID ();
412
413 STACK_UNWIND_STRICT (setattr, frame, op_ret, op_errno,do { fop_setattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 414, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_setattr_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &statpre, &statpost, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
414 &statpre, &statpost, NULL)do { fop_setattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 414, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_setattr_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &statpre, &statpost, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
415
416 return 0;
417}
418
419int32_t
420posix_do_fchown (xlator_t *this,
421 int fd,
422 struct iatt *stbuf,
423 int32_t valid)
424{
425 int ret = -1;
426 uid_t uid = -1;
427 gid_t gid = -1;
428
429 if (valid & GF_SET_ATTR_UID0x2)
430 uid = stbuf->ia_uid;
431
432 if (valid & GF_SET_ATTR_GID0x4)
433 gid = stbuf->ia_gid;
434
435 ret = fchown (fd, uid, gid);
436
437 return ret;
438}
439
440
441int32_t
442posix_do_fchmod (xlator_t *this,
443 int fd, struct iatt *stbuf)
444{
445 mode_t mode = 0;
446
447 mode = st_mode_from_ia (stbuf->ia_prot, stbuf->ia_type);
448 return fchmod (fd, mode);
449}
450
451static int
452posix_do_futimes (xlator_t *this,
453 int fd,
454 struct iatt *stbuf)
455{
456 gf_log (this->name, GF_LOG_WARNING, "function not implemented fd(%d)", fd)do { do { if (0) printf ("function not implemented fd(%d)", fd
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 456, GF_LOG_WARNING, "function not implemented fd(%d)", fd)
; } while (0)
;
457
458 errno(*__errno_location ()) = ENOSYS38;
459 return -1;
460}
461
462int
463posix_fsetattr (call_frame_t *frame, xlator_t *this,
464 fd_t *fd, struct iatt *stbuf, int32_t valid, dict_t *xdata)
465{
466 int32_t op_ret = -1;
467 int32_t op_errno = 0;
468 struct iatt statpre = {0,};
469 struct iatt statpost = {0,};
470 struct posix_fd *pfd = NULL((void*)0);
471 int32_t ret = -1;
472
473 DECLARE_OLD_FS_ID_VAR;
474
475 SET_FS_ID (frame->root->uid, frame->root->gid);
476
477 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 477, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
478 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 478, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
479 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 479, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
480
481 ret = posix_fd_ctx_get (fd, this, &pfd);
482 if (ret < 0) {
483 op_errno = -ret;
484 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 485, GF_LOG_DEBUG
, "pfd is NULL from fd=%p", fd); } while (0)
485 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 485, GF_LOG_DEBUG
, "pfd is NULL from fd=%p", fd); } while (0)
;
486 goto out;
487 }
488
489 op_ret = posix_fdstat (this, pfd->fd, &statpre);
490 if (op_ret == -1) {
491 op_errno = errno(*__errno_location ());
492 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 494, GF_LOG_ERROR, "fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
493 "fsetattr (fstat) failed on fd=%p: %s", fd,do { do { if (0) printf ("fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 494, GF_LOG_ERROR, "fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
494 strerror (op_errno))do { do { if (0) printf ("fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 494, GF_LOG_ERROR, "fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
495 goto out;
496 }
497
498 if (valid & GF_SET_ATTR_MODE0x1) {
499 op_ret = posix_do_fchmod (this, pfd->fd, stbuf);
500 if (op_ret == -1) {
501 op_errno = errno(*__errno_location ());
502 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsetattr (fchmod) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 504, GF_LOG_ERROR, "fsetattr (fchmod) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
503 "fsetattr (fchmod) failed on fd=%p: %s",do { do { if (0) printf ("fsetattr (fchmod) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 504, GF_LOG_ERROR, "fsetattr (fchmod) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
504 fd, strerror (op_errno))do { do { if (0) printf ("fsetattr (fchmod) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 504, GF_LOG_ERROR, "fsetattr (fchmod) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
505 goto out;
506 }
507 }
508
509 if (valid & (GF_SET_ATTR_UID0x2 | GF_SET_ATTR_GID0x4)) {
510 op_ret = posix_do_fchown (this, pfd->fd, stbuf, valid);
511 if (op_ret == -1) {
512 op_errno = errno(*__errno_location ());
513 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsetattr (fchown) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 515, GF_LOG_ERROR, "fsetattr (fchown) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
514 "fsetattr (fchown) failed on fd=%p: %s",do { do { if (0) printf ("fsetattr (fchown) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 515, GF_LOG_ERROR, "fsetattr (fchown) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
515 fd, strerror (op_errno))do { do { if (0) printf ("fsetattr (fchown) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 515, GF_LOG_ERROR, "fsetattr (fchown) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
516 goto out;
517 }
518
519 }
520
521 if (valid & (GF_SET_ATTR_ATIME0x10 | GF_SET_ATTR_MTIME0x20)) {
522 op_ret = posix_do_futimes (this, pfd->fd, stbuf);
523 if (op_ret == -1) {
524 op_errno = errno(*__errno_location ());
525 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsetattr (futimes) on failed fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 527, GF_LOG_ERROR, "fsetattr (futimes) on failed fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
526 "fsetattr (futimes) on failed fd=%p: %s", fd,do { do { if (0) printf ("fsetattr (futimes) on failed fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 527, GF_LOG_ERROR, "fsetattr (futimes) on failed fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
527 strerror (op_errno))do { do { if (0) printf ("fsetattr (futimes) on failed fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 527, GF_LOG_ERROR, "fsetattr (futimes) on failed fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
528 goto out;
529 }
530 }
531
532 if (!valid) {
533 op_ret = fchown (pfd->fd, -1, -1);
534 if (op_ret == -1) {
535 op_errno = errno(*__errno_location ());
536 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fchown (%d, -1, -1) failed => (%s)"
, pfd->fd, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 538, GF_LOG_ERROR, "fchown (%d, -1, -1) failed => (%s)"
, pfd->fd, strerror (op_errno)); } while (0)
537 "fchown (%d, -1, -1) failed => (%s)",do { do { if (0) printf ("fchown (%d, -1, -1) failed => (%s)"
, pfd->fd, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 538, GF_LOG_ERROR, "fchown (%d, -1, -1) failed => (%s)"
, pfd->fd, strerror (op_errno)); } while (0)
538 pfd->fd, strerror (op_errno))do { do { if (0) printf ("fchown (%d, -1, -1) failed => (%s)"
, pfd->fd, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 538, GF_LOG_ERROR, "fchown (%d, -1, -1) failed => (%s)"
, pfd->fd, strerror (op_errno)); } while (0)
;
539
540 goto out;
541 }
542 }
543
544 op_ret = posix_fdstat (this, pfd->fd, &statpost);
545 if (op_ret == -1) {
546 op_errno = errno(*__errno_location ());
547 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 549, GF_LOG_ERROR, "fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
548 "fsetattr (fstat) failed on fd=%p: %s", fd,do { do { if (0) printf ("fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 549, GF_LOG_ERROR, "fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
549 strerror (op_errno))do { do { if (0) printf ("fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 549, GF_LOG_ERROR, "fsetattr (fstat) failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
550 goto out;
551 }
552
553 op_ret = 0;
554
555out:
556 SET_TO_OLD_FS_ID ();
557
558 STACK_UNWIND_STRICT (fsetattr, frame, op_ret, op_errno,do { fop_fsetattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 559, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fsetattr_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &statpre, &statpost, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
559 &statpre, &statpost, NULL)do { fop_fsetattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 559, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fsetattr_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &statpre, &statpost, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
560
561 return 0;
562}
563
564int32_t
565posix_opendir (call_frame_t *frame, xlator_t *this,
566 loc_t *loc, fd_t *fd, dict_t *xdata)
567{
568 char * real_path = NULL((void*)0);
569 int32_t op_ret = -1;
570 int32_t op_errno = EINVAL22;
571 DIR * dir = NULL((void*)0);
572 struct posix_fd * pfd = NULL((void*)0);
573
574 DECLARE_OLD_FS_ID_VAR;
575
576 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 576, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
577 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 577, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
578 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 578, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
579 VALIDATE_OR_GOTO (loc->path, out)do { if (!loc->path) { (*__errno_location ()) = 22; do { do
{ if (0) printf ("invalid argument: " "loc->path"); } while
(0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "posix.c", __FUNCTION__, 579, GF_LOG_WARNING, "invalid argument: "
"loc->path"); } while (0); goto out; } } while (0)
;
580 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 580, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
581
582 SET_FS_ID (frame->root->uid, frame->root->gid);
583 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 583, GF_LOG_ERROR, "null gfid for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); op_ret =
posix_pstat (this, loc->gfid, real_path, ((void*)0)); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, loc
->gfid, ((void*)0), ((void*)0)); if ((*__errno_location ()
) != 40) { do { int __len; __len = posix_handle_path (this, loc
->gfid, ((void*)0), ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->gfid, ((void*)0), real_path, __len); } while (
0); break; } } while (0)
;
584
585 op_ret = -1;
586 dir = opendir (real_path);
587
588 if (dir == NULL((void*)0)) {
589 op_errno = errno(*__errno_location ());
590 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("opendir failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 592, GF_LOG_ERROR, "opendir failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
591 "opendir failed on %s: %s",do { do { if (0) printf ("opendir failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 592, GF_LOG_ERROR, "opendir failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
592 real_path, strerror (op_errno))do { do { if (0) printf ("opendir failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 592, GF_LOG_ERROR, "opendir failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
;
593 goto out;
594 }
595
596 op_ret = dirfd (dir);
597 if (op_ret < 0) {
598 op_errno = errno(*__errno_location ());
599 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("dirfd() failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 601, GF_LOG_ERROR, "dirfd() failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
600 "dirfd() failed on %s: %s",do { do { if (0) printf ("dirfd() failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 601, GF_LOG_ERROR, "dirfd() failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
601 real_path, strerror (op_errno))do { do { if (0) printf ("dirfd() failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 601, GF_LOG_ERROR, "dirfd() failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
;
602 goto out;
603 }
604
605 pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd)__gf_calloc (1, sizeof (*pfd), gf_posix_mt_posix_fd);
606 if (!pfd) {
607 op_errno = errno(*__errno_location ());
608 goto out;
609 }
610
611 pfd->dir = dir;
612 pfd->fd = dirfd (dir);
613
614 op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd);
615 if (op_ret)
616 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 618, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
617 "failed to set the fd context path=%s fd=%p",do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 618, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
618 real_path, fd)do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 618, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
;
619
620 op_ret = 0;
621
622out:
623 if (op_ret == -1) {
624 if (dir) {
625 closedir (dir);
626 dir = NULL((void*)0);
627 }
628 if (pfd) {
629 GF_FREE (pfd)__gf_free (pfd);
630 pfd = NULL((void*)0);
631 }
632 }
633
634 SET_TO_OLD_FS_ID ();
635 STACK_UNWIND_STRICT (opendir, frame, op_ret, op_errno, fd, NULL)do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 635, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_opendir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, fd, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
636 return 0;
637}
638
639int32_t
640posix_releasedir (xlator_t *this,
641 fd_t *fd)
642{
643 struct posix_fd * pfd = NULL((void*)0);
644 uint64_t tmp_pfd = 0;
645 int ret = 0;
646
647 struct posix_private *priv = NULL((void*)0);
648
649 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 649, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
650 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 650, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
651
652 ret = fd_ctx_del (fd, this, &tmp_pfd);
653 if (ret < 0) {
654 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("pfd from fd=%p is NULL", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 655, GF_LOG_DEBUG
, "pfd from fd=%p is NULL", fd); } while (0)
655 "pfd from fd=%p is NULL", fd)do { do { if (0) printf ("pfd from fd=%p is NULL", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 655, GF_LOG_DEBUG
, "pfd from fd=%p is NULL", fd); } while (0)
;
656 goto out;
657 }
658
659 pfd = (struct posix_fd *)(long)tmp_pfd;
660 if (!pfd->dir) {
661 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd->dir is NULL for fd=%p", fd)
; } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 662, GF_LOG_WARNING, "pfd->dir is NULL for fd=%p", fd); }
while (0)
662 "pfd->dir is NULL for fd=%p", fd)do { do { if (0) printf ("pfd->dir is NULL for fd=%p", fd)
; } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 662, GF_LOG_WARNING, "pfd->dir is NULL for fd=%p", fd); }
while (0)
;
663 goto out;
664 }
665
666 priv = this->private;
667
668 pthread_mutex_lock (&priv->janitor_lock);
669 {
670 INIT_LIST_HEAD (&pfd->list)do { (&pfd->list)->next = (&pfd->list)->prev
= &pfd->list; } while (0)
;
671 list_add_tail (&pfd->list, &priv->janitor_fds);
672 pthread_cond_signal (&priv->janitor_cond);
673 }
674 pthread_mutex_unlock (&priv->janitor_lock);
675
676out:
677 return 0;
678}
679
680
681int32_t
682posix_readlink (call_frame_t *frame, xlator_t *this,
683 loc_t *loc, size_t size, dict_t *xdata)
684{
685 char * dest = NULL((void*)0);
686 int32_t op_ret = -1;
687 int32_t op_errno = 0;
688 char * real_path = NULL((void*)0);
689 struct iatt stbuf = {0,};
690
691 DECLARE_OLD_FS_ID_VAR;
692
693 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 693, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
694
695 SET_FS_ID (frame->root->uid, frame->root->gid);
696
697 dest = alloca (size + 1)__builtin_alloca (size + 1);
698
699 MAKE_INODE_HANDLE (real_path, this, loc, &stbuf)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 699, GF_LOG_ERROR, "null gfid for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); op_ret =
posix_pstat (this, loc->gfid, real_path, &stbuf); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, loc
->gfid, ((void*)0), &stbuf); if ((*__errno_location ()
) != 40) { do { int __len; __len = posix_handle_path (this, loc
->gfid, ((void*)0), ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->gfid, ((void*)0), real_path, __len); } while (
0); break; } } while (0)
;
700 if (op_ret == -1) {
701 op_errno = errno(*__errno_location ());
702 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 704, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
703 "lstat on %s failed: %s", real_path,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 704, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
704 strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 704, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
705 goto out;
706 }
707
708 op_ret = readlink (real_path, dest, size);
709 if (op_ret == -1) {
710 op_errno = errno(*__errno_location ());
711 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("readlink on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 713, GF_LOG_ERROR, "readlink on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
712 "readlink on %s failed: %s", real_path,do { do { if (0) printf ("readlink on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 713, GF_LOG_ERROR, "readlink on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
713 strerror (op_errno))do { do { if (0) printf ("readlink on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 713, GF_LOG_ERROR, "readlink on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
714 goto out;
715 }
716
717 dest[op_ret] = 0;
718out:
719 SET_TO_OLD_FS_ID ();
720
721 STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, dest, &stbuf, NULL)do { fop_readlink_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 721, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_readlink_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, dest, &stbuf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
722
723 return 0;
724}
725
726
727int
728posix_mknod (call_frame_t *frame, xlator_t *this,
729 loc_t *loc, mode_t mode, dev_t dev, mode_t umask, dict_t *xdata)
730{
731 int tmp_fd = 0;
732 int32_t op_ret = -1;
733 int32_t op_errno = 0;
734 char *real_path = 0;
735 char *par_path = 0;
736 struct iatt stbuf = { 0, };
737 char was_present = 1;
738 struct posix_private *priv = NULL((void*)0);
739 gid_t gid = 0;
740 struct iatt preparent = {0,};
741 struct iatt postparent = {0,};
742 void * uuid_req = NULL((void*)0);
743
744 DECLARE_OLD_FS_ID_VAR;
745
746 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 746, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
747 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 747, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
748 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 748, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
749
750 priv = this->private;
751 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 751, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
752
753 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 753, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, ((void*)0)); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, ((void*)0)); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
754
755 gid = frame->root->gid;
756
757 SET_FS_ID (frame->root->uid, gid);
758
759 op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
760 if (op_ret == -1) {
761 op_errno = errno(*__errno_location ());
762 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 764, GF_LOG_ERROR, "pre-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
763 "pre-operation lstat on parent of %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 764, GF_LOG_ERROR, "pre-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
764 real_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 764, GF_LOG_ERROR, "pre-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
765 goto out;
766 }
767
768 if (preparent.ia_prot.sgid) {
769 gid = preparent.ia_gid;
770 }
771
772 /* Check if the 'gfid' already exists, because this mknod may be an
773 internal call from distribute for creating 'linkfile', and that
774 linkfile may be for a hardlinked file */
775 if (dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY"glusterfs-internal-fop")) {
776 dict_del (xdata, GLUSTERFS_INTERNAL_FOP_KEY"glusterfs-internal-fop");
777 op_ret = dict_get_ptr (xdata, "gfid-req", &uuid_req);
778 if (op_ret) {
779 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("failed to get the gfid from dict for %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 781, GF_LOG_DEBUG, "failed to get the gfid from dict for %s"
, loc->path); } while (0)
780 "failed to get the gfid from dict for %s",do { do { if (0) printf ("failed to get the gfid from dict for %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 781, GF_LOG_DEBUG, "failed to get the gfid from dict for %s"
, loc->path); } while (0)
781 loc->path)do { do { if (0) printf ("failed to get the gfid from dict for %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 781, GF_LOG_DEBUG, "failed to get the gfid from dict for %s"
, loc->path); } while (0)
;
782 goto real_op;
783 }
784 op_ret = posix_create_link_if_gfid_exists (this, uuid_req,
785 real_path);
786 if (!op_ret)
787 goto post_op;
788 }
789
790real_op:
791#ifdef __NetBSD__
792 if (S_ISFIFO(mode)((((mode)) & 0170000) == (0010000)))
793 op_ret = mkfifo (real_path, mode);
794 else
795#endif /* __NetBSD__ */
796 op_ret = mknod (real_path, mode, dev);
797
798 if (op_ret == -1) {
799 op_errno = errno(*__errno_location ());
800 if ((op_errno == EINVAL22) && S_ISREG (mode)((((mode)) & 0170000) == (0100000))) {
801 /* Over Darwin, mknod with (S_IFREG|mode)
802 doesn't work */
803 tmp_fd = creat (real_path, mode);
804 if (tmp_fd == -1) {
805 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("create failed on %s: %s", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 807, GF_LOG_ERROR, "create failed on %s: %s"
, real_path, strerror ((*__errno_location ()))); } while (0)
806 "create failed on %s: %s",do { do { if (0) printf ("create failed on %s: %s", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 807, GF_LOG_ERROR, "create failed on %s: %s"
, real_path, strerror ((*__errno_location ()))); } while (0)
807 real_path, strerror (errno))do { do { if (0) printf ("create failed on %s: %s", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 807, GF_LOG_ERROR, "create failed on %s: %s"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
808 goto out;
809 }
810 close (tmp_fd);
811 } else {
812
813 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("mknod on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 815, GF_LOG_ERROR, "mknod on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
814 "mknod on %s failed: %s", real_path,do { do { if (0) printf ("mknod on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 815, GF_LOG_ERROR, "mknod on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
815 strerror (op_errno))do { do { if (0) printf ("mknod on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 815, GF_LOG_ERROR, "mknod on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
816 goto out;
817 }
818 }
819
820 op_ret = posix_gfid_set (this, real_path, loc, xdata);
821 if (op_ret) {
822 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 823, GF_LOG_ERROR, "setting gfid on %s failed", real_path);
} while (0)
823 "setting gfid on %s failed", real_path)do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 823, GF_LOG_ERROR, "setting gfid on %s failed", real_path);
} while (0)
;
824 }
825
826#ifndef HAVE_SET_FSID
827 op_ret = lchown (real_path, frame->root->uid, gid);
828 if (op_ret == -1) {
829 op_errno = errno(*__errno_location ());
830 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lchown on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 832, GF_LOG_ERROR, "lchown on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
831 "lchown on %s failed: %s", real_path,do { do { if (0) printf ("lchown on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 832, GF_LOG_ERROR, "lchown on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
832 strerror (op_errno))do { do { if (0) printf ("lchown on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 832, GF_LOG_ERROR, "lchown on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
;
833 goto out;
834 }
835#endif
836
837post_op:
838 op_ret = posix_acl_xattr_set (this, real_path, xdata);
839 if (op_ret) {
840 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 842, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
841 "setting ACLs on %s failed (%s)", real_path,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 842, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
842 strerror (errno))do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 842, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
843 }
844
845 op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
846 if (op_ret) {
847 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 849, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
848 "setting xattrs on %s failed (%s)", real_path,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 849, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
849 strerror (errno))do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 849, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
850 }
851
852 op_ret = posix_pstat (this, NULL((void*)0), real_path, &stbuf);
853 if (op_ret == -1) {
854 op_errno = errno(*__errno_location ());
855 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("mknod on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 857, GF_LOG_ERROR, "mknod on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
856 "mknod on %s failed: %s", real_path,do { do { if (0) printf ("mknod on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 857, GF_LOG_ERROR, "mknod on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
857 strerror (op_errno))do { do { if (0) printf ("mknod on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 857, GF_LOG_ERROR, "mknod on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
858 goto out;
859 }
860
861 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
862 if (op_ret == -1) {
863 op_errno = errno(*__errno_location ());
864 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 866, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
865 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 866, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
866 par_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 866, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
867 goto out;
868 }
869
870 op_ret = 0;
871
872out:
873 SET_TO_OLD_FS_ID ();
874
875 STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno,do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 877, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
876 (loc)?loc->inode:NULL, &stbuf, &preparent,do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 877, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
877 &postparent, NULL)do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 877, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_mknod_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
878
879 if ((op_ret == -1) && (!was_present)) {
880 unlink (real_path);
881 }
882
883 return 0;
884}
885
886
887int
888posix_mkdir (call_frame_t *frame, xlator_t *this,
889 loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata)
890{
891 int32_t op_ret = -1;
892 int32_t op_errno = 0;
893 char *real_path = NULL((void*)0);
894 char *par_path = NULL((void*)0);
895 struct iatt stbuf = {0, };
896 char was_present = 1;
897 struct posix_private *priv = NULL((void*)0);
898 gid_t gid = 0;
899 struct iatt preparent = {0,};
900 struct iatt postparent = {0,};
901
902 DECLARE_OLD_FS_ID_VAR;
903
904 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 904, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
905 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 905, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
906 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 906, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
907
908 /* The Hidden directory should be for housekeeping purpose and it
909 should not get created from a user request */
910 if (__is_root_gfid (loc->pargfid) &&
911 (strcmp (loc->name, GF_HIDDEN_PATH".glusterfs") == 0)) {
912 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("mkdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 914, GF_LOG_WARNING, "mkdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
913 "mkdir issued on %s, which is not permitted",do { do { if (0) printf ("mkdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 914, GF_LOG_WARNING, "mkdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
914 GF_HIDDEN_PATH)do { do { if (0) printf ("mkdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 914, GF_LOG_WARNING, "mkdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
;
915 op_errno = EPERM1;
916 op_ret = -1;
917 goto out;
918 }
919
920 priv = this->private;
921 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 921, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
922
923 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 923, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, ((void*)0)); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, ((void*)0)); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
924
925 gid = frame->root->gid;
926
927 op_ret = posix_pstat (this, NULL((void*)0), real_path, &stbuf);
928 if ((op_ret == -1) && (errno(*__errno_location ()) == ENOENT2)) {
929 was_present = 0;
930 }
931
932 SET_FS_ID (frame->root->uid, gid);
933
934 op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
935 if (op_ret == -1) {
936 op_errno = errno(*__errno_location ());
937 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 939, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
938 "pre-operation lstat on parent %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 939, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
939 par_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 939, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
940 goto out;
941 }
942
943 if (preparent.ia_prot.sgid) {
944 gid = preparent.ia_gid;
945 mode |= S_ISGID02000;
946 }
947
948 op_ret = mkdir (real_path, mode);
949 if (op_ret == -1) {
950 op_errno = errno(*__errno_location ());
951 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("mkdir of %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 953, GF_LOG_ERROR, "mkdir of %s failed: %s", real_path
, strerror (op_errno)); } while (0)
952 "mkdir of %s failed: %s", real_path,do { do { if (0) printf ("mkdir of %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 953, GF_LOG_ERROR, "mkdir of %s failed: %s", real_path
, strerror (op_errno)); } while (0)
953 strerror (op_errno))do { do { if (0) printf ("mkdir of %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 953, GF_LOG_ERROR, "mkdir of %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
954 goto out;
955 }
956
957 op_ret = posix_gfid_set (this, real_path, loc, xdata);
958 if (op_ret) {
959 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 960, GF_LOG_ERROR, "setting gfid on %s failed", real_path);
} while (0)
960 "setting gfid on %s failed", real_path)do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 960, GF_LOG_ERROR, "setting gfid on %s failed", real_path);
} while (0)
;
961 }
962
963#ifndef HAVE_SET_FSID
964 op_ret = chown (real_path, frame->root->uid, gid);
965 if (op_ret == -1) {
966 op_errno = errno(*__errno_location ());
967 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("chown on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 969, GF_LOG_ERROR, "chown on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
968 "chown on %s failed: %s", real_path,do { do { if (0) printf ("chown on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 969, GF_LOG_ERROR, "chown on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
969 strerror (op_errno))do { do { if (0) printf ("chown on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 969, GF_LOG_ERROR, "chown on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
970 goto out;
971 }
972#endif
973
974 op_ret = posix_acl_xattr_set (this, real_path, xdata);
975 if (op_ret) {
976 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 978, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
977 "setting ACLs on %s failed (%s)", real_path,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 978, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
978 strerror (errno))do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 978, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
979 }
980
981 op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
982 if (op_ret) {
983 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 985, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
984 "setting xattrs on %s failed (%s)", real_path,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 985, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
985 strerror (errno))do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 985, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
986 }
987
988 op_ret = posix_pstat (this, NULL((void*)0), real_path, &stbuf);
989 if (op_ret == -1) {
990 op_errno = errno(*__errno_location ());
991 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 993, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
992 "lstat on %s failed: %s", real_path,do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 993, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
993 strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 993, GF_LOG_ERROR, "lstat on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
994 goto out;
995 }
996
997 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
998 if (op_ret == -1) {
999 op_errno = errno(*__errno_location ());
1000 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1002, GF_LOG_ERROR, "post-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1001 "post-operation lstat on parent of %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1002, GF_LOG_ERROR, "post-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1002 real_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1002, GF_LOG_ERROR, "post-operation lstat on parent of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
1003 goto out;
1004 }
1005
1006 op_ret = 0;
1007
1008out:
1009 SET_TO_OLD_FS_ID ();
1010
1011 STACK_UNWIND_STRICT (mkdir, frame, op_ret, op_errno,do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1013, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1012 (loc)?loc->inode:NULL, &stbuf, &preparent,do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1013, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1013 &postparent, NULL)do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1013, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1014
1015 if ((op_ret == -1) && (!was_present)) {
1016 unlink (real_path);
1017 }
1018
1019 return 0;
1020}
1021
1022
1023int32_t
1024posix_unlink (call_frame_t *frame, xlator_t *this,
1025 loc_t *loc, int xflag, dict_t *xdata)
1026{
1027 int32_t op_ret = -1;
1028 int32_t op_errno = 0;
1029 char *real_path = NULL((void*)0);
1030 char *par_path = NULL((void*)0);
1031 int32_t fd = -1;
1032 struct iatt stbuf = {0,};
1033 struct posix_private *priv = NULL((void*)0);
1034 struct iatt preparent = {0,};
1035 struct iatt postparent = {0,};
1036
1037 DECLARE_OLD_FS_ID_VAR;
1038
1039 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1039, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1040 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1040, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1041 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1041, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
1042
1043 SET_FS_ID (frame->root->uid, frame->root->gid);
1044 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1044, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &stbuf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
1045
1046 op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
1047 if (op_ret == -1) {
1048 op_errno = errno(*__errno_location ());
1049 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1051, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1050 "pre-operation lstat on parent %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1051, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1051 par_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1051, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1052 goto out;
1053 }
1054
1055 if (stbuf.ia_nlink == 1)
1056 posix_handle_unset (this, stbuf.ia_gfid, NULL((void*)0));
1057
1058 priv = this->private;
1059 if (priv->background_unlink) {
1060 if (IA_ISREG (loc->inode->ia_type)(loc->inode->ia_type == IA_IFREG)) {
1061 fd = open (real_path, O_RDONLY00);
1062 if (fd == -1) {
1063 op_ret = -1;
1064 op_errno = errno(*__errno_location ());
1065 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("open of %s failed: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1067, GF_LOG_ERROR, "open of %s failed: %s", real_path
, strerror (op_errno)); } while (0)
1066 "open of %s failed: %s", real_path,do { do { if (0) printf ("open of %s failed: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1067, GF_LOG_ERROR, "open of %s failed: %s", real_path
, strerror (op_errno)); } while (0)
1067 strerror (op_errno))do { do { if (0) printf ("open of %s failed: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1067, GF_LOG_ERROR, "open of %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
1068 goto out;
1069 }
1070 }
1071 }
1072
1073 op_ret = sys_unlink (real_path);
1074 if (op_ret == -1) {
1075 op_errno = errno(*__errno_location ());
1076 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("unlink of %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1078, GF_LOG_ERROR, "unlink of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1077 "unlink of %s failed: %s", real_path,do { do { if (0) printf ("unlink of %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1078, GF_LOG_ERROR, "unlink of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1078 strerror (op_errno))do { do { if (0) printf ("unlink of %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1078, GF_LOG_ERROR, "unlink of %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
1079 goto out;
1080 }
1081
1082 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
1083 if (op_ret == -1) {
1084 op_errno = errno(*__errno_location ());
1085 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1087, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1086 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1087, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1087 par_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1087, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1088 goto out;
1089 }
1090
1091 op_ret = 0;
1092
1093out:
1094 SET_TO_OLD_FS_ID ();
1095
1096 STACK_UNWIND_STRICT (unlink, frame, op_ret, op_errno,do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1097, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1097 &preparent, &postparent, NULL)do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1097, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_unlink_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1098
1099 if (fd != -1) {
1100 close (fd);
1101 }
1102
1103 return 0;
1104}
1105
1106
1107int
1108posix_rmdir (call_frame_t *frame, xlator_t *this,
1109 loc_t *loc, int flags, dict_t *xdata)
1110{
1111 int32_t op_ret = -1;
1112 int32_t op_errno = 0;
1113 char * real_path = NULL((void*)0);
1
'real_path' initialized to a null pointer value
1114 char * par_path = NULL((void*)0);
1115 char * gfid_str = NULL((void*)0);
1116 struct iatt preparent = {0,};
1117 struct iatt postparent = {0,};
1118 struct iatt stbuf;
1119 struct posix_private *priv = NULL((void*)0);
1120
1121 DECLARE_OLD_FS_ID_VAR;
1122
1123 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1123, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1124 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1124, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1125 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1125, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
1126
1127 SET_FS_ID (frame->root->uid, frame->root->gid);
1128
1129 /* The Hidden directory should be for housekeeping purpose and it
1130 should not get deleted from inside process */
1131 if (__is_root_gfid (loc->pargfid) &&
1132 (strcmp (loc->name, GF_HIDDEN_PATH".glusterfs") == 0)) {
1133 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("rmdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1135, GF_LOG_WARNING, "rmdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
1134 "rmdir issued on %s, which is not permitted",do { do { if (0) printf ("rmdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1135, GF_LOG_WARNING, "rmdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
1135 GF_HIDDEN_PATH)do { do { if (0) printf ("rmdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1135, GF_LOG_WARNING, "rmdir issued on %s, which is not permitted"
, ".glusterfs"); } while (0)
;
1136 op_errno = EPERM1;
1137 op_ret = -1;
1138 goto out;
1139 }
1140
1141 priv = this->private;
1142
1143 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1143, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &stbuf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
1144
1145 op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
1146 if (op_ret == -1) {
2
Taking false branch
1147 op_errno = errno(*__errno_location ());
1148 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1150, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1149 "pre-operation lstat on parent %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1150, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1150 par_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1150, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1151 goto out;
1152 }
1153
1154 if (flags) {
3
Assuming 'flags' is 0
4
Taking false branch
1155 gfid_str = uuid_utoa (stbuf.ia_gfid);
1156 char *tmp_path = alloca (strlen (priv->trash_path) +__builtin_alloca (strlen (priv->trash_path) + strlen ("/")
+ strlen (gfid_str) + 1)
1157 strlen ("/") +__builtin_alloca (strlen (priv->trash_path) + strlen ("/")
+ strlen (gfid_str) + 1)
1158 strlen (gfid_str) + 1)__builtin_alloca (strlen (priv->trash_path) + strlen ("/")
+ strlen (gfid_str) + 1)
;
1159
1160 mkdir (priv->trash_path, 0755);
1161 sprintf (tmp_path, "%s/%s", priv->trash_path, gfid_str);
1162 op_ret = rename (real_path, tmp_path);
1163 } else {
1164 op_ret = rmdir (real_path);
5
Null pointer passed as an argument to a 'nonnull' parameter
1165 }
1166 op_errno = errno(*__errno_location ());
1167
1168 if (op_ret == 0) {
1169 posix_handle_unset (this, stbuf.ia_gfid, NULL((void*)0));
1170 }
1171
1172 if (op_errno == EEXIST17)
1173 /* Solaris sets errno = EEXIST instead of ENOTEMPTY */
1174 op_errno = ENOTEMPTY39;
1175
1176 /* No need to log a common error as ENOTEMPTY */
1177 if (op_ret == -1 && op_errno != ENOTEMPTY39) {
1178 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("rmdir of %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1180, GF_LOG_ERROR, "rmdir of %s failed: %s",
real_path, strerror (op_errno)); } while (0)
1179 "rmdir of %s failed: %s", real_path,do { do { if (0) printf ("rmdir of %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1180, GF_LOG_ERROR, "rmdir of %s failed: %s",
real_path, strerror (op_errno)); } while (0)
1180 strerror (op_errno))do { do { if (0) printf ("rmdir of %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1180, GF_LOG_ERROR, "rmdir of %s failed: %s",
real_path, strerror (op_errno)); } while (0)
;
1181 }
1182
1183 if (op_ret == -1) {
1184 gf_log (this->name,do { do { if (0) printf ("%s on %s failed", (flags) ? "rename"
: "rmdir", real_path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1187, (op_errno == 39) ? GF_LOG_DEBUG : GF_LOG_ERROR
, "%s on %s failed", (flags) ? "rename" : "rmdir", real_path)
; } while (0)
1185 (op_errno == ENOTEMPTY) ? GF_LOG_DEBUG : GF_LOG_ERROR,do { do { if (0) printf ("%s on %s failed", (flags) ? "rename"
: "rmdir", real_path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1187, (op_errno == 39) ? GF_LOG_DEBUG : GF_LOG_ERROR
, "%s on %s failed", (flags) ? "rename" : "rmdir", real_path)
; } while (0)
1186 "%s on %s failed", (flags) ? "rename" : "rmdir",do { do { if (0) printf ("%s on %s failed", (flags) ? "rename"
: "rmdir", real_path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1187, (op_errno == 39) ? GF_LOG_DEBUG : GF_LOG_ERROR
, "%s on %s failed", (flags) ? "rename" : "rmdir", real_path)
; } while (0)
1187 real_path)do { do { if (0) printf ("%s on %s failed", (flags) ? "rename"
: "rmdir", real_path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1187, (op_errno == 39) ? GF_LOG_DEBUG : GF_LOG_ERROR
, "%s on %s failed", (flags) ? "rename" : "rmdir", real_path)
; } while (0)
;
1188 goto out;
1189 }
1190
1191 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
1192 if (op_ret == -1) {
1193 op_errno = errno(*__errno_location ());
1194 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent of %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1196, GF_LOG_ERROR, "post-operation lstat on parent of %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1195 "post-operation lstat on parent of %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent of %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1196, GF_LOG_ERROR, "post-operation lstat on parent of %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1196 par_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent of %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1196, GF_LOG_ERROR, "post-operation lstat on parent of %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1197 goto out;
1198 }
1199
1200out:
1201 SET_TO_OLD_FS_ID ();
1202
1203 STACK_UNWIND_STRICT (rmdir, frame, op_ret, op_errno,do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1204, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1204 &preparent, &postparent, NULL)do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1204, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1205
1206 return 0;
1207}
1208
1209
1210int
1211posix_symlink (call_frame_t *frame, xlator_t *this,
1212 const char *linkname, loc_t *loc, mode_t umask, dict_t *xdata)
1213{
1214 int32_t op_ret = -1;
1215 int32_t op_errno = 0;
1216 char * real_path = 0;
1217 char * par_path = 0;
1218 struct iatt stbuf = { 0, };
1219 struct posix_private *priv = NULL((void*)0);
1220 gid_t gid = 0;
1221 char was_present = 1;
1222 struct iatt preparent = {0,};
1223 struct iatt postparent = {0,};
1224
1225 DECLARE_OLD_FS_ID_VAR;
1226
1227 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1227, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1228 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1228, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1229 VALIDATE_OR_GOTO (linkname, out)do { if (!linkname) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "linkname"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1229, GF_LOG_WARNING, "invalid argument: " "linkname"
); } while (0); goto out; } } while (0)
;
1230 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1230, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
1231
1232 priv = this->private;
1233 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1233, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1234
1235 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1235, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &stbuf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
1236
1237 if ((op_ret == -1) && (errno(*__errno_location ()) == ENOENT2)){
1238 was_present = 0;
1239 }
1240
1241 SET_FS_ID (frame->root->uid, gid);
1242
1243 gid = frame->root->gid;
1244
1245 op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
1246 if (op_ret == -1) {
1247 op_errno = errno(*__errno_location ());
1248 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1250, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1249 "pre-operation lstat on parent %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1250, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1250 par_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1250, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1251 goto out;
1252 }
1253
1254 if (preparent.ia_prot.sgid) {
1255 gid = preparent.ia_gid;
1256 }
1257
1258 op_ret = symlink (linkname, real_path);
1259
1260 if (op_ret == -1) {
1261 op_errno = errno(*__errno_location ());
1262 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("symlink of %s --> %s failed: %s"
, real_path, linkname, strerror (op_errno)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1264, GF_LOG_ERROR,
"symlink of %s --> %s failed: %s", real_path, linkname, strerror
(op_errno)); } while (0)
1263 "symlink of %s --> %s failed: %s",do { do { if (0) printf ("symlink of %s --> %s failed: %s"
, real_path, linkname, strerror (op_errno)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1264, GF_LOG_ERROR,
"symlink of %s --> %s failed: %s", real_path, linkname, strerror
(op_errno)); } while (0)
1264 real_path, linkname, strerror (op_errno))do { do { if (0) printf ("symlink of %s --> %s failed: %s"
, real_path, linkname, strerror (op_errno)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1264, GF_LOG_ERROR,
"symlink of %s --> %s failed: %s", real_path, linkname, strerror
(op_errno)); } while (0)
;
1265 goto out;
1266 }
1267
1268 op_ret = posix_gfid_set (this, real_path, loc, xdata);
1269 if (op_ret) {
1270 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 1271, GF_LOG_ERROR, "setting gfid on %s failed", real_path)
; } while (0)
1271 "setting gfid on %s failed", real_path)do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 1271, GF_LOG_ERROR, "setting gfid on %s failed", real_path)
; } while (0)
;
1272 }
1273
1274#ifndef HAVE_SET_FSID
1275 op_ret = lchown (real_path, frame->root->uid, gid);
1276 if (op_ret == -1) {
1277 op_errno = errno(*__errno_location ());
1278 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lchown failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1280, GF_LOG_ERROR, "lchown failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
1279 "lchown failed on %s: %s",do { do { if (0) printf ("lchown failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1280, GF_LOG_ERROR, "lchown failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
1280 real_path, strerror (op_errno))do { do { if (0) printf ("lchown failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1280, GF_LOG_ERROR, "lchown failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
;
1281 goto out;
1282 }
1283#endif
1284
1285 op_ret = posix_acl_xattr_set (this, real_path, xdata);
1286 if (op_ret) {
1287 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1289, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1288 "setting ACLs on %s failed (%s)", real_path,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1289, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1289 strerror (errno))do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1289, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
1290 }
1291
1292 op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
1293 if (op_ret) {
1294 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1296, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1295 "setting xattrs on %s failed (%s)", real_path,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1296, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1296 strerror (errno))do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1296, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
1297 }
1298
1299 op_ret = posix_pstat (this, NULL((void*)0), real_path, &stbuf);
1300 if (op_ret == -1) {
1301 op_errno = errno(*__errno_location ());
1302 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lstat failed on %s: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1304, GF_LOG_ERROR, "lstat failed on %s: %s",
real_path, strerror (op_errno)); } while (0)
1303 "lstat failed on %s: %s",do { do { if (0) printf ("lstat failed on %s: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1304, GF_LOG_ERROR, "lstat failed on %s: %s",
real_path, strerror (op_errno)); } while (0)
1304 real_path, strerror (op_errno))do { do { if (0) printf ("lstat failed on %s: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1304, GF_LOG_ERROR, "lstat failed on %s: %s",
real_path, strerror (op_errno)); } while (0)
;
1305 goto out;
1306 }
1307
1308 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
1309 if (op_ret == -1) {
1310 op_errno = errno(*__errno_location ());
1311 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1313, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1312 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1313, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1313 par_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1313, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1314 goto out;
1315 }
1316
1317 op_ret = 0;
1318
1319out:
1320 SET_TO_OLD_FS_ID ();
1321
1322 STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno,do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1324, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_symlink_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1323 (loc)?loc->inode:NULL, &stbuf, &preparent,do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1324, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_symlink_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1324 &postparent, NULL)do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1324, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_symlink_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1325
1326 if ((op_ret == -1) && (!was_present)) {
1327 unlink (real_path);
1328 }
1329
1330 return 0;
1331}
1332
1333
1334int
1335posix_rename (call_frame_t *frame, xlator_t *this,
1336 loc_t *oldloc, loc_t *newloc, dict_t *xdata)
1337{
1338 int32_t op_ret = -1;
1339 int32_t op_errno = 0;
1340 char *real_oldpath = NULL((void*)0);
1341 char *real_newpath = NULL((void*)0);
1342 char *par_oldpath = NULL((void*)0);
1343 char *par_newpath = NULL((void*)0);
1344 struct iatt stbuf = {0, };
1345 struct posix_private *priv = NULL((void*)0);
1346 char was_present = 1;
1347 struct iatt preoldparent = {0, };
1348 struct iatt postoldparent = {0, };
1349 struct iatt prenewparent = {0, };
1350 struct iatt postnewparent = {0, };
1351 char olddirid[64];
1352 char newdirid[64];
1353 uuid_t victim = {0};
1354 int was_dir = 0;
1355 int nlink = 0;
1356
1357 DECLARE_OLD_FS_ID_VAR;
1358
1359 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1359, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1360 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1360, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1361 VALIDATE_OR_GOTO (oldloc, out)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1361, GF_LOG_WARNING, "invalid argument: " "oldloc"
); } while (0); goto out; } } while (0)
;
1362 VALIDATE_OR_GOTO (newloc, out)do { if (!newloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "newloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1362, GF_LOG_WARNING, "invalid argument: " "newloc"
); } while (0); goto out; } } while (0)
;
1363
1364 priv = this->private;
1365 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1365, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1366
1367 SET_FS_ID (frame->root->uid, frame->root->gid);
1368 MAKE_ENTRY_HANDLE (real_oldpath, par_oldpath, this, oldloc, NULL)do { char *__parp; if (uuid_is_null (oldloc->pargfid) || !
oldloc->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, oldloc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1368, GF_LOG_ERROR, "null pargfid/name for path %s"
, oldloc->path); } while (0); break; } if (((oldloc) &&
(oldloc->path) && (oldloc->path[0] == '/'))) {
do { real_oldpath = __builtin_alloca (strlen (oldloc->path
) + (((struct posix_private *)this->private)->base_path_length
) + 2); strcpy (real_oldpath, (((struct posix_private *)this->
private)->base_path)); strcpy (&real_oldpath[(((struct
posix_private *)this->private)->base_path_length)], oldloc
->path); } while (0); __parp = (__extension__ ({ const char
*__old = (real_oldpath); size_t __len = strlen (__old) + 1; char
*__new = (char *) __builtin_alloca (__len); (char *) memcpy (
__new, __old, __len); })); par_oldpath = dirname (__parp); op_ret
= posix_pstat (this, ((void*)0), real_oldpath, ((void*)0)); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, oldloc
->pargfid, oldloc->name, ((void*)0)); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, oldloc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_oldpath = __builtin_alloca (__len); __len = posix_handle_path
(this, oldloc->pargfid, ((void*)0), par_oldpath, __len); }
while (0); do { int __len; __len = posix_handle_path (this, oldloc
->pargfid, oldloc->name, ((void*)0), 0); if (__len <=
0) break; real_oldpath = __builtin_alloca (__len); __len = posix_handle_path
(this, oldloc->pargfid, oldloc->name, real_oldpath, __len
); } while (0); break; } } while (0)
;
1369 MAKE_ENTRY_HANDLE (real_newpath, par_newpath, this, newloc, &stbuf)do { char *__parp; if (uuid_is_null (newloc->pargfid) || !
newloc->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, newloc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1369, GF_LOG_ERROR, "null pargfid/name for path %s"
, newloc->path); } while (0); break; } if (((newloc) &&
(newloc->path) && (newloc->path[0] == '/'))) {
do { real_newpath = __builtin_alloca (strlen (newloc->path
) + (((struct posix_private *)this->private)->base_path_length
) + 2); strcpy (real_newpath, (((struct posix_private *)this->
private)->base_path)); strcpy (&real_newpath[(((struct
posix_private *)this->private)->base_path_length)], newloc
->path); } while (0); __parp = (__extension__ ({ const char
*__old = (real_newpath); size_t __len = strlen (__old) + 1; char
*__new = (char *) __builtin_alloca (__len); (char *) memcpy (
__new, __old, __len); })); par_newpath = dirname (__parp); op_ret
= posix_pstat (this, ((void*)0), real_newpath, &stbuf); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, newloc
->pargfid, newloc->name, &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, newloc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_newpath = __builtin_alloca (__len); __len = posix_handle_path
(this, newloc->pargfid, ((void*)0), par_newpath, __len); }
while (0); do { int __len; __len = posix_handle_path (this, newloc
->pargfid, newloc->name, ((void*)0), 0); if (__len <=
0) break; real_newpath = __builtin_alloca (__len); __len = posix_handle_path
(this, newloc->pargfid, newloc->name, real_newpath, __len
); } while (0); break; } } while (0)
;
1370
1371 op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &preoldparent);
1372 if (op_ret == -1) {
1373 op_errno = errno(*__errno_location ());
1374 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1376, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0)
1375 "pre-operation lstat on parent %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1376, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0)
1376 par_oldpath, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1376, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0)
;
1377 goto out;
1378 }
1379
1380 op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &prenewparent);
1381 if (op_ret == -1) {
1382 op_errno = errno(*__errno_location ());
1383 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent of %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1385, GF_LOG_ERROR, "pre-operation lstat on parent of %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0)
1384 "pre-operation lstat on parent of %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent of %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1385, GF_LOG_ERROR, "pre-operation lstat on parent of %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0)
1385 par_newpath, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent of %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1385, GF_LOG_ERROR, "pre-operation lstat on parent of %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0)
;
1386 goto out;
1387 }
1388
1389 op_ret = posix_pstat (this, NULL((void*)0), real_newpath, &stbuf);
1390 if ((op_ret == -1) && (errno(*__errno_location ()) == ENOENT2)){
1391 was_present = 0;
1392 } else {
1393 uuid_copy (victim, stbuf.ia_gfid);
1394 if (IA_ISDIR (stbuf.ia_type)(stbuf.ia_type == IA_IFDIR))
1395 was_dir = 1;
1396 nlink = stbuf.ia_nlink;
1397 }
1398
1399 if (was_present && IA_ISDIR(stbuf.ia_type)(stbuf.ia_type == IA_IFDIR) && !newloc->inode) {
1400 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("found directory at %s while expecting ENOENT"
, real_newpath); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1402, GF_LOG_WARNING, "found directory at %s while expecting ENOENT"
, real_newpath); } while (0)
1401 "found directory at %s while expecting ENOENT",do { do { if (0) printf ("found directory at %s while expecting ENOENT"
, real_newpath); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1402, GF_LOG_WARNING, "found directory at %s while expecting ENOENT"
, real_newpath); } while (0)
1402 real_newpath)do { do { if (0) printf ("found directory at %s while expecting ENOENT"
, real_newpath); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1402, GF_LOG_WARNING, "found directory at %s while expecting ENOENT"
, real_newpath); } while (0)
;
1403 op_ret = -1;
1404 op_errno = EEXIST17;
1405 goto out;
1406 }
1407
1408 if (was_present && IA_ISDIR(stbuf.ia_type)(stbuf.ia_type == IA_IFDIR) &&
1409 uuid_compare (newloc->inode->gfid, stbuf.ia_gfid)) {
1410 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("found directory %s at %s while renaming %s"
, uuid_utoa_r (newloc->inode->gfid, olddirid), real_newpath
, uuid_utoa_r (stbuf.ia_gfid, newdirid)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1414, GF_LOG_WARNING
, "found directory %s at %s while renaming %s", uuid_utoa_r (
newloc->inode->gfid, olddirid), real_newpath, uuid_utoa_r
(stbuf.ia_gfid, newdirid)); } while (0)
1411 "found directory %s at %s while renaming %s",do { do { if (0) printf ("found directory %s at %s while renaming %s"
, uuid_utoa_r (newloc->inode->gfid, olddirid), real_newpath
, uuid_utoa_r (stbuf.ia_gfid, newdirid)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1414, GF_LOG_WARNING
, "found directory %s at %s while renaming %s", uuid_utoa_r (
newloc->inode->gfid, olddirid), real_newpath, uuid_utoa_r
(stbuf.ia_gfid, newdirid)); } while (0)
1412 uuid_utoa_r (newloc->inode->gfid, olddirid),do { do { if (0) printf ("found directory %s at %s while renaming %s"
, uuid_utoa_r (newloc->inode->gfid, olddirid), real_newpath
, uuid_utoa_r (stbuf.ia_gfid, newdirid)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1414, GF_LOG_WARNING
, "found directory %s at %s while renaming %s", uuid_utoa_r (
newloc->inode->gfid, olddirid), real_newpath, uuid_utoa_r
(stbuf.ia_gfid, newdirid)); } while (0)
1413 real_newpath,do { do { if (0) printf ("found directory %s at %s while renaming %s"
, uuid_utoa_r (newloc->inode->gfid, olddirid), real_newpath
, uuid_utoa_r (stbuf.ia_gfid, newdirid)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1414, GF_LOG_WARNING
, "found directory %s at %s while renaming %s", uuid_utoa_r (
newloc->inode->gfid, olddirid), real_newpath, uuid_utoa_r
(stbuf.ia_gfid, newdirid)); } while (0)
1414 uuid_utoa_r (stbuf.ia_gfid, newdirid))do { do { if (0) printf ("found directory %s at %s while renaming %s"
, uuid_utoa_r (newloc->inode->gfid, olddirid), real_newpath
, uuid_utoa_r (stbuf.ia_gfid, newdirid)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1414, GF_LOG_WARNING
, "found directory %s at %s while renaming %s", uuid_utoa_r (
newloc->inode->gfid, olddirid), real_newpath, uuid_utoa_r
(stbuf.ia_gfid, newdirid)); } while (0)
;
1415 op_ret = -1;
1416 op_errno = EEXIST17;
1417 goto out;
1418 }
1419
1420 if (IA_ISDIR (oldloc->inode->ia_type)(oldloc->inode->ia_type == IA_IFDIR)) {
1421 posix_handle_unset (this, oldloc->inode->gfid, NULL((void*)0));
1422 }
1423
1424 op_ret = sys_rename (real_oldpath, real_newpath);
1425 if (op_ret == -1) {
1426 op_errno = errno(*__errno_location ());
1427 gf_log (this->name,do { do { if (0) printf ("rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1430, (op_errno == 39 ? GF_LOG_DEBUG
: GF_LOG_ERROR), "rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0)
1428 (op_errno == ENOTEMPTY ? GF_LOG_DEBUG : GF_LOG_ERROR),do { do { if (0) printf ("rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1430, (op_errno == 39 ? GF_LOG_DEBUG
: GF_LOG_ERROR), "rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0)
1429 "rename of %s to %s failed: %s",do { do { if (0) printf ("rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1430, (op_errno == 39 ? GF_LOG_DEBUG
: GF_LOG_ERROR), "rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0)
1430 real_oldpath, real_newpath, strerror (op_errno))do { do { if (0) printf ("rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1430, (op_errno == 39 ? GF_LOG_DEBUG
: GF_LOG_ERROR), "rename of %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0)
;
1431 goto out;
1432 }
1433
1434 if (was_dir)
1435 posix_handle_unset (this, victim, NULL((void*)0));
1436
1437 if (was_present && !was_dir && nlink == 1)
1438 posix_handle_unset (this, victim, NULL((void*)0));
1439
1440 if (IA_ISDIR (oldloc->inode->ia_type)(oldloc->inode->ia_type == IA_IFDIR)) {
1441 posix_handle_soft (this, real_newpath, newloc,
1442 oldloc->inode->gfid, NULL((void*)0));
1443 }
1444
1445 op_ret = posix_pstat (this, NULL((void*)0), real_newpath, &stbuf);
1446 if (op_ret == -1) {
1447 op_errno = errno(*__errno_location ());
1448 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lstat on %s failed: %s", real_newpath
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1450, GF_LOG_ERROR, "lstat on %s failed: %s",
real_newpath, strerror (op_errno)); } while (0)
1449 "lstat on %s failed: %s",do { do { if (0) printf ("lstat on %s failed: %s", real_newpath
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1450, GF_LOG_ERROR, "lstat on %s failed: %s",
real_newpath, strerror (op_errno)); } while (0)
1450 real_newpath, strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_newpath
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1450, GF_LOG_ERROR, "lstat on %s failed: %s",
real_newpath, strerror (op_errno)); } while (0)
;
1451 goto out;
1452 }
1453
1454 op_ret = posix_pstat (this, oldloc->pargfid, par_oldpath, &postoldparent);
1455 if (op_ret == -1) {
1456 op_errno = errno(*__errno_location ());
1457 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1459, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0)
1458 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1459, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0)
1459 par_oldpath, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1459, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_oldpath, strerror (op_errno)); } while (0)
;
1460 goto out;
1461 }
1462
1463 op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postnewparent);
1464 if (op_ret == -1) {
1465 op_errno = errno(*__errno_location ());
1466 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1468, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0)
1467 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1468, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0)
1468 par_newpath, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1468, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_newpath, strerror (op_errno)); } while (0)
;
1469 goto out;
1470 }
1471
1472 op_ret = 0;
1473
1474out:
1475
1476 SET_TO_OLD_FS_ID ();
1477
1478 STACK_UNWIND_STRICT (rename, frame, op_ret, op_errno, &stbuf,do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1480, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rename_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &stbuf, &preoldparent, &postoldparent
, &prenewparent, &postnewparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1479 &preoldparent, &postoldparent,do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1480, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rename_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &stbuf, &preoldparent, &postoldparent
, &prenewparent, &postnewparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1480 &prenewparent, &postnewparent, NULL)do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1480, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rename_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &stbuf, &preoldparent, &postoldparent
, &prenewparent, &postnewparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1481
1482 if ((op_ret == -1) && !was_present) {
1483 unlink (real_newpath);
1484 }
1485
1486 return 0;
1487}
1488
1489
1490int
1491posix_link (call_frame_t *frame, xlator_t *this,
1492 loc_t *oldloc, loc_t *newloc, dict_t *xdata)
1493{
1494 int32_t op_ret = -1;
1495 int32_t op_errno = 0;
1496 char *real_oldpath = 0;
1497 char *real_newpath = 0;
1498 char *par_newpath = 0;
1499 struct iatt stbuf = {0, };
1500 struct posix_private *priv = NULL((void*)0);
1501 char was_present = 1;
1502 struct iatt preparent = {0,};
1503 struct iatt postparent = {0,};
1504
1505 DECLARE_OLD_FS_ID_VAR;
1506
1507 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1507, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1508 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1508, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1509 VALIDATE_OR_GOTO (oldloc, out)do { if (!oldloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "oldloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1509, GF_LOG_WARNING, "invalid argument: " "oldloc"
); } while (0); goto out; } } while (0)
;
1510 VALIDATE_OR_GOTO (newloc, out)do { if (!newloc) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "newloc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1510, GF_LOG_WARNING, "invalid argument: " "newloc"
); } while (0); goto out; } } while (0)
;
1511
1512 priv = this->private;
1513 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1513, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1514
1515 SET_FS_ID (frame->root->uid, frame->root->gid);
1516 MAKE_INODE_HANDLE (real_oldpath, this, oldloc, &stbuf)do { if (uuid_is_null (oldloc->gfid)) { do { do { if (0) printf
("null gfid for path %s", oldloc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1516, GF_LOG_ERROR,
"null gfid for path %s", oldloc->path); } while (0); break
; } if (((oldloc) && (oldloc->path) && (oldloc
->path[0] == '/'))) { do { real_oldpath = __builtin_alloca
(strlen (oldloc->path) + (((struct posix_private *)this->
private)->base_path_length) + 2); strcpy (real_oldpath, ((
(struct posix_private *)this->private)->base_path)); strcpy
(&real_oldpath[(((struct posix_private *)this->private
)->base_path_length)], oldloc->path); } while (0); op_ret
= posix_pstat (this, oldloc->gfid, real_oldpath, &stbuf
); break; } (*__errno_location ()) = 0; op_ret = posix_istat (
this, oldloc->gfid, ((void*)0), &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, oldloc->gfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; real_oldpath = __builtin_alloca (__len); __len = posix_handle_path
(this, oldloc->gfid, ((void*)0), real_oldpath, __len); } while
(0); break; } } while (0)
;
1517
1518 MAKE_ENTRY_HANDLE (real_newpath, par_newpath, this, newloc, &stbuf)do { char *__parp; if (uuid_is_null (newloc->pargfid) || !
newloc->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, newloc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1518, GF_LOG_ERROR, "null pargfid/name for path %s"
, newloc->path); } while (0); break; } if (((newloc) &&
(newloc->path) && (newloc->path[0] == '/'))) {
do { real_newpath = __builtin_alloca (strlen (newloc->path
) + (((struct posix_private *)this->private)->base_path_length
) + 2); strcpy (real_newpath, (((struct posix_private *)this->
private)->base_path)); strcpy (&real_newpath[(((struct
posix_private *)this->private)->base_path_length)], newloc
->path); } while (0); __parp = (__extension__ ({ const char
*__old = (real_newpath); size_t __len = strlen (__old) + 1; char
*__new = (char *) __builtin_alloca (__len); (char *) memcpy (
__new, __old, __len); })); par_newpath = dirname (__parp); op_ret
= posix_pstat (this, ((void*)0), real_newpath, &stbuf); break
; } (*__errno_location ()) = 0; op_ret = posix_istat (this, newloc
->pargfid, newloc->name, &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, newloc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_newpath = __builtin_alloca (__len); __len = posix_handle_path
(this, newloc->pargfid, ((void*)0), par_newpath, __len); }
while (0); do { int __len; __len = posix_handle_path (this, newloc
->pargfid, newloc->name, ((void*)0), 0); if (__len <=
0) break; real_newpath = __builtin_alloca (__len); __len = posix_handle_path
(this, newloc->pargfid, newloc->name, real_newpath, __len
); } while (0); break; } } while (0)
;
1519 if ((op_ret == -1) && (errno(*__errno_location ()) == ENOENT2)) {
1520 was_present = 0;
1521 }
1522
1523 op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &preparent);
1524 if (op_ret == -1) {
1525 op_errno = errno(*__errno_location ());
1526 gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s",do { do { if (0) printf ("lstat failed: %s: %s", par_newpath,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1527, GF_LOG_ERROR, "lstat failed: %s: %s", par_newpath
, strerror (op_errno)); } while (0)
1527 par_newpath, strerror (op_errno))do { do { if (0) printf ("lstat failed: %s: %s", par_newpath,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1527, GF_LOG_ERROR, "lstat failed: %s: %s", par_newpath
, strerror (op_errno)); } while (0)
;
1528 goto out;
1529 }
1530
1531#ifdef HAVE_LINKAT1
1532 /*
1533 * On most systems (Linux being the notable exception), link(2)
1534 * first resolves symlinks. If the target is a directory or
1535 * is nonexistent, it will fail. linkat(2) operates on the
1536 * symlink instead of its target when the AT_SYMLINK_FOLLOW
1537 * flag is not supplied.
1538 */
1539 op_ret = linkat (AT_FDCWD-100, real_oldpath, AT_FDCWD-100, real_newpath, 0);
1540#else
1541 op_ret = link (real_oldpath, real_newpath);
1542#endif
1543 if (op_ret == -1) {
1544 op_errno = errno(*__errno_location ());
1545 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("link %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1547, GF_LOG_ERROR, "link %s to %s failed: %s"
, real_oldpath, real_newpath, strerror (op_errno)); } while (
0)
1546 "link %s to %s failed: %s",do { do { if (0) printf ("link %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1547, GF_LOG_ERROR, "link %s to %s failed: %s"
, real_oldpath, real_newpath, strerror (op_errno)); } while (
0)
1547 real_oldpath, real_newpath, strerror (op_errno))do { do { if (0) printf ("link %s to %s failed: %s", real_oldpath
, real_newpath, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1547, GF_LOG_ERROR, "link %s to %s failed: %s"
, real_oldpath, real_newpath, strerror (op_errno)); } while (
0)
;
1548 goto out;
1549 }
1550
1551 op_ret = posix_pstat (this, NULL((void*)0), real_newpath, &stbuf);
1552 if (op_ret == -1) {
1553 op_errno = errno(*__errno_location ());
1554 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("lstat on %s failed: %s", real_newpath
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1556, GF_LOG_ERROR, "lstat on %s failed: %s",
real_newpath, strerror (op_errno)); } while (0)
1555 "lstat on %s failed: %s",do { do { if (0) printf ("lstat on %s failed: %s", real_newpath
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1556, GF_LOG_ERROR, "lstat on %s failed: %s",
real_newpath, strerror (op_errno)); } while (0)
1556 real_newpath, strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_newpath
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1556, GF_LOG_ERROR, "lstat on %s failed: %s",
real_newpath, strerror (op_errno)); } while (0)
;
1557 goto out;
1558 }
1559
1560 op_ret = posix_pstat (this, newloc->pargfid, par_newpath, &postparent);
1561 if (op_ret == -1) {
1562 op_errno = errno(*__errno_location ());
1563 gf_log (this->name, GF_LOG_ERROR, "lstat failed: %s: %s",do { do { if (0) printf ("lstat failed: %s: %s", par_newpath,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1564, GF_LOG_ERROR, "lstat failed: %s: %s", par_newpath
, strerror (op_errno)); } while (0)
1564 par_newpath, strerror (op_errno))do { do { if (0) printf ("lstat failed: %s: %s", par_newpath,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1564, GF_LOG_ERROR, "lstat failed: %s: %s", par_newpath
, strerror (op_errno)); } while (0)
;
1565 goto out;
1566 }
1567
1568 op_ret = 0;
1569
1570out:
1571 SET_TO_OLD_FS_ID ();
1572
1573 STACK_UNWIND_STRICT (link, frame, op_ret, op_errno,do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = (
(void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do {
do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1575, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (oldloc)?oldloc->inode:((void*)0), &stbuf,
&preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1574 (oldloc)?oldloc->inode:NULL, &stbuf, &preparent,do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = (
(void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do {
do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1575, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (oldloc)?oldloc->inode:((void*)0), &stbuf,
&preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1575 &postparent, NULL)do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = (
(void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do {
do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1575, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, (oldloc)?oldloc->inode:((void*)0), &stbuf,
&preparent, &postparent, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1576
1577 if ((op_ret == -1) && (!was_present)) {
1578 unlink (real_newpath);
1579 }
1580
1581 return 0;
1582}
1583
1584
1585int32_t
1586posix_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
1587 dict_t *xdata)
1588{
1589 int32_t op_ret = -1;
1590 int32_t op_errno = 0;
1591 char *real_path = 0;
1592 struct posix_private *priv = NULL((void*)0);
1593 struct iatt prebuf = {0,};
1594 struct iatt postbuf = {0,};
1595
1596 DECLARE_OLD_FS_ID_VAR;
1597
1598 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1598, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1599 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1599, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1600 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1600, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
1601
1602 priv = this->private;
1603 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1603, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1604
1605 SET_FS_ID (frame->root->uid, frame->root->gid);
1606
1607 MAKE_INODE_HANDLE (real_path, this, loc, &prebuf)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1607, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, &prebuf); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), &prebuf); if ((*__errno_location ()) != 40) { do { int
__len; __len = posix_handle_path (this, loc->gfid, ((void
*)0), ((void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
1608 if (op_ret == -1) {
1609 op_errno = errno(*__errno_location ());
1610 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1612, GF_LOG_ERROR, "pre-operation lstat on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1611 "pre-operation lstat on %s failed: %s",do { do { if (0) printf ("pre-operation lstat on %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1612, GF_LOG_ERROR, "pre-operation lstat on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1612 real_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on %s failed: %s"
, real_path, strerror (op_errno)); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1612, GF_LOG_ERROR, "pre-operation lstat on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
1613 goto out;
1614 }
1615
1616 op_ret = truncate (real_path, offset);
1617 if (op_ret == -1) {
1618 op_errno = errno(*__errno_location ());
1619 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("truncate on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1621, GF_LOG_ERROR, "truncate on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1620 "truncate on %s failed: %s",do { do { if (0) printf ("truncate on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1621, GF_LOG_ERROR, "truncate on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
1621 real_path, strerror (op_errno))do { do { if (0) printf ("truncate on %s failed: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1621, GF_LOG_ERROR, "truncate on %s failed: %s"
, real_path, strerror (op_errno)); } while (0)
;
1622 goto out;
1623 }
1624
1625 op_ret = posix_pstat (this, loc->gfid, real_path, &postbuf);
1626 if (op_ret == -1) {
1627 op_errno = errno(*__errno_location ());
1628 gf_log (this->name, GF_LOG_ERROR, "lstat on %s failed: %s",do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1629, GF_LOG_ERROR, "lstat on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
1629 real_path, strerror (op_errno))do { do { if (0) printf ("lstat on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1629, GF_LOG_ERROR, "lstat on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
;
1630 goto out;
1631 }
1632
1633 op_ret = 0;
1634
1635out:
1636 SET_TO_OLD_FS_ID ();
1637
1638 STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno,do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1639, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_truncate_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &prebuf, &postbuf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1639 &prebuf, &postbuf, NULL)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1639, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_truncate_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &prebuf, &postbuf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1640
1641 return 0;
1642}
1643
1644
1645int
1646posix_create (call_frame_t *frame, xlator_t *this,
1647 loc_t *loc, int32_t flags, mode_t mode,
1648 mode_t umask, fd_t *fd, dict_t *xdata)
1649{
1650 int32_t op_ret = -1;
1651 int32_t op_errno = 0;
1652 int32_t _fd = -1;
1653 int _flags = 0;
1654 char * real_path = NULL((void*)0);
1655 char * par_path = NULL((void*)0);
1656 struct iatt stbuf = {0, };
1657 struct posix_fd * pfd = NULL((void*)0);
1658 struct posix_private * priv = NULL((void*)0);
1659 char was_present = 1;
1660
1661 gid_t gid = 0;
1662 struct iatt preparent = {0,};
1663 struct iatt postparent = {0,};
1664
1665 DECLARE_OLD_FS_ID_VAR;
1666
1667 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1667, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1668 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1668, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1669 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "posix.c", __FUNCTION__, 1669, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
1670 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1670, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
1671 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1671, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
1672
1673 priv = this->private;
1674 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1674, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1675
1676 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf)do { char *__parp; if (uuid_is_null (loc->pargfid) || !loc
->name) { do { do { if (0) printf ("null pargfid/name for path %s"
, loc->path); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1676, GF_LOG_ERROR, "null pargfid/name for path %s"
, loc->path); } while (0); break; } if (((loc) && (
loc->path) && (loc->path[0] == '/'))) { do { real_path
= __builtin_alloca (strlen (loc->path) + (((struct posix_private
*)this->private)->base_path_length) + 2); strcpy (real_path
, (((struct posix_private *)this->private)->base_path))
; strcpy (&real_path[(((struct posix_private *)this->private
)->base_path_length)], loc->path); } while (0); __parp =
(__extension__ ({ const char *__old = (real_path); size_t __len
= strlen (__old) + 1; char *__new = (char *) __builtin_alloca
(__len); (char *) memcpy (__new, __old, __len); })); par_path
= dirname (__parp); op_ret = posix_pstat (this, ((void*)0), real_path
, &stbuf); break; } (*__errno_location ()) = 0; op_ret = posix_istat
(this, loc->pargfid, loc->name, &stbuf); if ((*__errno_location
()) != 40) { do { int __len; __len = posix_handle_path (this
, loc->pargfid, ((void*)0), ((void*)0), 0); if (__len <=
0) break; par_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, ((void*)0), par_path, __len); } while
(0); do { int __len; __len = posix_handle_path (this, loc->
pargfid, loc->name, ((void*)0), 0); if (__len <= 0) break
; real_path = __builtin_alloca (__len); __len = posix_handle_path
(this, loc->pargfid, loc->name, real_path, __len); } while
(0); break; } } while (0)
;
1677
1678 gid = frame->root->gid;
1679
1680 SET_FS_ID (frame->root->uid, gid);
1681
1682 op_ret = posix_pstat (this, loc->pargfid, par_path, &preparent);
1683 if (op_ret == -1) {
1684 op_errno = errno(*__errno_location ());
1685 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1687, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1686 "pre-operation lstat on parent %s failed: %s",do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1687, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1687 par_path, strerror (op_errno))do { do { if (0) printf ("pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1687, GF_LOG_ERROR, "pre-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1688 goto out;
1689 }
1690
1691 if (preparent.ia_prot.sgid) {
1692 gid = preparent.ia_gid;
1693 }
1694
1695 if (!flags) {
1696 _flags = O_CREAT0100 | O_RDWR02 | O_EXCL0200;
1697 }
1698 else {
1699 _flags = flags | O_CREAT0100;
1700 }
1701
1702 op_ret = posix_pstat (this, NULL((void*)0), real_path, &stbuf);
1703 if ((op_ret == -1) && (errno(*__errno_location ()) == ENOENT2)) {
1704 was_present = 0;
1705 }
1706
1707 if (priv->o_direct)
1708 _flags |= O_DIRECT040000;
1709
1710 _fd = open (real_path, _flags, mode);
1711
1712 if (_fd == -1) {
1713 op_errno = errno(*__errno_location ());
1714 op_ret = -1;
1715 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("open on %s failed: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1717, GF_LOG_ERROR, "open on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
1716 "open on %s failed: %s", real_path,do { do { if (0) printf ("open on %s failed: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1717, GF_LOG_ERROR, "open on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
1717 strerror (op_errno))do { do { if (0) printf ("open on %s failed: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1717, GF_LOG_ERROR, "open on %s failed: %s", real_path
, strerror (op_errno)); } while (0)
;
1718 goto out;
1719 }
1720
1721 if (was_present)
1722 goto fill_stat;
1723
1724 op_ret = posix_gfid_set (this, real_path, loc, xdata);
1725 if (op_ret) {
1726 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 1727, GF_LOG_ERROR, "setting gfid on %s failed", real_path)
; } while (0)
1727 "setting gfid on %s failed", real_path)do { do { if (0) printf ("setting gfid on %s failed", real_path
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 1727, GF_LOG_ERROR, "setting gfid on %s failed", real_path)
; } while (0)
;
1728 }
1729
1730#ifndef HAVE_SET_FSID
1731 op_ret = chown (real_path, frame->root->uid, gid);
1732 if (op_ret == -1) {
1733 op_errno = errno(*__errno_location ());
1734 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("chown on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1736, GF_LOG_ERROR, "chown on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
1735 "chown on %s failed: %s",do { do { if (0) printf ("chown on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1736, GF_LOG_ERROR, "chown on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
1736 real_path, strerror (op_errno))do { do { if (0) printf ("chown on %s failed: %s", real_path,
strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1736, GF_LOG_ERROR, "chown on %s failed: %s",
real_path, strerror (op_errno)); } while (0)
;
1737 }
1738#endif
1739
1740 op_ret = posix_acl_xattr_set (this, real_path, xdata);
1741 if (op_ret) {
1742 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1744, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1743 "setting ACLs on %s failed (%s)", real_path,do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1744, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1744 strerror (errno))do { do { if (0) printf ("setting ACLs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1744, GF_LOG_ERROR, "setting ACLs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
1745 }
1746
1747 op_ret = posix_entry_create_xattr_set (this, real_path, xdata);
1748 if (op_ret) {
1749 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1751, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1750 "setting xattrs on %s failed (%s)", real_path,do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1751, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
1751 strerror (errno))do { do { if (0) printf ("setting xattrs on %s failed (%s)", real_path
, strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 1751, GF_LOG_ERROR, "setting xattrs on %s failed (%s)"
, real_path, strerror ((*__errno_location ()))); } while (0)
;
1752 }
1753
1754fill_stat:
1755 op_ret = posix_fdstat (this, _fd, &stbuf);
1756 if (op_ret == -1) {
1757 op_errno = errno(*__errno_location ());
1758 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fstat on %d failed: %s", _fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1759, GF_LOG_ERROR, "fstat on %d failed: %s", _fd
, strerror (op_errno)); } while (0)
1759 "fstat on %d failed: %s", _fd, strerror (op_errno))do { do { if (0) printf ("fstat on %d failed: %s", _fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1759, GF_LOG_ERROR, "fstat on %d failed: %s", _fd
, strerror (op_errno)); } while (0)
;
1760 goto out;
1761 }
1762
1763 op_ret = posix_pstat (this, loc->pargfid, par_path, &postparent);
1764 if (op_ret == -1) {
1765 op_errno = errno(*__errno_location ());
1766 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1768, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1767 "post-operation lstat on parent %s failed: %s",do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1768, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
1768 par_path, strerror (op_errno))do { do { if (0) printf ("post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 1768, GF_LOG_ERROR, "post-operation lstat on parent %s failed: %s"
, par_path, strerror (op_errno)); } while (0)
;
1769 goto out;
1770 }
1771
1772 op_ret = -1;
1773 pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd)__gf_calloc (1, sizeof (*pfd), gf_posix_mt_posix_fd);
1774 if (!pfd) {
1775 op_errno = errno(*__errno_location ());
1776 goto out;
1777 }
1778
1779 pfd->flags = flags;
1780 pfd->fd = _fd;
1781
1782 op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd);
1783 if (op_ret)
1784 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1786, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
1785 "failed to set the fd context path=%s fd=%p",do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1786, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
1786 real_path, fd)do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1786, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
;
1787
1788 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
1789 {
1790 priv->nr_files++;
1791 }
1792 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
1793
1794 op_ret = 0;
1795
1796out:
1797 SET_TO_OLD_FS_ID ();
1798
1799 if ((-1 == op_ret) && (_fd != -1)) {
1800 close (_fd);
1801
1802 if (!was_present) {
1803 unlink (real_path);
1804 }
1805 }
1806
1807 STACK_UNWIND_STRICT (create, frame, op_ret, op_errno,do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1809, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, fd, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1808 fd, (loc)?loc->inode:NULL, &stbuf, &preparent,do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1809, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, fd, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1809 &postparent, xdata)do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1809, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_create_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, fd, (loc)?loc->inode:((void*)0), &stbuf, &
preparent, &postparent, xdata); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1810
1811 return 0;
1812}
1813
1814int32_t
1815posix_open (call_frame_t *frame, xlator_t *this,
1816 loc_t *loc, int32_t flags, fd_t *fd, dict_t *xdata)
1817{
1818 int32_t op_ret = -1;
1819 int32_t op_errno = 0;
1820 char *real_path = NULL((void*)0);
1821 int32_t _fd = -1;
1822 struct posix_fd *pfd = NULL((void*)0);
1823 struct posix_private *priv = NULL((void*)0);
1824 struct iatt stbuf = {0, };
1825
1826 DECLARE_OLD_FS_ID_VAR;
1827
1828 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1828, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1829 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1829, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1830 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "posix.c", __FUNCTION__, 1830, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
1831 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1831, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
1832 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1832, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
1833
1834 priv = this->private;
1835 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1835, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1836
1837 MAKE_INODE_HANDLE (real_path, this, loc, &stbuf)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1837, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, &stbuf); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), &stbuf); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
1838
1839 op_ret = -1;
1840 SET_FS_ID (frame->root->uid, frame->root->gid);
1841
1842 if (priv->o_direct)
1843 flags |= O_DIRECT040000;
1844
1845 _fd = open (real_path, flags, 0);
1846 if (_fd == -1) {
1847 op_ret = -1;
1848 op_errno = errno(*__errno_location ());
1849 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("open on %s: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1850, GF_LOG_ERROR, "open on %s: %s", real_path
, strerror (op_errno)); } while (0)
1850 "open on %s: %s", real_path, strerror (op_errno))do { do { if (0) printf ("open on %s: %s", real_path, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1850, GF_LOG_ERROR, "open on %s: %s", real_path
, strerror (op_errno)); } while (0)
;
1851 goto out;
1852 }
1853
1854 pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd)__gf_calloc (1, sizeof (*pfd), gf_posix_mt_posix_fd);
1855 if (!pfd) {
1856 op_errno = errno(*__errno_location ());
1857 goto out;
1858 }
1859
1860 pfd->flags = flags;
1861 pfd->fd = _fd;
1862
1863 op_ret = fd_ctx_set (fd, this, (uint64_t)(long)pfd);
1864 if (op_ret)
1865 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1867, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
1866 "failed to set the fd context path=%s fd=%p",do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1867, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
1867 real_path, fd)do { do { if (0) printf ("failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 1867, GF_LOG_WARNING, "failed to set the fd context path=%s fd=%p"
, real_path, fd); } while (0)
;
1868
1869 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
1870 {
1871 priv->nr_files++;
1872 }
1873 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
1874
1875 op_ret = 0;
1876
1877out:
1878 if (op_ret == -1) {
1879 if (_fd != -1) {
1880 close (_fd);
1881 }
1882 }
1883
1884 SET_TO_OLD_FS_ID ();
1885
1886 STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, NULL)do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = (
(void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do {
do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1886, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, fd, ((void*)0)); (*__glusterfs_this_location()) =
old_THIS; } while (0)
;
1887
1888 return 0;
1889}
1890
1891int
1892posix_readv (call_frame_t *frame, xlator_t *this,
1893 fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata)
1894{
1895 int32_t op_ret = -1;
1896 int32_t op_errno = 0;
1897 int _fd = -1;
1898 struct posix_private * priv = NULL((void*)0);
1899 struct iobuf * iobuf = NULL((void*)0);
1900 struct iobref * iobref = NULL((void*)0);
1901 struct iovec vec = {0,};
1902 struct posix_fd * pfd = NULL((void*)0);
1903 struct iatt stbuf = {0,};
1904 int ret = -1;
1905
1906 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1906, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
1907 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1907, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
1908 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1908, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
1909 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "posix.c", __FUNCTION__, 1909, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
1910
1911 priv = this->private;
1912 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 1912, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
1913
1914 ret = posix_fd_ctx_get (fd, this, &pfd);
1915 if (ret < 0) {
1916 op_errno = -ret;
1917 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 1918, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
1918 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 1918, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
;
1919 goto out;
1920 }
1921
1922 if (!size) {
1923 op_errno = EINVAL22;
1924 gf_log (this->name, GF_LOG_WARNING, "size=%"GF_PRI_SIZET, size)do { do { if (0) printf ("size=%""zu", size); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 1924, GF_LOG_WARNING
, "size=%""zu", size); } while (0)
;
1925 goto out;
1926 }
1927
1928 iobuf = iobuf_get2 (this->ctx->iobuf_pool, size);
1929 if (!iobuf) {
1930 op_errno = ENOMEM12;
1931 goto out;
1932 }
1933
1934 _fd = pfd->fd;
1935 op_ret = pread (_fd, iobuf->ptr, size, offset);
1936 if (op_ret == -1) {
1937 op_errno = errno(*__errno_location ());
1938 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("read failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1940, GF_LOG_ERROR, "read failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
1939 "read failed on fd=%p: %s", fd,do { do { if (0) printf ("read failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1940, GF_LOG_ERROR, "read failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
1940 strerror (op_errno))do { do { if (0) printf ("read failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1940, GF_LOG_ERROR, "read failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
1941 goto out;
1942 }
1943
1944 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
1945 {
1946 priv->read_value += op_ret;
1947 }
1948 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
1949
1950 vec.iov_base = iobuf->ptr;
1951 vec.iov_len = op_ret;
1952
1953 iobref = iobref_new ();
1954
1955 iobref_add (iobref, iobuf);
1956
1957 /*
1958 * readv successful, and we need to get the stat of the file
1959 * we read from
1960 */
1961
1962 op_ret = posix_fdstat (this, _fd, &stbuf);
1963 if (op_ret == -1) {
1964 op_errno = errno(*__errno_location ());
1965 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fstat failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1967, GF_LOG_ERROR, "fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
1966 "fstat failed on fd=%p: %s", fd,do { do { if (0) printf ("fstat failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1967, GF_LOG_ERROR, "fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
1967 strerror (op_errno))do { do { if (0) printf ("fstat failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 1967, GF_LOG_ERROR, "fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
1968 goto out;
1969 }
1970
1971 /* Hack to notify higher layers of EOF. */
1972 if (stbuf.ia_size == 0)
1973 op_errno = ENOENT2;
1974 else if ((offset + vec.iov_len) == stbuf.ia_size)
1975 op_errno = ENOENT2;
1976 else if (offset > stbuf.ia_size)
1977 op_errno = ENOENT2;
1978
1979 op_ret = vec.iov_len;
1980out:
1981
1982 STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno,do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1983, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_readv_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &vec, 1, &stbuf, iobref, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
1983 &vec, 1, &stbuf, iobref, NULL)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 1983, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_readv_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &vec, 1, &stbuf, iobref, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
1984
1985 if (iobref)
1986 iobref_unref (iobref);
1987 if (iobuf)
1988 iobuf_unref (iobuf);
1989
1990 return 0;
1991}
1992
1993
1994int32_t
1995__posix_pwritev (int fd, struct iovec *vector, int count, off_t offset)
1996{
1997 int32_t op_ret = 0;
1998 int idx = 0;
1999 int retval = 0;
2000 off_t internal_off = 0;
2001
2002 if (!vector)
2003 return -EFAULT14;
2004
2005 internal_off = offset;
2006 for (idx = 0; idx < count; idx++) {
2007 retval = pwrite (fd, vector[idx].iov_base, vector[idx].iov_len,
2008 internal_off);
2009 if (retval == -1) {
2010 op_ret = -errno(*__errno_location ());
2011 goto err;
2012 }
2013 op_ret += retval;
2014 internal_off += retval;
2015 }
2016
2017err:
2018 return op_ret;
2019}
2020
2021char*
2022_page_aligned_alloc (size_t size, char **aligned_buf)
2023{
2024 char *alloc_buf = NULL((void*)0);
2025 char *buf = NULL((void*)0);
2026
2027 alloc_buf = GF_CALLOC (1, (size + ALIGN_SIZE), gf_posix_mt_char)__gf_calloc (1, (size + 4096), gf_posix_mt_char);
2028 if (!alloc_buf)
2029 goto out;
2030 /* page aligned buffer */
2031 buf = GF_ALIGN_BUF (alloc_buf, ALIGN_SIZE)((void *)((unsigned long)(alloc_buf + 4096 - 1) & (unsigned
long)(~(4096 - 1))))
;
2032 *aligned_buf = buf;
2033out:
2034 return alloc_buf;
2035}
2036
2037int32_t
2038__posix_writev (int fd, struct iovec *vector, int count, off_t startoff,
2039 int odirect)
2040{
2041 int32_t op_ret = 0;
2042 int idx = 0;
2043 int max_buf_size = 0;
2044 int retval = 0;
2045 char *buf = NULL((void*)0);
2046 char *alloc_buf = NULL((void*)0);
2047 off_t internal_off = 0;
2048
2049 /* Check for the O_DIRECT flag during open() */
2050 if (!odirect)
2051 return __posix_pwritev (fd, vector, count, startoff);
2052
2053 for (idx = 0; idx < count; idx++) {
2054 if (max_buf_size < vector[idx].iov_len)
2055 max_buf_size = vector[idx].iov_len;
2056 }
2057
2058 alloc_buf = _page_aligned_alloc (max_buf_size, &buf);
2059 if (!alloc_buf) {
2060 op_ret = -errno(*__errno_location ());
2061 goto err;
2062 }
2063
2064 internal_off = startoff;
2065 for (idx = 0; idx < count; idx++) {
2066 memcpy (buf, vector[idx].iov_base, vector[idx].iov_len);
2067
2068 /* not sure whether writev works on O_DIRECT'd fd */
2069 retval = pwrite (fd, buf, vector[idx].iov_len, internal_off);
2070 if (retval == -1) {
2071 op_ret = -errno(*__errno_location ());
2072 goto err;
2073 }
2074
2075 op_ret += retval;
2076 internal_off += retval;
2077 }
2078
2079err:
2080 GF_FREE (alloc_buf)__gf_free (alloc_buf);
2081
2082 return op_ret;
2083}
2084
2085
2086int32_t
2087posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
2088 struct iovec *vector, int32_t count, off_t offset,
2089 uint32_t flags, struct iobref *iobref, dict_t *xdata)
2090{
2091 int32_t op_ret = -1;
2092 int32_t op_errno = 0;
2093 int _fd = -1;
2094 struct posix_private * priv = NULL((void*)0);
2095 struct posix_fd * pfd = NULL((void*)0);
2096 struct iatt preop = {0,};
2097 struct iatt postop = {0,};
2098 int ret = -1;
2099
2100 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2100, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2101 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2101, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2102 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2102, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2103 VALIDATE_OR_GOTO (vector, out)do { if (!vector) { (*__errno_location ()) = 22; do { do { if
(0) printf ("invalid argument: " "vector"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2103, GF_LOG_WARNING, "invalid argument: " "vector"
); } while (0); goto out; } } while (0)
;
2104 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "posix.c", __FUNCTION__, 2104, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2105
2106 priv = this->private;
2107
2108 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2108, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
2109
2110 ret = posix_fd_ctx_get (fd, this, &pfd);
2111 if (ret < 0) {
2112 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2113, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
2113 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2113, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
;
2114 op_errno = -ret;
2115 goto out;
2116 }
2117
2118 _fd = pfd->fd;
2119
2120 op_ret = posix_fdstat (this, _fd, &preop);
2121 if (op_ret == -1) {
2122 op_errno = errno(*__errno_location ());
2123 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2125, GF_LOG_ERROR, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2124 "pre-operation fstat failed on fd=%p: %s", fd,do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2125, GF_LOG_ERROR, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2125 strerror (op_errno))do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2125, GF_LOG_ERROR, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
2126 goto out;
2127 }
2128
2129 op_ret = __posix_writev (_fd, vector, count, offset,
2130 (pfd->flags & O_DIRECT040000));
2131 if (op_ret < 0) {
2132 op_errno = -op_ret;
2133 op_ret = -1;
2134 gf_log (this->name, GF_LOG_ERROR, "write failed: offset %"PRIu64do { do { if (0) printf ("write failed: offset %""ll" "u" ", %s"
, offset, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2135, GF_LOG_ERROR, "write failed: offset %"
"ll" "u" ", %s", offset, strerror (op_errno)); } while (0)
2135 ", %s", offset, strerror (op_errno))do { do { if (0) printf ("write failed: offset %""ll" "u" ", %s"
, offset, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2135, GF_LOG_ERROR, "write failed: offset %"
"ll" "u" ", %s", offset, strerror (op_errno)); } while (0)
;
2136 goto out;
2137 }
2138
2139 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
2140 {
2141 priv->write_value += op_ret;
2142 }
2143 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
2144
2145 if (op_ret >= 0) {
2146 /* wiretv successful, we also need to get the stat of
2147 * the file we wrote to
2148 */
2149
2150 if (flags & (O_SYNC04010000|O_DSYNC010000)) {
2151 ret = fsync (_fd);
2152 if (ret) {
2153 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsync() in writev on fd %d failed: %s"
, _fd, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 2155, GF_LOG_ERROR,
"fsync() in writev on fd %d failed: %s", _fd, strerror ((*__errno_location
()))); } while (0)
2154 "fsync() in writev on fd %d failed: %s",do { do { if (0) printf ("fsync() in writev on fd %d failed: %s"
, _fd, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 2155, GF_LOG_ERROR,
"fsync() in writev on fd %d failed: %s", _fd, strerror ((*__errno_location
()))); } while (0)
2155 _fd, strerror (errno))do { do { if (0) printf ("fsync() in writev on fd %d failed: %s"
, _fd, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 2155, GF_LOG_ERROR,
"fsync() in writev on fd %d failed: %s", _fd, strerror ((*__errno_location
()))); } while (0)
;
2156 op_ret = -1;
2157 op_errno = errno(*__errno_location ());
2158 goto out;
2159 }
2160 }
2161
2162 ret = posix_fdstat (this, _fd, &postop);
2163 if (ret == -1) {
2164 op_ret = -1;
2165 op_errno = errno(*__errno_location ());
2166 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2168, GF_LOG_ERROR, "post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2167 "post-operation fstat failed on fd=%p: %s",do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2168, GF_LOG_ERROR, "post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2168 fd, strerror (op_errno))do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2168, GF_LOG_ERROR, "post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
2169 goto out;
2170 }
2171 }
2172
2173out:
2174
2175 STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, &preop, &postop,do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2176, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_writev_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preop, &postop, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2176 NULL)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2176, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_writev_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preop, &postop, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2177
2178 return 0;
2179}
2180
2181
2182int32_t
2183posix_statfs (call_frame_t *frame, xlator_t *this,
2184 loc_t *loc, dict_t *xdata)
2185{
2186 char * real_path = NULL((void*)0);
2187 int32_t op_ret = -1;
2188 int32_t op_errno = 0;
2189 struct statvfs buf = {0, };
2190 struct posix_private * priv = NULL((void*)0);
2191
2192 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2192, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2193 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2193, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2194 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2194, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
2195 VALIDATE_OR_GOTO (this->private, out)do { if (!this->private) { (*__errno_location ()) = 22; do
{ do { if (0) printf ("invalid argument: " "this->private"
); } while (0); _gf_log_callingfn ((this ? (this->name) : "(Govinda! Govinda!)"
), "posix.c", __FUNCTION__, 2195, GF_LOG_WARNING, "invalid argument: "
"this->private"); } while (0); goto out; } } while (0)
;
2196
2197 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 2197, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, ((void*)0)); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), ((void*)0)); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
2198
2199 priv = this->private;
2200
2201 op_ret = statvfs (real_path, &buf);
2202
2203 if (op_ret == -1) {
2204 op_errno = errno(*__errno_location ());
2205 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("statvfs failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2207, GF_LOG_ERROR, "statvfs failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
2206 "statvfs failed on %s: %s",do { do { if (0) printf ("statvfs failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2207, GF_LOG_ERROR, "statvfs failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
2207 real_path, strerror (op_errno))do { do { if (0) printf ("statvfs failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2207, GF_LOG_ERROR, "statvfs failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
;
2208 goto out;
2209 }
2210
2211 if (!priv->export_statfs) {
2212 buf.f_blocks = 0;
2213 buf.f_bfree = 0;
2214 buf.f_bavail = 0;
2215 buf.f_files = 0;
2216 buf.f_ffree = 0;
2217 buf.f_favail = 0;
2218 }
2219
2220 op_ret = 0;
2221
2222out:
2223 STACK_UNWIND_STRICT (statfs, frame, op_ret, op_errno, &buf, NULL)do { fop_statfs_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2223, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_statfs_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2224 return 0;
2225}
2226
2227
2228int32_t
2229posix_flush (call_frame_t *frame, xlator_t *this,
2230 fd_t *fd, dict_t *xdata)
2231{
2232 int32_t op_ret = -1;
2233 int32_t op_errno = 0;
2234 int ret = -1;
2235 struct posix_fd *pfd = NULL((void*)0);
2236
2237 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2237, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2238 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2238, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2239 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2239, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2240
2241 ret = posix_fd_ctx_get (fd, this, &pfd);
2242 if (ret < 0) {
2243 op_errno = -ret;
2244 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL on fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2245, GF_LOG_WARNING
, "pfd is NULL on fd=%p", fd); } while (0)
2245 "pfd is NULL on fd=%p", fd)do { do { if (0) printf ("pfd is NULL on fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2245, GF_LOG_WARNING
, "pfd is NULL on fd=%p", fd); } while (0)
;
2246 goto out;
2247 }
2248
2249 op_ret = 0;
2250
2251out:
2252 STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, NULL)do { fop_flush_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2252, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_flush_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
2253
2254 return 0;
2255}
2256
2257
2258int32_t
2259posix_release (xlator_t *this, fd_t *fd)
2260{
2261 struct posix_private * priv = NULL((void*)0);
2262 struct posix_fd * pfd = NULL((void*)0);
2263 int ret = -1;
2264 uint64_t tmp_pfd = 0;
2265
2266 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2266, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2267 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2267, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2268
2269 priv = this->private;
2270
2271 ret = fd_ctx_del (fd, this, &tmp_pfd);
2272 if (ret < 0) {
2273 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2274, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
2274 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2274, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
;
2275 goto out;
2276 }
2277 pfd = (struct posix_fd *)(long)tmp_pfd;
2278
2279 if (pfd->dir) {
2280 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd->dir is %p (not NULL) for file fd=%p"
, pfd->dir, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2282, GF_LOG_WARNING, "pfd->dir is %p (not NULL) for file fd=%p"
, pfd->dir, fd); } while (0)
2281 "pfd->dir is %p (not NULL) for file fd=%p",do { do { if (0) printf ("pfd->dir is %p (not NULL) for file fd=%p"
, pfd->dir, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2282, GF_LOG_WARNING, "pfd->dir is %p (not NULL) for file fd=%p"
, pfd->dir, fd); } while (0)
2282 pfd->dir, fd)do { do { if (0) printf ("pfd->dir is %p (not NULL) for file fd=%p"
, pfd->dir, fd); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2282, GF_LOG_WARNING, "pfd->dir is %p (not NULL) for file fd=%p"
, pfd->dir, fd); } while (0)
;
2283 }
2284
2285 pthread_mutex_lock (&priv->janitor_lock);
2286 {
2287 INIT_LIST_HEAD (&pfd->list)do { (&pfd->list)->next = (&pfd->list)->prev
= &pfd->list; } while (0)
;
2288 list_add_tail (&pfd->list, &priv->janitor_fds);
2289 pthread_cond_signal (&priv->janitor_cond);
2290 }
2291 pthread_mutex_unlock (&priv->janitor_lock);
2292
2293 LOCK (&priv->lock)pthread_spin_lock (&priv->lock);
2294 {
2295 priv->nr_files--;
2296 }
2297 UNLOCK (&priv->lock)pthread_spin_unlock (&priv->lock);
2298
2299out:
2300 return 0;
2301}
2302
2303
2304int32_t
2305posix_fsync (call_frame_t *frame, xlator_t *this,
2306 fd_t *fd, int32_t datasync, dict_t *xdata)
2307{
2308 int32_t op_ret = -1;
2309 int32_t op_errno = 0;
2310 int _fd = -1;
2311 struct posix_fd * pfd = NULL((void*)0);
2312 int ret = -1;
2313 struct iatt preop = {0,};
2314 struct iatt postop = {0,};
2315
2316 DECLARE_OLD_FS_ID_VAR;
2317
2318 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2318, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2319 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2319, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2320 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2320, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2321
2322 SET_FS_ID (frame->root->uid, frame->root->gid);
2323
2324#ifdef GF_DARWIN_HOST_OS
2325 /* Always return success in case of fsync in MAC OS X */
2326 op_ret = 0;
2327 goto out;
2328#endif
2329
2330 ret = posix_fd_ctx_get (fd, this, &pfd);
2331 if (ret < 0) {
2332 op_errno = -ret;
2333 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd not found in fd's ctx"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2334, GF_LOG_WARNING
, "pfd not found in fd's ctx"); } while (0)
2334 "pfd not found in fd's ctx")do { do { if (0) printf ("pfd not found in fd's ctx"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2334, GF_LOG_WARNING
, "pfd not found in fd's ctx"); } while (0)
;
2335 goto out;
2336 }
2337
2338 _fd = pfd->fd;
2339
2340 op_ret = posix_fdstat (this, _fd, &preop);
2341 if (op_ret == -1) {
2342 op_errno = errno(*__errno_location ());
2343 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2345, GF_LOG_WARNING, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2344 "pre-operation fstat failed on fd=%p: %s", fd,do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2345, GF_LOG_WARNING, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2345 strerror (op_errno))do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2345, GF_LOG_WARNING, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
2346 goto out;
2347 }
2348
2349 if (datasync) {
2350 ;
2351#ifdef HAVE_FDATASYNC1
2352 op_ret = fdatasync (_fd);
2353 if (op_ret == -1) {
2354 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fdatasync on fd=%p failed: %s", fd,
strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 2356, GF_LOG_ERROR, "fdatasync on fd=%p failed: %s"
, fd, strerror ((*__errno_location ()))); } while (0)
2355 "fdatasync on fd=%p failed: %s",do { do { if (0) printf ("fdatasync on fd=%p failed: %s", fd,
strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 2356, GF_LOG_ERROR, "fdatasync on fd=%p failed: %s"
, fd, strerror ((*__errno_location ()))); } while (0)
2356 fd, strerror (errno))do { do { if (0) printf ("fdatasync on fd=%p failed: %s", fd,
strerror ((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 2356, GF_LOG_ERROR, "fdatasync on fd=%p failed: %s"
, fd, strerror ((*__errno_location ()))); } while (0)
;
2357 }
2358#endif
2359 } else {
2360 op_ret = fsync (_fd);
2361 if (op_ret == -1) {
2362 op_errno = errno(*__errno_location ());
2363 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsync on fd=%p failed: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2365, GF_LOG_ERROR, "fsync on fd=%p failed: %s"
, fd, strerror (op_errno)); } while (0)
2364 "fsync on fd=%p failed: %s",do { do { if (0) printf ("fsync on fd=%p failed: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2365, GF_LOG_ERROR, "fsync on fd=%p failed: %s"
, fd, strerror (op_errno)); } while (0)
2365 fd, strerror (op_errno))do { do { if (0) printf ("fsync on fd=%p failed: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2365, GF_LOG_ERROR, "fsync on fd=%p failed: %s"
, fd, strerror (op_errno)); } while (0)
;
2366 goto out;
2367 }
2368 }
2369
2370 op_ret = posix_fdstat (this, _fd, &postop);
2371 if (op_ret == -1) {
2372 op_errno = errno(*__errno_location ());
2373 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2375, GF_LOG_WARNING, "post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2374 "post-operation fstat failed on fd=%p: %s", fd,do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2375, GF_LOG_WARNING, "post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
2375 strerror (op_errno))do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2375, GF_LOG_WARNING, "post-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
2376 goto out;
2377 }
2378
2379 op_ret = 0;
2380
2381out:
2382 SET_TO_OLD_FS_ID ();
2383
2384 STACK_UNWIND_STRICT (fsync, frame, op_ret, op_errno, &preop, &postop,do { fop_fsync_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2385, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fsync_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preop, &postop, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
2385 NULL)do { fop_fsync_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2385, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fsync_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preop, &postop, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
2386
2387 return 0;
2388}
2389
2390static int gf_posix_xattr_enotsup_log;
2391static int
2392_handle_setxattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
2393 void *tmp)
2394{
2395 posix_xattr_filler_t *filler = NULL((void*)0);
2396
2397 filler = tmp;
2398
2399 return posix_handle_pair (filler->this, filler->real_path, k, v,
2400 filler->flags);
2401}
2402
2403int32_t
2404posix_setxattr (call_frame_t *frame, xlator_t *this,
2405 loc_t *loc, dict_t *dict, int flags, dict_t *xdata)
2406{
2407 int32_t op_ret = -1;
2408 int32_t op_errno = 0;
2409 char * real_path = NULL((void*)0);
2410
2411 posix_xattr_filler_t filler = {0,};
2412
2413 DECLARE_OLD_FS_ID_VAR;
2414 SET_FS_ID (frame->root->uid, frame->root->gid);
2415
2416 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2416, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2417 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2417, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2418 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2418, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
2419 VALIDATE_OR_GOTO (dict, out)do { if (!dict) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "dict"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2419, GF_LOG_WARNING, "invalid argument: " "dict"
); } while (0); goto out; } } while (0)
;
2420
2421 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 2421, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, ((void*)0)); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), ((void*)0)); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
2422
2423 op_ret = -1;
2424 dict_del (dict, GFID_XATTR_KEY"trusted.gfid");
2425
2426 filler.real_path = real_path;
2427 filler.this = this;
2428 filler.flags = flags;
2429 op_ret = dict_foreach (dict, _handle_setxattr_keyvalue_pair,
2430 &filler);
2431 if (op_ret < 0)
2432 op_errno = -op_ret;
2433
2434out:
2435 SET_TO_OLD_FS_ID ();
2436
2437 STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL)do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2437, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_setxattr_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
2438
2439 return 0;
2440}
2441
2442/**
2443 * posix_getxattr - this function returns a dictionary with all the
2444 * key:value pair present as xattr. used for
2445 * both 'listxattr' and 'getxattr'.
2446 */
2447int32_t
2448posix_getxattr (call_frame_t *frame, xlator_t *this,
2449 loc_t *loc, const char *name, dict_t *xdata)
2450{
2451 struct posix_private *priv = NULL((void*)0);
2452 int32_t op_ret = -1;
2453 int32_t op_errno = 0;
2454 int32_t list_offset = 0;
2455 ssize_t size = 0;
2456 size_t remaining_size = 0;
2457 char key[4096] = {0,};
2458 char host_buf[1024] = {0,};
2459 char *value = NULL((void*)0);
2460 char *list = NULL((void*)0);
2461 char *real_path = NULL((void*)0);
2462 dict_t *dict = NULL((void*)0);
2463 char *file_contents = NULL((void*)0);
2464 int ret = -1;
2465 char *path = NULL((void*)0);
2466 char *rpath = NULL((void*)0);
2467 char *dyn_rpath = NULL((void*)0);
2468
2469 DECLARE_OLD_FS_ID_VAR;
2470
2471 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2471, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2472 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2472, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2473 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2473, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
2474
2475 SET_FS_ID (frame->root->uid, frame->root->gid);
2476 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 2476, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, ((void*)0)); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), ((void*)0)); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
2477
2478 op_ret = -1;
2479 priv = this->private;
2480
2481 if (loc->inode && IA_ISDIR(loc->inode->ia_type)(loc->inode->ia_type == IA_IFDIR) && name &&
2482 ZR_FILE_CONTENT_REQUEST(name)(!strncmp(name, "glusterfs.file.", 15))) {
2483 ret = posix_get_file_contents (this, loc->gfid, &name[15],
2484 &file_contents);
2485 if (ret < 0) {
2486 op_errno = -ret;
2487 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("getting file contents failed: %s", strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2489, GF_LOG_ERROR, "getting file contents failed: %s"
, strerror (op_errno)); } while (0)
2488 "getting file contents failed: %s",do { do { if (0) printf ("getting file contents failed: %s", strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2489, GF_LOG_ERROR, "getting file contents failed: %s"
, strerror (op_errno)); } while (0)
2489 strerror (op_errno))do { do { if (0) printf ("getting file contents failed: %s", strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2489, GF_LOG_ERROR, "getting file contents failed: %s"
, strerror (op_errno)); } while (0)
;
2490 goto out;
2491 }
2492 }
2493
2494 dict = dict_new ();
2495 if (!dict) {
2496 goto out;
2497 }
2498
2499 if (loc->inode && name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT"glusterfs.open-fd-count")) {
2500 if (!list_empty (&loc->inode->fd_list)) {
2501 ret = dict_set_uint32 (dict, (char *)name, 1);
2502 if (ret < 0)
2503 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2505, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
2504 "Failed to set dictionary value for %s",do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2505, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
2505 name)do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2505, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
;
2506 } else {
2507 ret = dict_set_uint32 (dict, (char *)name, 0);
2508 if (ret < 0)
2509 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2511, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
2510 "Failed to set dictionary value for %s",do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2511, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
2511 name)do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2511, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
;
2512 }
2513 goto done;
2514 }
2515 if (loc->inode && name &&
2516 (strcmp (name, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo") == 0)) {
2517 if (LOC_HAS_ABSPATH (loc)((loc) && (loc->path) && (loc->path[0] ==
'/'))
)
2518 MAKE_REAL_PATH (rpath, this, loc->path)do { rpath = __builtin_alloca (strlen (loc->path) + (((struct
posix_private *)this->private)->base_path_length) + 2)
; strcpy (rpath, (((struct posix_private *)this->private)->
base_path)); strcpy (&rpath[(((struct posix_private *)this
->private)->base_path_length)], loc->path); } while (
0)
;
2519 else
2520 rpath = real_path;
2521
2522 (void) snprintf (host_buf, 1024,
2523 "<POSIX(%s):%s:%s>", priv->base_path,
2524 ((priv->node_uuid_pathinfo
2525 && !uuid_is_null(priv->glusterd_uuid))
2526 ? uuid_utoa (priv->glusterd_uuid)
2527 : priv->hostname),
2528 rpath);
2529
2530 dyn_rpath = gf_strdup (host_buf);
2531 if (!dyn_rpath) {
2532 ret = -1;
2533 goto done;
2534 }
2535 size = strlen (dyn_rpath) + 1;
2536 ret = dict_set_dynstr (dict, GF_XATTR_PATHINFO_KEY"trusted.glusterfs.pathinfo",
2537 dyn_rpath);
2538 if (ret < 0) {
2539 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("could not set value (%s) in dictionary"
, dyn_rpath); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2541, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, dyn_rpath); } while (0)
2540 "could not set value (%s) in dictionary",do { do { if (0) printf ("could not set value (%s) in dictionary"
, dyn_rpath); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2541, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, dyn_rpath); } while (0)
2541 dyn_rpath)do { do { if (0) printf ("could not set value (%s) in dictionary"
, dyn_rpath); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2541, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, dyn_rpath); } while (0)
;
2542 GF_FREE (dyn_rpath)__gf_free (dyn_rpath);
2543 }
2544
2545 goto done;
2546 }
2547
2548 if (loc->inode && name &&
2549 (strcmp (name, GF_XATTR_NODE_UUID_KEY"trusted.glusterfs.node-uuid") == 0)
2550 && !uuid_is_null (priv->glusterd_uuid)) {
2551 (void) snprintf (host_buf, 1024, "%s",
2552 uuid_utoa (priv->glusterd_uuid));
2553
2554 dyn_rpath = gf_strdup (host_buf);
2555 if (!dyn_rpath) {
2556 ret = -1;
2557 goto done;
2558 }
2559
2560 size = strlen (dyn_rpath) + 1;
2561 ret = dict_set_dynstr (dict, GF_XATTR_NODE_UUID_KEY"trusted.glusterfs.node-uuid",
2562 dyn_rpath);
2563 if (ret < 0) {
2564 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("could not set value (%s) in dictionary"
, dyn_rpath); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2566, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, dyn_rpath); } while (0)
2565 "could not set value (%s) in dictionary",do { do { if (0) printf ("could not set value (%s) in dictionary"
, dyn_rpath); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2566, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, dyn_rpath); } while (0)
2566 dyn_rpath)do { do { if (0) printf ("could not set value (%s) in dictionary"
, dyn_rpath); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2566, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, dyn_rpath); } while (0)
;
2567 GF_FREE (dyn_rpath)__gf_free (dyn_rpath);
2568 }
2569 goto done;
2570 }
2571
2572 if (loc->inode && name &&
2573 (strcmp (name, GFID_TO_PATH_KEY"glusterfs.gfid2path") == 0)) {
2574 ret = inode_path (loc->inode, NULL((void*)0), &path);
2575 if (ret < 0) {
2576 gf_log (this->name, GF_LOG_WARNING, "%s: could not get "do { do { if (0) printf ("%s: could not get " "inode path", uuid_utoa
(loc->inode->gfid)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2577, GF_LOG_WARNING, "%s: could not get "
"inode path", uuid_utoa (loc->inode->gfid)); } while (
0)
2577 "inode path", uuid_utoa (loc->inode->gfid))do { do { if (0) printf ("%s: could not get " "inode path", uuid_utoa
(loc->inode->gfid)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2577, GF_LOG_WARNING, "%s: could not get "
"inode path", uuid_utoa (loc->inode->gfid)); } while (
0)
;
2578 goto done;
2579 }
2580
2581 ret = dict_set_dynstr (dict, GFID_TO_PATH_KEY"glusterfs.gfid2path", path);
2582 if (ret < 0) {
2583 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("could not set value (%s) in dictionary"
, host_buf); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2585, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, host_buf); } while (0)
2584 "could not set value (%s) in dictionary",do { do { if (0) printf ("could not set value (%s) in dictionary"
, host_buf); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2585, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, host_buf); } while (0)
2585 host_buf)do { do { if (0) printf ("could not set value (%s) in dictionary"
, host_buf); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2585, GF_LOG_WARNING, "could not set value (%s) in dictionary"
, host_buf); } while (0)
;
2586 GF_FREE (path)__gf_free (path);
2587 }
2588 goto done;
2589 }
2590
2591 if (name) {
2592 strcpy (key, name);
2593
2594 size = sys_lgetxattr (real_path, key, NULL((void*)0), 0);
2595 if (size <= 0) {
2596 op_errno = errno(*__errno_location ());
2597 if ((op_errno == ENOTSUP95) || (op_errno == ENOSYS38)) {
2598 GF_LOG_OCCASIONALLY (gf_posix_xattr_enotsup_log,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2603, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2599 this->name, GF_LOG_WARNING,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2603, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2600 "Extended attributes not "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2603, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2601 "supported (try remounting"if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2603, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2602 " brick with 'user_xattr' "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2603, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2603 "flag)")if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2603, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
;
2604 } else if (op_errno == ENOATTR61) {
2605 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("No such attribute:%s for file %s", key
, real_path); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2607, GF_LOG_DEBUG, "No such attribute:%s for file %s"
, key, real_path); } while (0)
2606 "No such attribute:%s for file %s",do { do { if (0) printf ("No such attribute:%s for file %s", key
, real_path); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2607, GF_LOG_DEBUG, "No such attribute:%s for file %s"
, key, real_path); } while (0)
2607 key, real_path)do { do { if (0) printf ("No such attribute:%s for file %s", key
, real_path); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2607, GF_LOG_DEBUG, "No such attribute:%s for file %s"
, key, real_path); } while (0)
;
2608 } else {
2609 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("getxattr failed on %s: %s (%s)", real_path
, key, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2611, GF_LOG_ERROR, "getxattr failed on %s: %s (%s)"
, real_path, key, strerror (op_errno)); } while (0)
2610 "getxattr failed on %s: %s (%s)",do { do { if (0) printf ("getxattr failed on %s: %s (%s)", real_path
, key, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2611, GF_LOG_ERROR, "getxattr failed on %s: %s (%s)"
, real_path, key, strerror (op_errno)); } while (0)
2611 real_path, key, strerror (op_errno))do { do { if (0) printf ("getxattr failed on %s: %s (%s)", real_path
, key, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2611, GF_LOG_ERROR, "getxattr failed on %s: %s (%s)"
, real_path, key, strerror (op_errno)); } while (0)
;
2612 }
2613
2614 goto done;
2615 }
2616 value = GF_CALLOC (size + 1, sizeof(char), gf_posix_mt_char)__gf_calloc (size + 1, sizeof(char), gf_posix_mt_char);
2617 if (!value) {
2618 op_ret = -1;
2619 goto out;
2620 }
2621 size = sys_lgetxattr (real_path, key, value, size);
2622 if (size == -1) {
2623 op_ret = -1;
2624 op_errno = errno(*__errno_location ());
2625 gf_log (this->name, GF_LOG_ERROR, "getxattr failed on "do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2627, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
2626 "%s: key = %s (%s)", real_path, key,do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2627, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
2627 strerror (op_errno))do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2627, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
;
2628 GF_FREE (value)__gf_free (value);
2629 goto out;
2630 }
2631 value [size] = '\0';
2632 op_ret = dict_set_dynptr (dict, key, value, size);
2633 if (op_ret < 0) {
2634 gf_log (this->name, GF_LOG_ERROR, "dict set operation "do { do { if (0) printf ("dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2635, GF_LOG_ERROR, "dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0)
2635 "on %s for the key %s failed.", real_path, key)do { do { if (0) printf ("dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2635, GF_LOG_ERROR, "dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0)
;
2636 GF_FREE (value)__gf_free (value);
2637 goto out;
2638 }
2639
2640 goto done;
2641 }
2642
2643 size = sys_llistxattr (real_path, NULL((void*)0), 0);
2644 if (size == -1) {
2645 op_errno = errno(*__errno_location ());
2646 if ((errno(*__errno_location ()) == ENOTSUP95) || (errno(*__errno_location ()) == ENOSYS38)) {
2647 GF_LOG_OCCASIONALLY (gf_posix_xattr_enotsup_log,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2652, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2648 this->name, GF_LOG_WARNING,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2652, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2649 "Extended attributes not "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2652, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2650 "supported (try remounting"if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2652, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2651 " brick with 'user_xattr' "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2652, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
2652 "flag)")if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting" " brick with 'user_xattr' "
"flag)"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2652, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting"
" brick with 'user_xattr' " "flag)"); } while (0); }
;
2653 }
2654 else {
2655 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("listxattr failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2657, GF_LOG_ERROR, "listxattr failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
2656 "listxattr failed on %s: %s",do { do { if (0) printf ("listxattr failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2657, GF_LOG_ERROR, "listxattr failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
2657 real_path, strerror (op_errno))do { do { if (0) printf ("listxattr failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2657, GF_LOG_ERROR, "listxattr failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
;
2658 }
2659 goto out;
2660 }
2661
2662 if (size == 0)
2663 goto done;
2664
2665 list = alloca (size + 1)__builtin_alloca (size + 1);
2666 if (!list) {
2667 op_errno = errno(*__errno_location ());
2668 goto out;
2669 }
2670
2671 size = sys_llistxattr (real_path, list, size);
2672
2673 remaining_size = size;
2674 list_offset = 0;
2675 while (remaining_size > 0) {
2676 if (*(list + list_offset) == '\0')
2677 break;
2678
2679 strcpy (key, list + list_offset);
2680 size = sys_lgetxattr (real_path, key, NULL((void*)0), 0);
2681 if (size == -1) {
2682 op_ret = -1;
2683 op_errno = errno(*__errno_location ());
2684 gf_log (this->name, GF_LOG_ERROR, "getxattr failed on "do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2686, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
2685 "%s: key = %s (%s)", real_path, key,do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2686, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
2686 strerror (op_errno))do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2686, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
;
2687 break;
2688 }
2689
2690 value = GF_CALLOC (size + 1, sizeof(char),__gf_calloc (size + 1, sizeof(char), gf_posix_mt_char)
2691 gf_posix_mt_char)__gf_calloc (size + 1, sizeof(char), gf_posix_mt_char);
2692 if (!value) {
2693 op_errno = errno(*__errno_location ());
2694 goto out;
2695 }
2696
2697 size = sys_lgetxattr (real_path, key, value, size);
2698 if (size == -1) {
2699 op_ret = -1;
2700 op_errno = errno(*__errno_location ());
2701 gf_log (this->name, GF_LOG_ERROR, "getxattr failed on "do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2703, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
2702 "%s: key = %s (%s)", real_path, key,do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2703, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
2703 strerror (op_errno))do { do { if (0) printf ("getxattr failed on " "%s: key = %s (%s)"
, real_path, key, strerror (op_errno)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 2703, GF_LOG_ERROR, "getxattr failed on "
"%s: key = %s (%s)", real_path, key, strerror (op_errno)); }
while (0)
;
2704 GF_FREE (value)__gf_free (value);
2705 break;
2706 }
2707
2708 value [size] = '\0';
2709 op_ret = dict_set_dynptr (dict, key, value, size);
2710 if (op_ret < 0) {
2711 gf_log (this->name, GF_LOG_ERROR, "dict set operation "do { do { if (0) printf ("dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2712, GF_LOG_ERROR, "dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0)
2712 "on %s for the key %s failed.", real_path, key)do { do { if (0) printf ("dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 2712, GF_LOG_ERROR, "dict set operation " "on %s for the key %s failed."
, real_path, key); } while (0)
;
2713 GF_FREE (value)__gf_free (value);
2714 goto out;
2715 }
2716
2717 remaining_size -= strlen (key) + 1;
2718 list_offset += strlen (key) + 1;
2719
2720 } /* while (remaining_size > 0) */
2721
2722done:
2723 op_ret = size;
2724
2725 if (dict) {
2726 dict_del (dict, GFID_XATTR_KEY"trusted.gfid");
2727 }
2728
2729out:
2730 SET_TO_OLD_FS_ID ();
2731
2732 STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, NULL)do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2732, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_getxattr_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, dict, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
;
2733
2734 if (dict)
2735 dict_unref (dict);
2736
2737 return 0;
2738}
2739
2740
2741int32_t
2742posix_fgetxattr (call_frame_t *frame, xlator_t *this,
2743 fd_t *fd, const char *name, dict_t *xdata)
2744{
2745 int32_t op_ret = -1;
2746 int32_t op_errno = ENOENT2;
2747 struct posix_fd * pfd = NULL((void*)0);
2748 int _fd = -1;
2749 int32_t list_offset = 0;
2750 ssize_t size = 0;
2751 size_t remaining_size = 0;
2752 char key[4096] = {0,};
2753 char * value = NULL((void*)0);
2754 char * list = NULL((void*)0);
2755 dict_t * dict = NULL((void*)0);
2756 int ret = -1;
2757
2758 DECLARE_OLD_FS_ID_VAR;
2759
2760 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2760, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2761 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2761, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2762 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2762, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2763
2764 SET_FS_ID (frame->root->uid, frame->root->gid);
2765
2766 ret = posix_fd_ctx_get (fd, this, &pfd);
2767 if (ret < 0) {
2768 op_errno = -ret;
2769 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2770, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
2770 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2770, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
;
2771 goto out;
2772 }
2773
2774 _fd = pfd->fd;
2775
2776 /* Get the total size */
2777 dict = get_new_dict ();
2778 if (!dict) {
2779 goto out;
2780 }
2781
2782 if (name && !strcmp (name, GLUSTERFS_OPEN_FD_COUNT"glusterfs.open-fd-count")) {
2783 ret = dict_set_uint32 (dict, (char *)name, 1);
2784 if (ret < 0)
2785 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2787, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
2786 "Failed to set dictionary value for %s",do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2787, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
2787 name)do { do { if (0) printf ("Failed to set dictionary value for %s"
, name); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2787, GF_LOG_WARNING, "Failed to set dictionary value for %s"
, name); } while (0)
;
2788 goto done;
2789 }
2790
2791 if (name) {
2792 strcpy (key, name);
2793
2794 size = sys_fgetxattr (_fd, key, NULL((void*)0), 0);
2795 if (size <= 0) {
2796 op_errno = errno(*__errno_location ());
2797 gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "do { do { if (0) printf ("fgetxattr failed on " "key %s (%s)"
, key, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2798, GF_LOG_ERROR, "fgetxattr failed on "
"key %s (%s)", key, strerror (op_errno)); } while (0)
2798 "key %s (%s)", key, strerror (op_errno))do { do { if (0) printf ("fgetxattr failed on " "key %s (%s)"
, key, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 2798, GF_LOG_ERROR, "fgetxattr failed on "
"key %s (%s)", key, strerror (op_errno)); } while (0)
;
2799 goto done;
2800 }
2801
2802 value = GF_CALLOC (size + 1, sizeof(char), gf_posix_mt_char)__gf_calloc (size + 1, sizeof(char), gf_posix_mt_char);
2803 if (!value) {
2804 op_ret = -1;
2805 goto out;
2806 }
2807 size = sys_fgetxattr (_fd, key, value, size);
2808 if (size == -1) {
2809 op_ret = -1;
2810 op_errno = errno(*__errno_location ());
2811 gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "do { do { if (0) printf ("fgetxattr failed on " "fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2813, GF_LOG_ERROR, "fgetxattr failed on "
"fd %p for the key %s (%s)", fd, key, strerror (op_errno)); }
while (0)
2812 "fd %p for the key %s (%s)", fd, key,do { do { if (0) printf ("fgetxattr failed on " "fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2813, GF_LOG_ERROR, "fgetxattr failed on "
"fd %p for the key %s (%s)", fd, key, strerror (op_errno)); }
while (0)
2813 strerror (op_errno))do { do { if (0) printf ("fgetxattr failed on " "fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2813, GF_LOG_ERROR, "fgetxattr failed on "
"fd %p for the key %s (%s)", fd, key, strerror (op_errno)); }
while (0)
;
2814 GF_FREE (value)__gf_free (value);
2815 goto out;
2816 }
2817 value [size] = '\0';
2818 op_ret = dict_set_dynptr (dict, key, value, size);
2819 if (op_ret < 0) {
2820 gf_log (this->name, GF_LOG_ERROR, "dict set operation "do { do { if (0) printf ("dict set operation " "on key %s failed"
, key); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2821, GF_LOG_ERROR, "dict set operation " "on key %s failed"
, key); } while (0)
2821 "on key %s failed", key)do { do { if (0) printf ("dict set operation " "on key %s failed"
, key); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2821, GF_LOG_ERROR, "dict set operation " "on key %s failed"
, key); } while (0)
;
2822 GF_FREE (value)__gf_free (value);
2823 goto out;
2824 }
2825 goto done;
2826 }
2827
2828 size = sys_flistxattr (_fd, NULL((void*)0), 0);
2829 if (size == -1) {
2830 op_errno = errno(*__errno_location ());
2831 if ((errno(*__errno_location ()) == ENOTSUP95) || (errno(*__errno_location ()) == ENOSYS38)) {
2832 GF_LOG_OCCASIONALLY (gf_posix_xattr_enotsup_log,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting " "brick with 'user_xattr' flag)"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2836, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting "
"brick with 'user_xattr' flag)"); } while (0); }
2833 this->name, GF_LOG_WARNING,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting " "brick with 'user_xattr' flag)"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2836, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting "
"brick with 'user_xattr' flag)"); } while (0); }
2834 "Extended attributes not "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting " "brick with 'user_xattr' flag)"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2836, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting "
"brick with 'user_xattr' flag)"); } while (0); }
2835 "supported (try remounting "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting " "brick with 'user_xattr' flag)"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2836, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting "
"brick with 'user_xattr' flag)"); } while (0); }
2836 "brick with 'user_xattr' flag)")if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported (try remounting " "brick with 'user_xattr' flag)"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2836, GF_LOG_WARNING, "Extended attributes not " "supported (try remounting "
"brick with 'user_xattr' flag)"); } while (0); }
;
2837 }
2838 else {
2839 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("listxattr failed on %p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2841, GF_LOG_ERROR, "listxattr failed on %p: %s"
, fd, strerror (op_errno)); } while (0)
2840 "listxattr failed on %p: %s",do { do { if (0) printf ("listxattr failed on %p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2841, GF_LOG_ERROR, "listxattr failed on %p: %s"
, fd, strerror (op_errno)); } while (0)
2841 fd, strerror (op_errno))do { do { if (0) printf ("listxattr failed on %p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 2841, GF_LOG_ERROR, "listxattr failed on %p: %s"
, fd, strerror (op_errno)); } while (0)
;
2842 }
2843 goto out;
2844 }
2845
2846 if (size == 0)
2847 goto done;
2848
2849 list = alloca (size + 1)__builtin_alloca (size + 1);
2850 if (!list) {
2851 op_errno = errno(*__errno_location ());
2852 goto out;
2853 }
2854
2855 size = sys_flistxattr (_fd, list, size);
2856
2857 remaining_size = size;
2858 list_offset = 0;
2859 while (remaining_size > 0) {
2860 if(*(list + list_offset) == '\0')
2861 break;
2862
2863 strcpy (key, list + list_offset);
2864 size = sys_fgetxattr (_fd, key, NULL((void*)0), 0);
2865 if (size == -1) {
2866 op_ret = -1;
2867 op_errno = errno(*__errno_location ());
2868 gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "do { do { if (0) printf ("fgetxattr failed on " "fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2870, GF_LOG_ERROR, "fgetxattr failed on "
"fd %p for the key %s (%s)", fd, key, strerror (op_errno)); }
while (0)
2869 "fd %p for the key %s (%s)", fd, key,do { do { if (0) printf ("fgetxattr failed on " "fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2870, GF_LOG_ERROR, "fgetxattr failed on "
"fd %p for the key %s (%s)", fd, key, strerror (op_errno)); }
while (0)
2870 strerror (op_errno))do { do { if (0) printf ("fgetxattr failed on " "fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2870, GF_LOG_ERROR, "fgetxattr failed on "
"fd %p for the key %s (%s)", fd, key, strerror (op_errno)); }
while (0)
;
2871 break;
2872 }
2873
2874 value = GF_CALLOC (size + 1, sizeof(char),__gf_calloc (size + 1, sizeof(char), gf_posix_mt_char)
2875 gf_posix_mt_char)__gf_calloc (size + 1, sizeof(char), gf_posix_mt_char);
2876 if (!value) {
2877 op_ret = -1;
2878 op_errno = errno(*__errno_location ());
2879 goto out;
2880 }
2881
2882 size = sys_fgetxattr (_fd, key, value, size);
2883 if (size == -1) {
2884 op_ret = -1;
2885 op_errno = errno(*__errno_location ());
2886 gf_log (this->name, GF_LOG_ERROR, "fgetxattr failed on "do { do { if (0) printf ("fgetxattr failed on " "the fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2888, GF_LOG_ERROR, "fgetxattr failed on "
"the fd %p for the key %s (%s)", fd, key, strerror (op_errno
)); } while (0)
2887 "the fd %p for the key %s (%s)", fd, key,do { do { if (0) printf ("fgetxattr failed on " "the fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2888, GF_LOG_ERROR, "fgetxattr failed on "
"the fd %p for the key %s (%s)", fd, key, strerror (op_errno
)); } while (0)
2888 strerror (op_errno))do { do { if (0) printf ("fgetxattr failed on " "the fd %p for the key %s (%s)"
, fd, key, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 2888, GF_LOG_ERROR, "fgetxattr failed on "
"the fd %p for the key %s (%s)", fd, key, strerror (op_errno
)); } while (0)
;
2889 GF_FREE (value)__gf_free (value);
2890 break;
2891 }
2892
2893 value [size] = '\0';
2894 op_ret = dict_set_dynptr (dict, key, value, size);
2895 if (op_ret) {
2896 gf_log (this->name, GF_LOG_ERROR, "dict set operation "do { do { if (0) printf ("dict set operation " "failed on key %s"
, key); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2897, GF_LOG_ERROR, "dict set operation " "failed on key %s"
, key); } while (0)
2897 "failed on key %s", key)do { do { if (0) printf ("dict set operation " "failed on key %s"
, key); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 2897, GF_LOG_ERROR, "dict set operation " "failed on key %s"
, key); } while (0)
;
2898 GF_FREE (value)__gf_free (value);
2899 goto out;
2900 }
2901 remaining_size -= strlen (key) + 1;
2902 list_offset += strlen (key) + 1;
2903
2904 } /* while (remaining_size > 0) */
2905
2906done:
2907 op_ret = size;
2908
2909 if (dict) {
2910 dict_del (dict, GFID_XATTR_KEY"trusted.gfid");
2911 dict_ref (dict);
2912 }
2913
2914out:
2915 SET_TO_OLD_FS_ID ();
2916
2917 STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict, NULL)do { fop_fgetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2917, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fgetxattr_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, dict, ((void*)0)); (*__glusterfs_this_location())
= old_THIS; } while (0)
;
2918
2919 if (dict)
2920 dict_unref (dict);
2921
2922 return 0;
2923}
2924
2925static int
2926_handle_fsetxattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
2927 void *tmp)
2928{
2929 posix_xattr_filler_t *filler = NULL((void*)0);
2930
2931 filler = tmp;
2932
2933 return posix_fhandle_pair (filler->this, filler->fd, k, v,
2934 filler->flags);
2935}
2936
2937int32_t
2938posix_fsetxattr (call_frame_t *frame, xlator_t *this,
2939 fd_t *fd, dict_t *dict, int flags, dict_t *xdata)
2940{
2941 int32_t op_ret = -1;
2942 int32_t op_errno = 0;
2943 struct posix_fd * pfd = NULL((void*)0);
2944 int _fd = -1;
2945 int ret = -1;
2946
2947 posix_xattr_filler_t filler = {0,};
2948
2949 DECLARE_OLD_FS_ID_VAR;
2950 SET_FS_ID (frame->root->uid, frame->root->gid);
2951
2952 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2952, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
2953 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2953, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
2954 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2954, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
2955 VALIDATE_OR_GOTO (dict, out)do { if (!dict) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "dict"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 2955, GF_LOG_WARNING, "invalid argument: " "dict"
); } while (0); goto out; } } while (0)
;
2956
2957 ret = posix_fd_ctx_get (fd, this, &pfd);
2958 if (ret < 0) {
2959 op_errno = -ret;
2960 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2961, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
2961 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 2961, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
;
2962 goto out;
2963 }
2964 _fd = pfd->fd;
2965
2966 dict_del (dict, GFID_XATTR_KEY"trusted.gfid");
2967
2968 filler.fd = _fd;
2969 filler.this = this;
2970 filler.flags = flags;
2971 op_ret = dict_foreach (dict, _handle_fsetxattr_keyvalue_pair,
2972 &filler);
2973 if (op_ret < 0)
2974 op_errno = -op_ret;
2975
2976out:
2977 SET_TO_OLD_FS_ID ();
2978
2979 STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, NULL)do { fop_fsetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 2979, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fsetxattr_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
2980
2981 return 0;
2982}
2983
2984int
2985_posix_remove_xattr (dict_t *dict, char *key, data_t *value, void *data)
2986{
2987 int32_t op_ret = 0;
2988 xlator_t *this = NULL((void*)0);
2989 posix_xattr_filler_t *filler = NULL((void*)0);
2990
2991 filler = (posix_xattr_filler_t *) data;
2992 this = filler->this;
2993
2994 op_ret = sys_lremovexattr (filler->real_path, key);
2995 if (op_ret == -1) {
2996 filler->op_errno = errno(*__errno_location ());
2997 if (errno(*__errno_location ()) != ENOATTR61 && errno(*__errno_location ()) != EPERM1)
2998 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("removexattr failed on %s (for %s): %s"
, filler->real_path, key, strerror ((*__errno_location ())
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3000, GF_LOG_ERROR, "removexattr failed on %s (for %s): %s"
, filler->real_path, key, strerror ((*__errno_location ())
)); } while (0)
2999 "removexattr failed on %s (for %s): %s",do { do { if (0) printf ("removexattr failed on %s (for %s): %s"
, filler->real_path, key, strerror ((*__errno_location ())
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3000, GF_LOG_ERROR, "removexattr failed on %s (for %s): %s"
, filler->real_path, key, strerror ((*__errno_location ())
)); } while (0)
3000 filler->real_path, key, strerror (errno))do { do { if (0) printf ("removexattr failed on %s (for %s): %s"
, filler->real_path, key, strerror ((*__errno_location ())
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3000, GF_LOG_ERROR, "removexattr failed on %s (for %s): %s"
, filler->real_path, key, strerror ((*__errno_location ())
)); } while (0)
;
3001 }
3002
3003 return op_ret;
3004}
3005
3006
3007int32_t
3008posix_removexattr (call_frame_t *frame, xlator_t *this,
3009 loc_t *loc, const char *name, dict_t *xdata)
3010{
3011 int32_t op_ret = -1;
3012 int32_t op_errno = 0;
3013 char * real_path = NULL((void*)0);
3014 posix_xattr_filler_t filler = {0,};
3015
3016 DECLARE_OLD_FS_ID_VAR;
3017
3018 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3018, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, ((void*)0)); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), ((void*)0)); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
3019
3020 if (!strcmp (GFID_XATTR_KEY"trusted.gfid", name)) {
3021 gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"do { do { if (0) printf ("Remove xattr called" " on gfid for file %s"
, real_path); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3022, GF_LOG_WARNING, "Remove xattr called" " on gfid for file %s"
, real_path); } while (0)
3022 " on gfid for file %s", real_path)do { do { if (0) printf ("Remove xattr called" " on gfid for file %s"
, real_path); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3022, GF_LOG_WARNING, "Remove xattr called" " on gfid for file %s"
, real_path); } while (0)
;
3023 op_ret = -1;
3024 goto out;
3025 }
3026
3027
3028 SET_FS_ID (frame->root->uid, frame->root->gid);
3029
3030 /**
3031 * sending an empty key name with xdata containing the
3032 * list of key(s) to be removed implies "bulk remove request"
3033 * for removexattr.
3034 */
3035 if (name && (strcmp (name, "") == 0) && xdata) {
3036 filler.real_path = real_path;
3037 filler.this = this;
3038 op_ret = dict_foreach (xdata, _posix_remove_xattr, &filler);
3039 if (op_ret) {
3040 op_errno = filler.op_errno;
3041 }
3042
3043 goto out;
3044 }
3045
3046 op_ret = sys_lremovexattr (real_path, name);
3047 if (op_ret == -1) {
3048 op_errno = errno(*__errno_location ());
3049 if (op_errno != ENOATTR61 && op_errno != EPERM1)
3050 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("removexattr on %s (for %s): %s", real_path
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 3052, GF_LOG_ERROR, "removexattr on %s (for %s): %s"
, real_path, name, strerror (op_errno)); } while (0)
3051 "removexattr on %s (for %s): %s", real_path,do { do { if (0) printf ("removexattr on %s (for %s): %s", real_path
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 3052, GF_LOG_ERROR, "removexattr on %s (for %s): %s"
, real_path, name, strerror (op_errno)); } while (0)
3052 name, strerror (op_errno))do { do { if (0) printf ("removexattr on %s (for %s): %s", real_path
, name, strerror (op_errno)); } while (0); _gf_log (this->
name, "posix.c", __FUNCTION__, 3052, GF_LOG_ERROR, "removexattr on %s (for %s): %s"
, real_path, name, strerror (op_errno)); } while (0)
;
3053 goto out;
3054 }
3055
3056 op_ret = 0;
3057
3058out:
3059 SET_TO_OLD_FS_ID ();
3060
3061 STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, NULL)do { fop_removexattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3061, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_removexattr_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
3062 return 0;
3063}
3064
3065int32_t
3066posix_fremovexattr (call_frame_t *frame, xlator_t *this,
3067 fd_t *fd, const char *name, dict_t *xdata)
3068{
3069 int32_t op_ret = -1;
3070 int32_t op_errno = 0;
3071 struct posix_fd * pfd = NULL((void*)0);
3072 int _fd = -1;
3073 int ret = -1;
3074
3075 DECLARE_OLD_FS_ID_VAR;
3076
3077 if (!strcmp (GFID_XATTR_KEY"trusted.gfid", name)) {
3078 gf_log (this->name, GF_LOG_WARNING, "Remove xattr called"do { do { if (0) printf ("Remove xattr called" " on gfid for file"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3079, GF_LOG_WARNING, "Remove xattr called" " on gfid for file"
); } while (0)
3079 " on gfid for file")do { do { if (0) printf ("Remove xattr called" " on gfid for file"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3079, GF_LOG_WARNING, "Remove xattr called" " on gfid for file"
); } while (0)
;
3080 goto out;
3081 }
3082
3083 ret = posix_fd_ctx_get (fd, this, &pfd);
3084 if (ret < 0) {
3085 op_errno = -ret;
3086 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3087, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
3087 "pfd is NULL from fd=%p", fd)do { do { if (0) printf ("pfd is NULL from fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3087, GF_LOG_WARNING
, "pfd is NULL from fd=%p", fd); } while (0)
;
3088 goto out;
3089 }
3090 _fd = pfd->fd;
3091
3092
3093
3094 SET_FS_ID (frame->root->uid, frame->root->gid);
3095
3096 op_ret = sys_fremovexattr (_fd, name);
3097 if (op_ret == -1) {
3098 op_errno = errno(*__errno_location ());
3099 if (op_errno != ENOATTR61 && op_errno != EPERM1)
3100 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fremovexattr (for %s): %s", name, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3102, GF_LOG_ERROR, "fremovexattr (for %s): %s"
, name, strerror (op_errno)); } while (0)
3101 "fremovexattr (for %s): %s",do { do { if (0) printf ("fremovexattr (for %s): %s", name, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3102, GF_LOG_ERROR, "fremovexattr (for %s): %s"
, name, strerror (op_errno)); } while (0)
3102 name, strerror (op_errno))do { do { if (0) printf ("fremovexattr (for %s): %s", name, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3102, GF_LOG_ERROR, "fremovexattr (for %s): %s"
, name, strerror (op_errno)); } while (0)
;
3103 goto out;
3104 }
3105
3106 op_ret = 0;
3107
3108out:
3109 SET_TO_OLD_FS_ID ();
3110
3111 STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno, NULL)do { fop_fremovexattr_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3111, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fremovexattr_cbk_t )frame->
ret; _parent = frame->parent; pthread_spin_lock (&frame
->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
3112 return 0;
3113}
3114
3115
3116int32_t
3117posix_fsyncdir (call_frame_t *frame, xlator_t *this,
3118 fd_t *fd, int datasync, dict_t *xdata)
3119{
3120 int32_t op_ret = -1;
3121 int32_t op_errno = 0;
3122 int ret = -1;
3123 struct posix_fd *pfd = NULL((void*)0);
3124
3125 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3125, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3126 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3126, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3127 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3127, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
3128
3129 ret = posix_fd_ctx_get (fd, this, &pfd);
3130 if (ret < 0) {
3131 op_errno = -ret;
3132 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3133, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
3133 "pfd is NULL, fd=%p", fd)do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3133, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
;
3134 goto out;
3135 }
3136
3137 op_ret = 0;
3138
3139out:
3140 STACK_UNWIND_STRICT (fsyncdir, frame, op_ret, op_errno, NULL)do { fop_fsyncdir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3140, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fsyncdir_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
3141
3142 return 0;
3143}
3144
3145
3146void
3147posix_print_xattr (dict_t *this,
3148 char *key,
3149 data_t *value,
3150 void *data)
3151{
3152 gf_log ("posix", GF_LOG_DEBUG,do { do { if (0) printf ("(key/val) = (%s/%d)", key, data_to_int32
(value)); } while (0); _gf_log ("posix", "posix.c", __FUNCTION__
, 3153, GF_LOG_DEBUG, "(key/val) = (%s/%d)", key, data_to_int32
(value)); } while (0)
3153 "(key/val) = (%s/%d)", key, data_to_int32 (value))do { do { if (0) printf ("(key/val) = (%s/%d)", key, data_to_int32
(value)); } while (0); _gf_log ("posix", "posix.c", __FUNCTION__
, 3153, GF_LOG_DEBUG, "(key/val) = (%s/%d)", key, data_to_int32
(value)); } while (0)
;
3154}
3155
3156
3157/**
3158 * add_array - add two arrays of 32-bit numbers (stored in network byte order)
3159 * dest = dest + src
3160 * @count: number of 32-bit numbers
3161 * FIXME: handle overflow
3162 */
3163
3164static void
3165__add_array (int32_t *dest, int32_t *src, int count)
3166{
3167 int i = 0;
3168 int32_t destval = 0;
3169 for (i = 0; i < count; i++) {
3170 destval = ntoh32hton32 (dest[i]);
3171 if (destval == 0xffffffff)
3172 continue;
3173 dest[i] = hton32 (destval + ntoh32hton32 (src[i]));
3174 }
3175}
3176
3177static void
3178__or_array (int32_t *dest, int32_t *src, int count)
3179{
3180 int i = 0;
3181 for (i = 0; i < count; i++) {
3182 dest[i] = hton32 (ntoh32hton32 (dest[i]) | ntoh32hton32 (src[i]));
3183 }
3184}
3185
3186static void
3187__and_array (int32_t *dest, int32_t *src, int count)
3188{
3189 int i = 0;
3190 for (i = 0; i < count; i++) {
3191 dest[i] = hton32 (ntoh32hton32 (dest[i]) & ntoh32hton32 (src[i]));
3192 }
3193}
3194
3195static void
3196__add_long_array (int64_t *dest, int64_t *src, int count)
3197{
3198 int i = 0;
3199 for (i = 0; i < count; i++) {
3200 dest[i] = hton64 (ntoh64hton64 (dest[i]) + ntoh64hton64 (src[i]));
3201 }
3202}
3203
3204static int
3205_posix_handle_xattr_keyvalue_pair (dict_t *d, char *k, data_t *v,
3206 void *tmp)
3207{
3208 int size = 0;
3209 int count = 0;
3210 int op_ret = 0;
3211 int op_errno = 0;
3212 gf_xattrop_flags_t optype = 0;
3213 char *array = NULL((void*)0);
3214 inode_t *inode = NULL((void*)0);
3215 xlator_t *this = NULL((void*)0);
3216 posix_xattr_filler_t *filler = NULL((void*)0);
3217
3218 filler = tmp;
3219
3220 optype = (gf_xattrop_flags_t)(filler->flags);
3221 this = filler->this;
3222 inode = filler->inode;
3223
3224 count = v->len;
3225 array = GF_CALLOC (count, sizeof (char), gf_posix_mt_char)__gf_calloc (count, sizeof (char), gf_posix_mt_char);
3226
3227 LOCK (&inode->lock)pthread_spin_lock (&inode->lock);
3228 {
3229 if (filler->real_path) {
3230 size = sys_lgetxattr (filler->real_path, k,
3231 (char *)array, v->len);
3232 } else {
3233 size = sys_fgetxattr (filler->fd, k, (char *)array,
3234 v->len);
3235 }
3236
3237 op_errno = errno(*__errno_location ());
3238 if ((size == -1) && (op_errno != ENODATA61) &&
3239 (op_errno != ENOATTR61)) {
3240 if (op_errno == ENOTSUP95) {
3241 GF_LOG_OCCASIONALLY(gf_posix_xattr_enotsup_log,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported by filesystem"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3244, GF_LOG_WARNING
, "Extended attributes not " "supported by filesystem"); } while
(0); }
3242 this->name, GF_LOG_WARNING,if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported by filesystem"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3244, GF_LOG_WARNING
, "Extended attributes not " "supported by filesystem"); } while
(0); }
3243 "Extended attributes not "if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported by filesystem"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3244, GF_LOG_WARNING
, "Extended attributes not " "supported by filesystem"); } while
(0); }
3244 "supported by filesystem")if (!(gf_posix_xattr_enotsup_log++%42)) { do { do { if (0) printf
("Extended attributes not " "supported by filesystem"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3244, GF_LOG_WARNING
, "Extended attributes not " "supported by filesystem"); } while
(0); }
;
3245 } else if (op_errno != ENOENT2 ||
3246 !posix_special_xattr (marker_xattrs,
3247 k)) {
3248 if (filler->real_path)
3249 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("getxattr failed on %s while doing "
"xattrop: Key:%s (%s)", filler->real_path, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3253, GF_LOG_ERROR, "getxattr failed on %s while doing " "xattrop: Key:%s (%s)"
, filler->real_path, k, strerror (op_errno)); } while (0)
3250 "getxattr failed on %s while doing "do { do { if (0) printf ("getxattr failed on %s while doing "
"xattrop: Key:%s (%s)", filler->real_path, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3253, GF_LOG_ERROR, "getxattr failed on %s while doing " "xattrop: Key:%s (%s)"
, filler->real_path, k, strerror (op_errno)); } while (0)
3251 "xattrop: Key:%s (%s)",do { do { if (0) printf ("getxattr failed on %s while doing "
"xattrop: Key:%s (%s)", filler->real_path, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3253, GF_LOG_ERROR, "getxattr failed on %s while doing " "xattrop: Key:%s (%s)"
, filler->real_path, k, strerror (op_errno)); } while (0)
3252 filler->real_path,do { do { if (0) printf ("getxattr failed on %s while doing "
"xattrop: Key:%s (%s)", filler->real_path, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3253, GF_LOG_ERROR, "getxattr failed on %s while doing " "xattrop: Key:%s (%s)"
, filler->real_path, k, strerror (op_errno)); } while (0)
3253 k, strerror (op_errno))do { do { if (0) printf ("getxattr failed on %s while doing "
"xattrop: Key:%s (%s)", filler->real_path, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3253, GF_LOG_ERROR, "getxattr failed on %s while doing " "xattrop: Key:%s (%s)"
, filler->real_path, k, strerror (op_errno)); } while (0)
;
3254 else
3255 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3259, GF_LOG_ERROR, "fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0)
3256 "fgetxattr failed on fd=%d while doing "do { do { if (0) printf ("fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3259, GF_LOG_ERROR, "fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0)
3257 "xattrop: Key:%s (%s)",do { do { if (0) printf ("fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3259, GF_LOG_ERROR, "fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0)
3258 filler->fd,do { do { if (0) printf ("fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3259, GF_LOG_ERROR, "fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0)
3259 k, strerror (op_errno))do { do { if (0) printf ("fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3259, GF_LOG_ERROR, "fgetxattr failed on fd=%d while doing "
"xattrop: Key:%s (%s)", filler->fd, k, strerror (op_errno
)); } while (0)
;
3260 }
3261
3262 op_ret = -1;
3263 goto unlock;
3264 }
3265
3266 switch (optype) {
3267
3268 case GF_XATTROP_ADD_ARRAY:
3269 __add_array ((int32_t *) array, (int32_t *) v->data,
3270 v->len / 4);
3271 break;
3272
3273 case GF_XATTROP_ADD_ARRAY64:
3274 __add_long_array ((int64_t *) array, (int64_t *) v->data,
3275 v->len / 8);
3276 break;
3277
3278 case GF_XATTROP_OR_ARRAY:
3279 __or_array ((int32_t *) array,
3280 (int32_t *) v->data,
3281 v->len / 4);
3282 break;
3283
3284 case GF_XATTROP_AND_ARRAY:
3285 __and_array ((int32_t *) array,
3286 (int32_t *) v->data,
3287 v->len / 4);
3288 break;
3289
3290 default:
3291 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3294, GF_LOG_ERROR, "Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0)
3292 "Unknown xattrop type (%d) on %s. Please send "do { do { if (0) printf ("Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3294, GF_LOG_ERROR, "Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0)
3293 "a bug report to gluster-devel@nongnu.org",do { do { if (0) printf ("Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3294, GF_LOG_ERROR, "Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0)
3294 optype, filler->real_path)do { do { if (0) printf ("Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3294, GF_LOG_ERROR, "Unknown xattrop type (%d) on %s. Please send "
"a bug report to gluster-devel@nongnu.org", optype, filler->
real_path); } while (0)
;
3295 op_ret = -1;
3296 op_errno = EINVAL22;
3297 goto unlock;
3298 }
3299
3300 if (filler->real_path) {
3301 size = sys_lsetxattr (filler->real_path, k, array,
3302 v->len, 0);
3303 } else {
3304 size = sys_fsetxattr (filler->fd, k, (char *)array,
3305 v->len, 0);
3306 }
3307 }
3308unlock:
3309 UNLOCK (&inode->lock)pthread_spin_unlock (&inode->lock);
3310
3311 if (op_ret == -1)
3312 goto out;
3313
3314 op_errno = errno(*__errno_location ());
3315 if (size == -1) {
3316 if (filler->real_path)
3317 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3320, GF_LOG_ERROR, "setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0)
3318 "setxattr failed on %s while doing xattrop: "do { do { if (0) printf ("setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3320, GF_LOG_ERROR, "setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0)
3319 "key=%s (%s)", filler->real_path,do { do { if (0) printf ("setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3320, GF_LOG_ERROR, "setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0)
3320 k, strerror (op_errno))do { do { if (0) printf ("setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3320, GF_LOG_ERROR, "setxattr failed on %s while doing xattrop: "
"key=%s (%s)", filler->real_path, k, strerror (op_errno))
; } while (0)
;
3321 else
3322 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("fsetxattr failed on fd=%d while doing xattrop: "
"key=%s (%s)", filler->fd, k, strerror (op_errno)); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3325, GF_LOG_ERROR
, "fsetxattr failed on fd=%d while doing xattrop: " "key=%s (%s)"
, filler->fd, k, strerror (op_errno)); } while (0)
3323 "fsetxattr failed on fd=%d while doing xattrop: "do { do { if (0) printf ("fsetxattr failed on fd=%d while doing xattrop: "
"key=%s (%s)", filler->fd, k, strerror (op_errno)); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3325, GF_LOG_ERROR
, "fsetxattr failed on fd=%d while doing xattrop: " "key=%s (%s)"
, filler->fd, k, strerror (op_errno)); } while (0)
3324 "key=%s (%s)", filler->fd,do { do { if (0) printf ("fsetxattr failed on fd=%d while doing xattrop: "
"key=%s (%s)", filler->fd, k, strerror (op_errno)); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3325, GF_LOG_ERROR
, "fsetxattr failed on fd=%d while doing xattrop: " "key=%s (%s)"
, filler->fd, k, strerror (op_errno)); } while (0)
3325 k, strerror (op_errno))do { do { if (0) printf ("fsetxattr failed on fd=%d while doing xattrop: "
"key=%s (%s)", filler->fd, k, strerror (op_errno)); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3325, GF_LOG_ERROR
, "fsetxattr failed on fd=%d while doing xattrop: " "key=%s (%s)"
, filler->fd, k, strerror (op_errno)); } while (0)
;
3326
3327 op_ret = -1;
3328 goto out;
3329 } else {
3330 size = dict_set_bin (d, k, array, v->len);
3331
3332 if (size != 0) {
3333 if (filler->real_path)
3334 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("dict_set_bin failed (path=%s): " "key=%s (%s)"
, filler->real_path, k, strerror (-size)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3337, GF_LOG_DEBUG,
"dict_set_bin failed (path=%s): " "key=%s (%s)", filler->
real_path, k, strerror (-size)); } while (0)
3335 "dict_set_bin failed (path=%s): "do { do { if (0) printf ("dict_set_bin failed (path=%s): " "key=%s (%s)"
, filler->real_path, k, strerror (-size)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3337, GF_LOG_DEBUG,
"dict_set_bin failed (path=%s): " "key=%s (%s)", filler->
real_path, k, strerror (-size)); } while (0)
3336 "key=%s (%s)", filler->real_path,do { do { if (0) printf ("dict_set_bin failed (path=%s): " "key=%s (%s)"
, filler->real_path, k, strerror (-size)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3337, GF_LOG_DEBUG,
"dict_set_bin failed (path=%s): " "key=%s (%s)", filler->
real_path, k, strerror (-size)); } while (0)
3337 k, strerror (-size))do { do { if (0) printf ("dict_set_bin failed (path=%s): " "key=%s (%s)"
, filler->real_path, k, strerror (-size)); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3337, GF_LOG_DEBUG,
"dict_set_bin failed (path=%s): " "key=%s (%s)", filler->
real_path, k, strerror (-size)); } while (0)
;
3338 else
3339 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("dict_set_bin failed (fd=%d): " "key=%s (%s)"
, filler->fd, k, strerror (-size)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 3342, GF_LOG_DEBUG, "dict_set_bin failed (fd=%d): "
"key=%s (%s)", filler->fd, k, strerror (-size)); } while (
0)
3340 "dict_set_bin failed (fd=%d): "do { do { if (0) printf ("dict_set_bin failed (fd=%d): " "key=%s (%s)"
, filler->fd, k, strerror (-size)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 3342, GF_LOG_DEBUG, "dict_set_bin failed (fd=%d): "
"key=%s (%s)", filler->fd, k, strerror (-size)); } while (
0)
3341 "key=%s (%s)", filler->fd,do { do { if (0) printf ("dict_set_bin failed (fd=%d): " "key=%s (%s)"
, filler->fd, k, strerror (-size)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 3342, GF_LOG_DEBUG, "dict_set_bin failed (fd=%d): "
"key=%s (%s)", filler->fd, k, strerror (-size)); } while (
0)
3342 k, strerror (-size))do { do { if (0) printf ("dict_set_bin failed (fd=%d): " "key=%s (%s)"
, filler->fd, k, strerror (-size)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 3342, GF_LOG_DEBUG, "dict_set_bin failed (fd=%d): "
"key=%s (%s)", filler->fd, k, strerror (-size)); } while (
0)
;
3343
3344 op_ret = -1;
3345 op_errno = EINVAL22;
3346 goto out;
3347 }
3348 array = NULL((void*)0);
3349 }
3350
3351 array = NULL((void*)0);
3352
3353out:
3354 return op_ret;
3355}
3356
3357/**
3358 * xattrop - xattr operations - for internal use by GlusterFS
3359 * @optype: ADD_ARRAY:
3360 * dict should contain:
3361 * "key" ==> array of 32-bit numbers
3362 */
3363
3364int
3365do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
3366 gf_xattrop_flags_t optype, dict_t *xattr)
3367{
3368 int op_ret = 0;
3369 int op_errno = 0;
3370 int _fd = -1;
3371 char *real_path = NULL((void*)0);
3372 struct posix_fd *pfd = NULL((void*)0);
3373 inode_t *inode = NULL((void*)0);
3374 posix_xattr_filler_t filler = {0,};
3375
3376 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3376, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3377 VALIDATE_OR_GOTO (xattr, out)do { if (!xattr) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "xattr"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3377, GF_LOG_WARNING, "invalid argument: " "xattr"
); } while (0); goto out; } } while (0)
;
3378 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3378, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3379
3380 if (fd) {
3381 op_ret = posix_fd_ctx_get (fd, this, &pfd);
3382 if (op_ret < 0) {
3383 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to get pfd from fd=%p", fd);
} while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3385, GF_LOG_WARNING, "failed to get pfd from fd=%p", fd); }
while (0)
3384 "failed to get pfd from fd=%p",do { do { if (0) printf ("failed to get pfd from fd=%p", fd);
} while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3385, GF_LOG_WARNING, "failed to get pfd from fd=%p", fd); }
while (0)
3385 fd)do { do { if (0) printf ("failed to get pfd from fd=%p", fd);
} while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3385, GF_LOG_WARNING, "failed to get pfd from fd=%p", fd); }
while (0)
;
3386 op_errno = EBADFD77;
3387 goto out;
3388 }
3389 _fd = pfd->fd;
3390 }
3391
3392 if (loc && !uuid_is_null (loc->gfid))
3393 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3393, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, ((void*)0)); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), ((void*)0)); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
3394
3395 if (real_path) {
3396 inode = loc->inode;
3397 } else if (fd) {
3398 inode = fd->inode;
3399 }
3400
3401 filler.this = this;
3402 filler.fd = _fd;
3403 filler.real_path = real_path;
3404 filler.flags = (int)optype;
3405 filler.inode = inode;
3406
3407 op_ret = dict_foreach (xattr, _posix_handle_xattr_keyvalue_pair,
3408 &filler);
3409
3410out:
3411
3412 STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xattr, NULL)do { fop_xattrop_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3412, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_xattrop_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, xattr, ((void*)0)); (*__glusterfs_this_location()
) = old_THIS; } while (0)
;
3413 return 0;
3414}
3415
3416
3417int
3418posix_xattrop (call_frame_t *frame, xlator_t *this,
3419 loc_t *loc, gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
3420{
3421 do_xattrop (frame, this, loc, NULL((void*)0), optype, xattr);
3422 return 0;
3423}
3424
3425
3426int
3427posix_fxattrop (call_frame_t *frame, xlator_t *this,
3428 fd_t *fd, gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
3429{
3430 do_xattrop (frame, this, NULL((void*)0), fd, optype, xattr);
3431 return 0;
3432}
3433
3434
3435int
3436posix_access (call_frame_t *frame, xlator_t *this,
3437 loc_t *loc, int32_t mask, dict_t *xdata)
3438{
3439 int32_t op_ret = -1;
3440 int32_t op_errno = 0;
3441 char *real_path = NULL((void*)0);
3442
3443 DECLARE_OLD_FS_ID_VAR;
3444 SET_FS_ID (frame->root->uid, frame->root->gid);
3445
3446 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3446, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3447 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3447, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3448 VALIDATE_OR_GOTO (loc, out)do { if (!loc) { (*__errno_location ()) = 22; do { do { if (0
) printf ("invalid argument: " "loc"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3448, GF_LOG_WARNING, "invalid argument: " "loc"
); } while (0); goto out; } } while (0)
;
3449
3450 MAKE_INODE_HANDLE (real_path, this, loc, NULL)do { if (uuid_is_null (loc->gfid)) { do { do { if (0) printf
("null gfid for path %s", loc->path); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3450, GF_LOG_ERROR,
"null gfid for path %s", loc->path); } while (0); break; }
if (((loc) && (loc->path) && (loc->path
[0] == '/'))) { do { real_path = __builtin_alloca (strlen (loc
->path) + (((struct posix_private *)this->private)->
base_path_length) + 2); strcpy (real_path, (((struct posix_private
*)this->private)->base_path)); strcpy (&real_path[
(((struct posix_private *)this->private)->base_path_length
)], loc->path); } while (0); op_ret = posix_pstat (this, loc
->gfid, real_path, ((void*)0)); break; } (*__errno_location
()) = 0; op_ret = posix_istat (this, loc->gfid, ((void*)0
), ((void*)0)); if ((*__errno_location ()) != 40) { do { int __len
; __len = posix_handle_path (this, loc->gfid, ((void*)0), (
(void*)0), 0); if (__len <= 0) break; real_path = __builtin_alloca
(__len); __len = posix_handle_path (this, loc->gfid, ((void
*)0), real_path, __len); } while (0); break; } } while (0)
;
3451
3452 op_ret = access (real_path, mask & 07);
3453 if (op_ret == -1) {
3454 op_errno = errno(*__errno_location ());
3455 gf_log (this->name, GF_LOG_ERROR, "access failed on %s: %s",do { do { if (0) printf ("access failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 3456, GF_LOG_ERROR, "access failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
3456 real_path, strerror (op_errno))do { do { if (0) printf ("access failed on %s: %s", real_path
, strerror (op_errno)); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 3456, GF_LOG_ERROR, "access failed on %s: %s"
, real_path, strerror (op_errno)); } while (0)
;
3457 goto out;
3458 }
3459 op_ret = 0;
3460
3461out:
3462 SET_TO_OLD_FS_ID ();
3463
3464 STACK_UNWIND_STRICT (access, frame, op_ret, op_errno, NULL)do { fop_access_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3464, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_access_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS
; } while (0)
;
3465 return 0;
3466}
3467
3468
3469int32_t
3470posix_ftruncate (call_frame_t *frame, xlator_t *this,
3471 fd_t *fd, off_t offset, dict_t *xdata)
3472{
3473 int32_t op_ret = -1;
3474 int32_t op_errno = 0;
3475 int _fd = -1;
3476 struct iatt preop = {0,};
3477 struct iatt postop = {0,};
3478 struct posix_fd *pfd = NULL((void*)0);
3479 int ret = -1;
3480 struct posix_private *priv = NULL((void*)0);
3481
3482 DECLARE_OLD_FS_ID_VAR;
3483 SET_FS_ID (frame->root->uid, frame->root->gid);
3484
3485 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3485, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3486 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3486, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3487 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3487, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
3488
3489 priv = this->private;
3490 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3490, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
3491
3492 ret = posix_fd_ctx_get (fd, this, &pfd);
3493 if (ret < 0) {
3494 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3495, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
3495 "pfd is NULL, fd=%p", fd)do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3495, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
;
3496 op_errno = -ret;
3497 goto out;
3498 }
3499
3500 _fd = pfd->fd;
3501
3502 op_ret = posix_fdstat (this, _fd, &preop);
3503 if (op_ret == -1) {
3504 op_errno = errno(*__errno_location ());
3505 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 3507, GF_LOG_ERROR, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
3506 "pre-operation fstat failed on fd=%p: %s", fd,do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 3507, GF_LOG_ERROR, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
3507 strerror (op_errno))do { do { if (0) printf ("pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 3507, GF_LOG_ERROR, "pre-operation fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
3508 goto out;
3509 }
3510
3511 op_ret = ftruncate (_fd, offset);
3512
3513 if (op_ret == -1) {
3514 op_errno = errno(*__errno_location ());
3515 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("ftruncate failed on fd=%p (%""ll" "d"
": %s", fd, offset, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3517, GF_LOG_ERROR
, "ftruncate failed on fd=%p (%""ll" "d"": %s", fd, offset, strerror
((*__errno_location ()))); } while (0)
3516 "ftruncate failed on fd=%p (%"PRId64": %s",do { do { if (0) printf ("ftruncate failed on fd=%p (%""ll" "d"
": %s", fd, offset, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3517, GF_LOG_ERROR
, "ftruncate failed on fd=%p (%""ll" "d"": %s", fd, offset, strerror
((*__errno_location ()))); } while (0)
3517 fd, offset, strerror (errno))do { do { if (0) printf ("ftruncate failed on fd=%p (%""ll" "d"
": %s", fd, offset, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3517, GF_LOG_ERROR
, "ftruncate failed on fd=%p (%""ll" "d"": %s", fd, offset, strerror
((*__errno_location ()))); } while (0)
;
3518 goto out;
3519 }
3520
3521 op_ret = posix_fdstat (this, _fd, &postop);
3522 if (op_ret == -1) {
3523 op_errno = errno(*__errno_location ());
3524 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3526, GF_LOG_ERROR,
"post-operation fstat failed on fd=%p: %s", fd, strerror ((*
__errno_location ()))); } while (0)
3525 "post-operation fstat failed on fd=%p: %s",do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3526, GF_LOG_ERROR,
"post-operation fstat failed on fd=%p: %s", fd, strerror ((*
__errno_location ()))); } while (0)
3526 fd, strerror (errno))do { do { if (0) printf ("post-operation fstat failed on fd=%p: %s"
, fd, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 3526, GF_LOG_ERROR,
"post-operation fstat failed on fd=%p: %s", fd, strerror ((*
__errno_location ()))); } while (0)
;
3527 goto out;
3528 }
3529
3530 op_ret = 0;
3531
3532out:
3533 SET_TO_OLD_FS_ID ();
3534
3535 STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno, &preop,do { fop_ftruncate_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3536, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_ftruncate_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preop, &postop, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
3536 &postop, NULL)do { fop_ftruncate_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3536, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_ftruncate_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &preop, &postop, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3537
3538 return 0;
3539}
3540
3541
3542int32_t
3543posix_fstat (call_frame_t *frame, xlator_t *this,
3544 fd_t *fd, dict_t *xdata)
3545{
3546 int _fd = -1;
3547 int32_t op_ret = -1;
3548 int32_t op_errno = 0;
3549 struct iatt buf = {0,};
3550 struct posix_fd *pfd = NULL((void*)0);
3551 int ret = -1;
3552 struct posix_private *priv = NULL((void*)0);
3553
3554 DECLARE_OLD_FS_ID_VAR;
3555 SET_FS_ID (frame->root->uid, frame->root->gid);
3556
3557 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3557, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3558 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3558, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3559 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3559, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
3560
3561 priv = this->private;
3562 VALIDATE_OR_GOTO (priv, out)do { if (!priv) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "priv"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3562, GF_LOG_WARNING, "invalid argument: " "priv"
); } while (0); goto out; } } while (0)
;
3563
3564 ret = posix_fd_ctx_get (fd, this, &pfd);
3565 if (ret < 0) {
3566 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3567, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
3567 "pfd is NULL, fd=%p", fd)do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3567, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
;
3568 op_errno = -ret;
3569 goto out;
3570 }
3571
3572 _fd = pfd->fd;
3573
3574 op_ret = posix_fdstat (this, _fd, &buf);
3575 if (op_ret == -1) {
3576 op_errno = errno(*__errno_location ());
3577 gf_log (this->name, GF_LOG_ERROR, "fstat failed on fd=%p: %s",do { do { if (0) printf ("fstat failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3578, GF_LOG_ERROR, "fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
3578 fd, strerror (op_errno))do { do { if (0) printf ("fstat failed on fd=%p: %s", fd, strerror
(op_errno)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 3578, GF_LOG_ERROR, "fstat failed on fd=%p: %s"
, fd, strerror (op_errno)); } while (0)
;
3579 goto out;
3580 }
3581
3582 op_ret = 0;
3583
3584out:
3585 SET_TO_OLD_FS_ID ();
3586
3587 STACK_UNWIND_STRICT (fstat, frame, op_ret, op_errno, &buf, NULL)do { fop_fstat_cbk_t fn = ((void*)0); call_frame_t *_parent =
((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do
{ do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3587, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fstat_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &buf, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3588 return 0;
3589}
3590
3591static int gf_posix_lk_log;
3592
3593int32_t
3594posix_lk (call_frame_t *frame, xlator_t *this,
3595 fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata)
3596{
3597 struct gf_flock nullock = {0, };
3598
3599 GF_LOG_OCCASIONALLY (gf_posix_lk_log, this->name, GF_LOG_CRITICAL,if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3602, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3600 "\"features/locks\" translator is "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3602, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3601 "not loaded. You need to use it for proper "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3602, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3602 "functioning of your application.")if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3602, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
;
3603
3604 STACK_UNWIND_STRICT (lk, frame, -1, ENOSYS, &nullock, NULL)do { fop_lk_cbk_t fn = ((void*)0); call_frame_t *_parent = ((
void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do {
do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3604, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_lk_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, 38, &nullock, ((void*)0)); (*__glusterfs_this_location(
)) = old_THIS; } while (0)
;
3605 return 0;
3606}
3607
3608int32_t
3609posix_inodelk (call_frame_t *frame, xlator_t *this,
3610 const char *volume, loc_t *loc, int32_t cmd,
3611 struct gf_flock *lock, dict_t *xdata)
3612{
3613 GF_LOG_OCCASIONALLY (gf_posix_lk_log, this->name, GF_LOG_CRITICAL,if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3616, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3614 "\"features/locks\" translator is "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3616, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3615 "not loaded. You need to use it for proper "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3616, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3616 "functioning of your application.")if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3616, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
;
3617
3618 STACK_UNWIND_STRICT (inodelk, frame, -1, ENOSYS, NULL)do { fop_inodelk_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3618, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_inodelk_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, 38, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
;
3619 return 0;
3620}
3621
3622int32_t
3623posix_finodelk (call_frame_t *frame, xlator_t *this,
3624 const char *volume, fd_t *fd, int32_t cmd,
3625 struct gf_flock *lock, dict_t *xdata)
3626{
3627 GF_LOG_OCCASIONALLY (gf_posix_lk_log, this->name, GF_LOG_CRITICAL,if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3630, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3628 "\"features/locks\" translator is "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3630, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3629 "not loaded. You need to use it for proper "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3630, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3630 "functioning of your application.")if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3630, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
;
3631
3632 STACK_UNWIND_STRICT (finodelk, frame, -1, ENOSYS, NULL)do { fop_finodelk_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3632, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_finodelk_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, 38, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
;
3633 return 0;
3634}
3635
3636
3637int32_t
3638posix_entrylk (call_frame_t *frame, xlator_t *this,
3639 const char *volume, loc_t *loc, const char *basename__xpg_basename,
3640 entrylk_cmd cmd, entrylk_type type, dict_t *xdata)
3641{
3642 GF_LOG_OCCASIONALLY (gf_posix_lk_log, this->name, GF_LOG_CRITICAL,if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3645, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3643 "\"features/locks\" translator is "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3645, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3644 "not loaded. You need to use it for proper "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3645, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3645 "functioning of your application.")if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3645, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
;
3646
3647 STACK_UNWIND_STRICT (entrylk, frame, -1, ENOSYS, NULL)do { fop_entrylk_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3647, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_entrylk_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, 38, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
;
3648 return 0;
3649}
3650
3651int32_t
3652posix_fentrylk (call_frame_t *frame, xlator_t *this,
3653 const char *volume, fd_t *fd, const char *basename__xpg_basename,
3654 entrylk_cmd cmd, entrylk_type type, dict_t *xdata)
3655{
3656 GF_LOG_OCCASIONALLY (gf_posix_lk_log, this->name, GF_LOG_CRITICAL,if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3659, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3657 "\"features/locks\" translator is "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3659, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3658 "not loaded. You need to use it for proper "if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3659, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
3659 "functioning of your application.")if (!(gf_posix_lk_log++%42)) { do { do { if (0) printf ("\"features/locks\" translator is "
"not loaded. You need to use it for proper " "functioning of your application."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 3659, GF_LOG_CRITICAL, "\"features/locks\" translator is " "not loaded. You need to use it for proper "
"functioning of your application."); } while (0); }
;
3660
3661 STACK_UNWIND_STRICT (fentrylk, frame, -1, ENOSYS, NULL)do { fop_fentrylk_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3661, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_fentrylk_cbk_t )frame->ret;
_parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, -1
, 38, ((void*)0)); (*__glusterfs_this_location()) = old_THIS;
} while (0)
;
3662 return 0;
3663}
3664
3665
3666int
3667posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t size,
3668 gf_dirent_t *entries, xlator_t *this, int32_t skip_dirs)
3669{
3670 off_t in_case = -1;
3671 size_t filled = 0;
3672 int count = 0;
3673 char entrybuf[sizeof(struct dirent) + 256 + 8];
3674 struct dirent *entry = NULL((void*)0);
3675 int32_t this_size = -1;
3676 gf_dirent_t *this_entry = NULL((void*)0);
3677 uuid_t rootgfid = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
3678 struct stat stbuf = {0,};
3679 char *hpath = NULL((void*)0);
3680 int len = 0;
3681 int ret = 0;
3682
3683 if (skip_dirs) {
3684 len = posix_handle_path (this, fd->inode->gfid, NULL((void*)0), NULL((void*)0), 0);
3685 hpath = alloca (len + 256)__builtin_alloca (len + 256); /* NAME_MAX */
3686 posix_handle_path (this, fd->inode->gfid, NULL((void*)0), hpath, len);
3687 len = strlen (hpath);
3688 hpath[len] = '/';
3689 }
3690
3691 if (!off) {
3692 rewinddir (dir);
3693 } else {
3694 seekdir (dir, off);
3695 }
3696
3697 while (filled <= size) {
3698 in_case = telldir (dir);
3699
3700 if (in_case == -1) {
3701 gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("telldir failed on dir=%p: %s", dir,
strerror ((*__errno_location ()))); } while (0); _gf_log ((*
__glusterfs_this_location())->name, "posix.c", __FUNCTION__
, 3703, GF_LOG_ERROR, "telldir failed on dir=%p: %s", dir, strerror
((*__errno_location ()))); } while (0)
3702 "telldir failed on dir=%p: %s",do { do { if (0) printf ("telldir failed on dir=%p: %s", dir,
strerror ((*__errno_location ()))); } while (0); _gf_log ((*
__glusterfs_this_location())->name, "posix.c", __FUNCTION__
, 3703, GF_LOG_ERROR, "telldir failed on dir=%p: %s", dir, strerror
((*__errno_location ()))); } while (0)
3703 dir, strerror (errno))do { do { if (0) printf ("telldir failed on dir=%p: %s", dir,
strerror ((*__errno_location ()))); } while (0); _gf_log ((*
__glusterfs_this_location())->name, "posix.c", __FUNCTION__
, 3703, GF_LOG_ERROR, "telldir failed on dir=%p: %s", dir, strerror
((*__errno_location ()))); } while (0)
;
3704 goto out;
3705 }
3706
3707 errno(*__errno_location ()) = 0;
3708 entry = NULL((void*)0);
3709 readdir_r (dir, (struct dirent *)entrybuf, &entry);
3710
3711 if (!entry) {
3712 if (errno(*__errno_location ()) == EBADF9) {
3713 gf_log (THIS->name, GF_LOG_WARNING,do { do { if (0) printf ("readdir failed on dir=%p: %s", dir,
strerror ((*__errno_location ()))); } while (0); _gf_log ((*
__glusterfs_this_location())->name, "posix.c", __FUNCTION__
, 3715, GF_LOG_WARNING, "readdir failed on dir=%p: %s", dir, strerror
((*__errno_location ()))); } while (0)
3714 "readdir failed on dir=%p: %s",do { do { if (0) printf ("readdir failed on dir=%p: %s", dir,
strerror ((*__errno_location ()))); } while (0); _gf_log ((*
__glusterfs_this_location())->name, "posix.c", __FUNCTION__
, 3715, GF_LOG_WARNING, "readdir failed on dir=%p: %s", dir, strerror
((*__errno_location ()))); } while (0)
3715 dir, strerror (errno))do { do { if (0) printf ("readdir failed on dir=%p: %s", dir,
strerror ((*__errno_location ()))); } while (0); _gf_log ((*
__glusterfs_this_location())->name, "posix.c", __FUNCTION__
, 3715, GF_LOG_WARNING, "readdir failed on dir=%p: %s", dir, strerror
((*__errno_location ()))); } while (0)
;
3716 goto out;
3717 }
3718 break;
3719 }
3720
3721#ifdef __NetBSD__
3722 /*
3723 * NetBSD with UFS1 backend uses backing files for
3724 * extended attributes. They can be found in a
3725 * .attribute file located at the root of the filesystem
3726 * We hide it to glusterfs clients, since chaos will occur
3727 * when the cluster/dht xlator decides to distribute
3728 * exended attribute backing file accross storage servers.
3729 */
3730 if ((uuid_compare (fd->inode->gfid, rootgfid) == 0)
3731 && (!strcmp(entry->d_name, ".attribute")))
3732 continue;
3733#endif /* __NetBSD__ */
3734
3735 if ((uuid_compare (fd->inode->gfid, rootgfid) == 0)
3736 && (!strcmp (GF_HIDDEN_PATH".glusterfs", entry->d_name))) {
3737 continue;
3738 }
3739
3740 if (skip_dirs) {
3741 if (DT_ISDIR (entry->d_type)(entry->d_type == DT_DIR)) {
3742 continue;
3743 } else if (hpath) {
3744 strcpy (&hpath[len+1],entry->d_name);
3745 ret = lstat (hpath, &stbuf);
3746 if (!ret && S_ISDIR (stbuf.st_mode)((((stbuf.st_mode)) & 0170000) == (0040000)))
3747 continue;
3748 }
3749 }
3750
3751 this_size = max (sizeof (gf_dirent_t),((sizeof (gf_dirent_t))>(sizeof (gfs3_dirplist))?(sizeof (
gf_dirent_t)):(sizeof (gfs3_dirplist)))
3752 sizeof (gfs3_dirplist))((sizeof (gf_dirent_t))>(sizeof (gfs3_dirplist))?(sizeof (
gf_dirent_t)):(sizeof (gfs3_dirplist)))
3753 + strlen (entry->d_name) + 1;
3754
3755 if (this_size + filled > size) {
3756 seekdir (dir, in_case);
3757 break;
3758 }
3759
3760 this_entry = gf_dirent_for_name (entry->d_name);
3761
3762 if (!this_entry) {
3763 gf_log (THIS->name, GF_LOG_ERROR,do { do { if (0) printf ("could not create gf_dirent for entry %s: (%s)"
, entry->d_name, strerror ((*__errno_location ()))); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "posix.c"
, __FUNCTION__, 3765, GF_LOG_ERROR, "could not create gf_dirent for entry %s: (%s)"
, entry->d_name, strerror ((*__errno_location ()))); } while
(0)
3764 "could not create gf_dirent for entry %s: (%s)",do { do { if (0) printf ("could not create gf_dirent for entry %s: (%s)"
, entry->d_name, strerror ((*__errno_location ()))); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "posix.c"
, __FUNCTION__, 3765, GF_LOG_ERROR, "could not create gf_dirent for entry %s: (%s)"
, entry->d_name, strerror ((*__errno_location ()))); } while
(0)
3765 entry->d_name, strerror (errno))do { do { if (0) printf ("could not create gf_dirent for entry %s: (%s)"
, entry->d_name, strerror ((*__errno_location ()))); } while
(0); _gf_log ((*__glusterfs_this_location())->name, "posix.c"
, __FUNCTION__, 3765, GF_LOG_ERROR, "could not create gf_dirent for entry %s: (%s)"
, entry->d_name, strerror ((*__errno_location ()))); } while
(0)
;
3766 goto out;
3767 }
3768 this_entry->d_off = telldir (dir);
3769 this_entry->d_ino = entry->d_ino;
3770 this_entry->d_type = entry->d_type;
3771
3772 list_add_tail (&this_entry->list, &entries->list);
3773
3774 filled += this_size;
3775 count ++;
3776 }
3777
3778 if ((!readdir (dir) && (errno(*__errno_location ()) == 0)))
3779 /* Indicate EOF */
3780 errno(*__errno_location ()) = ENOENT2;
3781out:
3782 return count;
3783}
3784
3785dict_t *
3786posix_entry_xattr_fill (xlator_t *this, inode_t *inode,
3787 fd_t *fd, char *name, dict_t *dict,
3788 struct iatt *stbuf)
3789{
3790 loc_t tmp_loc = {0,};
3791 char *entry_path = NULL((void*)0);
3792
3793 /* if we don't send the 'loc', open-fd-count be a problem. */
3794 tmp_loc.inode = inode;
3795
3796 MAKE_HANDLE_PATH (entry_path, this, fd->inode->gfid, name)do { int __len; __len = posix_handle_path (this, fd->inode
->gfid, name, ((void*)0), 0); if (__len <= 0) break; entry_path
= __builtin_alloca (__len); __len = posix_handle_path (this,
fd->inode->gfid, name, entry_path, __len); } while (0)
;
3797
3798 return posix_lookup_xattr_fill (this, entry_path,
3799 &tmp_loc, dict, stbuf);
3800
3801}
3802
3803
3804int
3805posix_readdirp_fill (xlator_t *this, fd_t *fd, gf_dirent_t *entries, dict_t *dict)
3806{
3807 gf_dirent_t *entry = NULL((void*)0);
3808 inode_table_t *itable = NULL((void*)0);
3809 inode_t *inode = NULL((void*)0);
3810 char *hpath = NULL((void*)0);
3811 int len = 0;
3812 struct iatt stbuf = {0, };
3813 uuid_t gfid;
3814
3815 if (list_empty(&entries->list))
3816 return 0;
3817
3818 itable = fd->inode->table;
3819
3820 len = posix_handle_path (this, fd->inode->gfid, NULL((void*)0), NULL((void*)0), 0);
3821 hpath = alloca (len + 256)__builtin_alloca (len + 256); /* NAME_MAX */
3822 posix_handle_path (this, fd->inode->gfid, NULL((void*)0), hpath, len);
3823 len = strlen (hpath);
3824 hpath[len] = '/';
3825
3826 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))))
{
3827 memset (gfid, 0, 16);
3828 inode = inode_grep (fd->inode->table, fd->inode,
3829 entry->d_name);
3830 if (inode)
3831 uuid_copy (gfid, inode->gfid);
3832
3833 strcpy (&hpath[len+1], entry->d_name);
3834
3835 posix_pstat (this, gfid, hpath, &stbuf);
3836
3837 if (!inode)
3838 inode = inode_find (itable, stbuf.ia_gfid);
3839
3840 if (!inode)
3841 inode = inode_new (itable);
3842
3843 entry->inode = inode;
3844
3845 if (dict) {
3846 entry->dict =
3847 posix_entry_xattr_fill (this, entry->inode,
3848 fd, entry->d_name,
3849 dict, &stbuf);
3850 dict_ref (entry->dict);
3851 }
3852
3853 entry->d_stat = stbuf;
3854 if (stbuf.ia_ino)
3855 entry->d_ino = stbuf.ia_ino;
3856 inode = NULL((void*)0);
3857 }
3858
3859 return 0;
3860}
3861
3862
3863int32_t
3864posix_do_readdir (call_frame_t *frame, xlator_t *this,
3865 fd_t *fd, size_t size, off_t off, int whichop, dict_t *dict)
3866{
3867 struct posix_fd *pfd = NULL((void*)0);
3868 DIR *dir = NULL((void*)0);
3869 int ret = -1;
3870 int count = 0;
3871 int32_t op_ret = -1;
3872 int32_t op_errno = 0;
3873 gf_dirent_t entries;
3874 int32_t skip_dirs = 0;
3875
3876
3877 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3877, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
3878 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3878, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
3879 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 3879, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
3880
3881 INIT_LIST_HEAD (&entries.list)do { (&entries.list)->next = (&entries.list)->prev
= &entries.list; } while (0)
;
3882
3883 ret = posix_fd_ctx_get (fd, this, &pfd);
3884 if (ret < 0) {
3885 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3886, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
3886 "pfd is NULL, fd=%p", fd)do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 3886, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
;
3887 op_errno = -ret;
3888 goto out;
3889 }
3890
3891 dir = pfd->dir;
3892
3893 if (!dir) {
3894 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("dir is NULL for fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3895, GF_LOG_WARNING
, "dir is NULL for fd=%p", fd); } while (0)
3895 "dir is NULL for fd=%p", fd)do { do { if (0) printf ("dir is NULL for fd=%p", fd); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 3895, GF_LOG_WARNING
, "dir is NULL for fd=%p", fd); } while (0)
;
3896 op_errno = EINVAL22;
3897 goto out;
3898 }
3899
3900 /* When READDIR_FILTER option is set to on, we can filter out
3901 * directory's entry from the entry->list.
3902 */
3903 ret = dict_get_int32 (dict, GF_READDIR_SKIP_DIRS"readdir-filter-directories", &skip_dirs);
3904
3905 LOCK (&fd->lock)pthread_spin_lock (&fd->lock);
3906 {
3907 /* posix_fill_readdir performs multiple separate individual
3908 readdir() calls to fill up the buffer.
3909
3910 In case of NFS where the same anonymous FD is shared between
3911 different applications, reading a common directory can
3912 result in the anonymous fd getting re-used unsafely between
3913 the two readdir requests (in two different io-threads).
3914
3915 It would also help, in the future, to replace the loop
3916 around readdir() with a single large getdents() call.
3917 */
3918 count = posix_fill_readdir (fd, dir, off, size, &entries, this,
3919 skip_dirs);
3920 }
3921 UNLOCK (&fd->lock)pthread_spin_unlock (&fd->lock);
3922
3923 /* pick ENOENT to indicate EOF */
3924 op_errno = errno(*__errno_location ());
3925 op_ret = count;
3926
3927 if (whichop != GF_FOP_READDIRP)
3928 goto out;
3929
3930 posix_readdirp_fill (this, fd, &entries, dict);
3931
3932out:
3933 STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, &entries, NULL)do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 3933, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_readdir_cbk_t )frame->ret; _parent
= frame->parent; pthread_spin_lock (&frame->root->
stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, &entries, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
3934
3935 gf_dirent_free (&entries);
3936
3937 return 0;
3938}
3939
3940
3941int32_t
3942posix_readdir (call_frame_t *frame, xlator_t *this,
3943 fd_t *fd, size_t size, off_t off, dict_t *xdata)
3944{
3945 posix_do_readdir (frame, this, fd, size, off, GF_FOP_READDIR, xdata);
3946 return 0;
3947}
3948
3949
3950int32_t
3951posix_readdirp (call_frame_t *frame, xlator_t *this,
3952 fd_t *fd, size_t size, off_t off, dict_t *dict)
3953{
3954 posix_do_readdir (frame, this, fd, size, off, GF_FOP_READDIRP, dict);
3955 return 0;
3956}
3957
3958int32_t
3959posix_priv (xlator_t *this)
3960{
3961 struct posix_private *priv = NULL((void*)0);
3962 char key_prefix[GF_DUMP_MAX_BUF_LEN4096];
3963
3964 snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN4096, "%s.%s", this->type,
3965 this->name);
3966 gf_proc_dump_add_section(key_prefix);
3967
3968 if (!this)
3969 return 0;
3970
3971 priv = this->private;
3972
3973 if (!priv)
3974 return 0;
3975
3976 gf_proc_dump_write("base_path","%s", priv->base_path);
3977 gf_proc_dump_write("base_path_length","%d", priv->base_path_length);
3978 gf_proc_dump_write("max_read","%d", priv->read_value);
3979 gf_proc_dump_write("max_write","%d", priv->write_value);
3980 gf_proc_dump_write("nr_files","%ld", priv->nr_files);
3981
3982 return 0;
3983}
3984
3985int32_t
3986posix_inode (xlator_t *this)
3987{
3988 return 0;
3989}
3990
3991
3992int32_t
3993posix_rchecksum (call_frame_t *frame, xlator_t *this,
3994 fd_t *fd, off_t offset, int32_t len, dict_t *xdata)
3995{
3996 char *alloc_buf = NULL((void*)0);
3997 char *buf = NULL((void*)0);
3998 int _fd = -1;
3999 struct posix_fd *pfd = NULL((void*)0);
4000 int op_ret = -1;
4001 int op_errno = 0;
4002 int ret = 0;
4003 int32_t weak_checksum = 0;
4004 unsigned char strong_checksum[MD5_DIGEST_LENGTH16] = {0};
4005 struct posix_private *priv = NULL((void*)0);
4006
4007 VALIDATE_OR_GOTO (frame, out)do { if (!frame) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "frame"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 4007, GF_LOG_WARNING, "invalid argument: " "frame"
); } while (0); goto out; } } while (0)
;
4008 VALIDATE_OR_GOTO (this, out)do { if (!this) { (*__errno_location ()) = 22; do { do { if (
0) printf ("invalid argument: " "this"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 4008, GF_LOG_WARNING, "invalid argument: " "this"
); } while (0); goto out; } } while (0)
;
4009 VALIDATE_OR_GOTO (fd, out)do { if (!fd) { (*__errno_location ()) = 22; do { do { if (0)
printf ("invalid argument: " "fd"); } while (0); _gf_log_callingfn
((this ? (this->name) : "(Govinda! Govinda!)"), "posix.c"
, __FUNCTION__, 4009, GF_LOG_WARNING, "invalid argument: " "fd"
); } while (0); goto out; } } while (0)
;
4010
4011 priv = this->private;
4012 memset (strong_checksum, 0, MD5_DIGEST_LENGTH16);
4013
4014 alloc_buf = _page_aligned_alloc (len, &buf);
4015 if (!alloc_buf) {
4016 op_errno = ENOMEM12;
4017 goto out;
4018 }
4019
4020 ret = posix_fd_ctx_get (fd, this, &pfd);
4021 if (ret < 0) {
4022 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 4023, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
4023 "pfd is NULL, fd=%p", fd)do { do { if (0) printf ("pfd is NULL, fd=%p", fd); } while (
0); _gf_log (this->name, "posix.c", __FUNCTION__, 4023, GF_LOG_WARNING
, "pfd is NULL, fd=%p", fd); } while (0)
;
4024 op_errno = -ret;
4025 goto out;
4026 }
4027
4028 _fd = pfd->fd;
4029
4030 LOCK (&fd->lock)pthread_spin_lock (&fd->lock);
4031 {
4032 if (priv->aio_capable && priv->aio_init_done)
4033 __posix_fd_set_odirect (fd, pfd, 0, offset, len);
4034
4035 ret = pread (_fd, buf, len, offset);
4036 if (ret < 0) {
4037 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("pread of %d bytes returned %d (%s)"
, len, ret, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4039, GF_LOG_WARNING
, "pread of %d bytes returned %d (%s)", len, ret, strerror ((
*__errno_location ()))); } while (0)
4038 "pread of %d bytes returned %d (%s)",do { do { if (0) printf ("pread of %d bytes returned %d (%s)"
, len, ret, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4039, GF_LOG_WARNING
, "pread of %d bytes returned %d (%s)", len, ret, strerror ((
*__errno_location ()))); } while (0)
4039 len, ret, strerror (errno))do { do { if (0) printf ("pread of %d bytes returned %d (%s)"
, len, ret, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4039, GF_LOG_WARNING
, "pread of %d bytes returned %d (%s)", len, ret, strerror ((
*__errno_location ()))); } while (0)
;
4040
4041 op_errno = errno(*__errno_location ());
4042 }
4043
4044 }
4045 UNLOCK (&fd->lock)pthread_spin_unlock (&fd->lock);
4046
4047 if (ret < 0)
4048 goto out;
4049
4050 weak_checksum = gf_rsync_weak_checksum ((unsigned char *) buf, (size_t) len);
4051 gf_rsync_strong_checksum ((unsigned char *) buf, (size_t) len, (unsigned char *) strong_checksum);
4052
4053 op_ret = 0;
4054out:
4055 STACK_UNWIND_STRICT (rchecksum, frame, op_ret, op_errno,do { fop_rchecksum_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 4056, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rchecksum_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, weak_checksum, strong_checksum, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
4056 weak_checksum, strong_checksum, NULL)do { fop_rchecksum_cbk_t fn = ((void*)0); call_frame_t *_parent
= ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) {
do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack"
, "posix.c", __FUNCTION__, 4056, GF_LOG_CRITICAL, "!frame"); }
while (0); break; } fn = (fop_rchecksum_cbk_t )frame->ret
; _parent = frame->parent; pthread_spin_lock (&frame->
root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock
(&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location
()); (*__glusterfs_this_location()) = _parent->this; frame
->complete = _gf_true; frame->unwind_from = __FUNCTION__
; if (frame->this->ctx->measure_latency) gf_latency_end
(frame); fn (_parent, frame->cookie, _parent->this, op_ret
, op_errno, weak_checksum, strong_checksum, ((void*)0)); (*__glusterfs_this_location
()) = old_THIS; } while (0)
;
4057
4058 GF_FREE (alloc_buf)__gf_free (alloc_buf);
4059
4060 return 0;
4061}
4062
4063
4064/**
4065 * notify - when parent sends PARENT_UP, send CHILD_UP event from here
4066 */
4067int32_t
4068notify (xlator_t *this,
4069 int32_t event,
4070 void *data,
4071 ...)
4072{
4073 switch (event)
4074 {
4075 case GF_EVENT_PARENT_UP:
4076 {
4077 /* Tell the parent that posix xlator is up */
4078 default_notify (this, GF_EVENT_CHILD_UP, data);
4079 }
4080 break;
4081 default:
4082 /* */
4083 break;
4084 }
4085 return 0;
4086}
4087
4088int32_t
4089mem_acct_init (xlator_t *this)
4090{
4091 int ret = -1;
4092
4093 if (!this)
4094 return ret;
4095
4096 ret = xlator_mem_acct_init (this, gf_posix_mt_end + 1);
4097
4098 if (ret != 0) {
4099 gf_log(this->name, GF_LOG_ERROR, "Memory accounting init"do { do { if (0) printf ("Memory accounting init" "failed"); }
while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 4100
, GF_LOG_ERROR, "Memory accounting init" "failed"); } while (
0)
4100 "failed")do { do { if (0) printf ("Memory accounting init" "failed"); }
while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 4100
, GF_LOG_ERROR, "Memory accounting init" "failed"); } while (
0)
;
4101 return ret;
4102 }
4103
4104 return ret;
4105}
4106
4107static int
4108posix_set_owner (xlator_t *this, uid_t uid, gid_t gid)
4109{
4110 struct posix_private *priv = NULL((void*)0);
4111 int ret = -1;
4112
4113 priv = this->private;
4114
4115 ret = sys_chown (priv->base_path, uid, gid);
4116 if (ret)
4117 gf_log (this->name, GF_LOG_ERROR, "Failed to set "do { do { if (0) printf ("Failed to set " "uid/gid for brick path %s, %s"
, priv->base_path, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4119, GF_LOG_ERROR
, "Failed to set " "uid/gid for brick path %s, %s", priv->
base_path, strerror ((*__errno_location ()))); } while (0)
4118 "uid/gid for brick path %s, %s",do { do { if (0) printf ("Failed to set " "uid/gid for brick path %s, %s"
, priv->base_path, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4119, GF_LOG_ERROR
, "Failed to set " "uid/gid for brick path %s, %s", priv->
base_path, strerror ((*__errno_location ()))); } while (0)
4119 priv->base_path, strerror (errno))do { do { if (0) printf ("Failed to set " "uid/gid for brick path %s, %s"
, priv->base_path, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4119, GF_LOG_ERROR
, "Failed to set " "uid/gid for brick path %s, %s", priv->
base_path, strerror ((*__errno_location ()))); } while (0)
;
4120
4121 return ret;
4122}
4123
4124int
4125reconfigure (xlator_t *this, dict_t *options)
4126{
4127 int ret = -1;
4128 struct posix_private *priv = NULL((void*)0);
4129 uid_t uid = -1;
4130 gid_t gid = -1;
4131
4132 priv = this->private;
4133
4134 GF_OPTION_RECONF ("brick-uid", uid, options, uint32, out)do { int val_ret = 0; val_ret = xlator_option_reconf_uint32 (
(*__glusterfs_this_location()), options, "brick-uid", &(uid
)); if (val_ret) goto out; } while (0)
;
4135 GF_OPTION_RECONF ("brick-gid", gid, options, uint32, out)do { int val_ret = 0; val_ret = xlator_option_reconf_uint32 (
(*__glusterfs_this_location()), options, "brick-gid", &(gid
)); if (val_ret) goto out; } while (0)
;
4136 posix_set_owner (this, uid, gid);
4137
4138 GF_OPTION_RECONF ("linux-aio", priv->aio_configured,do { int val_ret = 0; val_ret = xlator_option_reconf_bool ((*
__glusterfs_this_location()), options, "linux-aio", &(priv
->aio_configured)); if (val_ret) goto out; } while (0)
4139 options, bool, out)do { int val_ret = 0; val_ret = xlator_option_reconf_bool ((*
__glusterfs_this_location()), options, "linux-aio", &(priv
->aio_configured)); if (val_ret) goto out; } while (0)
;
4140
4141 if (priv->aio_configured)
4142 posix_aio_on (this);
4143 else
4144 posix_aio_off (this);
4145
4146 GF_OPTION_RECONF ("node-uuid-pathinfo", priv->node_uuid_pathinfo,do { int val_ret = 0; val_ret = xlator_option_reconf_bool ((*
__glusterfs_this_location()), options, "node-uuid-pathinfo", &
(priv->node_uuid_pathinfo)); if (val_ret) goto out; } while
(0)
4147 options, bool, out)do { int val_ret = 0; val_ret = xlator_option_reconf_bool ((*
__glusterfs_this_location()), options, "node-uuid-pathinfo", &
(priv->node_uuid_pathinfo)); if (val_ret) goto out; } while
(0)
;
4148
4149 if (priv->node_uuid_pathinfo &&
4150 (uuid_is_null (priv->glusterd_uuid))) {
4151 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("glusterd uuid is NULL, pathinfo xattr would"
" fallback to <hostname>:<export>"); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4153, GF_LOG_INFO
, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"
); } while (0)
4152 "glusterd uuid is NULL, pathinfo xattr would"do { do { if (0) printf ("glusterd uuid is NULL, pathinfo xattr would"
" fallback to <hostname>:<export>"); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4153, GF_LOG_INFO
, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"
); } while (0)
4153 " fallback to <hostname>:<export>")do { do { if (0) printf ("glusterd uuid is NULL, pathinfo xattr would"
" fallback to <hostname>:<export>"); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4153, GF_LOG_INFO
, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"
); } while (0)
;
4154 }
4155
4156 ret = 0;
4157out:
4158 return ret;
4159}
4160
4161
4162/**
4163 * init -
4164 */
4165int
4166init (xlator_t *this)
4167{
4168 struct posix_private *_private = NULL((void*)0);
4169 data_t *dir_data = NULL((void*)0);
4170 data_t *tmp_data = NULL((void*)0);
4171 struct stat buf = {0,};
4172 gf_boolean_t tmp_bool = 0;
4173 int dict_ret = 0;
4174 int ret = 0;
4175 int op_ret = -1;
4176 ssize_t size = -1;
4177 int32_t janitor_sleep = 0;
4178 uuid_t old_uuid = {0,};
4179 uuid_t dict_uuid = {0,};
4180 uuid_t gfid = {0,};
4181 uuid_t rootgfid = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
4182 char *guuid = NULL((void*)0);
4183 uid_t uid = -1;
4184 gid_t gid = -1;
4185
4186 dir_data = dict_get (this->options, "directory");
4187
4188 if (this->children) {
4189 gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("FATAL: storage/posix cannot have subvolumes"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4190, GF_LOG_CRITICAL, "FATAL: storage/posix cannot have subvolumes"
); } while (0)
4190 "FATAL: storage/posix cannot have subvolumes")do { do { if (0) printf ("FATAL: storage/posix cannot have subvolumes"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4190, GF_LOG_CRITICAL, "FATAL: storage/posix cannot have subvolumes"
); } while (0)
;
4191 ret = -1;
4192 goto out;
4193 }
4194
4195 if (!this->parents) {
4196 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Volume is dangling. Please check the volume file."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4197, GF_LOG_WARNING, "Volume is dangling. Please check the volume file."
); } while (0)
4197 "Volume is dangling. Please check the volume file.")do { do { if (0) printf ("Volume is dangling. Please check the volume file."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4197, GF_LOG_WARNING, "Volume is dangling. Please check the volume file."
); } while (0)
;
4198 }
4199
4200 if (!dir_data) {
4201 gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Export directory not specified in volume file."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4202, GF_LOG_CRITICAL, "Export directory not specified in volume file."
); } while (0)
4202 "Export directory not specified in volume file.")do { do { if (0) printf ("Export directory not specified in volume file."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4202, GF_LOG_CRITICAL, "Export directory not specified in volume file."
); } while (0)
;
4203 ret = -1;
4204 goto out;
4205 }
4206
4207 umask (000); // umask `masking' is done at the client side
4208
4209 /* Check whether the specified directory exists, if not log it. */
4210 op_ret = stat (dir_data->data, &buf);
4211 if ((op_ret != 0) || !S_ISDIR (buf.st_mode)((((buf.st_mode)) & 0170000) == (0040000))) {
4212 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Directory '%s' doesn't exist, exiting."
, dir_data->data); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4214, GF_LOG_ERROR, "Directory '%s' doesn't exist, exiting."
, dir_data->data); } while (0)
4213 "Directory '%s' doesn't exist, exiting.",do { do { if (0) printf ("Directory '%s' doesn't exist, exiting."
, dir_data->data); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4214, GF_LOG_ERROR, "Directory '%s' doesn't exist, exiting."
, dir_data->data); } while (0)
4214 dir_data->data)do { do { if (0) printf ("Directory '%s' doesn't exist, exiting."
, dir_data->data); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4214, GF_LOG_ERROR, "Directory '%s' doesn't exist, exiting."
, dir_data->data); } while (0)
;
4215 ret = -1;
4216 goto out;
4217 }
4218
4219 /* Check for Extended attribute support, if not present, log it */
4220 op_ret = sys_lsetxattr (dir_data->data,
4221 "trusted.glusterfs.test", "working", 8, 0);
4222 if (op_ret == 0) {
4223 sys_lremovexattr (dir_data->data, "trusted.glusterfs.test");
4224 } else {
4225 tmp_data = dict_get (this->options,
4226 "mandate-attribute");
4227 if (tmp_data) {
4228 if (gf_string2boolean (tmp_data->data,
4229 &tmp_bool) == -1) {
4230 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("wrong option provided for key " "\"mandate-attribute\""
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4232, GF_LOG_ERROR, "wrong option provided for key " "\"mandate-attribute\""
); } while (0)
4231 "wrong option provided for key "do { do { if (0) printf ("wrong option provided for key " "\"mandate-attribute\""
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4232, GF_LOG_ERROR, "wrong option provided for key " "\"mandate-attribute\""
); } while (0)
4232 "\"mandate-attribute\"")do { do { if (0) printf ("wrong option provided for key " "\"mandate-attribute\""
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4232, GF_LOG_ERROR, "wrong option provided for key " "\"mandate-attribute\""
); } while (0)
;
4233 ret = -1;
4234 goto out;
4235 }
4236 if (!tmp_bool) {
4237 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Extended attribute not supported, "
"starting as per option"); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4239, GF_LOG_WARNING, "Extended attribute not supported, "
"starting as per option"); } while (0)
4238 "Extended attribute not supported, "do { do { if (0) printf ("Extended attribute not supported, "
"starting as per option"); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4239, GF_LOG_WARNING, "Extended attribute not supported, "
"starting as per option"); } while (0)
4239 "starting as per option")do { do { if (0) printf ("Extended attribute not supported, "
"starting as per option"); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4239, GF_LOG_WARNING, "Extended attribute not supported, "
"starting as per option"); } while (0)
;
4240 } else {
4241 gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Extended attribute not supported, "
"exiting."); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4243, GF_LOG_CRITICAL, "Extended attribute not supported, "
"exiting."); } while (0)
4242 "Extended attribute not supported, "do { do { if (0) printf ("Extended attribute not supported, "
"exiting."); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4243, GF_LOG_CRITICAL, "Extended attribute not supported, "
"exiting."); } while (0)
4243 "exiting.")do { do { if (0) printf ("Extended attribute not supported, "
"exiting."); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4243, GF_LOG_CRITICAL, "Extended attribute not supported, "
"exiting."); } while (0)
;
4244 ret = -1;
4245 goto out;
4246 }
4247 } else {
4248 gf_log (this->name, GF_LOG_CRITICAL,do { do { if (0) printf ("Extended attribute not supported, exiting."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4249, GF_LOG_CRITICAL, "Extended attribute not supported, exiting."
); } while (0)
4249 "Extended attribute not supported, exiting.")do { do { if (0) printf ("Extended attribute not supported, exiting."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4249, GF_LOG_CRITICAL, "Extended attribute not supported, exiting."
); } while (0)
;
4250 ret = -1;
4251 goto out;
4252 }
4253 }
4254
4255 tmp_data = dict_get (this->options, "volume-id");
4256 if (tmp_data) {
4257 op_ret = uuid_parse (tmp_data->data, dict_uuid);
4258 if (op_ret < 0) {
4259 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("wrong volume-id (%s) set in volume file"
, tmp_data->data); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4261, GF_LOG_ERROR, "wrong volume-id (%s) set in volume file"
, tmp_data->data); } while (0)
4260 "wrong volume-id (%s) set in volume file",do { do { if (0) printf ("wrong volume-id (%s) set in volume file"
, tmp_data->data); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4261, GF_LOG_ERROR, "wrong volume-id (%s) set in volume file"
, tmp_data->data); } while (0)
4261 tmp_data->data)do { do { if (0) printf ("wrong volume-id (%s) set in volume file"
, tmp_data->data); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4261, GF_LOG_ERROR, "wrong volume-id (%s) set in volume file"
, tmp_data->data); } while (0)
;
4262 ret = -1;
4263 goto out;
4264 }
4265 size = sys_lgetxattr (dir_data->data,
4266 "trusted.glusterfs.volume-id", old_uuid, 16);
4267 if (size == 16) {
4268 if (uuid_compare (old_uuid, dict_uuid)) {
4269 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4272, GF_LOG_ERROR, "mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0)
4270 "mismatching volume-id (%s) received. "do { do { if (0) printf ("mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4272, GF_LOG_ERROR, "mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0)
4271 "already is a part of volume %s ",do { do { if (0) printf ("mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4272, GF_LOG_ERROR, "mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0)
4272 tmp_data->data, uuid_utoa (old_uuid))do { do { if (0) printf ("mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0); _gf_log (this->name, "posix.c",
__FUNCTION__, 4272, GF_LOG_ERROR, "mismatching volume-id (%s) received. "
"already is a part of volume %s ", tmp_data->data, uuid_utoa
(old_uuid)); } while (0)
;
4273 ret = -1;
4274 goto out;
4275 }
4276 } else if ((size == -1) && (errno(*__errno_location ()) == ENODATA61)) {
4277
4278 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Extended attribute trusted.glusterfs."
"volume-id is absent"); } while (0); _gf_log (this->name,
"posix.c", __FUNCTION__, 4280, GF_LOG_ERROR, "Extended attribute trusted.glusterfs."
"volume-id is absent"); } while (0)
4279 "Extended attribute trusted.glusterfs."do { do { if (0) printf ("Extended attribute trusted.glusterfs."
"volume-id is absent"); } while (0); _gf_log (this->name,
"posix.c", __FUNCTION__, 4280, GF_LOG_ERROR, "Extended attribute trusted.glusterfs."
"volume-id is absent"); } while (0)
4280 "volume-id is absent")do { do { if (0) printf ("Extended attribute trusted.glusterfs."
"volume-id is absent"); } while (0); _gf_log (this->name,
"posix.c", __FUNCTION__, 4280, GF_LOG_ERROR, "Extended attribute trusted.glusterfs."
"volume-id is absent"); } while (0)
;
4281 ret = -1;
4282 goto out;
4283
4284 } else if ((size == -1) && (errno(*__errno_location ()) != ENODATA61)) {
4285 /* Wrong 'volume-id' is set, it should be error */
4286 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to fetch volume-id (%s)"
, dir_data->data, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4288, GF_LOG_WARNING
, "%s: failed to fetch volume-id (%s)", dir_data->data, strerror
((*__errno_location ()))); } while (0)
4287 "%s: failed to fetch volume-id (%s)",do { do { if (0) printf ("%s: failed to fetch volume-id (%s)"
, dir_data->data, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4288, GF_LOG_WARNING
, "%s: failed to fetch volume-id (%s)", dir_data->data, strerror
((*__errno_location ()))); } while (0)
4288 dir_data->data, strerror (errno))do { do { if (0) printf ("%s: failed to fetch volume-id (%s)"
, dir_data->data, strerror ((*__errno_location ()))); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4288, GF_LOG_WARNING
, "%s: failed to fetch volume-id (%s)", dir_data->data, strerror
((*__errno_location ()))); } while (0)
;
4289 ret = -1;
4290 goto out;
4291 } else {
4292 ret = -1;
4293 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("failed to fetch proper volume id from export"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4294, GF_LOG_ERROR, "failed to fetch proper volume id from export"
); } while (0)
4294 "failed to fetch proper volume id from export")do { do { if (0) printf ("failed to fetch proper volume id from export"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4294, GF_LOG_ERROR, "failed to fetch proper volume id from export"
); } while (0)
;
4295 goto out;
4296 }
4297 }
4298
4299 /* Now check if the export directory has some other 'gfid',
4300 other than that of root '/' */
4301 size = sys_lgetxattr (dir_data->data, "trusted.gfid", gfid, 16);
4302 if (size == 16) {
4303 if (!__is_root_gfid (gfid)) {
4304 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: gfid (%s) is not that of glusterfs '/' "
, dir_data->data, uuid_utoa (gfid)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 4306, GF_LOG_WARNING,
"%s: gfid (%s) is not that of glusterfs '/' ", dir_data->
data, uuid_utoa (gfid)); } while (0)
4305 "%s: gfid (%s) is not that of glusterfs '/' ",do { do { if (0) printf ("%s: gfid (%s) is not that of glusterfs '/' "
, dir_data->data, uuid_utoa (gfid)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 4306, GF_LOG_WARNING,
"%s: gfid (%s) is not that of glusterfs '/' ", dir_data->
data, uuid_utoa (gfid)); } while (0)
4306 dir_data->data, uuid_utoa (gfid))do { do { if (0) printf ("%s: gfid (%s) is not that of glusterfs '/' "
, dir_data->data, uuid_utoa (gfid)); } while (0); _gf_log (
this->name, "posix.c", __FUNCTION__, 4306, GF_LOG_WARNING,
"%s: gfid (%s) is not that of glusterfs '/' ", dir_data->
data, uuid_utoa (gfid)); } while (0)
;
4307 ret = -1;
4308 goto out;
4309 }
4310 } else if (size != -1) {
4311 /* Wrong 'gfid' is set, it should be error */
4312 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: wrong value set as gfid", dir_data
->data); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4314, GF_LOG_WARNING, "%s: wrong value set as gfid", dir_data
->data); } while (0)
4313 "%s: wrong value set as gfid",do { do { if (0) printf ("%s: wrong value set as gfid", dir_data
->data); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4314, GF_LOG_WARNING, "%s: wrong value set as gfid", dir_data
->data); } while (0)
4314 dir_data->data)do { do { if (0) printf ("%s: wrong value set as gfid", dir_data
->data); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4314, GF_LOG_WARNING, "%s: wrong value set as gfid", dir_data
->data); } while (0)
;
4315 ret = -1;
4316 goto out;
4317 } else if ((size == -1) && (errno(*__errno_location ()) != ENODATA61)) {
4318 /* Wrong 'gfid' is set, it should be error */
4319 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("%s: failed to fetch gfid (%s)", dir_data
->data, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4321, GF_LOG_WARNING
, "%s: failed to fetch gfid (%s)", dir_data->data, strerror
((*__errno_location ()))); } while (0)
4320 "%s: failed to fetch gfid (%s)",do { do { if (0) printf ("%s: failed to fetch gfid (%s)", dir_data
->data, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4321, GF_LOG_WARNING
, "%s: failed to fetch gfid (%s)", dir_data->data, strerror
((*__errno_location ()))); } while (0)
4321 dir_data->data, strerror (errno))do { do { if (0) printf ("%s: failed to fetch gfid (%s)", dir_data
->data, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4321, GF_LOG_WARNING
, "%s: failed to fetch gfid (%s)", dir_data->data, strerror
((*__errno_location ()))); } while (0)
;
4322 ret = -1;
4323 goto out;
4324 } else {
4325 /* First time volume, set the GFID */
4326 size = sys_lsetxattr (dir_data->data, "trusted.gfid", rootgfid,
4327 16, XATTR_CREATEXATTR_CREATE);
4328 if (size) {
4329 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("%s: failed to set gfid (%s)", dir_data
->data, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4331, GF_LOG_ERROR,
"%s: failed to set gfid (%s)", dir_data->data, strerror (
(*__errno_location ()))); } while (0)
4330 "%s: failed to set gfid (%s)",do { do { if (0) printf ("%s: failed to set gfid (%s)", dir_data
->data, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4331, GF_LOG_ERROR,
"%s: failed to set gfid (%s)", dir_data->data, strerror (
(*__errno_location ()))); } while (0)
4331 dir_data->data, strerror (errno))do { do { if (0) printf ("%s: failed to set gfid (%s)", dir_data
->data, strerror ((*__errno_location ()))); } while (0); _gf_log
(this->name, "posix.c", __FUNCTION__, 4331, GF_LOG_ERROR,
"%s: failed to set gfid (%s)", dir_data->data, strerror (
(*__errno_location ()))); } while (0)
;
4332 ret = -1;
4333 goto out;
4334 }
4335 }
4336
4337 size = sys_lgetxattr (dir_data->data, "system.posix_acl_access",
4338 NULL((void*)0), 0);
4339 if ((size < 0) && (errno(*__errno_location ()) == ENOTSUP95))
4340 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Posix access control list is not supported."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4341, GF_LOG_WARNING, "Posix access control list is not supported."
); } while (0)
4341 "Posix access control list is not supported.")do { do { if (0) printf ("Posix access control list is not supported."
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4341, GF_LOG_WARNING, "Posix access control list is not supported."
); } while (0)
;
4342
4343 ret = 0;
4344 _private = GF_CALLOC (1, sizeof (*_private),__gf_calloc (1, sizeof (*_private), gf_posix_mt_posix_private
)
4345 gf_posix_mt_posix_private)__gf_calloc (1, sizeof (*_private), gf_posix_mt_posix_private
)
;
4346 if (!_private) {
4347 ret = -1;
4348 goto out;
4349 }
4350
4351 _private->base_path = gf_strdup (dir_data->data);
4352 _private->base_path_length = strlen (_private->base_path);
4353
4354 LOCK_INIT (&_private->lock)pthread_spin_init (&_private->lock, 0);
4355
4356 ret = dict_get_str (this->options, "hostname", &_private->hostname);
4357 if (ret) {
4358 _private->hostname = GF_CALLOC (256, sizeof (char),__gf_calloc (256, sizeof (char), gf_common_mt_char)
4359 gf_common_mt_char)__gf_calloc (256, sizeof (char), gf_common_mt_char);
4360 if (!_private->hostname) {
4361 goto out;
4362 }
4363 ret = gethostname (_private->hostname, 256);
4364 if (ret < 0) {
4365 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("could not find hostname (%s)", strerror
((*__errno_location ()))); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4366, GF_LOG_WARNING, "could not find hostname (%s)"
, strerror ((*__errno_location ()))); } while (0)
4366 "could not find hostname (%s)", strerror (errno))do { do { if (0) printf ("could not find hostname (%s)", strerror
((*__errno_location ()))); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4366, GF_LOG_WARNING, "could not find hostname (%s)"
, strerror ((*__errno_location ()))); } while (0)
;
4367 }
4368 }
4369
4370 _private->export_statfs = 1;
4371 tmp_data = dict_get (this->options, "export-statfs-size");
4372 if (tmp_data) {
4373 if (gf_string2boolean (tmp_data->data,
4374 &_private->export_statfs) == -1) {
4375 ret = -1;
4376 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("'export-statfs-size' takes only boolean "
"options"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4378, GF_LOG_ERROR, "'export-statfs-size' takes only boolean "
"options"); } while (0)
4377 "'export-statfs-size' takes only boolean "do { do { if (0) printf ("'export-statfs-size' takes only boolean "
"options"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4378, GF_LOG_ERROR, "'export-statfs-size' takes only boolean "
"options"); } while (0)
4378 "options")do { do { if (0) printf ("'export-statfs-size' takes only boolean "
"options"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4378, GF_LOG_ERROR, "'export-statfs-size' takes only boolean "
"options"); } while (0)
;
4379 goto out;
4380 }
4381 if (!_private->export_statfs)
4382 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("'statfs()' returns dummy size"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4383, GF_LOG_DEBUG
, "'statfs()' returns dummy size"); } while (0)
4383 "'statfs()' returns dummy size")do { do { if (0) printf ("'statfs()' returns dummy size"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4383, GF_LOG_DEBUG
, "'statfs()' returns dummy size"); } while (0)
;
4384 }
4385
4386 _private->background_unlink = 0;
4387 tmp_data = dict_get (this->options, "background-unlink");
4388 if (tmp_data) {
4389 if (gf_string2boolean (tmp_data->data,
4390 &_private->background_unlink) == -1) {
4391 ret = -1;
4392 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("'background-unlink' takes only boolean "
"options"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4394, GF_LOG_ERROR, "'background-unlink' takes only boolean "
"options"); } while (0)
4393 "'background-unlink' takes only boolean "do { do { if (0) printf ("'background-unlink' takes only boolean "
"options"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4394, GF_LOG_ERROR, "'background-unlink' takes only boolean "
"options"); } while (0)
4394 "options")do { do { if (0) printf ("'background-unlink' takes only boolean "
"options"); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4394, GF_LOG_ERROR, "'background-unlink' takes only boolean "
"options"); } while (0)
;
4395 goto out;
4396 }
4397
4398 if (_private->background_unlink)
4399 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("unlinks will be performed in background"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4400, GF_LOG_DEBUG, "unlinks will be performed in background"
); } while (0)
4400 "unlinks will be performed in background")do { do { if (0) printf ("unlinks will be performed in background"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4400, GF_LOG_DEBUG, "unlinks will be performed in background"
); } while (0)
;
4401 }
4402
4403 tmp_data = dict_get (this->options, "o-direct");
4404 if (tmp_data) {
4405 if (gf_string2boolean (tmp_data->data,
4406 &_private->o_direct) == -1) {
4407 ret = -1;
4408 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("wrong option provided for 'o-direct'"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4409, GF_LOG_ERROR, "wrong option provided for 'o-direct'")
; } while (0)
4409 "wrong option provided for 'o-direct'")do { do { if (0) printf ("wrong option provided for 'o-direct'"
); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4409, GF_LOG_ERROR, "wrong option provided for 'o-direct'")
; } while (0)
;
4410 goto out;
4411 }
4412 if (_private->o_direct)
4413 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("o-direct mode is enabled (O_DIRECT "
"for every open)"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4415, GF_LOG_DEBUG, "o-direct mode is enabled (O_DIRECT "
"for every open)"); } while (0)
4414 "o-direct mode is enabled (O_DIRECT "do { do { if (0) printf ("o-direct mode is enabled (O_DIRECT "
"for every open)"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4415, GF_LOG_DEBUG, "o-direct mode is enabled (O_DIRECT "
"for every open)"); } while (0)
4415 "for every open)")do { do { if (0) printf ("o-direct mode is enabled (O_DIRECT "
"for every open)"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4415, GF_LOG_DEBUG, "o-direct mode is enabled (O_DIRECT "
"for every open)"); } while (0)
;
4416 }
4417
4418 ret = dict_get_str (this->options, "glusterd-uuid", &guuid);
4419 if (!ret) {
4420 if (uuid_parse (guuid, _private->glusterd_uuid))
4421 gf_log (this->name, GF_LOG_WARNING, "Cannot parse "do { do { if (0) printf ("Cannot parse " "glusterd (node) UUID, node-uuid xattr "
"request would return - \"No such attribute\""); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4423, GF_LOG_WARNING
, "Cannot parse " "glusterd (node) UUID, node-uuid xattr " "request would return - \"No such attribute\""
); } while (0)
4422 "glusterd (node) UUID, node-uuid xattr "do { do { if (0) printf ("Cannot parse " "glusterd (node) UUID, node-uuid xattr "
"request would return - \"No such attribute\""); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4423, GF_LOG_WARNING
, "Cannot parse " "glusterd (node) UUID, node-uuid xattr " "request would return - \"No such attribute\""
); } while (0)
4423 "request would return - \"No such attribute\"")do { do { if (0) printf ("Cannot parse " "glusterd (node) UUID, node-uuid xattr "
"request would return - \"No such attribute\""); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4423, GF_LOG_WARNING
, "Cannot parse " "glusterd (node) UUID, node-uuid xattr " "request would return - \"No such attribute\""
); } while (0)
;
4424 } else {
4425 gf_log (this->name, GF_LOG_DEBUG, "No glusterd (node) UUID "do { do { if (0) printf ("No glusterd (node) UUID " "passed - node-uuid xattr request will return "
"\"No such attribute\""); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4427, GF_LOG_DEBUG, "No glusterd (node) UUID "
"passed - node-uuid xattr request will return " "\"No such attribute\""
); } while (0)
4426 "passed - node-uuid xattr request will return "do { do { if (0) printf ("No glusterd (node) UUID " "passed - node-uuid xattr request will return "
"\"No such attribute\""); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4427, GF_LOG_DEBUG, "No glusterd (node) UUID "
"passed - node-uuid xattr request will return " "\"No such attribute\""
); } while (0)
4427 "\"No such attribute\"")do { do { if (0) printf ("No glusterd (node) UUID " "passed - node-uuid xattr request will return "
"\"No such attribute\""); } while (0); _gf_log (this->name
, "posix.c", __FUNCTION__, 4427, GF_LOG_DEBUG, "No glusterd (node) UUID "
"passed - node-uuid xattr request will return " "\"No such attribute\""
); } while (0)
;
4428 }
4429 ret = 0;
4430
4431 _private->janitor_sleep_duration = 600;
4432
4433 dict_ret = dict_get_int32 (this->options, "janitor-sleep-duration",
4434 &janitor_sleep);
4435 if (dict_ret == 0) {
4436 gf_log (this->name, GF_LOG_DEBUG,do { do { if (0) printf ("Setting janitor sleep duration to %d."
, janitor_sleep); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4438, GF_LOG_DEBUG, "Setting janitor sleep duration to %d."
, janitor_sleep); } while (0)
4437 "Setting janitor sleep duration to %d.",do { do { if (0) printf ("Setting janitor sleep duration to %d."
, janitor_sleep); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4438, GF_LOG_DEBUG, "Setting janitor sleep duration to %d."
, janitor_sleep); } while (0)
4438 janitor_sleep)do { do { if (0) printf ("Setting janitor sleep duration to %d."
, janitor_sleep); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4438, GF_LOG_DEBUG, "Setting janitor sleep duration to %d."
, janitor_sleep); } while (0)
;
4439
4440 _private->janitor_sleep_duration = janitor_sleep;
4441 }
4442 /* performing open dir on brick dir locks the brick dir
4443 * and prevents it from being unmounted
4444 */
4445 _private->mount_lock = opendir (dir_data->data);
4446 if (!_private->mount_lock) {
4447 ret = -1;
4448 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Could not lock brick directory"); }
while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 4449
, GF_LOG_ERROR, "Could not lock brick directory"); } while (0
)
4449 "Could not lock brick directory")do { do { if (0) printf ("Could not lock brick directory"); }
while (0); _gf_log (this->name, "posix.c", __FUNCTION__, 4449
, GF_LOG_ERROR, "Could not lock brick directory"); } while (0
)
;
4450 goto out;
4451 }
4452#ifndef GF_DARWIN_HOST_OS
4453 {
4454 struct rlimit lim;
4455 lim.rlim_cur = 1048576;
4456 lim.rlim_max = 1048576;
4457
4458 if (setrlimit (RLIMIT_NOFILERLIMIT_NOFILE, &lim) == -1) {
4459 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Failed to set 'ulimit -n " " 1048576': %s"
, strerror((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 4461, GF_LOG_WARNING, "Failed to set 'ulimit -n "
" 1048576': %s", strerror((*__errno_location ()))); } while (
0)
4460 "Failed to set 'ulimit -n "do { do { if (0) printf ("Failed to set 'ulimit -n " " 1048576': %s"
, strerror((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 4461, GF_LOG_WARNING, "Failed to set 'ulimit -n "
" 1048576': %s", strerror((*__errno_location ()))); } while (
0)
4461 " 1048576': %s", strerror(errno))do { do { if (0) printf ("Failed to set 'ulimit -n " " 1048576': %s"
, strerror((*__errno_location ()))); } while (0); _gf_log (this
->name, "posix.c", __FUNCTION__, 4461, GF_LOG_WARNING, "Failed to set 'ulimit -n "
" 1048576': %s", strerror((*__errno_location ()))); } while (
0)
;
4462 lim.rlim_cur = 65536;
4463 lim.rlim_max = 65536;
4464
4465 if (setrlimit (RLIMIT_NOFILERLIMIT_NOFILE, &lim) == -1) {
4466 gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4469, GF_LOG_WARNING, "Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0)
4467 "Failed to set maximum allowed open "do { do { if (0) printf ("Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4469, GF_LOG_WARNING, "Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0)
4468 "file descriptors to 64k: %s",do { do { if (0) printf ("Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4469, GF_LOG_WARNING, "Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0)
4469 strerror(errno))do { do { if (0) printf ("Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0); _gf_log (this->name, "posix.c", __FUNCTION__
, 4469, GF_LOG_WARNING, "Failed to set maximum allowed open "
"file descriptors to 64k: %s", strerror((*__errno_location (
)))); } while (0)
;
4470 }
4471 else {
4472 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("Maximum allowed open file descriptors "
"set to 65536"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4474, GF_LOG_INFO, "Maximum allowed open file descriptors "
"set to 65536"); } while (0)
4473 "Maximum allowed open file descriptors "do { do { if (0) printf ("Maximum allowed open file descriptors "
"set to 65536"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4474, GF_LOG_INFO, "Maximum allowed open file descriptors "
"set to 65536"); } while (0)
4474 "set to 65536")do { do { if (0) printf ("Maximum allowed open file descriptors "
"set to 65536"); } while (0); _gf_log (this->name, "posix.c"
, __FUNCTION__, 4474, GF_LOG_INFO, "Maximum allowed open file descriptors "
"set to 65536"); } while (0)
;
4475 }
4476 }
4477 }
4478#endif
4479 this->private = (void *)_private;
4480
4481 op_ret = posix_handle_init (this);
4482 if (op_ret == -1) {
4483 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Posix handle setup failed"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4484, GF_LOG_ERROR
, "Posix handle setup failed"); } while (0)
4484 "Posix handle setup failed")do { do { if (0) printf ("Posix handle setup failed"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4484, GF_LOG_ERROR
, "Posix handle setup failed"); } while (0)
;
4485 ret = -1;
4486 goto out;
4487 }
4488
4489 op_ret = posix_handle_trash_init (this);
4490 if (op_ret < 0) {
4491 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Posix landfill setup failed"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4492, GF_LOG_ERROR
, "Posix landfill setup failed"); } while (0)
4492 "Posix landfill setup failed")do { do { if (0) printf ("Posix landfill setup failed"); } while
(0); _gf_log (this->name, "posix.c", __FUNCTION__, 4492, GF_LOG_ERROR
, "Posix landfill setup failed"); } while (0)
;
4493 ret = -1;
4494 goto out;
4495 }
4496
4497 _private->aio_init_done = _gf_false;
4498 _private->aio_capable = _gf_false;
4499
4500 GF_OPTION_INIT ("brick-uid", uid, uint32, out)do { int val_ret = 0; val_ret = xlator_option_init_uint32 ((*
__glusterfs_this_location()), (*__glusterfs_this_location())->
options, "brick-uid", &(uid)); if (val_ret) goto out; } while
(0)
;
4501 GF_OPTION_INIT ("brick-gid", gid, uint32, out)do { int val_ret = 0; val_ret = xlator_option_init_uint32 ((*
__glusterfs_this_location()), (*__glusterfs_this_location())->
options, "brick-gid", &(gid)); if (val_ret) goto out; } while
(0)
;
4502 posix_set_owner (this, uid, gid);
4503
4504 GF_OPTION_INIT ("linux-aio", _private->aio_configured, bool, out)do { int val_ret = 0; val_ret = xlator_option_init_bool ((*__glusterfs_this_location
()), (*__glusterfs_this_location())->options, "linux-aio",
&(_private->aio_configured)); if (val_ret) goto out; }
while (0)
;
4505
4506 if (_private->aio_configured) {
4507 op_ret = posix_aio_on (this);
4508
4509 if (op_ret == -1) {
4510 gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("Posix AIO init failed"); } while (0
); _gf_log (this->name, "posix.c", __FUNCTION__, 4511, GF_LOG_ERROR
, "Posix AIO init failed"); } while (0)
4511 "Posix AIO init failed")do { do { if (0) printf ("Posix AIO init failed"); } while (0
); _gf_log (this->name, "posix.c", __FUNCTION__, 4511, GF_LOG_ERROR
, "Posix AIO init failed"); } while (0)
;
4512 ret = -1;
4513 goto out;
4514 }
4515 }
4516
4517 GF_OPTION_INIT ("node-uuid-pathinfo",do { int val_ret = 0; val_ret = xlator_option_init_bool ((*__glusterfs_this_location
()), (*__glusterfs_this_location())->options, "node-uuid-pathinfo"
, &(_private->node_uuid_pathinfo)); if (val_ret) goto out
; } while (0)
4518 _private->node_uuid_pathinfo, bool, out)do { int val_ret = 0; val_ret = xlator_option_init_bool ((*__glusterfs_this_location
()), (*__glusterfs_this_location())->options, "node-uuid-pathinfo"
, &(_private->node_uuid_pathinfo)); if (val_ret) goto out
; } while (0)
;
4519 if (_private->node_uuid_pathinfo &&
4520 (uuid_is_null (_private->glusterd_uuid))) {
4521 gf_log (this->name, GF_LOG_INFO,do { do { if (0) printf ("glusterd uuid is NULL, pathinfo xattr would"
" fallback to <hostname>:<export>"); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4523, GF_LOG_INFO
, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"
); } while (0)
4522 "glusterd uuid is NULL, pathinfo xattr would"do { do { if (0) printf ("glusterd uuid is NULL, pathinfo xattr would"
" fallback to <hostname>:<export>"); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4523, GF_LOG_INFO
, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"
); } while (0)
4523 " fallback to <hostname>:<export>")do { do { if (0) printf ("glusterd uuid is NULL, pathinfo xattr would"
" fallback to <hostname>:<export>"); } while (0)
; _gf_log (this->name, "posix.c", __FUNCTION__, 4523, GF_LOG_INFO
, "glusterd uuid is NULL, pathinfo xattr would" " fallback to <hostname>:<export>"
); } while (0)
;
4524 }
4525
4526 pthread_mutex_init (&_private->janitor_lock, NULL((void*)0));
4527 pthread_cond_init (&_private->janitor_cond, NULL((void*)0));
4528 INIT_LIST_HEAD (&_private->janitor_fds)do { (&_private->janitor_fds)->next = (&_private
->janitor_fds)->prev = &_private->janitor_fds; }
while (0)
;
4529
4530 posix_spawn_janitor_thread (this);
4531out:
4532 return ret;
4533}
4534
4535void
4536fini (xlator_t *this)
4537{
4538 struct posix_private *priv = this->private;
4539 if (!priv)
4540 return;
4541 this->private = NULL((void*)0);
4542 /*unlock brick dir*/
4543 if (priv->mount_lock)
4544 closedir (priv->mount_lock);
4545 GF_FREE (priv)__gf_free (priv);
4546 return;
4547}
4548
4549struct xlator_dumpops dumpops = {
4550 .priv = posix_priv,
4551 .inode = posix_inode,
4552};
4553
4554struct xlator_fops fops = {
4555 .lookup = posix_lookup,
4556 .stat = posix_stat,
4557 .opendir = posix_opendir,
4558 .readdir = posix_readdir,
4559 .readdirp = posix_readdirp,
4560 .readlink = posix_readlink,
4561 .mknod = posix_mknod,
4562 .mkdir = posix_mkdir,
4563 .unlink = posix_unlink,
4564 .rmdir = posix_rmdir,
4565 .symlink = posix_symlink,
4566 .rename = posix_rename,
4567 .link = posix_link,
4568 .truncate = posix_truncate,
4569 .create = posix_create,
4570 .open = posix_open,
4571 .readv = posix_readv,
4572 .writev = posix_writev,
4573 .statfs = posix_statfs,
4574 .flush = posix_flush,
4575 .fsync = posix_fsync,
4576 .setxattr = posix_setxattr,
4577 .fsetxattr = posix_fsetxattr,
4578 .getxattr = posix_getxattr,
4579 .fgetxattr = posix_fgetxattr,
4580 .removexattr = posix_removexattr,
4581 .fremovexattr = posix_fremovexattr,
4582 .fsyncdir = posix_fsyncdir,
4583 .access = posix_access,
4584 .ftruncate = posix_ftruncate,
4585 .fstat = posix_fstat,
4586 .lk = posix_lk,
4587 .inodelk = posix_inodelk,
4588 .finodelk = posix_finodelk,
4589 .entrylk = posix_entrylk,
4590 .fentrylk = posix_fentrylk,
4591 .rchecksum = posix_rchecksum,
4592 .xattrop = posix_xattrop,
4593 .fxattrop = posix_fxattrop,
4594 .setattr = posix_setattr,
4595 .fsetattr = posix_fsetattr,
4596};
4597
4598struct xlator_cbks cbks = {
4599 .release = posix_release,
4600 .releasedir = posix_releasedir,
4601 .forget = posix_forget
4602};
4603
4604struct volume_options options[] = {
4605 { .key = {"o-direct"},
4606 .type = GF_OPTION_TYPE_BOOL },
4607 { .key = {"directory"},
4608 .type = GF_OPTION_TYPE_PATH },
4609 { .key = {"hostname"},
4610 .type = GF_OPTION_TYPE_ANY },
4611 { .key = {"export-statfs-size"},
4612 .type = GF_OPTION_TYPE_BOOL },
4613 { .key = {"mandate-attribute"},
4614 .type = GF_OPTION_TYPE_BOOL },
4615 { .key = {"background-unlink"},
4616 .type = GF_OPTION_TYPE_BOOL },
4617 { .key = {"janitor-sleep-duration"},
4618 .type = GF_OPTION_TYPE_INT },
4619 { .key = {"volume-id"},
4620 .type = GF_OPTION_TYPE_ANY },
4621 { .key = {"glusterd-uuid"},
4622 .type = GF_OPTION_TYPE_STR },
4623 {
4624 .key = {"linux-aio"},
4625 .type = GF_OPTION_TYPE_BOOL,
4626 .default_value = "off",
4627 .description = "Support for native Linux AIO"
4628 },
4629 {
4630 .key = {"brick-uid"},
4631 .type = GF_OPTION_TYPE_INT,
4632 .min = 0,
4633 .validate = GF_OPT_VALIDATE_MIN,
4634 .description = "Support for setting uid of brick's owner"
4635 },
4636 {
4637 .key = {"brick-gid"},
4638 .type = GF_OPTION_TYPE_INT,
4639 .min = 0,
4640 .validate = GF_OPT_VALIDATE_MIN,
4641 .description = "Support for setting gid of brick's owner"
4642 },
4643 { .key = {"node-uuid-pathinfo"},
4644 .type = GF_OPTION_TYPE_BOOL,
4645 .default_value = "off",
4646 .description = "return glusterd's node-uuid in pathinfo xattr"
4647 " string instead of hostname"
4648 },
4649 { .key = {NULL((void*)0)} }
4650};