1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
GlusterFS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
GlusterFS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif
#include "client.h"
#include "fd.h"
clnt_fd_ctx_t *
this_fd_del_ctx (fd_t *file, xlator_t *this)
{
int dict_ret = -1;
uint64_t ctxaddr = 0;
GF_VALIDATE_OR_GOTO ("client", this, out);
GF_VALIDATE_OR_GOTO (this->name, file, out);
dict_ret = fd_ctx_del (file, this, &ctxaddr);
if (dict_ret < 0) {
ctxaddr = 0;
}
out:
return (clnt_fd_ctx_t *)(unsigned long)ctxaddr;
}
clnt_fd_ctx_t *
this_fd_get_ctx (fd_t *file, xlator_t *this)
{
int dict_ret = -1;
uint64_t ctxaddr = 0;
GF_VALIDATE_OR_GOTO ("client", this, out);
GF_VALIDATE_OR_GOTO (this->name, file, out);
dict_ret = fd_ctx_get (file, this, &ctxaddr);
if (dict_ret < 0) {
ctxaddr = 0;
}
out:
return (clnt_fd_ctx_t *)(unsigned long)ctxaddr;
}
void
this_fd_set_ctx (fd_t *file, xlator_t *this, loc_t *loc, clnt_fd_ctx_t *ctx)
{
uint64_t oldaddr = 0;
int32_t ret = -1;
GF_VALIDATE_OR_GOTO ("client", this, out);
GF_VALIDATE_OR_GOTO (this->name, file, out);
ret = fd_ctx_get (file, this, &oldaddr);
if (ret >= 0) {
gf_log (this->name, GF_LOG_DEBUG,
"%s (%"PRId64"): trying duplicate remote fd set. ",
loc->path, loc->inode->ino);
}
ret = fd_ctx_set (file, this, (uint64_t)(unsigned long)ctx);
if (ret < 0) {
gf_log (this->name, GF_LOG_DEBUG,
"%s (%"PRId64"): failed to set remote fd",
loc->path, loc->inode->ino);
}
out:
return;
}
int
client_local_wipe (clnt_local_t *local)
{
if (local) {
loc_wipe (&local->loc);
if (local->fd)
fd_unref (local->fd);
GF_FREE (local);
}
return 0;
}
|