diff options
author | Amar Tumballi <amar@gluster.com> | 2012-01-18 18:06:44 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2012-01-25 02:03:44 -0800 |
commit | cf8486cbef329ef66868f658fa35f470f97db462 (patch) | |
tree | 18cf37bd7cf65ac820d435fb1ee43dc205a2917b /xlators/protocol/server/src | |
parent | b02afc6d008f9959db28244eb2b9dd3b9ef92393 (diff) |
core: get xattrs also as part of readdirp
readdirp_req() call sends a dict_t * as an argument, which
contains all the xattr keys for which the entries got in
readdirp_rsp() are having xattr value filled dictionary.
Change-Id: I8b7e1290740ea3e884e67d19156ce849227167c0
Signed-off-by: Amar Tumballi <amar@gluster.com>
BUG: 765785
Reviewed-on: http://review.gluster.com/771
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 31 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 2 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 32 |
3 files changed, 60 insertions, 5 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 43f60e0e2..4980424d3 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -1327,11 +1327,40 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) trav->d_off = entry->d_off; trav->d_len = entry->d_len; trav->d_type = entry->d_type; - //trav->name = memdup (entry->d_name, entry->d_len + 1); trav->name = entry->d_name; gf_stat_from_iatt (&trav->stat, &entry->d_stat); + /* if 'dict' is present, pack it */ + if (entry->dict) { + trav->dict.dict_len = dict_serialized_length (entry->dict); + if (trav->dict.dict_len < 0) { + gf_log (THIS->name, GF_LOG_ERROR, + "failed to get serialized length " + "of reply dict"); + errno = EINVAL; + trav->dict.dict_len = 0; + goto out; + } + + trav->dict.dict_val = GF_CALLOC (1, trav->dict.dict_len, + gf_server_mt_rsp_buf_t); + if (!trav->dict.dict_val) { + errno = ENOMEM; + trav->dict.dict_len = 0; + goto out; + } + + ret = dict_serialize (entry->dict, trav->dict.dict_val); + if (ret < 0) { + gf_log (THIS->name, GF_LOG_ERROR, + "failed to serialize reply dict"); + errno = -ret; + trav->dict.dict_len = 0; + goto out; + } + } + if (prev) prev->nextentry = trav; else diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index f26175217..92785c5a9 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -154,7 +154,7 @@ struct _server_state { fd_t *fd; dict_t *params; - int flags; + int32_t flags; int wbflags; struct iovec payload_vector[MAX_IOVEC]; int payload_count; diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index c2ab3590e..482c242d5 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -1038,7 +1038,6 @@ server_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, gf_stat_from_iatt (&rsp.preparent, preparent); gf_stat_from_iatt (&rsp.postparent, postparent); - link_inode = inode_link (inode, state->loc2.parent, state->loc2.name, stbuf); inode_unref (link_inode); @@ -1738,6 +1737,10 @@ server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, op_errno = ENOMEM; goto out; } + + /* TODO: need more clear thoughts before calling this function. */ + /* gf_link_inodes_from_dirent (this, state->fd->inode, entries); */ + } else { /* (op_ret == 0) is valid, and means EOF, don't log for that */ gf_log (this->name, (op_ret) ? GF_LOG_INFO : GF_LOG_TRACE, @@ -2132,7 +2135,7 @@ server_readdirp_resume (call_frame_t *frame, xlator_t *bound_xl) STACK_WIND (frame, server_readdirp_cbk, bound_xl, bound_xl->fops->readdirp, state->fd, state->size, - state->offset); + state->offset, state->dict); return 0; err: @@ -3979,10 +3982,10 @@ server_readdirp (rpcsvc_request_t *req) { server_state_t *state = NULL; call_frame_t *frame = NULL; + char *buf = NULL; gfs3_readdirp_req args = {{0,},}; size_t headers_size = 0; int ret = -1; - if (!req) return ret; @@ -4023,6 +4026,29 @@ server_readdirp (rpcsvc_request_t *req) state->offset = args.offset; memcpy (state->resolve.gfid, args.gfid, 16); + if (args.dict.dict_len) { + /* Unserialize the dictionary */ + state->dict = dict_new (); + + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + goto out; + } + + ret = dict_unserialize (buf, args.dict.dict_len, + &state->dict); + if (ret < 0) { + gf_log (state->conn->bound_xl->name, GF_LOG_ERROR, + "%"PRId64": failed to unserialize req-buffer " + " to dictionary", frame->root->unique); + goto out; + } + + state->dict->extra_free = buf; + + buf = NULL; + } + ret = 0; resolve_and_resume (frame, server_readdirp_resume); out: |