3
#include <glusterfs/compat-errno.h>
4
#include "server-messages.h"
5
#include "server-helpers.h"
14
server4_post_readlink(gfx_readlink_rsp *rsp, struct iatt *stbuf,
17
gfx_stat_from_iattx(&rsp->buf, stbuf);
18
rsp->path = (char *)buf;
22
server4_post_common_3iatt(server_state_t *state, gfx_common_3iatt_rsp *rsp,
23
inode_t *inode, struct iatt *stbuf,
24
struct iatt *preparent, struct iatt *postparent)
26
inode_t *link_inode = NULL;
28
gfx_stat_from_iattx(&rsp->stat, stbuf);
29
if (state->client->subdir_mount &&
30
!gf_uuid_compare(preparent->ia_gfid, state->client->subdir_gfid)) {
37
static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
39
preparent->ia_ino = 1;
40
postparent->ia_ino = 1;
41
gf_uuid_copy(preparent->ia_gfid, gfid);
42
gf_uuid_copy(postparent->ia_gfid, gfid);
45
gfx_stat_from_iattx(&rsp->preparent, preparent);
46
gfx_stat_from_iattx(&rsp->postparent, postparent);
48
link_inode = inode_link(inode, state->loc.parent, state->loc.name, stbuf);
49
inode_lookup(link_inode);
50
inode_unref(link_inode);
54
server4_post_common_3iatt_noinode(gfx_common_3iatt_rsp *rsp, struct iatt *stbuf,
55
struct iatt *prebuf_dst,
56
struct iatt *postbuf_dst)
58
gfx_stat_from_iattx(&rsp->stat, stbuf);
59
gfx_stat_from_iattx(&rsp->preparent, prebuf_dst);
60
gfx_stat_from_iattx(&rsp->postparent, postbuf_dst);
64
server4_post_common_2iatt(gfx_common_2iatt_rsp *rsp, struct iatt *prebuf,
67
gfx_stat_from_iattx(&rsp->prestat, prebuf);
68
gfx_stat_from_iattx(&rsp->poststat, postbuf);
72
server4_post_entry_remove(server_state_t *state, gfx_common_2iatt_rsp *rsp,
73
struct iatt *prebuf, struct iatt *postbuf)
75
inode_unlink(state->loc.inode, state->loc.parent, state->loc.name);
80
forget_inode_if_no_dentry(state->loc.inode);
82
gfx_stat_from_iattx(&rsp->prestat, prebuf);
83
gfx_stat_from_iattx(&rsp->poststat, postbuf);
87
server4_post_statfs(gfx_statfs_rsp *rsp, struct statvfs *stbuf)
89
gf_statfs_from_statfs(&rsp->statfs, stbuf);
93
server4_post_common_iatt(server_state_t *state, gfx_common_iatt_rsp *rsp,
96
if (state->client->subdir_mount &&
97
!gf_uuid_compare(stbuf->ia_gfid, state->client->subdir_gfid)) {
104
static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
107
gf_uuid_copy(stbuf->ia_gfid, gfid);
110
gfx_stat_from_iattx(&rsp->stat, stbuf);
114
server4_post_lk(xlator_t *this, gfx_lk_rsp *rsp, struct gf_flock *lock)
116
switch (lock->l_type) {
118
lock->l_type = GF_LK_F_RDLCK;
121
lock->l_type = GF_LK_F_WRLCK;
124
lock->l_type = GF_LK_F_UNLCK;
127
gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_LOCK_ERROR,
128
"Unknown lock type: %" PRId32 "!", lock->l_type);
132
gf_proto_flock_from_flock(&rsp->flock, lock);
136
server4_post_readdir(gfx_readdir_rsp *rsp, gf_dirent_t *entries)
140
ret = serialize_rsp_dirent_v2(entries, rsp);
146
server4_post_seek(gfx_seek_rsp *rsp, off_t offset)
148
rsp->offset = offset;
152
server4_post_readdirp(gfx_readdirp_rsp *rsp, gf_dirent_t *entries)
156
ret = serialize_rsp_direntp_v2(entries, rsp);
162
server4_post_rchecksum(gfx_rchecksum_rsp *rsp, uint32_t weak_checksum,
163
uint8_t *strong_checksum)
165
rsp->weak_checksum = weak_checksum;
168
rsp->strong_checksum.strong_checksum_val = (char *)strong_checksum;
169
rsp->strong_checksum.strong_checksum_len = SHA256_DIGEST_LENGTH;
174
server4_post_rename(call_frame_t *frame, server_state_t *state,
175
gfx_rename_rsp *rsp, struct iatt *stbuf,
176
struct iatt *preoldparent, struct iatt *postoldparent,
177
struct iatt *prenewparent, struct iatt *postnewparent)
179
inode_t *tmp_inode = NULL;
181
stbuf->ia_type = state->loc.inode->ia_type;
184
gf_msg_trace(frame->root->client->bound_xl->name, 0,
187
"RENAME_CBK %s ==> %s",
188
frame->root->unique, state->loc.name, state->loc2.name);
198
tmp_inode = inode_grep(state->loc.inode->table, state->loc2.parent,
201
inode_unlink(tmp_inode, state->loc2.parent, state->loc2.name);
202
forget_inode_if_no_dentry(tmp_inode);
203
inode_unref(tmp_inode);
206
inode_rename(state->itable, state->loc.parent, state->loc.name,
207
state->loc2.parent, state->loc2.name, state->loc.inode, stbuf);
208
gfx_stat_from_iattx(&rsp->stat, stbuf);
210
gfx_stat_from_iattx(&rsp->preoldparent, preoldparent);
211
gfx_stat_from_iattx(&rsp->postoldparent, postoldparent);
213
gfx_stat_from_iattx(&rsp->prenewparent, prenewparent);
214
gfx_stat_from_iattx(&rsp->postnewparent, postnewparent);
218
server4_post_open(call_frame_t *frame, xlator_t *this, gfx_open_rsp *rsp,
221
server_ctx_t *serv_ctx = NULL;
224
serv_ctx = server_ctx_get(frame->root->client, this);
225
if (serv_ctx == NULL) {
226
gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED,
234
fd_no = gf_fd_unused_get(serv_ctx->fdtable, fd);
241
server4_post_readv(gfx_read_rsp *rsp, struct iatt *stbuf, int op_ret)
243
gfx_stat_from_iattx(&rsp->stat, stbuf);
248
server4_post_create(call_frame_t *frame, gfx_create_rsp *rsp,
249
server_state_t *state, xlator_t *this, fd_t *fd,
250
inode_t *inode, struct iatt *stbuf, struct iatt *preparent,
251
struct iatt *postparent)
253
server_ctx_t *serv_ctx = NULL;
254
inode_t *link_inode = NULL;
258
link_inode = inode_link(inode, state->loc.parent, state->loc.name, stbuf);
265
if (link_inode != inode) {
271
inode_ctx_merge(fd, fd->inode, link_inode);
272
inode_unref(fd->inode);
273
fd->inode = inode_ref(link_inode);
276
inode_lookup(link_inode);
277
inode_unref(link_inode);
279
serv_ctx = server_ctx_get(frame->root->client, this);
280
if (serv_ctx == NULL) {
281
gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED,
289
fd_no = gf_fd_unused_get(serv_ctx->fdtable, fd);
291
if ((fd_no > UINT64_MAX) || (fd == 0)) {
296
gfx_stat_from_iattx(&rsp->stat, stbuf);
297
gfx_stat_from_iattx(&rsp->preparent, preparent);
298
gfx_stat_from_iattx(&rsp->postparent, postparent);
307
server4_post_lookup(gfx_common_2iatt_rsp *rsp, call_frame_t *frame,
308
server_state_t *state, inode_t *inode, struct iatt *stbuf,
311
inode_t *root_inode = NULL;
312
inode_t *link_inode = NULL;
313
static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
315
root_inode = frame->root->client->bound_xl->itable->root;
317
if (!__is_root_gfid(inode->gfid)) {
318
link_inode = inode_link(inode, state->loc.parent, state->loc.name,
321
if (dict_get_sizen(xdata, GF_NAMESPACE_KEY)) {
322
inode_set_namespace_inode(link_inode, link_inode);
325
inode_lookup(link_inode);
326
inode_unref(link_inode);
330
if ((inode == root_inode) || (state->client->subdir_mount &&
331
(inode == state->client->subdir_inode))) {
341
gf_uuid_copy(stbuf->ia_gfid, rootgfid);
342
if (inode->ia_type == 0)
343
inode->ia_type = stbuf->ia_type;
346
gfx_stat_from_iattx(&rsp->prestat, stbuf);
350
server4_post_lease(gfx_lease_rsp *rsp, struct gf_lease *lease)
352
gf_proto_lease_from_lease(&rsp->lease, lease);
356
server4_post_link(server_state_t *state, gfx_common_3iatt_rsp *rsp,
357
inode_t *inode, struct iatt *stbuf, struct iatt *preparent,
358
struct iatt *postparent)
360
inode_t *link_inode = NULL;
362
gfx_stat_from_iattx(&rsp->stat, stbuf);
363
gfx_stat_from_iattx(&rsp->preparent, preparent);
364
gfx_stat_from_iattx(&rsp->postparent, postparent);
366
link_inode = inode_link(inode, state->loc2.parent, state->loc2.name, stbuf);
367
inode_lookup(link_inode);
368
inode_unref(link_inode);