From e82ca8fc5164f4ba2ff396da86b4a490d9a47370 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 23 Jun 2010 02:55:21 +0000 Subject: minor improvements in protocol * rpc_clnt_submit() now takes 'cbkfn' as an argument. * readdir xdr now uses dirent structure directly instead of using 'opaque' buffer through which it was serializing / unserializing the dirent structure. * 'gfs_id' field (currently used for debugging) is properly updated Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875 --- xlators/protocol/client/src/client-helpers.c | 106 ++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) (limited to 'xlators/protocol/client/src/client-helpers.c') diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index ae091ed1d..6c028d4eb 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -25,7 +25,6 @@ #include "client.h" #include "fd.h" - clnt_fd_ctx_t * this_fd_del_ctx (fd_t *file, xlator_t *this) { @@ -107,3 +106,108 @@ client_local_wipe (clnt_local_t *local) return 0; } + +int +unserialize_rsp_dirent (struct gfs3_readdir_rsp *rsp, gf_dirent_t *entries) +{ + struct gfs3_dirlist *trav = NULL; + gf_dirent_t *entry = NULL; + int entry_len = 0; + int ret = -1; + + trav = rsp->reply; + while (trav) { + entry_len = gf_dirent_size (trav->name); + entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t); + if (!entry) + goto out; + + entry->d_ino = trav->d_ino; + entry->d_off = trav->d_off; + entry->d_len = trav->d_len; + entry->d_type = trav->d_type; + + strcpy (entry->d_name, trav->name); + + list_add_tail (&entry->list, &entries->list); + + trav = trav->nextentry; + } + + ret = 0; +out: + return ret; +} + +int +unserialize_rsp_direntp (struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries) +{ + struct gfs3_dirplist *trav = NULL; + gf_dirent_t *entry = NULL; + int entry_len = 0; + int ret = -1; + + trav = rsp->reply; + + while (trav) { + entry_len = gf_dirent_size (trav->name); + entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t); + if (!entry) + goto out; + + entry->d_ino = trav->d_ino; + entry->d_off = trav->d_off; + entry->d_len = trav->d_len; + entry->d_type = trav->d_type; + + gf_stat_to_iatt (&trav->stat, &entry->d_stat); + + strcpy (entry->d_name, trav->name); + + list_add_tail (&entry->list, &entries->list); + + trav = trav->nextentry; + } + + ret = 0; +out: + return ret; +} + +int +clnt_readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp) +{ + gfs3_dirplist *prev = NULL; + gfs3_dirplist *trav = NULL; + + trav = rsp->reply; + prev = trav; + while (trav) { + trav = trav->nextentry; + /* on client, the rpc lib allocates this */ + free (prev->name); + free (prev); + prev = trav; + } + + return 0; +} + +int +clnt_readdir_rsp_cleanup (gfs3_readdir_rsp *rsp) +{ + gfs3_dirlist *prev = NULL; + gfs3_dirlist *trav = NULL; + + trav = rsp->reply; + prev = trav; + while (trav) { + trav = trav->nextentry; + /* on client, the rpc lib allocates this */ + free (prev->name); + free (prev); + prev = trav; + } + + return 0; +} -- cgit