diff options
Diffstat (limited to 'xlators/protocol/server')
| -rw-r--r-- | xlators/protocol/server/src/Makefile.am | 4 | ||||
| -rw-r--r-- | xlators/protocol/server/src/authenticate.h | 8 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-common.c | 53 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-common.h | 11 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 159 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 4706 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 39 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-mem-types.h | 8 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-messages.h | 181 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-resolve.c | 40 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-rpc-fops.c | 401 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server-rpc-fops_v2.c | 1647 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server.c | 523 | ||||
| -rw-r--r-- | xlators/protocol/server/src/server.h | 97 |
14 files changed, 1657 insertions, 6220 deletions
diff --git a/xlators/protocol/server/src/Makefile.am b/xlators/protocol/server/src/Makefile.am index 01edbd35d9c..5e875c8df0b 100644 --- a/xlators/protocol/server/src/Makefile.am +++ b/xlators/protocol/server/src/Makefile.am @@ -4,11 +4,11 @@ endif xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/protocol -server_la_LDFLAGS = $(LIB_DL) -module $(GF_XLATOR_DEFAULT_LDFLAGS) +server_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ - $(top_builddir)/rpc/xdr/src/libgfxdr.la + $(top_builddir)/rpc/xdr/src/libgfxdr.la $(LIB_DL) server_la_SOURCES = server.c server-resolve.c server-helpers.c \ server-rpc-fops.c server-handshake.c authenticate.c \ diff --git a/xlators/protocol/server/src/authenticate.h b/xlators/protocol/server/src/authenticate.h index 6fc53933343..6888cf696e6 100644 --- a/xlators/protocol/server/src/authenticate.h +++ b/xlators/protocol/server/src/authenticate.h @@ -17,10 +17,10 @@ #include <stdio.h> #include <fnmatch.h> -#include "dict.h" -#include "compat.h" -#include "list.h" -#include "xlator.h" +#include <glusterfs/dict.h> +#include <glusterfs/compat.h> +#include <glusterfs/list.h> +#include <glusterfs/xlator.h> typedef enum { AUTH_ACCEPT, AUTH_REJECT, AUTH_DONT_CARE } auth_result_t; diff --git a/xlators/protocol/server/src/server-common.c b/xlators/protocol/server/src/server-common.c index b5d61edccfb..cd79cf4d930 100644 --- a/xlators/protocol/server/src/server-common.c +++ b/xlators/protocol/server/src/server-common.c @@ -1,13 +1,13 @@ #include "server.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "server-messages.h" #include "server-helpers.h" -#include "defaults.h" -#include "fd.h" +#include <glusterfs/defaults.h> +#include <glusterfs/fd.h> #include "xdr-nfs3.h" void @@ -21,11 +21,8 @@ server_post_stat(server_state_t *state, gfs3_stat_rsp *rsp, struct iatt *stbuf) we use inode table which is shared by everyone, but make sure we send fops only from subdir and below, we have to alter inode gfid and send it to client */ - uuid_t gfid = { - 0, - }; + static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - gfid[15] = 1; stbuf->ia_ino = 1; gf_uuid_copy(stbuf->ia_gfid, gfid); } @@ -182,11 +179,8 @@ server_post_fstat(server_state_t *state, gfs3_fstat_rsp *rsp, we use inode table which is shared by everyone, but make sure we send fops only from subdir and below, we have to alter inode gfid and send it to client */ - uuid_t gfid = { - 0, - }; + static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - gfid[15] = 1; stbuf->ia_ino = 1; gf_uuid_copy(stbuf->ia_gfid, gfid); } @@ -454,9 +448,7 @@ server_post_lookup(gfs3_lookup_rsp *rsp, call_frame_t *frame, { inode_t *root_inode = NULL; inode_t *link_inode = NULL; - uuid_t rootgfid = { - 0, - }; + static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; root_inode = frame->root->client->bound_xl->itable->root; @@ -480,7 +472,6 @@ server_post_lookup(gfs3_lookup_rsp *rsp, call_frame_t *frame, make sure we send fops only from subdir and below, we have to alter inode gfid and send it to client */ stbuf->ia_ino = 1; - rootgfid[15] = 1; gf_uuid_copy(stbuf->ia_gfid, rootgfid); if (inode->ia_type == 0) inode->ia_type = stbuf->ia_type; @@ -521,11 +512,8 @@ server4_post_common_3iatt(server_state_t *state, gfx_common_3iatt_rsp *rsp, we use inode table which is shared by everyone, but make sure we send fops only from subdir and below, we have to alter inode gfid and send it to client */ - uuid_t gfid = { - 0, - }; + static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - gfid[15] = 1; preparent->ia_ino = 1; postparent->ia_ino = 1; gf_uuid_copy(preparent->ia_gfid, gfid); @@ -541,6 +529,16 @@ server4_post_common_3iatt(server_state_t *state, gfx_common_3iatt_rsp *rsp, } void +server4_post_common_3iatt_noinode(gfx_common_3iatt_rsp *rsp, struct iatt *stbuf, + struct iatt *prebuf_dst, + struct iatt *postbuf_dst) +{ + gfx_stat_from_iattx(&rsp->stat, stbuf); + gfx_stat_from_iattx(&rsp->preparent, prebuf_dst); + gfx_stat_from_iattx(&rsp->postparent, postbuf_dst); +} + +void server4_post_common_2iatt(gfx_common_2iatt_rsp *rsp, struct iatt *prebuf, struct iatt *postbuf) { @@ -581,11 +579,8 @@ server4_post_common_iatt(server_state_t *state, gfx_common_iatt_rsp *rsp, we use inode table which is shared by everyone, but make sure we send fops only from subdir and below, we have to alter inode gfid and send it to client */ - uuid_t gfid = { - 0, - }; + static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; - gfid[15] = 1; stbuf->ia_ino = 1; gf_uuid_copy(stbuf->ia_gfid, gfid); } @@ -646,7 +641,8 @@ server4_post_rchecksum(gfx_rchecksum_rsp *rsp, uint32_t weak_checksum, uint8_t *strong_checksum) { rsp->weak_checksum = weak_checksum; - + /* When the length encoding changes, update the change + in posix code also. */ rsp->strong_checksum.strong_checksum_val = (char *)strong_checksum; rsp->strong_checksum.strong_checksum_len = SHA256_DIGEST_LENGTH; rsp->flags = 1; /* Indicates SHA256 TYPE */ @@ -791,9 +787,7 @@ server4_post_lookup(gfx_common_2iatt_rsp *rsp, call_frame_t *frame, { inode_t *root_inode = NULL; inode_t *link_inode = NULL; - uuid_t rootgfid = { - 0, - }; + static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; root_inode = frame->root->client->bound_xl->itable->root; @@ -817,7 +811,6 @@ server4_post_lookup(gfx_common_2iatt_rsp *rsp, call_frame_t *frame, make sure we send fops only from subdir and below, we have to alter inode gfid and send it to client */ stbuf->ia_ino = 1; - rootgfid[15] = 1; gf_uuid_copy(stbuf->ia_gfid, rootgfid); if (inode->ia_type == 0) inode->ia_type = stbuf->ia_type; @@ -835,7 +828,7 @@ server4_post_lease(gfx_lease_rsp *rsp, struct gf_lease *lease) void server4_post_link(server_state_t *state, gfx_common_3iatt_rsp *rsp, inode_t *inode, struct iatt *stbuf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) + struct iatt *postparent) { inode_t *link_inode = NULL; diff --git a/xlators/protocol/server/src/server-common.h b/xlators/protocol/server/src/server-common.h index 53e46afdc69..6200415e304 100644 --- a/xlators/protocol/server/src/server-common.h +++ b/xlators/protocol/server/src/server-common.h @@ -1,11 +1,11 @@ #include "server.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "server-messages.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #include "xdr-nfs3.h" void @@ -192,3 +192,8 @@ void server4_post_link(server_state_t *state, gfx_common_3iatt_rsp *rsp, inode_t *inode, struct iatt *stbuf, struct iatt *pre, struct iatt *post); + +void +server4_post_common_3iatt_noinode(gfx_common_3iatt_rsp *rsp, struct iatt *stbuf, + struct iatt *prebuf_dst, + struct iatt *postbuf_dst); diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index db502ee5034..85c87c1ab8b 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -12,13 +12,13 @@ #include "server-helpers.h" #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "glusterfs3.h" #include "authenticate.h" #include "server-messages.h" -#include "syscall.h" -#include "events.h" -#include "syncop.h" +#include <glusterfs/syscall.h> +#include <glusterfs/events.h> +#include <glusterfs/syncop.h> struct __get_xl_struct { const char *name; @@ -36,7 +36,6 @@ gf_compare_client_version(rpcsvc_request_t *req, int fop_prognum, return ret; } - int server_getspec(rpcsvc_request_t *req) { @@ -232,6 +231,7 @@ server_setvolume(rpcsvc_request_t *req) dict_t *config_params = NULL; dict_t *params = NULL; char *name = NULL; + char *volume_id = NULL; char *client_uid = NULL; char *clnt_version = NULL; xlator_t *xl = NULL; @@ -240,7 +240,6 @@ server_setvolume(rpcsvc_request_t *req) int32_t ret = -1; int32_t op_ret = -1; int32_t op_errno = EINVAL; - char *buf = NULL; uint32_t opversion = 0; rpc_transport_t *xprt = NULL; int32_t fop_version = 0; @@ -250,6 +249,7 @@ server_setvolume(rpcsvc_request_t *req) char *subdir_mount = NULL; char *client_name = NULL; gf_boolean_t cleanup_starting = _gf_false; + gf_boolean_t xlator_in_graph = _gf_true; params = dict_new(); reply = dict_new(); @@ -267,18 +267,11 @@ server_setvolume(rpcsvc_request_t *req) */ config_params = dict_copy_with_ref(this->options, NULL); - buf = memdup(args.dict.dict_val, args.dict.dict_len); - if (buf == NULL) { - op_ret = -1; - op_errno = ENOMEM; - goto fail; - } - - ret = dict_unserialize(buf, args.dict.dict_len, ¶ms); + ret = dict_unserialize(args.dict.dict_val, args.dict.dict_len, ¶ms); if (ret < 0) { - ret = dict_set_str(reply, "ERROR", - "Internal error: failed to unserialize " - "request dictionary"); + ret = dict_set_sizen_str_sizen(reply, "ERROR", + "Internal error: failed to unserialize " + "request dictionary"); if (ret < 0) gf_msg_debug(this->name, 0, "failed to set error " @@ -291,9 +284,6 @@ server_setvolume(rpcsvc_request_t *req) goto fail; } - params->extra_free = buf; - buf = NULL; - ret = dict_get_str(params, "remote-subvolume", &name); if (ret < 0) { ret = dict_set_str(reply, "ERROR", @@ -311,8 +301,10 @@ server_setvolume(rpcsvc_request_t *req) LOCK(&ctx->volfile_lock); { xl = get_xlator_by_name(this, name); - if (!xl) + if (!xl) { + xlator_in_graph = _gf_false; xl = this; + } } UNLOCK(&ctx->volfile_lock); if (xl == NULL) { @@ -354,6 +346,7 @@ server_setvolume(rpcsvc_request_t *req) goto fail; } + pthread_mutex_lock(&conf->mutex); list_for_each_entry(tmp, &conf->child_status->status_list, status_list) { if (strcmp(tmp->name, name) == 0) @@ -361,10 +354,8 @@ server_setvolume(rpcsvc_request_t *req) } if (!tmp->name) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_CHILD_STATUS_FAILED, - "No xlator %s is found in " - "child status list", - name); + gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_CHILD_STATUS_FAILED, + "No xlator %s is found in child status list", name); } else { ret = dict_set_int32(reply, "child_up", tmp->child_up); if (ret < 0) @@ -372,7 +363,21 @@ server_setvolume(rpcsvc_request_t *req) "Failed to set 'child_up' for xlator %s " "in the reply dict", tmp->name); + if (!tmp->child_up) { + ret = dict_set_str(reply, "ERROR", + "Not received child_up for this xlator"); + if (ret < 0) + gf_msg_debug(this->name, 0, "failed to set error msg"); + + gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_CHILD_STATUS_FAILED, + "Not received child_up for this xlator %s", name); + op_ret = -1; + op_errno = EAGAIN; + pthread_mutex_unlock(&conf->mutex); + goto fail; + } } + pthread_mutex_unlock(&conf->mutex); ret = dict_get_str(params, "process-uuid", &client_uid); if (ret < 0) { @@ -396,6 +401,25 @@ server_setvolume(rpcsvc_request_t *req) client_name = "unknown"; } + /* If any value is set, the first element will be non-0. + It would be '0', but not '\0' :-) */ + if (xl->graph->volume_id[0]) { + ret = dict_get_str_sizen(params, "volume-id", &volume_id); + if (!ret && strcmp(xl->graph->volume_id, volume_id)) { + ret = dict_set_str(reply, "ERROR", + "Volume-ID different, possible case " + "of same brick re-used in another volume"); + if (ret < 0) + gf_msg_debug(this->name, 0, "failed to set error msg"); + + op_ret = -1; + op_errno = EINVAL; + goto fail; + } + ret = dict_set_str(reply, "volume-id", tmp->volume_id); + if (ret) + gf_msg_debug(this->name, 0, "failed to set 'volume-id'"); + } client = gf_client_get(this, &req->cred, client_uid, subdir_mount); if (client == NULL) { op_ret = -1; @@ -533,8 +557,8 @@ server_setvolume(rpcsvc_request_t *req) req->trans->clnt_options = dict_ref(params); gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_CLIENT_ACCEPTED, - "accepted client from %s (version: %s)", client->client_uid, - (clnt_version) ? clnt_version : "old"); + "accepted client from %s (version: %s) with subvol %s", + client->client_uid, (clnt_version) ? clnt_version : "old", name); gf_event(EVENT_CLIENT_CONNECT, "client_uid=%s;" @@ -555,20 +579,30 @@ server_setvolume(rpcsvc_request_t *req) "failed to set error " "msg"); } else { - gf_event(EVENT_CLIENT_AUTH_REJECT, - "client_uid=%s;" - "client_identifier=%s;server_identifier=%s;" - "brick_path=%s", - client->client_uid, req->trans->peerinfo.identifier, - req->trans->myinfo.identifier, name); - gf_msg(this->name, GF_LOG_ERROR, EACCES, PS_MSG_AUTHENTICATE_ERROR, - "Cannot authenticate client" - " from %s %s", - client->client_uid, (clnt_version) ? clnt_version : "old"); - op_ret = -1; - op_errno = EACCES; - ret = dict_set_str(reply, "ERROR", "Authentication failed"); + if (!xlator_in_graph) { + gf_msg(this->name, GF_LOG_ERROR, ENOENT, PS_MSG_AUTHENTICATE_ERROR, + "Cannot authenticate client" + " from %s %s because brick is not attached in graph", + client->client_uid, (clnt_version) ? clnt_version : "old"); + + op_errno = ENOENT; + ret = dict_set_str(reply, "ERROR", "Brick not found"); + } else { + gf_event(EVENT_CLIENT_AUTH_REJECT, + "client_uid=%s;" + "client_identifier=%s;server_identifier=%s;" + "brick_path=%s", + client->client_uid, req->trans->peerinfo.identifier, + req->trans->myinfo.identifier, name); + gf_msg(this->name, GF_LOG_ERROR, EACCES, PS_MSG_AUTHENTICATE_ERROR, + "Cannot authenticate client" + " from %s %s", + client->client_uid, (clnt_version) ? clnt_version : "old"); + + op_errno = EACCES; + ret = dict_set_str(reply, "ERROR", "Authentication failed"); + } if (ret < 0) gf_msg_debug(this->name, 0, "failed to set error " @@ -638,6 +672,8 @@ fail: ret = dict_set_str(reply, "ERROR", "cleanup flag is set for xlator " "before call first_lookup Try again later"); + /* quisce coverity about UNUSED_VALUE ret */ + (void)(ret); } else { op_ret = server_first_lookup(this, client, reply); if (op_ret == -1) @@ -649,21 +685,16 @@ fail: GF_ASSERT(rsp); rsp->op_ret = 0; - rsp->dict.dict_len = dict_serialized_length(reply); - if (rsp->dict.dict_len) { - rsp->dict.dict_val = GF_CALLOC(1, rsp->dict.dict_len, - gf_server_mt_rsp_buf_t); - if (rsp->dict.dict_val) { - ret = dict_serialize(reply, rsp->dict.dict_val); - if (ret < 0) { - gf_msg_debug("server-handshake", 0, - "failed " - "to serialize reply dict"); - op_ret = -1; - op_errno = -ret; - } - } + + ret = dict_allocate_and_serialize(reply, (char **)&rsp->dict.dict_val, + &rsp->dict.dict_len); + if (ret != 0) { + ret = -1; + gf_msg_debug("server-handshake", 0, "failed to serialize reply dict"); + op_ret = -1; + op_errno = -ret; } + rsp->op_ret = op_ret; rsp->op_errno = gf_errno_to_error(op_errno); @@ -698,8 +729,6 @@ fail: dict_unref(config_params); } - GF_FREE(buf); - return 0; } @@ -747,15 +776,15 @@ fail: return 0; } -rpcsvc_actor_t gluster_handshake_actors[GF_HNDSK_MAXVALUE] = { - [GF_HNDSK_NULL] = {"NULL", GF_HNDSK_NULL, server_null, NULL, 0, DRC_NA}, - [GF_HNDSK_SETVOLUME] = {"SETVOLUME", GF_HNDSK_SETVOLUME, server_setvolume, - NULL, 0, DRC_NA}, - [GF_HNDSK_GETSPEC] = {"GETSPEC", GF_HNDSK_GETSPEC, server_getspec, NULL, 0, - DRC_NA}, - [GF_HNDSK_PING] = {"PING", GF_HNDSK_PING, server_ping, NULL, 0, DRC_NA}, - [GF_HNDSK_SET_LK_VER] = {"SET_LK_VER", GF_HNDSK_SET_LK_VER, - server_set_lk_version, NULL, 0, DRC_NA}, +static rpcsvc_actor_t gluster_handshake_actors[GF_HNDSK_MAXVALUE] = { + [GF_HNDSK_NULL] = {"NULL", server_null, NULL, GF_HNDSK_NULL, DRC_NA, 0}, + [GF_HNDSK_SETVOLUME] = {"SETVOLUME", server_setvolume, NULL, + GF_HNDSK_SETVOLUME, DRC_NA, 0}, + [GF_HNDSK_GETSPEC] = {"GETSPEC", server_getspec, NULL, GF_HNDSK_GETSPEC, + DRC_NA, 0}, + [GF_HNDSK_PING] = {"PING", server_ping, NULL, GF_HNDSK_PING, DRC_NA, 0}, + [GF_HNDSK_SET_LK_VER] = {"SET_LK_VER", server_set_lk_version, NULL, + GF_HNDSK_SET_LK_VER, DRC_NA, 0}, }; struct rpcsvc_program gluster_handshake_prog = { diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index cb2a73c7168..6e644912a46 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -10,16 +10,15 @@ #include "server.h" #include "server-helpers.h" -#include "gidcache.h" +#include <glusterfs/gidcache.h> #include "server-messages.h" -#include "syscall.h" -#include "defaults.h" -#include "default-args.h" +#include <glusterfs/syscall.h> +#include <glusterfs/defaults.h> +#include <glusterfs/default-args.h> #include "server-common.h" #include <fnmatch.h> #include <pwd.h> -#include "compound-fop-utils.h" /* based on nfs_fix_aux_groups() */ int @@ -53,14 +52,14 @@ gid_resolve(server_conf_t *conf, call_stack_t *root) ret = getpwuid_r(root->uid, &mypw, mystrs, sizeof(mystrs), &result); if (ret != 0) { - gf_msg("gid-cache", GF_LOG_ERROR, errno, PS_MSG_GET_UID_FAILED, - "getpwuid_r(%u) failed", root->uid); + gf_smsg("gid-cache", GF_LOG_ERROR, errno, PS_MSG_GET_UID_FAILED, + "uid=%u", root->uid, NULL); return -1; } if (!result) { - gf_msg("gid-cache", GF_LOG_ERROR, 0, PS_MSG_UID_NOT_FOUND, - "getpwuid_r(%u) found nothing", root->uid); + gf_smsg("gid-cache", GF_LOG_ERROR, 0, PS_MSG_UID_NOT_FOUND, "uid=%u", + root->uid, NULL); return -1; } @@ -68,9 +67,9 @@ gid_resolve(server_conf_t *conf, call_stack_t *root) ngroups = gf_getgrouplist(result->pw_name, root->gid, &mygroups); if (ngroups == -1) { - gf_msg("gid-cache", GF_LOG_ERROR, 0, PS_MSG_MAPPING_ERROR, - "could not map %s to group list (%d gids)", result->pw_name, - root->ngrps); + gf_smsg("gid-cache", GF_LOG_ERROR, 0, PS_MSG_MAPPING_ERROR, + "pw_name=%s", result->pw_name, "root->ngtps=%d", root->ngrps, + NULL); return -1; } root->ngrps = (uint16_t)ngroups; @@ -210,8 +209,6 @@ free_state(server_state_t *state) server_resolve_wipe(&state->resolve); server_resolve_wipe(&state->resolve2); - compound_args_cleanup(state->args); - /* Call rpc_trnasport_unref to avoid crashes at last after free all resources because of server_rpc_notify (for transport destroy) call's xlator_mem_cleanup if all xprt are destroyed that internally @@ -233,16 +230,51 @@ server_connection_cleanup_flush_cbk(call_frame_t *frame, void *cookie, int32_t ret = -1; fd_t *fd = NULL; client_t *client = NULL; + uint64_t fd_cnt = 0; + xlator_t *victim = NULL; + server_conf_t *conf = NULL; + xlator_t *serv_xl = NULL; + rpc_transport_t *xprt = NULL; + rpc_transport_t *xp_next = NULL; + int32_t detach = (long)cookie; + gf_boolean_t xprt_found = _gf_false; GF_VALIDATE_OR_GOTO("server", this, out); GF_VALIDATE_OR_GOTO("server", frame, out); fd = frame->local; client = frame->root->client; + serv_xl = frame->this; + conf = serv_xl->private; fd_unref(fd); frame->local = NULL; + if (client) + victim = client->bound_xl; + + if (victim) { + fd_cnt = GF_ATOMIC_DEC(client->fd_cnt); + if (!fd_cnt && conf && detach) { + pthread_mutex_lock(&conf->mutex); + { + list_for_each_entry_safe(xprt, xp_next, &conf->xprt_list, list) + { + if (!xprt->xl_private) + continue; + if (xprt->xl_private == client) { + xprt_found = _gf_true; + break; + } + } + } + pthread_mutex_unlock(&conf->mutex); + if (xprt_found) { + rpc_transport_unref(xprt); + } + } + } + gf_client_unref(client); STACK_DESTROY(frame->root); @@ -253,7 +285,7 @@ out: static int do_fd_cleanup(xlator_t *this, client_t *client, fdentry_t *fdentries, - int fd_count) + int fd_count, int32_t detach) { fd_t *fd = NULL; int i = 0, ret = -1; @@ -265,6 +297,7 @@ do_fd_cleanup(xlator_t *this, client_t *client, fdentry_t *fdentries, GF_VALIDATE_OR_GOTO("server", fdentries, out); bound_xl = client->bound_xl; + for (i = 0; i < fd_count; i++) { fd = fdentries[i].fd; @@ -274,18 +307,18 @@ do_fd_cleanup(xlator_t *this, client_t *client, fdentry_t *fdentries, goto out; } + tmp_frame->root->type = GF_OP_TYPE_FOP; GF_ASSERT(fd->inode); ret = inode_path(fd->inode, NULL, &path); if (ret > 0) { - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_FD_CLEANUP, - "fd cleanup on %s", path); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_FD_CLEANUP, + "path=%s", path, NULL); GF_FREE(path); } else { - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_FD_CLEANUP, - "fd cleanup on inode with gfid %s", - uuid_utoa(fd->inode->gfid)); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_FD_CLEANUP, + "inode-gfid=%s", uuid_utoa(fd->inode->gfid), NULL); } tmp_frame->local = fd; @@ -294,8 +327,9 @@ do_fd_cleanup(xlator_t *this, client_t *client, fdentry_t *fdentries, tmp_frame->root->client = client; memset(&tmp_frame->root->lk_owner, 0, sizeof(gf_lkowner_t)); - STACK_WIND(tmp_frame, server_connection_cleanup_flush_cbk, bound_xl, - bound_xl->fops->flush, fd, NULL); + STACK_WIND_COOKIE(tmp_frame, server_connection_cleanup_flush_cbk, + (void *)(long)detach, bound_xl, + bound_xl->fops->flush, fd, NULL); } } @@ -307,13 +341,19 @@ out: } int -server_connection_cleanup(xlator_t *this, client_t *client, int32_t flags) +server_connection_cleanup(xlator_t *this, client_t *client, int32_t flags, + gf_boolean_t *fd_exist) { server_ctx_t *serv_ctx = NULL; fdentry_t *fdentries = NULL; uint32_t fd_count = 0; int cd_ret = 0; int ret = 0; + xlator_t *bound_xl = NULL; + int i = 0; + fd_t *fd = NULL; + uint64_t fd_cnt = 0; + int32_t detach = 0; GF_VALIDATE_OR_GOTO("server", this, out); GF_VALIDATE_OR_GOTO(this->name, client, out); @@ -322,9 +362,7 @@ server_connection_cleanup(xlator_t *this, client_t *client, int32_t flags) serv_ctx = server_ctx_get(client, client->this); if (serv_ctx == NULL) { - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED, - "server_ctx_get() " - "failed"); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED, NULL); goto out; } @@ -343,14 +381,36 @@ server_connection_cleanup(xlator_t *this, client_t *client, int32_t flags) } if (fdentries != NULL) { + /* Loop to configure fd_count on victim brick */ + bound_xl = client->bound_xl; + if (bound_xl) { + for (i = 0; i < fd_count; i++) { + fd = fdentries[i].fd; + if (!fd) + continue; + fd_cnt++; + } + if (fd_cnt) { + if (fd_exist) + (*fd_exist) = _gf_true; + GF_ATOMIC_ADD(client->fd_cnt, fd_cnt); + } + } + + /* If fd_exist is not NULL it means function is invoke + by server_rpc_notify at the time of getting DISCONNECT + notification + */ + if (fd_exist) + detach = 1; + gf_msg_debug(this->name, 0, "Performing cleanup on %d " "fdentries", fd_count); - ret = do_fd_cleanup(this, client, fdentries, fd_count); + ret = do_fd_cleanup(this, client, fdentries, fd_count, detach); } else - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_FDENTRY_NULL, - "no fdentries to clean"); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_FDENTRY_NULL, NULL); if (cd_ret || ret) ret = -1; @@ -378,6 +438,7 @@ server_alloc_frame(rpcsvc_request_t *req) if (!frame) goto out; + frame->root->type = GF_OP_TYPE_FOP; state = GF_CALLOC(1, sizeof(*state), gf_server_mt_state_t); if (!state) goto out; @@ -391,7 +452,6 @@ server_alloc_frame(rpcsvc_request_t *req) frame->root->client = client; frame->root->state = state; /* which socket */ - frame->root->unique = 0; /* which call */ frame->this = client->this; out: @@ -413,16 +473,12 @@ get_frame_from_request(rpcsvc_request_t *req) GF_VALIDATE_OR_GOTO("server", req, out); - client = req->trans->xl_private; - frame = server_alloc_frame(req); if (!frame) goto out; frame->root->op = req->procnum; - frame->root->unique = req->xid; - client = req->trans->xl_private; this = req->trans->xl; priv = this->private; @@ -435,44 +491,51 @@ get_frame_from_request(rpcsvc_request_t *req) would not have been set. So for non trusted clients (i.e clients not from the same machine as the brick, and clients from outside the storage pool) - do the root-squashing. + do the root-squashing and all-squashing. TODO: If any client within the storage pool (i.e mounting within a machine from the pool but using other machine's ip/hostname from the same pool) is present treat it as a trusted client */ - if (!client->auth.username && req->pid != NFS_PID) + if (!client->auth.username && req->pid != NFS_PID) { RPC_AUTH_ROOT_SQUASH(req); + RPC_AUTH_ALL_SQUASH(req); + } /* Problem: If we just check whether the client is - trusted client and do not do root squashing for - them, then for smb clients and UFO clients root - squashing will never happen as they use the fuse - mounts done within the trusted pool (i.e they are - trusted clients). - Solution: To fix it, do root squashing for trusted - clients also. If one wants to have a client within - the storage pool for which root-squashing does not - happen, then the client has to be mounted with + trusted client and do not do root squashing and + all squashing for them, then for smb clients and + UFO clients root squashing and all squashing will + never happen as they use the fuse mounts done within + the trusted pool (i.e they are trusted clients). + Solution: To fix it, do root squashing and all squashing + for trusted clients also. If one wants to have a client + within the storage pool for which root-squashing does + not happen, then the client has to be mounted with --no-root-squash option. But for defrag client and - gsyncd client do not do root-squashing. + gsyncd client do not do root-squashing and all-squashing. */ if (client->auth.username && req->pid != GF_CLIENT_PID_NO_ROOT_SQUASH && req->pid != GF_CLIENT_PID_GSYNCD && req->pid != GF_CLIENT_PID_DEFRAG && req->pid != GF_CLIENT_PID_SELF_HEALD && - req->pid != GF_CLIENT_PID_QUOTA_MOUNT) + req->pid != GF_CLIENT_PID_QUOTA_MOUNT) { RPC_AUTH_ROOT_SQUASH(req); + RPC_AUTH_ALL_SQUASH(req); + } /* For nfs clients the server processes will be running within the trusted storage pool machines. So if we - do not do root-squashing for nfs servers, thinking - that its a trusted client, then root-squashing won't - work for nfs clients. + do not do root-squashing and all-squashing for nfs + servers, thinking that its a trusted client, then + root-squashing and all-squashing won't work for nfs + clients. */ - if (req->pid == NFS_PID) + if (req->pid == NFS_PID) { RPC_AUTH_ROOT_SQUASH(req); + RPC_AUTH_ALL_SQUASH(req); + } } } @@ -531,9 +594,8 @@ server_build_config(xlator_t *this, server_conf_t *conf) if (data) { ret = gf_string2boolean(data->data, &conf->verify_volfile); if (ret != 0) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, - "wrong value for '" - "verify-volfile-checksum', Neglecting option"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_WRONG_VALUE, + NULL); } } @@ -541,9 +603,8 @@ server_build_config(xlator_t *this, server_conf_t *conf) if (data) { ret = gf_string2boolean(data->data, &conf->trace); if (ret != 0) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, - "'trace' takes on only " - "boolean values. Neglecting option"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, + NULL); } } @@ -564,18 +625,16 @@ server_build_config(xlator_t *this, server_conf_t *conf) or directory specified is non standard */ ret = sys_stat(data->data, &buf); if ((ret != 0) || !S_ISDIR(buf.st_mode)) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_DIR_NOT_FOUND, - "Directory '%s' doesn't " - "exist, exiting.", - data->data); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_DIR_NOT_FOUND, + "data=%s", data->data, NULL); ret = -1; goto out; } /* Make sure that conf-dir doesn't contain ".." in path */ if ((gf_strstr(data->data, "/", "..")) == -1) { ret = -1; - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_CONF_DIR_INVALID, - "%s: invalid conf_dir", data->data); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_CONF_DIR_INVALID, + "data=%s", data->data, NULL); goto out; } @@ -757,8 +816,9 @@ server_print_reply(call_frame_t *frame, int op_ret, int op_errno) if (state->fd) snprintf(fdstr, 32, " fd=%p", state->fd); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SERVER_MSG, - "%s%s => (%d, %d)%s", op, caller, op_ret, op_errno, fdstr); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SERVER_MSG, "op=%s", op, + "caller=%s", caller, "op_ret=%d", op_ret, "op_errno=%d", op_errno, + "fdstr=%s", fdstr, NULL); out: return; } @@ -818,9 +878,10 @@ server_print_request(call_frame_t *frame) break; } - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_MSG, "%s%s%s%s%s%s%s", op, - caller, resolve_vars, loc_vars, resolve2_vars, loc2_vars, - other_vars); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_SERVER_MSG, "op=%s", op, + "caller=%s", caller, "resolve_vars=%s", resolve_vars, "loc_vars=%s", + loc_vars, "resolve2_vars=%s", resolve2_vars, "loc2_vars=%s", + loc2_vars, "other_vars=%s", other_vars, NULL); out: return; } @@ -832,7 +893,6 @@ serialize_rsp_direntp(gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) gfs3_dirplist *trav = NULL; gfs3_dirplist *prev = NULL; int ret = -1; - int temp = 0; GF_VALIDATE_OR_GOTO("server", entries, out); GF_VALIDATE_OR_GOTO("server", rsp, out); @@ -853,30 +913,12 @@ serialize_rsp_direntp(gf_dirent_t *entries, gfs3_readdirp_rsp *rsp) /* if 'dict' is present, pack it */ if (entry->dict) { - temp = dict_serialized_length(entry->dict); - - if (temp < 0) { - gf_msg(THIS->name, GF_LOG_ERROR, EINVAL, PS_MSG_INVALID_ENTRY, - "failed to get " - "serialized length of reply dict"); - errno = EINVAL; - trav->dict.dict_len = 0; - goto out; - } - trav->dict.dict_len = temp; - - 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_msg(THIS->name, GF_LOG_ERROR, 0, PS_MSG_DICT_SERIALIZE_FAIL, - "failed to serialize reply dict"); + ret = dict_allocate_and_serialize(entry->dict, + (char **)&trav->dict.dict_val, + &trav->dict.dict_len); + if (ret != 0) { + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PS_MSG_DICT_SERIALIZE_FAIL, + NULL); errno = -ret; trav->dict.dict_len = 0; goto out; @@ -1107,8 +1149,8 @@ common_rsp_locklist(lock_migration_info_t *locklist, gfs3_locklist **reply) break; default: - gf_msg(THIS->name, GF_LOG_ERROR, 0, PS_MSG_LOCK_ERROR, - "Unknown lock type: %" PRId32 "!", tmp->flock.l_type); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PS_MSG_LOCK_ERROR, + "lock_type=%" PRId32, tmp->flock.l_type, NULL); break; } @@ -1207,8 +1249,9 @@ gf_server_check_getxattr_cmd(call_frame_t *frame, const char *key) { list_for_each_entry(xprt, &conf->xprt_list, list) { - gf_msg("mount-point-list", GF_LOG_INFO, 0, PS_MSG_MOUNT_PT_FAIL, - "%s", xprt->peerinfo.identifier); + gf_smsg("mount-point-list", GF_LOG_INFO, 0, + PS_MSG_MOUNT_PT_FAIL, "identifier=%s", + xprt->peerinfo.identifier, NULL); } } pthread_mutex_unlock(&conf->mutex); @@ -1238,9 +1281,8 @@ gf_server_check_setxattr_cmd(call_frame_t *frame, dict_t *dict) total_read += xprt->total_bytes_read; total_write += xprt->total_bytes_write; } - gf_msg("stats", GF_LOG_INFO, 0, PS_MSG_RW_STAT, - "total-read %" PRIu64 ", total-write %" PRIu64, total_read, - total_write); + gf_smsg("stats", GF_LOG_INFO, 0, PS_MSG_RW_STAT, "total-read=%" PRIu64, + total_read, "total-write=%" PRIu64, total_write, NULL); } return 0; @@ -1316,15 +1358,15 @@ auth_set_username_passwd(dict_t *input_params, dict_t *config_params, ret = dict_get_str(input_params, "password", &password); if (ret) { - gf_msg("auth/login", GF_LOG_WARNING, 0, PS_MSG_DICT_GET_FAILED, - "password not found, returning DONT-CARE"); + gf_smsg("auth/login", GF_LOG_WARNING, 0, PS_MSG_PASSWORD_NOT_FOUND, + NULL); goto out; } ret = dict_get_str(input_params, "remote-subvolume", &brick_name); if (ret) { - gf_msg("auth/login", GF_LOG_ERROR, 0, PS_MSG_DICT_GET_FAILED, - "remote-subvolume not specified"); + gf_smsg("auth/login", GF_LOG_ERROR, 0, + PS_MSG_REMOTE_SUBVOL_NOT_SPECIFIED, NULL); ret = -1; goto out; } @@ -1356,10 +1398,8 @@ auth_set_username_passwd(dict_t *input_params, dict_t *config_params, GF_FREE(searchstr); if (!passwd_data) { - gf_msg("auth/login", GF_LOG_ERROR, 0, PS_MSG_LOGIN_ERROR, - "wrong " - "username/password " - "combination"); + gf_smsg("auth/login", GF_LOG_ERROR, 0, PS_MSG_LOGIN_ERROR, + NULL); ret = -1; goto out; } @@ -1369,10 +1409,8 @@ auth_set_username_passwd(dict_t *input_params, dict_t *config_params, client->auth.username = gf_strdup(username); client->auth.passwd = gf_strdup(password); } else { - gf_msg("auth/login", GF_LOG_ERROR, 0, PS_MSG_LOGIN_ERROR, - "wrong " - "password for user %s", - username); + gf_smsg("auth/login", GF_LOG_ERROR, 0, PS_MSG_LOGIN_ERROR, + "username=%s", username, NULL); } break; } @@ -1409,7 +1447,7 @@ unserialize_req_locklist(gfs3_setactivelk_req *req, lock_migration_info_t *lmi) while (trav) { temp = GF_CALLOC(1, sizeof(*lmi), gf_common_mt_lock_mig); if (temp == NULL) { - gf_msg(THIS->name, GF_LOG_ERROR, 0, 0, "No memory"); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PS_MSG_NO_MEM, NULL); goto out; } @@ -1446,7 +1484,7 @@ unserialize_req_locklist_v2(gfx_setactivelk_req *req, while (trav) { temp = GF_CALLOC(1, sizeof(*lmi), gf_common_mt_lock_mig); if (temp == NULL) { - gf_msg(THIS->name, GF_LOG_ERROR, 0, 0, "No memory"); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PS_MSG_NO_MEM, NULL); goto out; } @@ -1467,4443 +1505,3 @@ unserialize_req_locklist_v2(gfx_setactivelk_req *req, out: return ret; } - -int -server_populate_compound_request(gfs3_compound_req *req, call_frame_t *frame, - default_args_t *this_args, int index) -{ - int op_errno = 0; - int ret = -1; - dict_t *xdata = NULL; - dict_t *xattr = NULL; - struct iovec req_iovec[MAX_IOVEC] = {{ - 0, - }}; - compound_req *this_req = NULL; - server_state_t *state = CALL_STATE(frame); - - this_req = &req->compound_req_array.compound_req_array_val[index]; - - switch (this_req->fop_enum) { - case GF_FOP_STAT: { - gfs3_stat_req *args = NULL; - - args = &this_req->compound_req_u.compound_stat_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_stat_store(this_args, &state->loc, xdata); - break; - } - case GF_FOP_READLINK: { - gfs3_readlink_req *args = NULL; - - args = &this_req->compound_req_u.compound_readlink_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_readlink_store(this_args, &state->loc, args->size, xdata); - break; - } - case GF_FOP_MKNOD: { - gfs3_mknod_req *args = NULL; - - args = &this_req->compound_req_u.compound_mknod_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_mknod_store(this_args, &state->loc, args->mode, args->dev, - args->umask, xdata); - break; - } - case GF_FOP_MKDIR: { - gfs3_mkdir_req *args = NULL; - - args = &this_req->compound_req_u.compound_mkdir_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_mkdir_store(this_args, &state->loc, args->mode, args->umask, - xdata); - break; - } - case GF_FOP_UNLINK: { - gfs3_unlink_req *args = NULL; - - args = &this_req->compound_req_u.compound_unlink_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_unlink_store(this_args, &state->loc, args->xflags, xdata); - break; - } - case GF_FOP_RMDIR: { - gfs3_rmdir_req *args = NULL; - - args = &this_req->compound_req_u.compound_rmdir_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_rmdir_store(this_args, &state->loc, args->xflags, xdata); - break; - } - case GF_FOP_SYMLINK: { - gfs3_symlink_req *args = NULL; - - args = &this_req->compound_req_u.compound_symlink_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_symlink_store(this_args, args->linkname, &state->loc, - args->umask, xdata); - - this_args->loc.inode = inode_new(state->itable); - - break; - } - case GF_FOP_RENAME: { - gfs3_rename_req *args = NULL; - - args = &this_req->compound_req_u.compound_rename_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_rename_store(this_args, &state->loc, &state->loc2, xdata); - break; - } - case GF_FOP_LINK: { - gfs3_link_req *args = NULL; - - args = &this_req->compound_req_u.compound_link_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_link_store(this_args, &state->loc, &state->loc2, xdata); - - this_args->loc2.inode = inode_ref(this_args->loc.inode); - - break; - } - case GF_FOP_TRUNCATE: { - gfs3_truncate_req *args = NULL; - - args = &this_req->compound_req_u.compound_truncate_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_truncate_store(this_args, &state->loc, args->offset, xdata); - break; - } - case GF_FOP_OPEN: { - gfs3_open_req *args = NULL; - - args = &this_req->compound_req_u.compound_open_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_open_store(this_args, &state->loc, args->flags, state->fd, - xdata); - - this_args->fd = fd_create(this_args->loc.inode, frame->root->pid); - this_args->fd->flags = this_args->flags; - - break; - } - case GF_FOP_READ: { - gfs3_read_req *args = NULL; - - args = &this_req->compound_req_u.compound_read_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_readv_store(this_args, state->fd, args->size, args->offset, - args->flag, xdata); - break; - } - case GF_FOP_WRITE: { - gfs3_write_req *args = NULL; - - args = &this_req->compound_req_u.compound_write_req; - - /*TODO : What happens when payload count is more than one? */ - req_iovec[0].iov_base = state->payload_vector[0].iov_base + - state->write_length; - req_iovec[0].iov_len = args->size; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - /* The way writev fop works : - * xdr args of write along with other args contains - * write length not count. But when the call is wound to posix, - * this length is not used. It is taken from the request - * write vector that is passed down. Posix needs the vector - * count to determine the amount of write to be done. - * This count for writes that come as part of compound fops - * will be 1. The vectors are merged into one under - * GF_FOP_WRITE section of client_handle_fop_requirements() - * in protocol client. - */ - args_writev_store(this_args, state->fd, req_iovec, 1, args->offset, - args->flag, state->iobref, xdata); - state->write_length += req_iovec[0].iov_len; - break; - } - case GF_FOP_STATFS: { - gfs3_statfs_req *args = NULL; - - args = &this_req->compound_req_u.compound_statfs_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_statfs_store(this_args, &state->loc, xdata); - break; - } - case GF_FOP_FLUSH: { - gfs3_flush_req *args = NULL; - - args = &this_req->compound_req_u.compound_flush_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_flush_store(this_args, state->fd, xdata); - break; - } - case GF_FOP_FSYNC: { - gfs3_fsync_req *args = NULL; - - args = &this_req->compound_req_u.compound_fsync_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_fsync_store(this_args, state->fd, args->data, xdata); - break; - } - case GF_FOP_SETXATTR: { - gfs3_setxattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_setxattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xattr, args->dict.dict_val, - args->dict.dict_len, ret, op_errno, out); - args_setxattr_store(this_args, &state->loc, xattr, args->flags, - xdata); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_getxattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - gf_server_check_getxattr_cmd(frame, args->name); - - args_getxattr_store(this_args, &state->loc, args->name, xdata); - break; - } - case GF_FOP_REMOVEXATTR: { - gfs3_removexattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_removexattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_removexattr_store(this_args, &state->loc, args->name, xdata); - break; - } - case GF_FOP_OPENDIR: { - gfs3_opendir_req *args = NULL; - - args = &this_req->compound_req_u.compound_opendir_req; - - this_args->fd = fd_create(this_args->loc.inode, frame->root->pid); - if (!this_args->fd) { - gf_msg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, - "could not create the fd"); - goto out; - } - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_opendir_store(this_args, &state->loc, state->fd, xdata); - break; - } - case GF_FOP_FSYNCDIR: { - gfs3_fsyncdir_req *args = NULL; - - args = &this_req->compound_req_u.compound_fsyncdir_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_fsyncdir_store(this_args, state->fd, args->data, xdata); - break; - } - case GF_FOP_ACCESS: { - gfs3_access_req *args = NULL; - - args = &this_req->compound_req_u.compound_access_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_access_store(this_args, &state->loc, args->mask, xdata); - break; - } - case GF_FOP_CREATE: { - gfs3_create_req *args = NULL; - - args = &this_req->compound_req_u.compound_create_req; - - state->loc.inode = inode_new(state->itable); - - state->fd = fd_create(state->loc.inode, frame->root->pid); - if (!state->fd) { - gf_msg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, - "fd creation for the inode %s failed", - state->loc.inode ? uuid_utoa(state->loc.inode->gfid) - : NULL); - goto out; - } - state->fd->flags = state->flags; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_create_store(this_args, &state->loc, args->flags, args->mode, - args->umask, state->fd, xdata); - break; - } - case GF_FOP_FTRUNCATE: { - gfs3_ftruncate_req *args = NULL; - - args = &this_req->compound_req_u.compound_ftruncate_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_ftruncate_store(this_args, state->fd, args->offset, xdata); - break; - } - case GF_FOP_FSTAT: { - gfs3_fstat_req *args = NULL; - - args = &this_req->compound_req_u.compound_fstat_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_fstat_store(this_args, state->fd, xdata); - break; - } - case GF_FOP_LK: { - gfs3_lk_req *args = NULL; - - args = &this_req->compound_req_u.compound_lk_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - switch (args->cmd) { - case GF_LK_GETLK: - this_args->cmd = F_GETLK; - break; - case GF_LK_SETLK: - this_args->cmd = F_SETLK; - break; - case GF_LK_SETLKW: - this_args->cmd = F_SETLKW; - break; - case GF_LK_RESLK_LCK: - this_args->cmd = F_RESLK_LCK; - break; - case GF_LK_RESLK_LCKW: - this_args->cmd = F_RESLK_LCKW; - break; - case GF_LK_RESLK_UNLCK: - this_args->cmd = F_RESLK_UNLCK; - break; - case GF_LK_GETLK_FD: - this_args->cmd = F_GETLK_FD; - break; - } - - gf_proto_flock_to_flock(&args->flock, &this_args->lock); - - switch (args->type) { - case GF_LK_F_RDLCK: - this_args->lock.l_type = F_RDLCK; - break; - case GF_LK_F_WRLCK: - this_args->lock.l_type = F_WRLCK; - break; - case GF_LK_F_UNLCK: - this_args->lock.l_type = F_UNLCK; - break; - default: - gf_msg(frame->root->client->bound_xl->name, GF_LOG_ERROR, 0, - PS_MSG_LOCK_ERROR, - "fd - %" PRId64 - " (%s):" - " Unknown " - "lock type: %" PRId32 "!", - state->resolve.fd_no, - uuid_utoa(state->fd->inode->gfid), args->type); - break; - } - args_lk_store(this_args, state->fd, this_args->cmd, - &this_args->lock, xdata); - break; - } - case GF_FOP_LOOKUP: { - gfs3_lookup_req *args = NULL; - - args = &this_req->compound_req_u.compound_lookup_req; - - if (this_args->loc.inode) - this_args->loc.inode = server_inode_new(state->itable, - state->loc.gfid); - else - state->is_revalidate = 1; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_lookup_store(this_args, &state->loc, xdata); - break; - } - case GF_FOP_READDIR: { - gfs3_readdir_req *args = NULL; - - args = &this_req->compound_req_u.compound_readdir_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_readdir_store(this_args, state->fd, args->size, args->offset, - xdata); - break; - } - case GF_FOP_INODELK: { - gfs3_inodelk_req *args = NULL; - - args = &this_req->compound_req_u.compound_inodelk_req; - - switch (args->cmd) { - case GF_LK_GETLK: - this_args->cmd = F_GETLK; - break; - case GF_LK_SETLK: - this_args->cmd = F_SETLK; - break; - case GF_LK_SETLKW: - this_args->cmd = F_SETLKW; - break; - } - - gf_proto_flock_to_flock(&args->flock, &this_args->lock); - - switch (args->type) { - case GF_LK_F_RDLCK: - this_args->lock.l_type = F_RDLCK; - break; - case GF_LK_F_WRLCK: - this_args->lock.l_type = F_WRLCK; - break; - case GF_LK_F_UNLCK: - this_args->lock.l_type = F_UNLCK; - break; - } - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_inodelk_store(this_args, args->volume, &state->loc, - this_args->cmd, &this_args->lock, xdata); - break; - } - case GF_FOP_FINODELK: { - gfs3_finodelk_req *args = NULL; - - args = &this_req->compound_req_u.compound_finodelk_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - switch (args->cmd) { - case GF_LK_GETLK: - this_args->cmd = F_GETLK; - break; - case GF_LK_SETLK: - this_args->cmd = F_SETLK; - break; - case GF_LK_SETLKW: - this_args->cmd = F_SETLKW; - break; - } - - gf_proto_flock_to_flock(&args->flock, &this_args->lock); - - switch (args->type) { - case GF_LK_F_RDLCK: - this_args->lock.l_type = F_RDLCK; - break; - case GF_LK_F_WRLCK: - this_args->lock.l_type = F_WRLCK; - break; - case GF_LK_F_UNLCK: - this_args->lock.l_type = F_UNLCK; - break; - } - args_finodelk_store(this_args, args->volume, state->fd, - this_args->cmd, &this_args->lock, xdata); - break; - } - case GF_FOP_ENTRYLK: { - gfs3_entrylk_req *args = NULL; - - args = &this_req->compound_req_u.compound_entrylk_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_entrylk_store(this_args, args->volume, &state->loc, args->name, - args->cmd, args->type, xdata); - break; - } - case GF_FOP_FENTRYLK: { - gfs3_fentrylk_req *args = NULL; - - args = &this_req->compound_req_u.compound_fentrylk_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_fentrylk_store(this_args, args->volume, state->fd, args->name, - args->cmd, args->type, xdata); - break; - } - case GF_FOP_XATTROP: { - gfs3_xattrop_req *args = NULL; - - args = &this_req->compound_req_u.compound_xattrop_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xattr, (args->dict.dict_val), - (args->dict.dict_len), ret, op_errno, out); - args_xattrop_store(this_args, &state->loc, args->flags, xattr, - xdata); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_req *args = NULL; - - args = &this_req->compound_req_u.compound_fxattrop_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xattr, (args->dict.dict_val), - (args->dict.dict_len), ret, op_errno, out); - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_fxattrop_store(this_args, state->fd, args->flags, xattr, - xdata); - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_fgetxattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_fgetxattr_store(this_args, state->fd, args->name, xdata); - break; - } - case GF_FOP_FSETXATTR: { - gfs3_fsetxattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_fsetxattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xattr, (args->dict.dict_val), - (args->dict.dict_len), ret, op_errno, out); - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_fsetxattr_store(this_args, state->fd, xattr, args->flags, - xdata); - break; - } - case GF_FOP_RCHECKSUM: { - gfs3_rchecksum_req *args = NULL; - - args = &this_req->compound_req_u.compound_rchecksum_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_rchecksum_store(this_args, state->fd, args->offset, args->len, - xdata); - break; - } - case GF_FOP_SETATTR: { - gfs3_setattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_setattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - gf_stat_to_iatt(&args->stbuf, &this_args->stat); - - args_setattr_store(this_args, &state->loc, &this_args->stat, - args->valid, xdata); - break; - } - case GF_FOP_FSETATTR: { - gfs3_fsetattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_fsetattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - gf_stat_to_iatt(&args->stbuf, &this_args->stat); - - args_fsetattr_store(this_args, state->fd, &this_args->stat, - args->valid, xdata); - break; - } - case GF_FOP_READDIRP: { - gfs3_readdirp_req *args = NULL; - - args = &this_req->compound_req_u.compound_readdirp_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xattr, (args->dict.dict_val), - (args->dict.dict_len), ret, op_errno, out); - - args_readdirp_store(this_args, state->fd, args->size, args->offset, - xattr); - break; - } - case GF_FOP_FREMOVEXATTR: { - gfs3_fremovexattr_req *args = NULL; - - args = &this_req->compound_req_u.compound_fremovexattr_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_fremovexattr_store(this_args, state->fd, args->name, xdata); - break; - } - case GF_FOP_FALLOCATE: { - gfs3_fallocate_req *args = NULL; - - args = &this_req->compound_req_u.compound_fallocate_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_fallocate_store(this_args, state->fd, args->flags, - args->offset, args->size, xdata); - break; - } - case GF_FOP_DISCARD: { - gfs3_discard_req *args = NULL; - - args = &this_req->compound_req_u.compound_discard_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - args_discard_store(this_args, state->fd, args->offset, args->size, - xdata); - break; - } - case GF_FOP_ZEROFILL: { - gfs3_zerofill_req *args = NULL; - - args = &this_req->compound_req_u.compound_zerofill_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_zerofill_store(this_args, state->fd, args->offset, args->size, - xdata); - break; - } - case GF_FOP_SEEK: { - gfs3_seek_req *args = NULL; - - args = &this_req->compound_req_u.compound_seek_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - args_seek_store(this_args, state->fd, args->offset, args->what, - xdata); - break; - } - case GF_FOP_LEASE: { - gfs3_lease_req *args = NULL; - - args = &this_req->compound_req_u.compound_lease_req; - - GF_PROTOCOL_DICT_UNSERIALIZE( - frame->root->client->bound_xl, xdata, args->xdata.xdata_val, - args->xdata.xdata_len, ret, op_errno, out); - - gf_proto_lease_to_lease(&args->lease, &state->lease); - - args_lease_store(this_args, &state->loc, &state->lease, xdata); - break; - } - default: - return ENOTSUP; - } -out: - if (xattr) - dict_unref(xattr); - if (xdata) - dict_unref(xdata); - return op_errno; -} - -int -server_populate_compound_response(xlator_t *this, gfs3_compound_rsp *rsp, - call_frame_t *frame, - compound_args_cbk_t *args_cbk, int index) -{ - int op_errno = EINVAL; - default_args_cbk_t *this_args_cbk = NULL; - compound_rsp *this_rsp = NULL; - server_state_t *state = NULL; - int ret = 0; - - state = CALL_STATE(frame); - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index]; - - this_args_cbk = &args_cbk->rsp_list[index]; - this_rsp->fop_enum = args_cbk->enum_list[index]; - - switch (this_rsp->fop_enum) { - case GF_FOP_STAT: { - gfs3_stat_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_stat_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (!this_args_cbk->op_ret) { - server_post_stat(state, rsp_args, &this_args_cbk->stat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READLINK: { - gfs3_readlink_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_readlink_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (this_args_cbk->op_ret >= 0) { - server_post_readlink(rsp_args, &this_args_cbk->stat, - this_args_cbk->buf); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - if (!rsp_args->path) - rsp_args->path = ""; - break; - } - case GF_FOP_MKNOD: { - gfs3_mknod_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_mknod_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (!this_args_cbk->op_ret) { - server_post_mknod(state, rsp_args, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, - this_args_cbk->inode); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_MKDIR: { - gfs3_mkdir_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_mkdir_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_mkdir( - state, rsp_args, this_args_cbk->inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - this_args_cbk->xdata); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_UNLINK: { - gfs3_unlink_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_unlink_rsp; - - if (gf_replace_old_iatt_in_dict(this_args_cbk->xdata)) { - rsp_args->op_errno = errno; - rsp_args->op_ret = -1; - goto out; - } - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (!this_args_cbk->op_ret) { - server_post_unlink(state, rsp_args, &this_args_cbk->preparent, - &this_args_cbk->postparent); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_RMDIR: { - gfs3_rmdir_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_rmdir_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (!this_args_cbk->op_ret) { - server_post_rmdir(state, rsp_args, &this_args_cbk->preparent, - &this_args_cbk->postparent); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_SYMLINK: { - gfs3_symlink_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_symlink_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_symlink( - state, rsp_args, this_args_cbk->inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - this_args_cbk->xdata); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_RENAME: { - gfs3_rename_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_rename_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_rename( - frame, state, rsp_args, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - &this_args_cbk->preparent2, &this_args_cbk->postparent2); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_LINK: { - gfs3_link_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_link_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_link( - state, rsp_args, this_args_cbk->inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - this_args_cbk->xdata); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_TRUNCATE: { - gfs3_truncate_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_truncate_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_truncate(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_OPEN: { - gfs3_open_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_open_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_open(frame, this, rsp_args, this_args_cbk->fd); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READ: { - gfs3_read_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_read_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (this_args_cbk->op_ret >= 0) { - server_post_readv(rsp_args, &this_args_cbk->stat, - this_args_cbk->op_ret); - - if (!state->rsp_iobref) { - state->rsp_iobref = this_args_cbk->iobref; - state->rsp_count = 0; - } - iobref_merge(state->rsp_iobref, this_args_cbk->iobref); - memcpy(&state->rsp_vector[state->rsp_count], - this_args_cbk->vector, - (this_args_cbk->count * sizeof(state->rsp_vector[0]))); - state->rsp_count += this_args_cbk->count; - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_WRITE: { - gfs3_write_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_write_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (this_args_cbk->op_ret >= 0) { - server_post_writev(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_STATFS: { - gfs3_statfs_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_statfs_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (!this_args_cbk->op_ret) { - server_post_statfs(rsp_args, &this_args_cbk->statvfs); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FLUSH: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_flush_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FSYNC: { - gfs3_fsync_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fsync_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_fsync(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_SETXATTR: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_setxattr_rsp; - - if (gf_replace_old_iatt_in_dict(this_args_cbk->xdata)) { - rsp_args->op_errno = errno; - rsp_args->op_ret = -1; - goto out; - } - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_getxattr_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (-1 != this_args_cbk->op_ret) { - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xattr, &rsp_args->dict.dict_val, - rsp_args->dict.dict_len, rsp_args->op_errno, out); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_REMOVEXATTR: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_removexattr_rsp; - - if (gf_replace_old_iatt_in_dict(this_args_cbk->xdata)) { - rsp_args->op_errno = errno; - rsp_args->op_ret = -1; - goto out; - } - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_OPENDIR: { - gfs3_opendir_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_opendir_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_opendir(frame, this, rsp_args, this_args_cbk->fd); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FSYNCDIR: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fsyncdir_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_ACCESS: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_access_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_CREATE: { - gfs3_create_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_create_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - - if (!this_args_cbk->op_ret) { - rsp_args->op_ret = server_post_create( - frame, rsp_args, state, this, this_args_cbk->fd, - this_args_cbk->inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent); - if (rsp_args->op_ret) { - rsp_args->op_errno = -rsp_args->op_ret; - rsp_args->op_ret = -1; - } - } - break; - } - case GF_FOP_FTRUNCATE: { - gfs3_ftruncate_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_ftruncate_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_ftruncate(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FSTAT: { - gfs3_fstat_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fstat_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - if (!this_args_cbk->op_ret) { - server_post_fstat(state, rsp_args, &this_args_cbk->stat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_LK: { - gfs3_lk_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_lk_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_lk(this, rsp_args, &this_args_cbk->lock); - } - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_LOOKUP: { - gfs3_lookup_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_lookup_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_lookup(rsp_args, frame, state, this_args_cbk->inode, - &this_args_cbk->stat, - &this_args_cbk->postparent); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READDIR: { - gfs3_readdir_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_readdir_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - - if (this_args_cbk->op_ret > 0) { - ret = server_post_readdir(rsp_args, &this_args_cbk->entries); - if (ret < 0) { - rsp_args->op_ret = ret; - rsp_args->op_errno = ENOMEM; - } - } - break; - } - case GF_FOP_INODELK: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_inodelk_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FINODELK: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_finodelk_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_ENTRYLK: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_entrylk_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FENTRYLK: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fentrylk_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_XATTROP: { - gfs3_xattrop_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_xattrop_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xattr, &rsp_args->dict.dict_val, - rsp_args->dict.dict_len, rsp_args->op_errno, out); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fxattrop_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xattr, &rsp_args->dict.dict_val, - rsp_args->dict.dict_len, rsp_args->op_errno, out); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fgetxattr_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (-1 != this_args_cbk->op_ret) { - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xattr, &rsp_args->dict.dict_val, - rsp_args->dict.dict_len, rsp_args->op_errno, out); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FSETXATTR: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_setxattr_rsp; - - if (gf_replace_old_iatt_in_dict(this_args_cbk->xdata)) { - rsp_args->op_errno = errno; - rsp_args->op_ret = -1; - goto out; - } - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_RCHECKSUM: { - gfs3_rchecksum_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_rchecksum_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_rchecksum(rsp_args, this_args_cbk->weak_checksum, - this_args_cbk->strong_checksum); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_SETATTR: { - gfs3_setattr_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_setattr_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_setattr(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FSETATTR: { - gfs3_fsetattr_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fsetattr_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_fsetattr(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READDIRP: { - gfs3_readdirp_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_readdirp_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (this_args_cbk->op_ret > 0) { - ret = server_post_readdirp(rsp_args, &this_args_cbk->entries); - if (ret < 0) { - rsp_args->op_ret = ret; - rsp_args->op_errno = ENOMEM; - goto out; - } - gf_link_inodes_from_dirent(this, state->fd->inode, - &this_args_cbk->entries); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FREMOVEXATTR: { - gf_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fremovexattr_rsp; - - if (gf_replace_old_iatt_in_dict(this_args_cbk->xdata)) { - rsp_args->op_errno = errno; - rsp_args->op_ret = -1; - goto out; - } - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FALLOCATE: { - gfs3_fallocate_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_fallocate_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_fallocate(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_DISCARD: { - gfs3_discard_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_discard_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_discard(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_ZEROFILL: { - gfs3_zerofill_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_zerofill_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_zerofill(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_SEEK: { - gfs3_seek_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_seek_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_LEASE: { - gfs3_lease_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_u.compound_lease_rsp; - - GF_PROTOCOL_DICT_SERIALIZE( - this, this_args_cbk->xdata, &rsp_args->xdata.xdata_val, - rsp_args->xdata.xdata_len, rsp_args->op_errno, out); - - if (!this_args_cbk->op_ret) { - server_post_lease(rsp_args, &this_args_cbk->lease); - } - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - default: - return ENOTSUP; - } - op_errno = 0; -out: - return op_errno; -} -/* This works only when the compound fop acts on one loc/inode/gfid. - * If compound fops on more than one inode is required, multiple - * resolve and resumes will have to be done. This will have to change. - * Right now, multiple unlinks, rmdirs etc is are not supported. - * This can be added for future enhancements. - */ -int -server_get_compound_resolve(server_state_t *state, gfs3_compound_req *req) -{ - int i = 0; - compound_req *array = &req->compound_req_array.compound_req_array_val[i]; - - switch (array->fop_enum) { - case GF_FOP_STAT: { - gfs3_stat_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_stat_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_READLINK: { - gfs3_readlink_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_readlink_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_MKNOD: { - gfs3_mknod_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_mknod_req; - - state->resolve.type = RESOLVE_NOT; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_MKDIR: { - gfs3_mkdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_mkdir_req; - - state->resolve.type = RESOLVE_NOT; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_UNLINK: { - gfs3_unlink_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_unlink_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_RMDIR: { - gfs3_rmdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_rmdir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_SYMLINK: { - gfs3_symlink_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_symlink_req; - - state->resolve.type = RESOLVE_NOT; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_RENAME: { - gfs3_rename_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_rename_req; - - state->resolve.type = RESOLVE_MUST; - state->resolve.bname = gf_strdup(this_req.oldbname); - memcpy(state->resolve.pargfid, this_req.oldgfid, 16); - - state->resolve2.type = RESOLVE_MAY; - state->resolve2.bname = gf_strdup(this_req.newbname); - memcpy(state->resolve2.pargfid, this_req.newgfid, 16); - break; - } - case GF_FOP_LINK: { - gfs3_link_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_link_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.oldgfid, 16); - - state->resolve2.type = RESOLVE_NOT; - state->resolve2.bname = gf_strdup(this_req.newbname); - memcpy(state->resolve2.pargfid, this_req.newgfid, 16); - break; - } - case GF_FOP_TRUNCATE: { - gfs3_truncate_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_truncate_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_OPEN: { - gfs3_open_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_open_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_READ: { - gfs3_read_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_read_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_WRITE: { - gfs3_write_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_write_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_STATFS: { - gfs3_statfs_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_statfs_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FLUSH: { - gfs3_flush_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_flush_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FSYNC: { - gfs3_fsync_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fsync_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_SETXATTR: { - gfs3_setxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_setxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_getxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_REMOVEXATTR: { - gfs3_removexattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_removexattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_OPENDIR: { - gfs3_opendir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_opendir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FSYNCDIR: { - gfs3_fsyncdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fsyncdir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_ACCESS: { - gfs3_access_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_access_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_CREATE: { - gfs3_create_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_create_req; - - state->flags = gf_flags_to_flags(this_req.flags); - if (state->flags & O_EXCL) { - state->resolve.type = RESOLVE_NOT; - } else { - state->resolve.type = RESOLVE_DONTCARE; - } - - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_FTRUNCATE: { - gfs3_ftruncate_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_ftruncate_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FSTAT: { - gfs3_fstat_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fstat_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_LK: { - gfs3_lk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_lk_req; - - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_LOOKUP: { - gfs3_lookup_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_lookup_req; - state->resolve.type = RESOLVE_DONTCARE; - - if (this_req.bname && strcmp(this_req.bname, "")) { - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - } else { - memcpy(state->resolve.gfid, this_req.gfid, 16); - } - break; - } - case GF_FOP_READDIR: { - gfs3_readdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_readdir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_INODELK: { - gfs3_inodelk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_inodelk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FINODELK: { - gfs3_finodelk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_finodelk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_ENTRYLK: { - gfs3_entrylk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_entrylk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FENTRYLK: { - gfs3_fentrylk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fentrylk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_XATTROP: { - gfs3_xattrop_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_xattrop_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fxattrop_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fgetxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FSETXATTR: { - gfs3_fsetxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fsetxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_RCHECKSUM: { - gfs3_rchecksum_req this_req = { - 0, - }; - - this_req = array[i].compound_req_u.compound_rchecksum_req; - - state->resolve.type = RESOLVE_MAY; - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_SETATTR: { - gfs3_setattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_setattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FSETATTR: { - gfs3_fsetattr_req this_req = { - 0, - }; - - this_req = array[i].compound_req_u.compound_fsetattr_req; - - state->resolve.type = RESOLVE_MUST; - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_READDIRP: { - gfs3_readdirp_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_readdirp_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FREMOVEXATTR: { - gfs3_fremovexattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fremovexattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FALLOCATE: { - gfs3_fallocate_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_fallocate_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_DISCARD: { - gfs3_discard_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_discard_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_ZEROFILL: { - gfs3_zerofill_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_zerofill_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_SEEK: { - gfs3_seek_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_seek_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_LEASE: { - gfs3_lease_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_u.compound_lease_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - default: - return ENOTSUP; - } - return 0; -} - -void -server_compound_rsp_cleanup(gfs3_compound_rsp *rsp, compound_args_cbk_t *args) -{ - int i, len = 0; - compound_rsp *this_rsp = NULL; - - if (!rsp->compound_rsp_array.compound_rsp_array_val) - return; - - len = rsp->compound_rsp_array.compound_rsp_array_len; - - for (i = 0; i < len; i++) { - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; - switch (args->enum_list[i]) { - case GF_FOP_STAT: - SERVER_FOP_RSP_CLEANUP(rsp, stat, i); - break; - case GF_FOP_MKNOD: - SERVER_FOP_RSP_CLEANUP(rsp, mknod, i); - break; - case GF_FOP_MKDIR: - SERVER_FOP_RSP_CLEANUP(rsp, mkdir, i); - break; - case GF_FOP_UNLINK: - SERVER_FOP_RSP_CLEANUP(rsp, unlink, i); - break; - case GF_FOP_RMDIR: - SERVER_FOP_RSP_CLEANUP(rsp, rmdir, i); - break; - case GF_FOP_SYMLINK: - SERVER_FOP_RSP_CLEANUP(rsp, symlink, i); - break; - case GF_FOP_RENAME: - SERVER_FOP_RSP_CLEANUP(rsp, rename, i); - break; - case GF_FOP_LINK: - SERVER_FOP_RSP_CLEANUP(rsp, link, i); - break; - case GF_FOP_TRUNCATE: - SERVER_FOP_RSP_CLEANUP(rsp, truncate, i); - break; - case GF_FOP_OPEN: - SERVER_FOP_RSP_CLEANUP(rsp, open, i); - break; - case GF_FOP_READ: - SERVER_FOP_RSP_CLEANUP(rsp, read, i); - break; - case GF_FOP_WRITE: - SERVER_FOP_RSP_CLEANUP(rsp, write, i); - break; - case GF_FOP_STATFS: - SERVER_FOP_RSP_CLEANUP(rsp, statfs, i); - break; - case GF_FOP_FSYNC: - SERVER_FOP_RSP_CLEANUP(rsp, fsync, i); - break; - case GF_FOP_OPENDIR: - SERVER_FOP_RSP_CLEANUP(rsp, opendir, i); - break; - case GF_FOP_CREATE: - SERVER_FOP_RSP_CLEANUP(rsp, create, i); - break; - case GF_FOP_FTRUNCATE: - SERVER_FOP_RSP_CLEANUP(rsp, ftruncate, i); - break; - case GF_FOP_FSTAT: - SERVER_FOP_RSP_CLEANUP(rsp, fstat, i); - break; - case GF_FOP_LK: - SERVER_FOP_RSP_CLEANUP(rsp, lk, i); - break; - case GF_FOP_LOOKUP: - SERVER_FOP_RSP_CLEANUP(rsp, lookup, i); - break; - case GF_FOP_SETATTR: - SERVER_FOP_RSP_CLEANUP(rsp, setattr, i); - break; - case GF_FOP_FSETATTR: - SERVER_FOP_RSP_CLEANUP(rsp, fsetattr, i); - break; - case GF_FOP_FALLOCATE: - SERVER_FOP_RSP_CLEANUP(rsp, fallocate, i); - break; - case GF_FOP_DISCARD: - SERVER_FOP_RSP_CLEANUP(rsp, discard, i); - break; - case GF_FOP_ZEROFILL: - SERVER_FOP_RSP_CLEANUP(rsp, zerofill, i); - break; - case GF_FOP_IPC: - SERVER_FOP_RSP_CLEANUP(rsp, ipc, i); - break; - case GF_FOP_SEEK: - SERVER_FOP_RSP_CLEANUP(rsp, seek, i); - break; - case GF_FOP_LEASE: - SERVER_FOP_RSP_CLEANUP(rsp, lease, i); - break; - /* fops that use gf_common_rsp */ - case GF_FOP_FLUSH: - SERVER_COMMON_RSP_CLEANUP(rsp, flush, i); - break; - case GF_FOP_SETXATTR: - SERVER_COMMON_RSP_CLEANUP(rsp, setxattr, i); - break; - case GF_FOP_REMOVEXATTR: - SERVER_COMMON_RSP_CLEANUP(rsp, removexattr, i); - break; - case GF_FOP_FSETXATTR: - SERVER_COMMON_RSP_CLEANUP(rsp, fsetxattr, i); - break; - case GF_FOP_FREMOVEXATTR: - SERVER_COMMON_RSP_CLEANUP(rsp, fremovexattr, i); - break; - case GF_FOP_FSYNCDIR: - SERVER_COMMON_RSP_CLEANUP(rsp, fsyncdir, i); - break; - case GF_FOP_ACCESS: - SERVER_COMMON_RSP_CLEANUP(rsp, access, i); - break; - case GF_FOP_INODELK: - SERVER_COMMON_RSP_CLEANUP(rsp, inodelk, i); - break; - case GF_FOP_FINODELK: - SERVER_COMMON_RSP_CLEANUP(rsp, finodelk, i); - break; - case GF_FOP_ENTRYLK: - SERVER_COMMON_RSP_CLEANUP(rsp, entrylk, i); - break; - case GF_FOP_FENTRYLK: - SERVER_COMMON_RSP_CLEANUP(rsp, fentrylk, i); - break; - case GF_FOP_READLINK: - SERVER_FOP_RSP_CLEANUP(rsp, readlink, i); - break; - case GF_FOP_RCHECKSUM: - SERVER_FOP_RSP_CLEANUP(rsp, rchecksum, i); - break; - /* fops that need extra cleanup */ - case GF_FOP_XATTROP: { - gfs3_xattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, xattrop); - SERVER_FOP_RSP_CLEANUP(rsp, xattrop, i); - GF_FREE(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, fxattrop); - SERVER_FOP_RSP_CLEANUP(rsp, fxattrop, i); - GF_FREE(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_READDIR: { - gfs3_readdir_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readdir); - SERVER_FOP_RSP_CLEANUP(rsp, readdir, i); - readdir_rsp_cleanup(tmp_rsp); - break; - } - case GF_FOP_READDIRP: { - gfs3_readdirp_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readdirp); - SERVER_FOP_RSP_CLEANUP(rsp, readdir, i); - readdirp_rsp_cleanup(tmp_rsp); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, getxattr); - SERVER_FOP_RSP_CLEANUP(rsp, getxattr, i); - GF_FREE(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, - fgetxattr); - SERVER_FOP_RSP_CLEANUP(rsp, fgetxattr, i); - GF_FREE(tmp_rsp->dict.dict_val); - break; - } - default: - break; - } - } - GF_FREE(rsp->compound_rsp_array.compound_rsp_array_val); - return; -} - -void -server_compound_req_cleanup(gfs3_compound_req *req, int len) -{ - int i = 0; - compound_req *curr_req = NULL; - - if (!req->compound_req_array.compound_req_array_val) - return; - - for (i = 0; i < len; i++) { - curr_req = &req->compound_req_array.compound_req_array_val[i]; - - switch (curr_req->fop_enum) { - case GF_FOP_STAT: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, stat); - break; - case GF_FOP_READLINK: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, readlink); - break; - case GF_FOP_MKNOD: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, mknod); - break; - case GF_FOP_MKDIR: { - gfs3_mkdir_req *args = &CPD_REQ_FIELD(curr_req, mkdir); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, mkdir); - free(args->bname); - break; - } - case GF_FOP_UNLINK: { - gfs3_unlink_req *args = &CPD_REQ_FIELD(curr_req, unlink); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, unlink); - free(args->bname); - break; - } - case GF_FOP_RMDIR: { - gfs3_rmdir_req *args = &CPD_REQ_FIELD(curr_req, rmdir); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, rmdir); - free(args->bname); - break; - } - case GF_FOP_SYMLINK: { - gfs3_symlink_req *args = &CPD_REQ_FIELD(curr_req, symlink); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, symlink); - free(args->bname); - free(args->linkname); - break; - } - case GF_FOP_RENAME: { - gfs3_rename_req *args = &CPD_REQ_FIELD(curr_req, rename); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, rename); - free(args->oldbname); - free(args->newbname); - break; - } - case GF_FOP_LINK: { - gfs3_link_req *args = &CPD_REQ_FIELD(curr_req, link); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, link); - free(args->newbname); - break; - } - case GF_FOP_TRUNCATE: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, truncate); - break; - case GF_FOP_OPEN: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, open); - break; - case GF_FOP_READ: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, read); - break; - case GF_FOP_WRITE: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, write); - break; - case GF_FOP_STATFS: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, statfs); - break; - case GF_FOP_FLUSH: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, flush); - break; - case GF_FOP_FSYNC: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fsync); - break; - case GF_FOP_SETXATTR: { - gfs3_setxattr_req *args = &CPD_REQ_FIELD(curr_req, setxattr); - - free(args->dict.dict_val); - SERVER_COMPOUND_FOP_CLEANUP(curr_req, setxattr); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_req *args = &CPD_REQ_FIELD(curr_req, getxattr); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, getxattr); - free(args->name); - break; - } - case GF_FOP_REMOVEXATTR: { - gfs3_removexattr_req *args = &CPD_REQ_FIELD(curr_req, - removexattr); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, removexattr); - free(args->name); - break; - } - case GF_FOP_OPENDIR: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, opendir); - break; - case GF_FOP_FSYNCDIR: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fsyncdir); - break; - case GF_FOP_ACCESS: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, access); - break; - case GF_FOP_CREATE: { - gfs3_create_req *args = &CPD_REQ_FIELD(curr_req, create); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, create); - free(args->bname); - break; - } - case GF_FOP_FTRUNCATE: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, ftruncate); - break; - case GF_FOP_FSTAT: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fstat); - break; - case GF_FOP_LK: { - gfs3_lk_req *args = &CPD_REQ_FIELD(curr_req, lk); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, lk); - free(args->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_LOOKUP: { - gfs3_lookup_req *args = &CPD_REQ_FIELD(curr_req, lookup); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, lookup); - free(args->bname); - break; - } - case GF_FOP_READDIR: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, readdir); - break; - case GF_FOP_INODELK: { - gfs3_inodelk_req *args = &CPD_REQ_FIELD(curr_req, inodelk); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, inodelk); - free(args->volume); - free(args->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_FINODELK: { - gfs3_finodelk_req *args = &CPD_REQ_FIELD(curr_req, finodelk); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, finodelk); - free(args->volume); - free(args->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_ENTRYLK: { - gfs3_entrylk_req *args = &CPD_REQ_FIELD(curr_req, entrylk); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, entrylk); - free(args->volume); - free(args->name); - break; - } - case GF_FOP_FENTRYLK: { - gfs3_fentrylk_req *args = &CPD_REQ_FIELD(curr_req, fentrylk); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fentrylk); - free(args->volume); - free(args->name); - break; - } - case GF_FOP_XATTROP: { - gfs3_xattrop_req *args = &CPD_REQ_FIELD(curr_req, xattrop); - - free(args->dict.dict_val); - SERVER_COMPOUND_FOP_CLEANUP(curr_req, xattrop); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_req *args = &CPD_REQ_FIELD(curr_req, fxattrop); - - free(args->dict.dict_val); - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fxattrop); - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_req *args = &CPD_REQ_FIELD(curr_req, fgetxattr); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fgetxattr); - free(args->name); - break; - } - case GF_FOP_FSETXATTR: { - gfs3_fsetxattr_req *args = &CPD_REQ_FIELD(curr_req, fsetxattr); - - free(args->dict.dict_val); - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fsetxattr); - break; - } - case GF_FOP_RCHECKSUM: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, rchecksum); - break; - case GF_FOP_SETATTR: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, setattr); - break; - case GF_FOP_FSETATTR: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fsetattr); - break; - case GF_FOP_READDIRP: { - gfs3_readdirp_req *args = &CPD_REQ_FIELD(curr_req, readdirp); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fremovexattr); - free(args->dict.dict_val); - break; - } - case GF_FOP_FREMOVEXATTR: { - gfs3_fremovexattr_req *args = &CPD_REQ_FIELD(curr_req, - fremovexattr); - - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fremovexattr); - free(args->name); - break; - } - case GF_FOP_FALLOCATE: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, fallocate); - break; - case GF_FOP_DISCARD: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, discard); - break; - case GF_FOP_ZEROFILL: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, zerofill); - break; - case GF_FOP_IPC: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, ipc); - break; - case GF_FOP_SEEK: - SERVER_COMPOUND_FOP_CLEANUP(curr_req, seek); - break; - default: - break; - } - } - - return; -} - -/* compound v2 */ -int -server_populate_compound_request_v2(gfx_compound_req *req, call_frame_t *frame, - default_args_t *this_args, int index) -{ - int op_errno = 0; - dict_t *xdata = NULL; - dict_t *xattr = NULL; - struct iovec req_iovec[MAX_IOVEC] = {{ - 0, - }}; - compound_req_v2 *this_req = NULL; - server_state_t *state = CALL_STATE(frame); - - this_req = &req->compound_req_array.compound_req_array_val[index]; - - switch (this_req->fop_enum) { - case GF_FOP_STAT: { - gfx_stat_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_stat_req; - - xdr_to_dict(&args->xdata, &xdata); - args_stat_store(this_args, &state->loc, xdata); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_readlink_req; - - xdr_to_dict(&args->xdata, &xdata); - args_readlink_store(this_args, &state->loc, args->size, xdata); - break; - } - case GF_FOP_MKNOD: { - gfx_mknod_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_mknod_req; - - xdr_to_dict(&args->xdata, &xdata); - args_mknod_store(this_args, &state->loc, args->mode, args->dev, - args->umask, xdata); - break; - } - case GF_FOP_MKDIR: { - gfx_mkdir_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_mkdir_req; - - xdr_to_dict(&args->xdata, &xdata); - args_mkdir_store(this_args, &state->loc, args->mode, args->umask, - xdata); - break; - } - case GF_FOP_UNLINK: { - gfx_unlink_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_unlink_req; - - xdr_to_dict(&args->xdata, &xdata); - args_unlink_store(this_args, &state->loc, args->xflags, xdata); - break; - } - case GF_FOP_RMDIR: { - gfx_rmdir_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_rmdir_req; - - xdr_to_dict(&args->xdata, &xdata); - args_rmdir_store(this_args, &state->loc, args->xflags, xdata); - break; - } - case GF_FOP_SYMLINK: { - gfx_symlink_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_symlink_req; - - xdr_to_dict(&args->xdata, &xdata); - args_symlink_store(this_args, args->linkname, &state->loc, - args->umask, xdata); - - this_args->loc.inode = inode_new(state->itable); - - break; - } - case GF_FOP_RENAME: { - gfx_rename_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_rename_req; - - xdr_to_dict(&args->xdata, &xdata); - - args_rename_store(this_args, &state->loc, &state->loc2, xdata); - break; - } - case GF_FOP_LINK: { - gfx_link_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_link_req; - - xdr_to_dict(&args->xdata, &xdata); - args_link_store(this_args, &state->loc, &state->loc2, xdata); - - this_args->loc2.inode = inode_ref(this_args->loc.inode); - - break; - } - case GF_FOP_TRUNCATE: { - gfx_truncate_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_truncate_req; - - xdr_to_dict(&args->xdata, &xdata); - args_truncate_store(this_args, &state->loc, args->offset, xdata); - break; - } - case GF_FOP_OPEN: { - gfx_open_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_open_req; - - xdr_to_dict(&args->xdata, &xdata); - args_open_store(this_args, &state->loc, args->flags, state->fd, - xdata); - - this_args->fd = fd_create(this_args->loc.inode, frame->root->pid); - this_args->fd->flags = this_args->flags; - - break; - } - case GF_FOP_READ: { - gfx_read_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_read_req; - - xdr_to_dict(&args->xdata, &xdata); - args_readv_store(this_args, state->fd, args->size, args->offset, - args->flag, xdata); - break; - } - case GF_FOP_WRITE: { - gfx_write_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_write_req; - - /*TODO : What happens when payload count is more than one? */ - req_iovec[0].iov_base = state->payload_vector[0].iov_base + - state->write_length; - req_iovec[0].iov_len = args->size; - - xdr_to_dict(&args->xdata, &xdata); - /* The way writev fop works : - * xdr args of write along with other args contains - * write length not count. But when the call is wound to posix, - * this length is not used. It is taken from the request - * write vector that is passed down. Posix needs the vector - * count to determine the amount of write to be done. - * This count for writes that come as part of compound fops - * will be 1. The vectors are merged into one under - * GF_FOP_WRITE section of client_handle_fop_requirements() - * in protocol client. - */ - args_writev_store(this_args, state->fd, req_iovec, 1, args->offset, - args->flag, state->iobref, xdata); - state->write_length += req_iovec[0].iov_len; - break; - } - case GF_FOP_STATFS: { - gfx_statfs_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_statfs_req; - - xdr_to_dict(&args->xdata, &xdata); - args_statfs_store(this_args, &state->loc, xdata); - break; - } - case GF_FOP_FLUSH: { - gfx_flush_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_flush_req; - - xdr_to_dict(&args->xdata, &xdata); - args_flush_store(this_args, state->fd, xdata); - break; - } - case GF_FOP_FSYNC: { - gfx_fsync_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fsync_req; - - xdr_to_dict(&args->xdata, &xdata); - args_fsync_store(this_args, state->fd, args->data, xdata); - break; - } - case GF_FOP_SETXATTR: { - gfx_setxattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_setxattr_req; - - xdr_to_dict(&args->dict, &xattr); - xdr_to_dict(&args->xdata, &xdata); - args_setxattr_store(this_args, &state->loc, xattr, args->flags, - xdata); - break; - } - case GF_FOP_GETXATTR: { - gfx_getxattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_getxattr_req; - - xdr_to_dict(&args->xdata, &xdata); - gf_server_check_getxattr_cmd(frame, args->name); - - args_getxattr_store(this_args, &state->loc, args->name, xdata); - break; - } - case GF_FOP_REMOVEXATTR: { - gfx_removexattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_removexattr_req; - - xdr_to_dict(&args->xdata, &xdata); - args_removexattr_store(this_args, &state->loc, args->name, xdata); - break; - } - case GF_FOP_OPENDIR: { - gfx_opendir_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_opendir_req; - - this_args->fd = fd_create(this_args->loc.inode, frame->root->pid); - if (!this_args->fd) { - gf_msg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, - "could not create the fd"); - goto out; - } - xdr_to_dict(&args->xdata, &xdata); - - args_opendir_store(this_args, &state->loc, state->fd, xdata); - break; - } - case GF_FOP_FSYNCDIR: { - gfx_fsyncdir_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fsyncdir_req; - - xdr_to_dict(&args->xdata, &xdata); - args_fsyncdir_store(this_args, state->fd, args->data, xdata); - break; - } - case GF_FOP_ACCESS: { - gfx_access_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_access_req; - - xdr_to_dict(&args->xdata, &xdata); - args_access_store(this_args, &state->loc, args->mask, xdata); - break; - } - case GF_FOP_CREATE: { - gfx_create_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_create_req; - - state->loc.inode = inode_new(state->itable); - - state->fd = fd_create(state->loc.inode, frame->root->pid); - if (!state->fd) { - gf_msg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, - "fd creation for the inode %s failed", - state->loc.inode ? uuid_utoa(state->loc.inode->gfid) - : NULL); - goto out; - } - state->fd->flags = state->flags; - - xdr_to_dict(&args->xdata, &xdata); - args_create_store(this_args, &state->loc, args->flags, args->mode, - args->umask, state->fd, xdata); - break; - } - case GF_FOP_FTRUNCATE: { - gfx_ftruncate_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_ftruncate_req; - - xdr_to_dict(&args->xdata, &xdata); - args_ftruncate_store(this_args, state->fd, args->offset, xdata); - break; - } - case GF_FOP_FSTAT: { - gfx_fstat_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fstat_req; - - xdr_to_dict(&args->xdata, &xdata); - args_fstat_store(this_args, state->fd, xdata); - break; - } - case GF_FOP_LK: { - gfx_lk_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_lk_req; - - xdr_to_dict(&args->xdata, &xdata); - - switch (args->cmd) { - case GF_LK_GETLK: - this_args->cmd = F_GETLK; - break; - case GF_LK_SETLK: - this_args->cmd = F_SETLK; - break; - case GF_LK_SETLKW: - this_args->cmd = F_SETLKW; - break; - case GF_LK_RESLK_LCK: - this_args->cmd = F_RESLK_LCK; - break; - case GF_LK_RESLK_LCKW: - this_args->cmd = F_RESLK_LCKW; - break; - case GF_LK_RESLK_UNLCK: - this_args->cmd = F_RESLK_UNLCK; - break; - case GF_LK_GETLK_FD: - this_args->cmd = F_GETLK_FD; - break; - } - - gf_proto_flock_to_flock(&args->flock, &this_args->lock); - - switch (args->type) { - case GF_LK_F_RDLCK: - this_args->lock.l_type = F_RDLCK; - break; - case GF_LK_F_WRLCK: - this_args->lock.l_type = F_WRLCK; - break; - case GF_LK_F_UNLCK: - this_args->lock.l_type = F_UNLCK; - break; - default: - gf_msg(frame->root->client->bound_xl->name, GF_LOG_ERROR, 0, - PS_MSG_LOCK_ERROR, - "fd - %" PRId64 - " (%s):" - " Unknown " - "lock type: %" PRId32 "!", - state->resolve.fd_no, - uuid_utoa(state->fd->inode->gfid), args->type); - break; - } - args_lk_store(this_args, state->fd, this_args->cmd, - &this_args->lock, xdata); - break; - } - case GF_FOP_LOOKUP: { - gfx_lookup_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_lookup_req; - - if (this_args->loc.inode) - this_args->loc.inode = server_inode_new(state->itable, - state->loc.gfid); - else - state->is_revalidate = 1; - - xdr_to_dict(&args->xdata, &xdata); - args_lookup_store(this_args, &state->loc, xdata); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_readdir_req; - - xdr_to_dict(&args->xdata, &xdata); - args_readdir_store(this_args, state->fd, args->size, args->offset, - xdata); - break; - } - case GF_FOP_INODELK: { - gfx_inodelk_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_inodelk_req; - - switch (args->cmd) { - case GF_LK_GETLK: - this_args->cmd = F_GETLK; - break; - case GF_LK_SETLK: - this_args->cmd = F_SETLK; - break; - case GF_LK_SETLKW: - this_args->cmd = F_SETLKW; - break; - } - - gf_proto_flock_to_flock(&args->flock, &this_args->lock); - - switch (args->type) { - case GF_LK_F_RDLCK: - this_args->lock.l_type = F_RDLCK; - break; - case GF_LK_F_WRLCK: - this_args->lock.l_type = F_WRLCK; - break; - case GF_LK_F_UNLCK: - this_args->lock.l_type = F_UNLCK; - break; - } - - xdr_to_dict(&args->xdata, &xdata); - args_inodelk_store(this_args, args->volume, &state->loc, - this_args->cmd, &this_args->lock, xdata); - break; - } - case GF_FOP_FINODELK: { - gfx_finodelk_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_finodelk_req; - - xdr_to_dict(&args->xdata, &xdata); - - switch (args->cmd) { - case GF_LK_GETLK: - this_args->cmd = F_GETLK; - break; - case GF_LK_SETLK: - this_args->cmd = F_SETLK; - break; - case GF_LK_SETLKW: - this_args->cmd = F_SETLKW; - break; - } - - gf_proto_flock_to_flock(&args->flock, &this_args->lock); - - switch (args->type) { - case GF_LK_F_RDLCK: - this_args->lock.l_type = F_RDLCK; - break; - case GF_LK_F_WRLCK: - this_args->lock.l_type = F_WRLCK; - break; - case GF_LK_F_UNLCK: - this_args->lock.l_type = F_UNLCK; - break; - } - args_finodelk_store(this_args, args->volume, state->fd, - this_args->cmd, &this_args->lock, xdata); - break; - } - case GF_FOP_ENTRYLK: { - gfx_entrylk_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_entrylk_req; - - xdr_to_dict(&args->xdata, &xdata); - args_entrylk_store(this_args, args->volume, &state->loc, args->name, - args->cmd, args->type, xdata); - break; - } - case GF_FOP_FENTRYLK: { - gfx_fentrylk_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fentrylk_req; - - xdr_to_dict(&args->xdata, &xdata); - args_fentrylk_store(this_args, args->volume, state->fd, args->name, - args->cmd, args->type, xdata); - break; - } - case GF_FOP_XATTROP: { - gfx_xattrop_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_xattrop_req; - - xdr_to_dict(&args->dict, &xattr); - - xdr_to_dict(&args->xdata, &xdata); - args_xattrop_store(this_args, &state->loc, args->flags, xattr, - xdata); - break; - } - case GF_FOP_FXATTROP: { - gfx_fxattrop_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fxattrop_req; - - xdr_to_dict(&args->dict, &xattr); - - xdr_to_dict(&args->xdata, &xdata); - - args_fxattrop_store(this_args, state->fd, args->flags, xattr, - xdata); - break; - } - case GF_FOP_FGETXATTR: { - gfx_fgetxattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fgetxattr_req; - - xdr_to_dict(&args->xdata, &xdata); - - args_fgetxattr_store(this_args, state->fd, args->name, xdata); - break; - } - case GF_FOP_FSETXATTR: { - gfx_fsetxattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fsetxattr_req; - - xdr_to_dict(&args->dict, &xattr); - - xdr_to_dict(&args->xdata, &xdata); - - args_fsetxattr_store(this_args, state->fd, xattr, args->flags, - xdata); - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_rchecksum_req; - - xdr_to_dict(&args->xdata, &xdata); - - args_rchecksum_store(this_args, state->fd, args->offset, args->len, - xdata); - break; - } - case GF_FOP_SETATTR: { - gfx_setattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_setattr_req; - - xdr_to_dict(&args->xdata, &xdata); - - gfx_stat_to_iattx(&args->stbuf, &this_args->stat); - - args_setattr_store(this_args, &state->loc, &this_args->stat, - args->valid, xdata); - break; - } - case GF_FOP_FSETATTR: { - gfx_fsetattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fsetattr_req; - - xdr_to_dict(&args->xdata, &xdata); - - gfx_stat_to_iattx(&args->stbuf, &this_args->stat); - - args_fsetattr_store(this_args, state->fd, &this_args->stat, - args->valid, xdata); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_readdirp_req; - - xdr_to_dict(&args->xdata, &xdata); - - args_readdirp_store(this_args, state->fd, args->size, args->offset, - xattr); - break; - } - case GF_FOP_FREMOVEXATTR: { - gfx_fremovexattr_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fremovexattr_req; - - xdr_to_dict(&args->xdata, &xdata); - - args_fremovexattr_store(this_args, state->fd, args->name, xdata); - break; - } - case GF_FOP_FALLOCATE: { - gfx_fallocate_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_fallocate_req; - - xdr_to_dict(&args->xdata, &xdata); - args_fallocate_store(this_args, state->fd, args->flags, - args->offset, args->size, xdata); - break; - } - case GF_FOP_DISCARD: { - gfx_discard_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_discard_req; - - xdr_to_dict(&args->xdata, &xdata); - - args_discard_store(this_args, state->fd, args->offset, args->size, - xdata); - break; - } - case GF_FOP_ZEROFILL: { - gfx_zerofill_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_zerofill_req; - - xdr_to_dict(&args->xdata, &xdata); - args_zerofill_store(this_args, state->fd, args->offset, args->size, - xdata); - break; - } - case GF_FOP_SEEK: { - gfx_seek_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_seek_req; - - xdr_to_dict(&args->xdata, &xdata); - args_seek_store(this_args, state->fd, args->offset, args->what, - xdata); - break; - } - case GF_FOP_LEASE: { - gfx_lease_req *args = NULL; - - args = &this_req->compound_req_v2_u.compound_lease_req; - - xdr_to_dict(&args->xdata, &xdata); - - gf_proto_lease_to_lease(&args->lease, &state->lease); - - args_lease_store(this_args, &state->loc, &state->lease, xdata); - break; - } - default: - return ENOTSUP; - } -out: - if (xattr) - dict_unref(xattr); - if (xdata) - dict_unref(xdata); - return op_errno; -} - -int -server_populate_compound_response_v2(xlator_t *this, gfx_compound_rsp *rsp, - call_frame_t *frame, - compound_args_cbk_t *args_cbk, int index) -{ - int op_errno = EINVAL; - default_args_cbk_t *this_args_cbk = NULL; - compound_rsp_v2 *this_rsp = NULL; - server_state_t *state = NULL; - int ret = 0; - - state = CALL_STATE(frame); - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index]; - - this_args_cbk = &args_cbk->rsp_list[index]; - this_rsp->fop_enum = args_cbk->enum_list[index]; - - switch (this_rsp->fop_enum) { - case GF_FOP_FSTAT: - case GF_FOP_STAT: { - gfx_common_iatt_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_stat_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - if (!this_args_cbk->op_ret) { - server4_post_common_iatt(state, rsp_args, &this_args_cbk->stat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_readlink_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - if (this_args_cbk->op_ret >= 0) { - server4_post_readlink(rsp_args, &this_args_cbk->stat, - this_args_cbk->buf); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - if (!rsp_args->path) - rsp_args->path = ""; - break; - } - case GF_FOP_MKNOD: - case GF_FOP_MKDIR: - case GF_FOP_SYMLINK: - case GF_FOP_LINK: { - gfx_common_3iatt_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_mknod_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - if (!this_args_cbk->op_ret) { - server4_post_common_3iatt( - state, rsp_args, this_args_cbk->inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_UNLINK: - case GF_FOP_RMDIR: { - gfx_common_2iatt_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_unlink_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - if (!this_args_cbk->op_ret) { - server4_post_entry_remove(state, rsp_args, - &this_args_cbk->preparent, - &this_args_cbk->postparent); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_RENAME: { - gfx_rename_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_rename_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (!this_args_cbk->op_ret) { - server4_post_rename( - frame, state, rsp_args, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - &this_args_cbk->preparent2, &this_args_cbk->postparent2); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FALLOCATE: - case GF_FOP_ZEROFILL: - case GF_FOP_DISCARD: - case GF_FOP_SETATTR: - case GF_FOP_FSETATTR: - case GF_FOP_FTRUNCATE: - case GF_FOP_TRUNCATE: - case GF_FOP_WRITE: - case GF_FOP_FSYNC: { - gfx_common_2iatt_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_truncate_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (!this_args_cbk->op_ret) { - server4_post_common_2iatt(rsp_args, &this_args_cbk->prestat, - &this_args_cbk->poststat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_OPEN: - case GF_FOP_OPENDIR: { - gfx_open_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_open_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (!this_args_cbk->op_ret) { - server4_post_open(frame, this, rsp_args, this_args_cbk->fd); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READ: { - gfx_read_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_read_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (this_args_cbk->op_ret >= 0) { - server4_post_readv(rsp_args, &this_args_cbk->stat, - this_args_cbk->op_ret); - - if (!state->rsp_iobref) { - state->rsp_iobref = this_args_cbk->iobref; - state->rsp_count = 0; - } - iobref_merge(state->rsp_iobref, this_args_cbk->iobref); - memcpy(&state->rsp_vector[state->rsp_count], - this_args_cbk->vector, - (this_args_cbk->count * sizeof(state->rsp_vector[0]))); - state->rsp_count += this_args_cbk->count; - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_STATFS: { - gfx_statfs_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_statfs_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - if (!this_args_cbk->op_ret) { - server4_post_statfs(rsp_args, &this_args_cbk->statvfs); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FLUSH: - case GF_FOP_SETXATTR: - case GF_FOP_FSETXATTR: - case GF_FOP_REMOVEXATTR: - case GF_FOP_FREMOVEXATTR: - case GF_FOP_FSYNCDIR: - case GF_FOP_ACCESS: - case GF_FOP_INODELK: - case GF_FOP_FINODELK: - case GF_FOP_ENTRYLK: - case GF_FOP_FENTRYLK: { - gfx_common_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_flush_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_FGETXATTR: - case GF_FOP_GETXATTR: - case GF_FOP_XATTROP: - case GF_FOP_FXATTROP: { - gfx_common_dict_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_getxattr_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (-1 != this_args_cbk->op_ret) { - dict_to_xdr(this_args_cbk->xattr, &rsp_args->dict); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_CREATE: { - gfx_create_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_create_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - - if (!this_args_cbk->op_ret) { - rsp_args->op_ret = server4_post_create( - frame, rsp_args, state, this, this_args_cbk->fd, - this_args_cbk->inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent); - if (rsp_args->op_ret) { - rsp_args->op_errno = -rsp_args->op_ret; - rsp_args->op_ret = -1; - } - } - break; - } - case GF_FOP_LK: { - gfx_lk_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_lk_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (!this_args_cbk->op_ret) { - server4_post_lk(this, rsp_args, &this_args_cbk->lock); - } - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_LOOKUP: { - gfx_common_2iatt_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_lookup_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - gfx_stat_from_iattx(&rsp_args->poststat, - &this_args_cbk->postparent); - - if (!this_args_cbk->op_ret) { - server4_post_lookup(rsp_args, frame, state, - this_args_cbk->inode, &this_args_cbk->stat); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_readdir_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - - if (this_args_cbk->op_ret > 0) { - ret = server4_post_readdir(rsp_args, &this_args_cbk->entries); - if (ret < 0) { - rsp_args->op_ret = ret; - rsp_args->op_errno = ENOMEM; - } - } - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_rchecksum_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (!this_args_cbk->op_ret) { - server4_post_rchecksum(rsp_args, this_args_cbk->weak_checksum, - this_args_cbk->strong_checksum); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_readdirp_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (this_args_cbk->op_ret > 0) { - ret = server4_post_readdirp(rsp_args, &this_args_cbk->entries); - if (ret < 0) { - rsp_args->op_ret = ret; - rsp_args->op_errno = ENOMEM; - goto out; - } - gf_link_inodes_from_dirent(this, state->fd->inode, - &this_args_cbk->entries); - } - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_SEEK: { - gfx_seek_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_seek_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - case GF_FOP_LEASE: { - gfx_lease_rsp *rsp_args = NULL; - - rsp_args = &this_rsp->compound_rsp_v2_u.compound_lease_rsp; - - dict_to_xdr(this_args_cbk->xdata, &rsp_args->xdata); - - if (!this_args_cbk->op_ret) { - server4_post_lease(rsp_args, &this_args_cbk->lease); - } - - rsp_args->op_ret = this_args_cbk->op_ret; - rsp_args->op_errno = gf_errno_to_error(this_args_cbk->op_errno); - break; - } - default: - return ENOTSUP; - } - op_errno = 0; -out: - return op_errno; -} -/* This works only when the compound fop acts on one loc/inode/gfid. - * If compound fops on more than one inode is required, multiple - * resolve and resumes will have to be done. This will have to change. - * Right now, multiple unlinks, rmdirs etc is are not supported. - * This can be added for future enhancements. - */ -int -server_get_compound_resolve_v2(server_state_t *state, gfx_compound_req *req) -{ - int i = 0; - compound_req_v2 *array = NULL; - - array = &req->compound_req_array.compound_req_array_val[i]; - - switch (array->fop_enum) { - case GF_FOP_STAT: { - gfx_stat_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_stat_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_readlink_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_MKNOD: { - gfx_mknod_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_mknod_req; - - state->resolve.type = RESOLVE_NOT; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_MKDIR: { - gfx_mkdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_mkdir_req; - - state->resolve.type = RESOLVE_NOT; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_UNLINK: { - gfx_unlink_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_unlink_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_RMDIR: { - gfx_rmdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_rmdir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_SYMLINK: { - gfx_symlink_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_symlink_req; - - state->resolve.type = RESOLVE_NOT; - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_RENAME: { - gfx_rename_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_rename_req; - - state->resolve.type = RESOLVE_MUST; - state->resolve.bname = gf_strdup(this_req.oldbname); - memcpy(state->resolve.pargfid, this_req.oldgfid, 16); - - state->resolve2.type = RESOLVE_MAY; - state->resolve2.bname = gf_strdup(this_req.newbname); - memcpy(state->resolve2.pargfid, this_req.newgfid, 16); - break; - } - case GF_FOP_LINK: { - gfx_link_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_link_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.oldgfid, 16); - - state->resolve2.type = RESOLVE_NOT; - state->resolve2.bname = gf_strdup(this_req.newbname); - memcpy(state->resolve2.pargfid, this_req.newgfid, 16); - break; - } - case GF_FOP_TRUNCATE: { - gfx_truncate_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_truncate_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_OPEN: { - gfx_open_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_open_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_READ: { - gfx_read_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_read_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_WRITE: { - gfx_write_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_write_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_STATFS: { - gfx_statfs_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_statfs_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FLUSH: { - gfx_flush_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_flush_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FSYNC: { - gfx_fsync_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fsync_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_SETXATTR: { - gfx_setxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_setxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_GETXATTR: { - gfx_getxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_getxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_REMOVEXATTR: { - gfx_removexattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_removexattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_OPENDIR: { - gfx_opendir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_opendir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FSYNCDIR: { - gfx_fsyncdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fsyncdir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_ACCESS: { - gfx_access_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_access_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_CREATE: { - gfx_create_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_create_req; - - state->flags = gf_flags_to_flags(this_req.flags); - if (state->flags & O_EXCL) { - state->resolve.type = RESOLVE_NOT; - } else { - state->resolve.type = RESOLVE_DONTCARE; - } - - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - break; - } - case GF_FOP_FTRUNCATE: { - gfx_ftruncate_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_ftruncate_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FSTAT: { - gfx_fstat_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fstat_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_LK: { - gfx_lk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_lk_req; - - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_LOOKUP: { - gfx_lookup_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_lookup_req; - state->resolve.type = RESOLVE_DONTCARE; - - if (this_req.bname && strcmp(this_req.bname, "")) { - memcpy(state->resolve.pargfid, this_req.pargfid, 16); - state->resolve.bname = gf_strdup(this_req.bname); - } else { - memcpy(state->resolve.gfid, this_req.gfid, 16); - } - break; - } - case GF_FOP_READDIR: { - gfx_readdir_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_readdir_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_INODELK: { - gfx_inodelk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_inodelk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FINODELK: { - gfx_finodelk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_finodelk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_ENTRYLK: { - gfx_entrylk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_entrylk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FENTRYLK: { - gfx_fentrylk_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fentrylk_req; - - state->resolve.type = RESOLVE_EXACT; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_XATTROP: { - gfx_xattrop_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_xattrop_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FXATTROP: { - gfx_fxattrop_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fxattrop_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FGETXATTR: { - gfx_fgetxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fgetxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FSETXATTR: { - gfx_fsetxattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fsetxattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_req this_req = { - { - 0, - }, - }; - - this_req = array[i].compound_req_v2_u.compound_rchecksum_req; - - state->resolve.type = RESOLVE_MAY; - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_SETATTR: { - gfx_setattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_setattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_FSETATTR: { - gfx_fsetattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fsetattr_req; - - state->resolve.type = RESOLVE_MUST; - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_readdirp_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FREMOVEXATTR: { - gfx_fremovexattr_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fremovexattr_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_FALLOCATE: { - gfx_fallocate_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_fallocate_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_DISCARD: { - gfx_discard_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_discard_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_ZEROFILL: { - gfx_zerofill_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_zerofill_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_SEEK: { - gfx_seek_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_seek_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - state->resolve.fd_no = this_req.fd; - break; - } - case GF_FOP_LEASE: { - gfx_lease_req this_req = {{ - 0, - }}; - - this_req = array[i].compound_req_v2_u.compound_lease_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - default: - return ENOTSUP; - } - return 0; -} - -void -server_compound_rsp_cleanup_v2(gfx_compound_rsp *rsp, compound_args_cbk_t *args) -{ - int i, len = 0; - compound_rsp_v2 *this_rsp = NULL; - - if (!rsp->compound_rsp_array.compound_rsp_array_val) - return; - - len = rsp->compound_rsp_array.compound_rsp_array_len; - - for (i = 0; i < len; i++) { - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; - switch (args->enum_list[i]) { - case GF_FOP_STAT: - SERVER4_FOP_RSP_CLEANUP(rsp, stat, i, common_iatt); - break; - case GF_FOP_MKNOD: - SERVER4_FOP_RSP_CLEANUP(rsp, mknod, i, common_3iatt); - break; - case GF_FOP_MKDIR: - SERVER4_FOP_RSP_CLEANUP(rsp, mkdir, i, common_3iatt); - break; - case GF_FOP_UNLINK: - SERVER4_FOP_RSP_CLEANUP(rsp, unlink, i, common_2iatt); - break; - case GF_FOP_RMDIR: - SERVER4_FOP_RSP_CLEANUP(rsp, rmdir, i, common_2iatt); - break; - case GF_FOP_SYMLINK: - SERVER4_FOP_RSP_CLEANUP(rsp, symlink, i, common_3iatt); - break; - case GF_FOP_RENAME: - SERVER4_FOP_RSP_CLEANUP(rsp, rename, i, rename); - break; - case GF_FOP_LINK: - SERVER4_FOP_RSP_CLEANUP(rsp, link, i, common_3iatt); - break; - case GF_FOP_TRUNCATE: - SERVER4_FOP_RSP_CLEANUP(rsp, truncate, i, common_2iatt); - break; - case GF_FOP_OPEN: - SERVER4_FOP_RSP_CLEANUP(rsp, open, i, open); - break; - case GF_FOP_READ: - SERVER4_FOP_RSP_CLEANUP(rsp, read, i, read); - break; - case GF_FOP_WRITE: - SERVER4_FOP_RSP_CLEANUP(rsp, write, i, common_2iatt); - break; - case GF_FOP_STATFS: - SERVER4_FOP_RSP_CLEANUP(rsp, statfs, i, statfs); - break; - case GF_FOP_FSYNC: - SERVER4_FOP_RSP_CLEANUP(rsp, fsync, i, common_2iatt); - break; - case GF_FOP_OPENDIR: - SERVER4_FOP_RSP_CLEANUP(rsp, opendir, i, open); - break; - case GF_FOP_CREATE: - SERVER4_FOP_RSP_CLEANUP(rsp, create, i, create); - break; - case GF_FOP_FTRUNCATE: - SERVER4_FOP_RSP_CLEANUP(rsp, ftruncate, i, common_2iatt); - break; - case GF_FOP_FSTAT: - SERVER4_FOP_RSP_CLEANUP(rsp, fstat, i, common_iatt); - break; - case GF_FOP_LK: - SERVER4_FOP_RSP_CLEANUP(rsp, lk, i, lk); - break; - case GF_FOP_LOOKUP: - SERVER4_FOP_RSP_CLEANUP(rsp, lookup, i, common_2iatt); - break; - case GF_FOP_SETATTR: - SERVER4_FOP_RSP_CLEANUP(rsp, setattr, i, common_2iatt); - break; - case GF_FOP_FSETATTR: - SERVER4_FOP_RSP_CLEANUP(rsp, fsetattr, i, common_2iatt); - break; - case GF_FOP_FALLOCATE: - SERVER4_FOP_RSP_CLEANUP(rsp, fallocate, i, common_2iatt); - break; - case GF_FOP_DISCARD: - SERVER4_FOP_RSP_CLEANUP(rsp, discard, i, common_2iatt); - break; - case GF_FOP_ZEROFILL: - SERVER4_FOP_RSP_CLEANUP(rsp, zerofill, i, common_2iatt); - break; - case GF_FOP_SEEK: - SERVER4_FOP_RSP_CLEANUP(rsp, seek, i, seek); - break; - case GF_FOP_LEASE: - SERVER4_FOP_RSP_CLEANUP(rsp, lease, i, lease); - break; - case GF_FOP_READLINK: - SERVER4_FOP_RSP_CLEANUP(rsp, readlink, i, readlink); - break; - case GF_FOP_RCHECKSUM: - SERVER4_FOP_RSP_CLEANUP(rsp, rchecksum, i, rchecksum); - break; - /* fops that use gfx_common_rsp */ - case GF_FOP_IPC: - SERVER4_COMMON_RSP_CLEANUP(rsp, ipc, i); - break; - case GF_FOP_FLUSH: - SERVER4_COMMON_RSP_CLEANUP(rsp, flush, i); - break; - case GF_FOP_SETXATTR: - SERVER4_COMMON_RSP_CLEANUP(rsp, setxattr, i); - break; - case GF_FOP_REMOVEXATTR: - SERVER4_COMMON_RSP_CLEANUP(rsp, removexattr, i); - break; - case GF_FOP_FSETXATTR: - SERVER4_COMMON_RSP_CLEANUP(rsp, fsetxattr, i); - break; - case GF_FOP_FREMOVEXATTR: - SERVER4_COMMON_RSP_CLEANUP(rsp, fremovexattr, i); - break; - case GF_FOP_FSYNCDIR: - SERVER4_COMMON_RSP_CLEANUP(rsp, fsyncdir, i); - break; - case GF_FOP_ACCESS: - SERVER4_COMMON_RSP_CLEANUP(rsp, access, i); - break; - case GF_FOP_INODELK: - SERVER4_COMMON_RSP_CLEANUP(rsp, inodelk, i); - break; - case GF_FOP_FINODELK: - SERVER4_COMMON_RSP_CLEANUP(rsp, finodelk, i); - break; - case GF_FOP_ENTRYLK: - SERVER4_COMMON_RSP_CLEANUP(rsp, entrylk, i); - break; - case GF_FOP_FENTRYLK: - SERVER4_COMMON_RSP_CLEANUP(rsp, fentrylk, i); - break; - /* fops that need extra cleanup */ - case GF_FOP_XATTROP: { - gfx_common_dict_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, - xattrop); - SERVER4_FOP_RSP_CLEANUP(rsp, xattrop, i, common_dict); - GF_FREE(tmp_rsp->dict.pairs.pairs_val); - break; - } - case GF_FOP_FXATTROP: { - gfx_common_dict_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, - fxattrop); - SERVER4_FOP_RSP_CLEANUP(rsp, fxattrop, i, common_dict); - GF_FREE(tmp_rsp->dict.pairs.pairs_val); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readdir); - SERVER4_FOP_RSP_CLEANUP(rsp, readdir, i, readdir); - readdir_rsp_cleanup_v2(tmp_rsp); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readdirp); - SERVER4_FOP_RSP_CLEANUP(rsp, readdirp, i, readdirp); - readdirp_rsp_cleanup_v2(tmp_rsp); - break; - } - case GF_FOP_GETXATTR: { - gfx_common_dict_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, - getxattr); - SERVER4_FOP_RSP_CLEANUP(rsp, getxattr, i, common_dict); - GF_FREE(tmp_rsp->dict.pairs.pairs_val); - break; - } - case GF_FOP_FGETXATTR: { - gfx_common_dict_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, - fgetxattr); - SERVER4_FOP_RSP_CLEANUP(rsp, fgetxattr, i, common_dict); - GF_FREE(tmp_rsp->dict.pairs.pairs_val); - break; - } - default: - break; - } - } - GF_FREE(rsp->compound_rsp_array.compound_rsp_array_val); - return; -} - -void -server_compound_req_cleanup_v2(gfx_compound_req *req, int len) -{ - int i = 0; - compound_req_v2 *curr_req = NULL; - - if (!req->compound_req_array.compound_req_array_val) - return; - - for (i = 0; i < len; i++) { - curr_req = &req->compound_req_array.compound_req_array_val[i]; - - switch (curr_req->fop_enum) { - case GF_FOP_MKDIR: { - gfx_mkdir_req *args = &CPD4_REQ_FIELD(curr_req, mkdir); - - free(args->bname); - break; - } - case GF_FOP_UNLINK: { - gfx_unlink_req *args = &CPD4_REQ_FIELD(curr_req, unlink); - free(args->bname); - break; - } - case GF_FOP_RMDIR: { - gfx_rmdir_req *args = &CPD4_REQ_FIELD(curr_req, rmdir); - free(args->bname); - break; - } - case GF_FOP_SYMLINK: { - gfx_symlink_req *args = &CPD4_REQ_FIELD(curr_req, symlink); - free(args->bname); - free(args->linkname); - break; - } - case GF_FOP_RENAME: { - gfx_rename_req *args = &CPD4_REQ_FIELD(curr_req, rename); - free(args->oldbname); - free(args->newbname); - break; - } - case GF_FOP_LINK: { - gfx_link_req *args = &CPD4_REQ_FIELD(curr_req, link); - free(args->newbname); - break; - } - case GF_FOP_GETXATTR: { - gfx_getxattr_req *args = &CPD4_REQ_FIELD(curr_req, getxattr); - - free(args->name); - break; - } - case GF_FOP_REMOVEXATTR: { - gfx_removexattr_req *args = &CPD4_REQ_FIELD(curr_req, - removexattr); - - free(args->name); - break; - } - case GF_FOP_CREATE: { - gfx_create_req *args = &CPD4_REQ_FIELD(curr_req, create); - - free(args->bname); - break; - } - case GF_FOP_LK: { - gfx_lk_req *args = &CPD4_REQ_FIELD(curr_req, lk); - free(args->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_LOOKUP: { - gfx_lookup_req *args = &CPD4_REQ_FIELD(curr_req, lookup); - free(args->bname); - break; - } - case GF_FOP_INODELK: { - gfx_inodelk_req *args = &CPD4_REQ_FIELD(curr_req, inodelk); - - free(args->volume); - free(args->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_FINODELK: { - gfx_finodelk_req *args = &CPD4_REQ_FIELD(curr_req, finodelk); - - free(args->volume); - free(args->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_ENTRYLK: { - gfx_entrylk_req *args = &CPD4_REQ_FIELD(curr_req, entrylk); - - free(args->volume); - free(args->name); - break; - } - case GF_FOP_FENTRYLK: { - gfx_fentrylk_req *args = &CPD4_REQ_FIELD(curr_req, fentrylk); - - free(args->volume); - free(args->name); - break; - } - case GF_FOP_FGETXATTR: { - gfx_fgetxattr_req *args = &CPD4_REQ_FIELD(curr_req, fgetxattr); - - free(args->name); - break; - } - case GF_FOP_FREMOVEXATTR: { - gfx_fremovexattr_req *args = &CPD4_REQ_FIELD(curr_req, - fremovexattr); - free(args->name); - break; - } - default: - break; - } - } - - return; -} diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h index 20b8d901bd2..837fdc84f17 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -12,7 +12,7 @@ #define _SERVER_HELPERS_H #include "server.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #define CALL_STATE(frame) ((server_state_t *)frame->root->state) @@ -43,8 +43,8 @@ call_frame_t * get_frame_from_request(rpcsvc_request_t *req); int -server_connection_cleanup(xlator_t *this, struct _client *client, - int32_t flags); +server_connection_cleanup(xlator_t *this, struct _client *client, int32_t flags, + gf_boolean_t *fd_exist); int server_build_config(xlator_t *this, server_conf_t *conf); @@ -86,22 +86,6 @@ int getactivelkinfo_rsp_cleanup_v2(gfx_getactivelk_rsp *rsp); int -server_populate_compound_response(xlator_t *this, gfs3_compound_rsp *rsp, - call_frame_t *frame, - compound_args_cbk_t *args_cbk, int index); -int -server_get_compound_resolve(server_state_t *state, gfs3_compound_req *req); - -int -server_populate_compound_request(gfs3_compound_req *req, call_frame_t *frame, - default_args_t *this_args, int index); -void -server_compound_rsp_cleanup(gfs3_compound_rsp *rsp, compound_args_cbk_t *args); - -void -server_compound_req_cleanup(gfs3_compound_req *req, int len); - -int unserialize_req_locklist(gfs3_setactivelk_req *req, lock_migration_info_t *lmi); int @@ -120,21 +104,4 @@ serialize_rsp_dirent_v2(gf_dirent_t *entries, gfx_readdir_rsp *rsp); int serialize_rsp_direntp_v2(gf_dirent_t *entries, gfx_readdirp_rsp *rsp); -int -server_populate_compound_response_v2(xlator_t *this, gfx_compound_rsp *rsp, - call_frame_t *frame, - compound_args_cbk_t *args_cbk, int index); -int -server_get_compound_resolve_v2(server_state_t *state, gfx_compound_req *req); - -int -server_populate_compound_request_v2(gfx_compound_req *req, call_frame_t *frame, - default_args_t *this_args, int index); -void -server_compound_rsp_cleanup_v2(gfx_compound_rsp *rsp, - compound_args_cbk_t *args); - -void -server_compound_req_cleanup_v2(gfx_compound_req *req, int len); - #endif /* !_SERVER_HELPERS_H */ diff --git a/xlators/protocol/server/src/server-mem-types.h b/xlators/protocol/server/src/server-mem-types.h index 4b341e53845..081e9f40e84 100644 --- a/xlators/protocol/server/src/server-mem-types.h +++ b/xlators/protocol/server/src/server-mem-types.h @@ -11,19 +11,13 @@ #ifndef __SERVER_MEM_TYPES_H__ #define __SERVER_MEM_TYPES_H__ -#include "mem-types.h" +#include <glusterfs/mem-types.h> enum gf_server_mem_types_ { gf_server_mt_server_conf_t = gf_common_mt_end + 1, - gf_server_mt_resolv_comp_t, gf_server_mt_state_t, - gf_server_mt_locker_t, - gf_server_mt_lock_table_t, - gf_server_mt_conn_t, gf_server_mt_dirent_rsp_t, gf_server_mt_rsp_buf_t, - gf_server_mt_volfile_ctx_t, - gf_server_mt_timer_data_t, gf_server_mt_setvolume_rsp_t, gf_server_mt_lock_mig_t, gf_server_mt_compound_rsp_t, diff --git a/xlators/protocol/server/src/server-messages.h b/xlators/protocol/server/src/server-messages.h index bc7431b9d86..1b2e149cb7d 100644 --- a/xlators/protocol/server/src/server-messages.h +++ b/xlators/protocol/server/src/server-messages.h @@ -11,7 +11,7 @@ #ifndef _PS_MESSAGES_H__ #define _PS_MESSAGES_H__ -#include "glfs-message-id.h" +#include <glusterfs/glfs-message-id.h> /* To add new message IDs, append new identifiers at the end of the list. * @@ -23,43 +23,146 @@ * glfs-message-id.h. */ -GLFS_MSGID(PS, PS_MSG_AUTHENTICATE_ERROR, PS_MSG_VOL_VALIDATE_FAILED, - PS_MSG_AUTH_INIT_FAILED, PS_MSG_REMOTE_CLIENT_REFUSED, - PS_MSG_GFID_RESOLVE_FAILED, PS_MSG_ANONYMOUS_FD_CREATE_FAILED, - PS_MSG_NO_MEMORY, PS_MSG_FD_NOT_FOUND, PS_MSG_INVALID_ENTRY, - PS_MSG_GET_UID_FAILED, PS_MSG_UID_NOT_FOUND, PS_MSG_MAPPING_ERROR, - PS_MSG_FD_CLEANUP, PS_MSG_SERVER_CTX_GET_FAILED, PS_MSG_FDENTRY_NULL, - PS_MSG_DIR_NOT_FOUND, PS_MSG_SERVER_MSG, PS_MSG_DICT_SERIALIZE_FAIL, - PS_MSG_RW_STAT, PS_MSG_DICT_GET_FAILED, PS_MSG_LOGIN_ERROR, - PS_MSG_REMOUNT_CLIENT_REQD, PS_MSG_DEFAULTING_FILE, - PS_MSG_VOL_FILE_OPEN_FAILED, PS_MSG_STAT_ERROR, - PS_MSG_SSL_NAME_SET_FAILED, PS_MSG_ASPRINTF_FAILED, - PS_MSG_CLIENT_VERSION_NOT_SET, PS_MSG_CLIENT_ACCEPTED, - PS_MSG_CLIENT_LK_VERSION_ERROR, PS_MSG_GRACE_TIMER_EXPD, - PS_MSG_SERIALIZE_REPLY_FAILED, PS_MSG_AUTH_IP_ERROR, - PS_MSG_SKIP_FORMAT_CHK, PS_MSG_INTERNET_ADDR_ERROR, - PS_MSG_CLIENT_DISCONNECTING, PS_MSG_GRACE_TIMER_START, - PS_MSG_STATEDUMP_PATH_ERROR, PS_MSG_GRP_CACHE_ERROR, - PS_MSG_RPC_CONF_ERROR, PS_MSG_TRANSPORT_ERROR, PS_MSG_SUBVOL_NULL, - PS_MSG_PARENT_VOL_ERROR, PS_MSG_RPCSVC_CREATE_FAILED, - PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, PS_MSG_RPCSVC_NOTIFY, - PS_MSG_PGM_REG_FAILED, PS_MSG_ULIMIT_SET_FAILED, PS_MSG_STATFS, - PS_MSG_LOOKUP_INFO, PS_MSG_LK_INFO, PS_MSG_LOCK_ERROR, - PS_MSG_INODELK_INFO, PS_MSG_ENTRYLK_INFO, PS_MSG_ACCESS_INFO, - PS_MSG_DIR_INFO, PS_MSG_MKNOD_INFO, PS_MSG_REMOVEXATTR_INFO, - PS_MSG_GETXATTR_INFO, PS_MSG_SETXATTR_INFO, PS_MSG_RENAME_INFO, - PS_MSG_LINK_INFO, PS_MSG_TRUNCATE_INFO, PS_MSG_FSTAT_INFO, - PS_MSG_FLUSH_INFO, PS_MSG_SYNC_INFO, PS_MSG_WRITE_INFO, - PS_MSG_READ_INFO, PS_MSG_CHKSUM_INFO, PS_MSG_OPEN_INFO, - PS_MSG_CREATE_INFO, PS_MSG_SETATTR_INFO, PS_MSG_XATTROP_INFO, - PS_MSG_ALLOC_INFO, PS_MSG_DISCARD_INFO, PS_MSG_ZEROFILL_INFO, - PS_MSG_FD_CREATE_FAILED, PS_MSG_WRONG_STATE, PS_MSG_CONF_DIR_INVALID, - PS_MSG_MOUNT_PT_FAIL, PS_MSG_STAT_INFO, PS_MSG_FILE_OP_FAILED, - PS_MSG_GRACE_TIMER_CANCELLED, PS_MSG_ENCODE_MSG_FAILED, - PS_MSG_REPLY_SUBMIT_FAILED, PS_MSG_RPC_NOTIFY_ERROR, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, PS_MSG_SERVER_IPC_INFO, - PS_MSG_SEEK_INFO, PS_MSG_COMPOUND_INFO, - PS_MSG_CLIENT_OPVERSION_GET_FAILED, PS_MSG_CHILD_STATUS_FAILED, - PS_MSG_PUT_INFO); +GLFS_MSGID( + PS, PS_MSG_AUTHENTICATE_ERROR, PS_MSG_VOL_VALIDATE_FAILED, + PS_MSG_AUTH_INIT_FAILED, PS_MSG_REMOTE_CLIENT_REFUSED, + PS_MSG_GFID_RESOLVE_FAILED, PS_MSG_ANONYMOUS_FD_CREATE_FAILED, + PS_MSG_NO_MEMORY, PS_MSG_FD_NOT_FOUND, PS_MSG_INVALID_ENTRY, + PS_MSG_GET_UID_FAILED, PS_MSG_UID_NOT_FOUND, PS_MSG_MAPPING_ERROR, + PS_MSG_FD_CLEANUP, PS_MSG_SERVER_CTX_GET_FAILED, PS_MSG_FDENTRY_NULL, + PS_MSG_DIR_NOT_FOUND, PS_MSG_SERVER_MSG, PS_MSG_DICT_SERIALIZE_FAIL, + PS_MSG_RW_STAT, PS_MSG_DICT_GET_FAILED, PS_MSG_LOGIN_ERROR, + PS_MSG_REMOUNT_CLIENT_REQD, PS_MSG_DEFAULTING_FILE, + PS_MSG_VOL_FILE_OPEN_FAILED, PS_MSG_STAT_ERROR, PS_MSG_SSL_NAME_SET_FAILED, + PS_MSG_ASPRINTF_FAILED, PS_MSG_CLIENT_VERSION_NOT_SET, + PS_MSG_CLIENT_ACCEPTED, PS_MSG_CLIENT_LK_VERSION_ERROR, + PS_MSG_GRACE_TIMER_EXPD, PS_MSG_SERIALIZE_REPLY_FAILED, + PS_MSG_AUTH_IP_ERROR, PS_MSG_SKIP_FORMAT_CHK, PS_MSG_INTERNET_ADDR_ERROR, + PS_MSG_CLIENT_DISCONNECTING, PS_MSG_GRACE_TIMER_START, + PS_MSG_STATEDUMP_PATH_ERROR, PS_MSG_GRP_CACHE_ERROR, PS_MSG_RPC_CONF_ERROR, + PS_MSG_TRANSPORT_ERROR, PS_MSG_SUBVOL_NULL, PS_MSG_PARENT_VOL_ERROR, + PS_MSG_RPCSVC_CREATE_FAILED, PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, + PS_MSG_RPCSVC_NOTIFY, PS_MSG_PGM_REG_FAILED, PS_MSG_ULIMIT_SET_FAILED, + PS_MSG_STATFS, PS_MSG_LOOKUP_INFO, PS_MSG_LK_INFO, PS_MSG_LOCK_ERROR, + PS_MSG_INODELK_INFO, PS_MSG_ENTRYLK_INFO, PS_MSG_ACCESS_INFO, + PS_MSG_DIR_INFO, PS_MSG_MKNOD_INFO, PS_MSG_REMOVEXATTR_INFO, + PS_MSG_GETXATTR_INFO, PS_MSG_SETXATTR_INFO, PS_MSG_RENAME_INFO, + PS_MSG_LINK_INFO, PS_MSG_TRUNCATE_INFO, PS_MSG_FSTAT_INFO, + PS_MSG_FLUSH_INFO, PS_MSG_SYNC_INFO, PS_MSG_WRITE_INFO, PS_MSG_READ_INFO, + PS_MSG_CHKSUM_INFO, PS_MSG_OPEN_INFO, PS_MSG_CREATE_INFO, + PS_MSG_SETATTR_INFO, PS_MSG_XATTROP_INFO, PS_MSG_ALLOC_INFO, + PS_MSG_DISCARD_INFO, PS_MSG_ZEROFILL_INFO, PS_MSG_FD_CREATE_FAILED, + PS_MSG_WRONG_STATE, PS_MSG_CONF_DIR_INVALID, PS_MSG_MOUNT_PT_FAIL, + PS_MSG_STAT_INFO, PS_MSG_FILE_OP_FAILED, PS_MSG_GRACE_TIMER_CANCELLED, + PS_MSG_ENCODE_MSG_FAILED, PS_MSG_REPLY_SUBMIT_FAILED, + PS_MSG_RPC_NOTIFY_ERROR, PS_MSG_SERVER_EVENT_UPCALL_FAILED, + PS_MSG_SERVER_IPC_INFO, PS_MSG_SEEK_INFO, PS_MSG_COMPOUND_INFO, + PS_MSG_CLIENT_OPVERSION_GET_FAILED, PS_MSG_CHILD_STATUS_FAILED, + PS_MSG_PUT_INFO, PS_MSG_UNAUTHORIZED_CLIENT, PS_MSG_RECONFIGURE_FAILED, + PS_MSG_SET_STATEDUMP_PATH_ERROR, PS_MSG_INIT_GRP_CACHE_ERROR, + PS_MSG_RPC_CONFIGURE_FAILED, PS_MSG_TRANSPORT_TYPE_NOT_SET, + PS_MSG_GET_TOTAL_AVAIL_TRANSPORT_FAILED, PS_MSG_INVLAID_UPCALL_EVENT, + PS_MSG_SERVER_CHILD_EVENT_FAILED, PS_MSG_SETACTIVELK_INFO, + PS_MSG_GETACTIVELK_INFO, PS_MSG_WRONG_VALUE, PS_MSG_PASSWORD_NOT_FOUND, + PS_MSG_REMOTE_SUBVOL_NOT_SPECIFIED, PS_MSG_NO_MEM); +#define PS_MSG_SERIALIZE_REPLY_FAILED_STR "Failed to serialize reply" +#define PS_MSG_AUTH_IP_ERROR_STR "assuming 'auth.ip' to be 'auth.addr'" +#define PS_MSG_SKIP_FORMAT_CHK_STR "skip format check for non-addr auth option" +#define PS_MSG_INTERNET_ADDR_ERROR_STR \ + "internet address does not confirm to standards" +#define PS_MSG_AUTHENTICATE_ERROR_STR \ + "volume defined as subvolume, but no authentication defined for the same" +#define PS_MSG_CLIENT_DISCONNECTING_STR "disconnecting connection" +#define PS_MSG_DICT_GET_FAILED_STR "failed to get" +#define PS_MSG_NO_MEMORY_STR "Memory accounting init failed" +#define PS_MSG_INVALID_ENTRY_STR \ + "'trace' takes on only boolean values. Neglecting option" +#define PS_MSG_STATEDUMP_PATH_ERROR_STR \ + "Error while reconfiguring statedump path" +#define PS_MSG_GRP_CACHE_ERROR_STR "Failed to reconfigure group cache." +#define PS_MSG_RPC_CONF_ERROR_STR "No rpc_conf !!!!" +#define PS_MSG_CLIENT_ACCEPTED_STR \ + "authorized client, hence we continue with this connection" +#define PS_MSG_UNAUTHORIZED_CLIENT_STR \ + "unauthorized client, hence terminating the connection" +#define PS_MSG_RECONFIGURE_FAILED_STR \ + "Failed to reconfigure outstanding-rpc-limit" +#define PS_MSG_TRANSPORT_ERROR_STR "Reconfigure not found for transport" +#define PS_MSG_SUBVOL_NULL_STR "protocol/server should have subvolume" +#define PS_MSG_PARENT_VOL_ERROR_STR \ + "protocol/server should not have parent volumes" +#define PS_MSG_SET_STATEDUMP_PATH_ERROR_STR "Error setting statedump path" +#define PS_MSG_INIT_GRP_CACHE_ERROR_STR "Failed to initialize group cache." +#define PS_MSG_RPCSVC_CREATE_FAILED_STR "creation of rpcsvc failed" +#define PS_MSG_RPC_CONFIGURE_FAILED_STR \ + "Failed to configure outstanding-rpc-limit" +#define PS_MSG_TRANSPORT_TYPE_NOT_SET_STR "option transport-type not set" +#define PS_MSG_GET_TOTAL_AVAIL_TRANSPORT_FAILED_STR \ + "failed to get total number of available tranpsorts" +#define PS_MSG_RPCSVC_LISTENER_CREATE_FAILED_STR "creation of listener failed" +#define PS_MSG_RPCSVC_NOTIFY_STR "registration of notify with rpcsvc failed" +#define PS_MSG_PGM_REG_FAILED_STR "registration of program failed" +#define PS_MSG_ULIMIT_SET_FAILED_STR "WARNING: Failed to set 'ulimit -n 1M'" +#define PS_MSG_FD_NOT_FOUND_STR "Failed to set max open fd to 64k" +#define PS_MSG_VOL_FILE_OPEN_FAILED_STR \ + "volfile-id argument not given. This is mandatory argument, defaulting " \ + "to 'gluster'" +#define PS_MSG_INVLAID_UPCALL_EVENT_STR "Received invalid upcall event" +#define PS_MSG_CHILD_STATUS_FAILED_STR "No xlator is found in child status list" +#define PS_MSG_SERVER_EVENT_UPCALL_FAILED_STR \ + "server_process_event_upcall failed" +#define PS_MSG_SERVER_CHILD_EVENT_FAILED_STR "server_process_child_event failed" +#define PS_MSG_STATFS_STR "STATFS" +#define PS_MSG_LOOKUP_INFO_STR "LOOKUP info" +#define PS_MSG_LK_INFO_STR "LEASE info" +#define PS_MSG_INODELK_INFO_STR "INODELK info" +#define PS_MSG_DIR_INFO_STR "MKDIR info" +#define PS_MSG_MKNOD_INFO_STR "MKNOD info" +#define PS_MSG_REMOVEXATTR_INFO_STR "REMOVEXATTR info" +#define PS_MSG_GETXATTR_INFO_STR "GETXATTR info" +#define PS_MSG_SETXATTR_INFO_STR "SETXATTR info" +#define PS_MSG_RENAME_INFO_STR "RENAME inf" +#define PS_MSG_LINK_INFO_STR "LINK info" +#define PS_MSG_TRUNCATE_INFO_STR "TRUNCATE info" +#define PS_MSG_STAT_INFO_STR "STAT info" +#define PS_MSG_FLUSH_INFO_STR "FLUSH info" +#define PS_MSG_SYNC_INFO_STR "SYNC info" +#define PS_MSG_WRITE_INFO_STR "WRITE info" +#define PS_MSG_READ_INFO_STR "READ info" +#define PS_MSG_CHKSUM_INFO_STR "CHKSUM info" +#define PS_MSG_OPEN_INFO_STR "OPEN info" +#define PS_MSG_XATTROP_INFO_STR "XATTROP info" +#define PS_MSG_ALLOC_INFO_STR "ALLOC info" +#define PS_MSG_DISCARD_INFO_STR "DISCARD info" +#define PS_MSG_ZEROFILL_INFO_STR "ZEROFILL info" +#define PS_MSG_SERVER_IPC_INFO_STR "IPC info" +#define PS_MSG_SEEK_INFO_STR "SEEK info" +#define PS_MSG_SETACTIVELK_INFO_STR "SETACTIVELK info" +#define PS_MSG_CREATE_INFO_STR "CREATE info" +#define PS_MSG_PUT_INFO_STR "PUT info" +#define PS_MSG_FD_CREATE_FAILED_STR "could not create the fd" +#define PS_MSG_GETACTIVELK_INFO_STR "GETACTIVELK info" +#define PS_MSG_ENTRYLK_INFO_STR "ENTRYLK info" +#define PS_MSG_ACCESS_INFO_STR "ACCESS info" +#define PS_MSG_SETATTR_INFO_STR "SETATTR info" +#define PS_MSG_SERVER_CTX_GET_FAILED_STR "server_ctx_get() failed" +#define PS_MSG_LOCK_ERROR_STR "Unknown lock type" +#define PS_MSG_GET_UID_FAILED_STR "getpwuid_r failed" +#define PS_MSG_UID_NOT_FOUND_STR "getpwuid_r found nothing" +#define PS_MSG_MAPPING_ERROR_STR "could not map to group list" +#define PS_MSG_FD_CLEANUP_STR "fd cleanup" +#define PS_MSG_FDENTRY_NULL_STR "no fdentry to clean" +#define PS_MSG_WRONG_VALUE_STR \ + "wrong value for 'verify-volfile-checksum', Neglecting option" +#define PS_MSG_DIR_NOT_FOUND_STR "Directory doesnot exist" +#define PS_MSG_CONF_DIR_INVALID_STR "invalid conf_dir" +#define PS_MSG_SERVER_MSG_STR "server msg" +#define PS_MSG_DICT_SERIALIZE_FAIL_STR "failed to serialize reply dict" +#define PS_MSG_MOUNT_PT_FAIL_STR "mount point fail" +#define PS_MSG_RW_STAT_STR "stat" +#define PS_MSG_PASSWORD_NOT_FOUND_STR "password not found, returning DONT-CARE" +#define PS_MSG_REMOTE_SUBVOL_NOT_SPECIFIED_STR "remote-subvolume not specified" +#define PS_MSG_LOGIN_ERROR_STR "wrong password for user" +#define PS_MSG_NO_MEM_STR "No memory" #endif /* !_PS_MESSAGES_H__ */ diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c index 57aa474b8f5..ec768acba44 100644 --- a/xlators/protocol/server/src/server-resolve.c +++ b/xlators/protocol/server/src/server-resolve.c @@ -308,7 +308,6 @@ resolve_entry_simple(call_frame_t *frame) /* expected @parent was found from the inode cache */ gf_uuid_copy(state->loc_now->pargfid, resolve->pargfid); state->loc_now->parent = inode_ref(parent); - if (strchr(resolve->bname, '/')) { /* basename should be a string (without '/') in a directory, it can't span multiple levels. This can also lead to @@ -546,14 +545,39 @@ server_resolve_fd(call_frame_t *frame) return 0; } - state->fd = gf_fd_fdptr_get(serv_ctx->fdtable, fd_no); - + /* + * With copy_file_range, there will be 2 fds to resolve. + * This same function is called to resolve both the source + * fd and the destination fd. As of now, this function does + * not have any mechanism to distinguish between the 2 fds + * being resolved except for checking the value of state->fd. + * The assumption is that, if source fd the one which is + * being resolved here, then state->fd would be NULL. If it + * is not NULL, then it is the destination fd which is being + * resolved. + * This method (provided the above assumption is true) is + * to achieve the ability to distinguish between 2 fds with + * minimum changes being done to this function. If this way + * is not correct, then more changes might be needed. + */ if (!state->fd) { - gf_msg("", GF_LOG_INFO, EBADF, PS_MSG_FD_NOT_FOUND, - "fd not " - "found in context"); - resolve->op_ret = -1; - resolve->op_errno = EBADF; + state->fd = gf_fd_fdptr_get(serv_ctx->fdtable, fd_no); + if (!state->fd) { + gf_msg("", GF_LOG_INFO, EBADF, PS_MSG_FD_NOT_FOUND, + "fd not " + "found in context"); + resolve->op_ret = -1; + resolve->op_errno = EBADF; + } + } else { + state->fd_out = gf_fd_fdptr_get(serv_ctx->fdtable, fd_no); + if (!state->fd_out) { + gf_msg("", GF_LOG_INFO, EBADF, PS_MSG_FD_NOT_FOUND, + "fd not " + "found in context"); + resolve->op_ret = -1; + resolve->op_errno = EBADF; + } } server_resolve_all(frame); diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index c621743fa06..4d8b7be5a34 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -15,13 +15,12 @@ #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "server-messages.h" -#include "defaults.h" -#include "default-args.h" +#include <glusterfs/defaults.h> +#include <glusterfs/default-args.h> #include "server-common.h" -#include "xlator.h" -#include "compound-fop-utils.h" +#include <glusterfs/xlator.h> #include "xdr-nfs3.h" @@ -2261,78 +2260,6 @@ out: return 0; } -int -server_compound_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, void *data, dict_t *xdata) -{ - struct gfs3_compound_rsp rsp = { - 0, - }; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - compound_args_cbk_t *args_cbk = data; - int i = 0; - - req = frame->local; - state = CALL_STATE(frame); - - GF_PROTOCOL_DICT_SERIALIZE(this, xdata, (&rsp.xdata.xdata_val), - rsp.xdata.xdata_len, op_errno, out); - - if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_COMPOUND, op_errno), op_errno, - PS_MSG_COMPOUND_INFO, - "%" PRId64 ": COMPOUND%" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); - } - - /* TODO: I assume a single 10MB payload is large, if not, we need to - agree to valid payload */ - if ((args_cbk->fop_length <= 0) || - ((args_cbk->fop_length > (10 * 1024 * 1024)))) { - op_ret = -1; - op_errno = EINVAL; - goto out; - } - - rsp.compound_rsp_array.compound_rsp_array_val = GF_CALLOC( - args_cbk->fop_length, sizeof(compound_rsp), - gf_server_mt_compound_rsp_t); - - if (!rsp.compound_rsp_array.compound_rsp_array_val) { - op_ret = -1; - op_errno = ENOMEM; - goto out; - } - rsp.compound_rsp_array.compound_rsp_array_len = args_cbk->fop_length; - - for (i = 0; i < args_cbk->fop_length; i++) { - op_ret = server_populate_compound_response(this, &rsp, frame, args_cbk, - i); - - if (op_ret) { - op_errno = op_ret; - op_ret = -1; - goto out; - } - } -out: - rsp.op_ret = op_ret; - rsp.op_errno = gf_errno_to_error(op_errno); - - server_submit_reply(frame, req, &rsp, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_compound_rsp); - - server_compound_rsp_cleanup(&rsp, args_cbk); - GF_FREE(rsp.xdata.xdata_val); - - return 0; -} - /* Resume function section */ int @@ -3453,60 +3380,6 @@ err: return 0; } -int -server_compound_resume(call_frame_t *frame, xlator_t *bound_xl) -{ - server_state_t *state = NULL; - gfs3_compound_req *req = NULL; - compound_args_t *args = NULL; - int i = 0; - int ret = -1; - int length = 0; - int op_errno = ENOMEM; - compound_req *c_req = NULL; - - state = CALL_STATE(frame); - - if (state->resolve.op_ret != 0) { - ret = state->resolve.op_ret; - op_errno = state->resolve.op_errno; - goto err; - } - - req = &state->req; - - length = req->compound_req_array.compound_req_array_len; - state->args = compound_fop_alloc(length, req->compound_fop_enum, - state->xdata); - args = state->args; - - if (!args) - goto err; - - for (i = 0; i < length; i++) { - c_req = &req->compound_req_array.compound_req_array_val[i]; - args->enum_list[i] = c_req->fop_enum; - - ret = server_populate_compound_request(req, frame, &args->req_list[i], - i); - - if (ret) { - op_errno = ret; - ret = -1; - goto err; - } - } - - STACK_WIND(frame, server_compound_cbk, bound_xl, bound_xl->fops->compound, - args, state->xdata); - - return 0; -err: - server_compound_cbk(frame, NULL, frame->this, ret, op_errno, NULL, NULL); - - return ret; -} - /* Fop section */ int rpc_receive_common(rpcsvc_request_t *req, call_frame_t **fr, @@ -4180,7 +4053,7 @@ server3_3_writev_vecsizer(int state, ssize_t *readsize, char *base_addr, /* need to round off to proper roof (%4), as XDR packing pads the end of opaque object with '0' */ - size = roof(write_req.xdata.xdata_len, 4); + size = gf_roof(write_req.xdata.xdata_len, 4); *readsize = size; @@ -4250,6 +4123,7 @@ server3_3_release(rpcsvc_request_t *req) ret = 0; out: + free(args.xdata.xdata_val); return ret; } @@ -4297,6 +4171,7 @@ server3_3_releasedir(rpcsvc_request_t *req) ret = 0; out: + free(args.xdata.xdata_val); return ret; } @@ -6087,166 +5962,116 @@ out: int server3_3_compound(rpcsvc_request_t *req) { - server_state_t *state = NULL; - call_frame_t *frame = NULL; - gfs3_compound_req args = { - 0, - }; - ssize_t len = 0; - int length = 0; - int i = 0; int ret = -1; - int op_errno = 0; - - if (!req) - return ret; - - ret = rpc_receive_common(req, &frame, &state, &len, &args, - xdr_gfs3_compound_req, GF_FOP_COMPOUND); - if (ret != 0) { - goto out; - } - - state->req = args; - state->iobref = iobref_ref(req->iobref); - - if (len < req->msg[0].iov_len) { - state->payload_vector[0].iov_base = (req->msg[0].iov_base + len); - state->payload_vector[0].iov_len = req->msg[0].iov_len - len; - state->payload_count = 1; - } - - for (i = 1; i < req->count; i++) { - state->payload_vector[state->payload_count++] = req->msg[i]; - } - - state->size = iov_length(state->payload_vector, state->payload_count); - - ret = server_get_compound_resolve(state, &args); - - if (ret) { - SERVER_REQ_SET_ERROR(req, ret); - goto out; - } - - GF_PROTOCOL_DICT_UNSERIALIZE(frame->root->client->bound_xl, state->xdata, - args.xdata.xdata_val, args.xdata.xdata_len, - ret, op_errno, out); - - ret = 0; - resolve_and_resume(frame, server_compound_resume); -out: - free(args.xdata.xdata_val); - - length = args.compound_req_array.compound_req_array_len; - server_compound_req_cleanup(&args, length); - free(args.compound_req_array.compound_req_array_val); - - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - + SERVER_REQ_SET_ERROR(req, ret); return ret; } -rpcsvc_actor_t glusterfs3_3_fop_actors[GLUSTER_FOP_PROCCNT] = { - [GFS3_OP_NULL] = {"NULL", GFS3_OP_NULL, server_null, NULL, 0, DRC_NA}, - [GFS3_OP_STAT] = {"STAT", GFS3_OP_STAT, server3_3_stat, NULL, 0, DRC_NA}, - [GFS3_OP_READLINK] = {"READLINK", GFS3_OP_READLINK, server3_3_readlink, - NULL, 0, DRC_NA}, - [GFS3_OP_MKNOD] = {"MKNOD", GFS3_OP_MKNOD, server3_3_mknod, NULL, 0, - DRC_NA}, - [GFS3_OP_MKDIR] = {"MKDIR", GFS3_OP_MKDIR, server3_3_mkdir, NULL, 0, - DRC_NA}, - [GFS3_OP_UNLINK] = {"UNLINK", GFS3_OP_UNLINK, server3_3_unlink, NULL, 0, - DRC_NA}, - [GFS3_OP_RMDIR] = {"RMDIR", GFS3_OP_RMDIR, server3_3_rmdir, NULL, 0, - DRC_NA}, - [GFS3_OP_SYMLINK] = {"SYMLINK", GFS3_OP_SYMLINK, server3_3_symlink, NULL, 0, - DRC_NA}, - [GFS3_OP_RENAME] = {"RENAME", GFS3_OP_RENAME, server3_3_rename, NULL, 0, - DRC_NA}, - [GFS3_OP_LINK] = {"LINK", GFS3_OP_LINK, server3_3_link, NULL, 0, DRC_NA}, - [GFS3_OP_TRUNCATE] = {"TRUNCATE", GFS3_OP_TRUNCATE, server3_3_truncate, - NULL, 0, DRC_NA}, - [GFS3_OP_OPEN] = {"OPEN", GFS3_OP_OPEN, server3_3_open, NULL, 0, DRC_NA}, - [GFS3_OP_READ] = {"READ", GFS3_OP_READ, server3_3_readv, NULL, 0, DRC_NA}, - [GFS3_OP_WRITE] = {"WRITE", GFS3_OP_WRITE, server3_3_writev, - server3_3_writev_vecsizer, 0, DRC_NA}, - [GFS3_OP_STATFS] = {"STATFS", GFS3_OP_STATFS, server3_3_statfs, NULL, 0, - DRC_NA}, - [GFS3_OP_FLUSH] = {"FLUSH", GFS3_OP_FLUSH, server3_3_flush, NULL, 0, - DRC_NA}, - [GFS3_OP_FSYNC] = {"FSYNC", GFS3_OP_FSYNC, server3_3_fsync, NULL, 0, - DRC_NA}, - [GFS3_OP_SETXATTR] = {"SETXATTR", GFS3_OP_SETXATTR, server3_3_setxattr, - NULL, 0, DRC_NA}, - [GFS3_OP_GETXATTR] = {"GETXATTR", GFS3_OP_GETXATTR, server3_3_getxattr, - NULL, 0, DRC_NA}, - [GFS3_OP_REMOVEXATTR] = {"REMOVEXATTR", GFS3_OP_REMOVEXATTR, - server3_3_removexattr, NULL, 0, DRC_NA}, - [GFS3_OP_OPENDIR] = {"OPENDIR", GFS3_OP_OPENDIR, server3_3_opendir, NULL, 0, - DRC_NA}, - [GFS3_OP_FSYNCDIR] = {"FSYNCDIR", GFS3_OP_FSYNCDIR, server3_3_fsyncdir, - NULL, 0, DRC_NA}, - [GFS3_OP_ACCESS] = {"ACCESS", GFS3_OP_ACCESS, server3_3_access, NULL, 0, - DRC_NA}, - [GFS3_OP_CREATE] = {"CREATE", GFS3_OP_CREATE, server3_3_create, NULL, 0, - DRC_NA}, - [GFS3_OP_FTRUNCATE] = {"FTRUNCATE", GFS3_OP_FTRUNCATE, server3_3_ftruncate, - NULL, 0, DRC_NA}, - [GFS3_OP_FSTAT] = {"FSTAT", GFS3_OP_FSTAT, server3_3_fstat, NULL, 0, - DRC_NA}, - [GFS3_OP_LK] = {"LK", GFS3_OP_LK, server3_3_lk, NULL, 0, DRC_NA}, - [GFS3_OP_LOOKUP] = {"LOOKUP", GFS3_OP_LOOKUP, server3_3_lookup, NULL, 0, - DRC_NA}, - [GFS3_OP_READDIR] = {"READDIR", GFS3_OP_READDIR, server3_3_readdir, NULL, 0, - DRC_NA}, - [GFS3_OP_INODELK] = {"INODELK", GFS3_OP_INODELK, server3_3_inodelk, NULL, 0, - DRC_NA}, - [GFS3_OP_FINODELK] = {"FINODELK", GFS3_OP_FINODELK, server3_3_finodelk, - NULL, 0, DRC_NA}, - [GFS3_OP_ENTRYLK] = {"ENTRYLK", GFS3_OP_ENTRYLK, server3_3_entrylk, NULL, 0, - DRC_NA}, - [GFS3_OP_FENTRYLK] = {"FENTRYLK", GFS3_OP_FENTRYLK, server3_3_fentrylk, - NULL, 0, DRC_NA}, - [GFS3_OP_XATTROP] = {"XATTROP", GFS3_OP_XATTROP, server3_3_xattrop, NULL, 0, - DRC_NA}, - [GFS3_OP_FXATTROP] = {"FXATTROP", GFS3_OP_FXATTROP, server3_3_fxattrop, - NULL, 0, DRC_NA}, - [GFS3_OP_FGETXATTR] = {"FGETXATTR", GFS3_OP_FGETXATTR, server3_3_fgetxattr, - NULL, 0, DRC_NA}, - [GFS3_OP_FSETXATTR] = {"FSETXATTR", GFS3_OP_FSETXATTR, server3_3_fsetxattr, - NULL, 0, DRC_NA}, - [GFS3_OP_RCHECKSUM] = {"RCHECKSUM", GFS3_OP_RCHECKSUM, server3_3_rchecksum, - NULL, 0, DRC_NA}, - [GFS3_OP_SETATTR] = {"SETATTR", GFS3_OP_SETATTR, server3_3_setattr, NULL, 0, - DRC_NA}, - [GFS3_OP_FSETATTR] = {"FSETATTR", GFS3_OP_FSETATTR, server3_3_fsetattr, - NULL, 0, DRC_NA}, - [GFS3_OP_READDIRP] = {"READDIRP", GFS3_OP_READDIRP, server3_3_readdirp, - NULL, 0, DRC_NA}, - [GFS3_OP_RELEASE] = {"RELEASE", GFS3_OP_RELEASE, server3_3_release, NULL, 0, - DRC_NA}, - [GFS3_OP_RELEASEDIR] = {"RELEASEDIR", GFS3_OP_RELEASEDIR, - server3_3_releasedir, NULL, 0, DRC_NA}, - [GFS3_OP_FREMOVEXATTR] = {"FREMOVEXATTR", GFS3_OP_FREMOVEXATTR, - server3_3_fremovexattr, NULL, 0, DRC_NA}, - [GFS3_OP_FALLOCATE] = {"FALLOCATE", GFS3_OP_FALLOCATE, server3_3_fallocate, - NULL, 0, DRC_NA}, - [GFS3_OP_DISCARD] = {"DISCARD", GFS3_OP_DISCARD, server3_3_discard, NULL, 0, - DRC_NA}, - [GFS3_OP_ZEROFILL] = {"ZEROFILL", GFS3_OP_ZEROFILL, server3_3_zerofill, - NULL, 0, DRC_NA}, - [GFS3_OP_IPC] = {"IPC", GFS3_OP_IPC, server3_3_ipc, NULL, 0, DRC_NA}, - [GFS3_OP_SEEK] = {"SEEK", GFS3_OP_SEEK, server3_3_seek, NULL, 0, DRC_NA}, - [GFS3_OP_LEASE] = {"LEASE", GFS3_OP_LEASE, server3_3_lease, NULL, 0, - DRC_NA}, - [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", GFS3_OP_GETACTIVELK, - server3_3_getactivelk, NULL, 0, DRC_NA}, - [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", GFS3_OP_SETACTIVELK, - server3_3_setactivelk, NULL, 0, DRC_NA}, - [GFS3_OP_COMPOUND] = {"COMPOUND", GFS3_OP_COMPOUND, server3_3_compound, - NULL, 0, DRC_NA}, +static rpcsvc_actor_t glusterfs3_3_fop_actors[GLUSTER_FOP_PROCCNT] = { + [GFS3_OP_NULL] = {"NULL", server_null, NULL, GFS3_OP_NULL, DRC_NA, 0}, + [GFS3_OP_STAT] = {"STAT", server3_3_stat, NULL, GFS3_OP_STAT, DRC_NA, 0}, + [GFS3_OP_READLINK] = {"READLINK", server3_3_readlink, NULL, + GFS3_OP_READLINK, DRC_NA, 0}, + [GFS3_OP_MKNOD] = {"MKNOD", server3_3_mknod, NULL, GFS3_OP_MKNOD, DRC_NA, + 0}, + [GFS3_OP_MKDIR] = {"MKDIR", server3_3_mkdir, NULL, GFS3_OP_MKDIR, DRC_NA, + 0}, + [GFS3_OP_UNLINK] = {"UNLINK", server3_3_unlink, NULL, GFS3_OP_UNLINK, + DRC_NA, 0}, + [GFS3_OP_RMDIR] = {"RMDIR", server3_3_rmdir, NULL, GFS3_OP_RMDIR, DRC_NA, + 0}, + [GFS3_OP_SYMLINK] = {"SYMLINK", server3_3_symlink, NULL, GFS3_OP_SYMLINK, + DRC_NA, 0}, + [GFS3_OP_RENAME] = {"RENAME", server3_3_rename, NULL, GFS3_OP_RENAME, + DRC_NA, 0}, + [GFS3_OP_LINK] = {"LINK", server3_3_link, NULL, GFS3_OP_LINK, DRC_NA, 0}, + [GFS3_OP_TRUNCATE] = {"TRUNCATE", server3_3_truncate, NULL, + GFS3_OP_TRUNCATE, DRC_NA, 0}, + [GFS3_OP_OPEN] = {"OPEN", server3_3_open, NULL, GFS3_OP_OPEN, DRC_NA, 0}, + [GFS3_OP_READ] = {"READ", server3_3_readv, NULL, GFS3_OP_READ, DRC_NA, 0}, + [GFS3_OP_WRITE] = {"WRITE", server3_3_writev, server3_3_writev_vecsizer, + GFS3_OP_WRITE, DRC_NA, 0}, + [GFS3_OP_STATFS] = {"STATFS", server3_3_statfs, NULL, GFS3_OP_STATFS, + DRC_NA, 0}, + [GFS3_OP_FLUSH] = {"FLUSH", server3_3_flush, NULL, GFS3_OP_FLUSH, DRC_NA, + 0}, + [GFS3_OP_FSYNC] = {"FSYNC", server3_3_fsync, NULL, GFS3_OP_FSYNC, DRC_NA, + 0}, + [GFS3_OP_SETXATTR] = {"SETXATTR", server3_3_setxattr, NULL, + GFS3_OP_SETXATTR, DRC_NA, 0}, + [GFS3_OP_GETXATTR] = {"GETXATTR", server3_3_getxattr, NULL, + GFS3_OP_GETXATTR, DRC_NA, 0}, + [GFS3_OP_REMOVEXATTR] = {"REMOVEXATTR", server3_3_removexattr, NULL, + GFS3_OP_REMOVEXATTR, DRC_NA, 0}, + [GFS3_OP_OPENDIR] = {"OPENDIR", server3_3_opendir, NULL, GFS3_OP_OPENDIR, + DRC_NA, 0}, + [GFS3_OP_FSYNCDIR] = {"FSYNCDIR", server3_3_fsyncdir, NULL, + GFS3_OP_FSYNCDIR, DRC_NA, 0}, + [GFS3_OP_ACCESS] = {"ACCESS", server3_3_access, NULL, DRC_NA, 0}, + [GFS3_OP_CREATE] = {"CREATE", server3_3_create, NULL, GFS3_OP_ACCESS, + DRC_NA, 0}, + [GFS3_OP_FTRUNCATE] = {"FTRUNCATE", server3_3_ftruncate, NULL, + GFS3_OP_FTRUNCATE, DRC_NA, 0}, + [GFS3_OP_FSTAT] = {"FSTAT", server3_3_fstat, NULL, GFS3_OP_FSTAT, DRC_NA, + 0}, + [GFS3_OP_LK] = {"LK", server3_3_lk, NULL, GFS3_OP_LK, DRC_NA, 0}, + [GFS3_OP_LOOKUP] = {"LOOKUP", server3_3_lookup, NULL, GFS3_OP_LOOKUP, + DRC_NA, 0}, + [GFS3_OP_READDIR] = {"READDIR", server3_3_readdir, NULL, GFS3_OP_READDIR, + DRC_NA, 0}, + [GFS3_OP_INODELK] = {"INODELK", server3_3_inodelk, NULL, GFS3_OP_INODELK, + DRC_NA, 0}, + [GFS3_OP_FINODELK] = {"FINODELK", server3_3_finodelk, NULL, + GFS3_OP_FINODELK, DRC_NA, 0}, + [GFS3_OP_ENTRYLK] = {"ENTRYLK", server3_3_entrylk, NULL, GFS3_OP_ENTRYLK, + DRC_NA, 0}, + [GFS3_OP_FENTRYLK] = {"FENTRYLK", server3_3_fentrylk, NULL, + GFS3_OP_FENTRYLK, DRC_NA, 0}, + [GFS3_OP_XATTROP] = {"XATTROP", server3_3_xattrop, NULL, GFS3_OP_XATTROP, + DRC_NA, 0}, + [GFS3_OP_FXATTROP] = {"FXATTROP", server3_3_fxattrop, NULL, + GFS3_OP_FXATTROP, DRC_NA, 0}, + [GFS3_OP_FGETXATTR] = {"FGETXATTR", server3_3_fgetxattr, NULL, + GFS3_OP_FGETXATTR, DRC_NA, 0}, + [GFS3_OP_FSETXATTR] = {"FSETXATTR", server3_3_fsetxattr, NULL, + GFS3_OP_FSETXATTR, DRC_NA, 0}, + [GFS3_OP_RCHECKSUM] = {"RCHECKSUM", server3_3_rchecksum, NULL, + GFS3_OP_RCHECKSUM, DRC_NA, 0}, + [GFS3_OP_SETATTR] = {"SETATTR", server3_3_setattr, NULL, GFS3_OP_SETATTR, + DRC_NA, 0}, + [GFS3_OP_FSETATTR] = {"FSETATTR", server3_3_fsetattr, NULL, + GFS3_OP_FSETATTR, DRC_NA, 0}, + [GFS3_OP_READDIRP] = {"READDIRP", server3_3_readdirp, NULL, + GFS3_OP_READDIRP, DRC_NA, 0}, + [GFS3_OP_RELEASE] = {"RELEASE", server3_3_release, NULL, GFS3_OP_RELEASE, + DRC_NA, 0}, + [GFS3_OP_RELEASEDIR] = + { + "RELEASEDIR", + server3_3_releasedir, + NULL, + GFS3_OP_RELEASEDIR, + DRC_NA, + 0, + }, + [GFS3_OP_FREMOVEXATTR] = {"FREMOVEXATTR", server3_3_fremovexattr, NULL, + GFS3_OP_FREMOVEXATTR, DRC_NA, 0}, + [GFS3_OP_FALLOCATE] = {"FALLOCATE", server3_3_fallocate, NULL, + GFS3_OP_FALLOCATE, DRC_NA, 0}, + [GFS3_OP_DISCARD] = {"DISCARD", server3_3_discard, NULL, GFS3_OP_DISCARD, + DRC_NA, 0}, + [GFS3_OP_ZEROFILL] = {"ZEROFILL", server3_3_zerofill, NULL, + GFS3_OP_ZEROFILL, DRC_NA, 0}, + [GFS3_OP_IPC] = {"IPC", server3_3_ipc, NULL, GFS3_OP_IPC, DRC_NA, 0}, + [GFS3_OP_SEEK] = {"SEEK", server3_3_seek, NULL, GFS3_OP_SEEK, DRC_NA, 0}, + [GFS3_OP_LEASE] = {"LEASE", server3_3_lease, NULL, GFS3_OP_LEASE, DRC_NA, + 0}, + [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", server3_3_getactivelk, NULL, + GFS3_OP_GETACTIVELK, DRC_NA, 0}, + [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", server3_3_setactivelk, NULL, + GFS3_OP_SETACTIVELK, DRC_NA, 0}, + [GFS3_OP_COMPOUND] = {"COMPOUND", server3_3_compound, NULL, + GFS3_OP_COMPOUND, DRC_NA, 0}, }; struct rpcsvc_program glusterfs3_3_fop_prog = { diff --git a/xlators/protocol/server/src/server-rpc-fops_v2.c b/xlators/protocol/server/src/server-rpc-fops_v2.c index 21df9021c66..c267f8f7832 100644 --- a/xlators/protocol/server/src/server-rpc-fops_v2.c +++ b/xlators/protocol/server/src/server-rpc-fops_v2.c @@ -15,13 +15,12 @@ #include "rpc-common-xdr.h" #include "glusterfs4-xdr.h" #include "glusterfs3.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "server-messages.h" -#include "defaults.h" -#include "default-args.h" +#include <glusterfs/defaults.h> +#include <glusterfs/default-args.h> #include "server-common.h" -#include "xlator.h" -#include "compound-fop-utils.h" +#include <glusterfs/xlator.h> #include "xdr-nfs3.h" @@ -57,10 +56,10 @@ server4_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this, dict_to_xdr(xdata, &rsp.xdata); if (op_ret < 0) { - gf_msg(this->name, GF_LOG_WARNING, op_errno, PS_MSG_STATFS, - "%" PRId64 ": STATFS, client: %s, error-xlator: %s", - frame->root->unique, STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, PS_MSG_STATFS, + "frame=%" PRId64, frame->root->unique, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -147,25 +146,20 @@ out: if (op_ret) { if (state->resolve.bname) { - gf_msg(this->name, fop_log_level(GF_FOP_LOOKUP, op_errno), op_errno, - PS_MSG_LOOKUP_INFO, - "%" PRId64 - ": LOOKUP %s (%s/%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_LOOKUP, op_errno), + op_errno, PS_MSG_LOOKUP_INFO, "frame=%" PRId64, + frame->root->unique, "path=%s", state->loc.path, + "uuid_utoa=%s", uuid_utoa(state->resolve.pargfid), + "bname=%s", state->resolve.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); } else { - gf_msg(this->name, fop_log_level(GF_FOP_LOOKUP, op_errno), op_errno, - PS_MSG_LOOKUP_INFO, - "%" PRId64 - ": LOOKUP %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), - STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_LOOKUP, op_errno), + op_errno, PS_MSG_LOOKUP_INFO, "frame=%" PRId64, + frame->root->unique, "path=%s", state->loc.path, + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); } } @@ -193,12 +187,12 @@ server4_lease_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_LEASE, op_errno), op_errno, - PS_MSG_LK_INFO, - "%" PRId64 ": LEASE %s (%s), client: %s, error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_LEASE, op_errno), op_errno, + PS_MSG_LK_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); } server4_post_lease(&rsp, lease); @@ -229,14 +223,12 @@ server4_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_LK, op_errno), op_errno, - PS_MSG_LK_INFO, - "%" PRId64 ": LK %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_LK, op_errno), op_errno, + PS_MSG_LK_INFO, "frame=%" PRId64, frame->root->unique, + "fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -269,14 +261,12 @@ server4_inodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, fop_log_level(GF_FOP_INODELK, op_errno), op_errno, - PS_MSG_INODELK_INFO, - "%" PRId64 - ": INODELK %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_INODELK, op_errno), op_errno, + PS_MSG_INODELK_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", state->loc.path, "uuuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -308,14 +298,12 @@ server4_finodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, fop_log_level(GF_FOP_FINODELK, op_errno), op_errno, - PS_MSG_INODELK_INFO, - "%" PRId64 ": FINODELK %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FINODELK, op_errno), op_errno, + PS_MSG_INODELK_INFO, "frame=%" PRId64, frame->root->unique, + "FINODELK_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -347,14 +335,12 @@ server4_entrylk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, fop_log_level(GF_FOP_ENTRYLK, op_errno), op_errno, - PS_MSG_ENTRYLK_INFO, - "%" PRId64 - ": ENTRYLK %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_ENTRYLK, op_errno), op_errno, + PS_MSG_ENTRYLK_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -386,14 +372,12 @@ server4_fentrylk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, fop_log_level(GF_FOP_FENTRYLK, op_errno), op_errno, - PS_MSG_ENTRYLK_INFO, - "%" PRId64 ": FENTRYLK %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FENTRYLK, op_errno), op_errno, + PS_MSG_ENTRYLK_INFO, "frame=%" PRId64, frame->root->unique, + "FENTRYLK_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator: %s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -424,13 +408,12 @@ server4_access_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_ACCESS_INFO, - "%" PRId64 - ": ACCESS %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_ACCESS_INFO, + "frame=%" PRId64, frame->root->unique, "path=%s", + (state->loc.path) ? state->loc.path : "", "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -463,13 +446,13 @@ server4_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret) { - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_DIR_INFO, - "%" PRId64 - ": RMDIR %s (%s/%s), client: %s, " - "error-xlator: %s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_DIR_INFO, + "frame=%" PRId64, frame->root->unique, "RMDIR_pat=%s", + (state->loc.path) ? state->loc.path : "", "uuid_utoa=%s", + uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -505,14 +488,13 @@ server4_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, fop_log_level(GF_FOP_MKDIR, op_errno), op_errno, - PS_MSG_DIR_INFO, - "%" PRId64 - ": MKDIR %s (%s/%s) client: %s, " - "error-xlator: %s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_MKDIR, op_errno), op_errno, + PS_MSG_DIR_INFO, "frame=%" PRId64, frame->root->unique, + "MKDIR_path=%s", (state->loc.path) ? state->loc.path : "", + "uuid_utoa=%s", uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -547,14 +529,13 @@ server4_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, fop_log_level(GF_FOP_MKNOD, op_errno), op_errno, - PS_MSG_MKNOD_INFO, - "%" PRId64 - ": MKNOD %s (%s/%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_MKNOD, op_errno), op_errno, + PS_MSG_MKNOD_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -586,14 +567,12 @@ server4_fsyncdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FSYNCDIR, op_errno), op_errno, - PS_MSG_DIR_INFO, - "%" PRId64 ": FSYNCDIR %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FSYNCDIR, op_errno), op_errno, + PS_MSG_DIR_INFO, "frame=%" PRId64, frame->root->unique, + "FSYNCDIR_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -626,14 +605,12 @@ server4_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_READDIR, op_errno), op_errno, - PS_MSG_DIR_INFO, - "%" PRId64 ": READDIR %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_READDIR, op_errno), op_errno, + PS_MSG_DIR_INFO, "frame=%" PRId64, frame->root->unique, + "READDIR_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -677,14 +654,12 @@ server4_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_OPENDIR, op_errno), op_errno, - PS_MSG_DIR_INFO, - "%" PRId64 - ": OPENDIR %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_OPENDIR, op_errno), op_errno, + PS_MSG_DIR_INFO, "frame=%" PRId64, frame->root->unique, + "OPENDIR_path=%s", (state->loc.path) ? state->loc.path : "", + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -726,13 +701,12 @@ server4_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, else loglevel = GF_LOG_INFO; - gf_msg(this->name, loglevel, op_errno, PS_MSG_REMOVEXATTR_INFO, - "%" PRId64 - ": REMOVEXATTR %s (%s) of key %s, client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), state->name, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, loglevel, op_errno, PS_MSG_REMOVEXATTR_INFO, + "frame=%" PRId64, frame->root->unique, "path=%s", + state->loc.path, "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), + "name=%s", state->name, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -763,14 +737,13 @@ server4_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FREMOVEXATTR, op_errno), - op_errno, PS_MSG_REMOVEXATTR_INFO, - "%" PRId64 ": FREMOVEXATTR %" PRId64 - " (%s) (%s), " - "client: %s, error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), state->name, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FREMOVEXATTR, op_errno), + op_errno, PS_MSG_REMOVEXATTR_INFO, "frame=%" PRId64, + frame->root->unique, "FREMOVEXATTR_fd_no%" PRId64, + state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "name=%s", state->name, + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator: %s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -802,14 +775,12 @@ server4_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_GETXATTR, op_errno), op_errno, - PS_MSG_GETXATTR_INFO, - "%" PRId64 - ": GETXATTR %s (%s) (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), state->name, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_GETXATTR, op_errno), op_errno, + PS_MSG_GETXATTR_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "name=%s", state->name, + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -844,14 +815,12 @@ server4_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FGETXATTR, op_errno), op_errno, - PS_MSG_GETXATTR_INFO, - "%" PRId64 ": FGETXATTR %" PRId64 - " (%s) (%s), " - "client: %s, error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), state->name, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FGETXATTR, op_errno), op_errno, + PS_MSG_GETXATTR_INFO, "frame=%" PRId64, frame->root->unique, + "FGETXATTR_fd_no=%" PRId64, state->resolve.fd_no, + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "name=%s", + state->name, "client=%s", STACK_CLIENT_NAME(frame->root), + "error-xlator=%s", STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -891,11 +860,9 @@ server4_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_errno == ENOTSUP) { gf_msg_debug(THIS->name, 0, "%s", strerror(op_errno)); } else { - gf_msg(THIS->name, GF_LOG_INFO, op_errno, PS_MSG_SETXATTR_INFO, - "client: %s, " - "error-xlator: %s", - STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(THIS->name, GF_LOG_INFO, op_errno, PS_MSG_SETXATTR_INFO, + "client=%s", STACK_CLIENT_NAME(frame->root), + "error-xlator=%s", STACK_ERR_XL_NAME(frame->root), NULL); } goto out; } @@ -933,11 +900,9 @@ server4_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_errno == ENOTSUP) { gf_msg_debug(THIS->name, 0, "%s", strerror(op_errno)); } else { - gf_msg(THIS->name, GF_LOG_INFO, op_errno, PS_MSG_SETXATTR_INFO, - "client: %s, " - "error-xlator: %s", - STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(THIS->name, GF_LOG_INFO, op_errno, PS_MSG_SETXATTR_INFO, + "client=%s", STACK_CLIENT_NAME(frame->root), + "error-xlator=%s", STACK_ERR_XL_NAME(frame->root), NULL); } goto out; } @@ -981,14 +946,14 @@ server4_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { uuid_utoa_r(state->resolve.pargfid, oldpar_str); uuid_utoa_r(state->resolve2.pargfid, newpar_str); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_RENAME_INFO, - "%" PRId64 - ": RENAME %s (%s/%s) -> %s (%s/%s), " - "client: %s, error-xlator: %s", - frame->root->unique, state->loc.path, oldpar_str, - state->resolve.bname, state->loc2.path, newpar_str, - state->resolve2.bname, STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_RENAME_INFO, + "frame=%" PRId64, frame->root->unique, "loc.path=%s", + state->loc.path, "oldpar_str=%s", oldpar_str, "resolve-name=%s", + state->resolve.bname, "loc2.path=%s", state->loc2.path, + "newpar_str=%s", newpar_str, "resolve2=%s", + state->resolve2.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1023,14 +988,13 @@ server4_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_UNLINK, op_errno), op_errno, - PS_MSG_LINK_INFO, - "%" PRId64 - ": UNLINK %s (%s/%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_UNLINK, op_errno), op_errno, + PS_MSG_LINK_INFO, "frame=%" PRId64, frame->root->unique, + "UNLINK_path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator: %s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1073,13 +1037,13 @@ server4_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, - "%" PRId64 - ": SYMLINK %s (%s/%s), client: %s, " - "error-xlator:%s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, + "frame=%" PRId64, frame->root->unique, "SYMLINK_path= %s", + (state->loc.path) ? state->loc.path : "", "uuid_utoa=%s", + uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1124,13 +1088,12 @@ server4_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, uuid_utoa_r(state->resolve.gfid, gfid_str); uuid_utoa_r(state->resolve2.pargfid, newpar_str); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, - "%" PRId64 - ": LINK %s (%s) -> %s/%s, client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, gfid_str, newpar_str, - state->resolve2.bname, STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, + "frame=%" PRId64, frame->root->unique, "LINK_path=%s", + state->loc.path, "gfid_str=%s", gfid_str, "newpar_str=%s", + newpar_str, "resolve2.bname=%s", state->resolve2.bname, + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1164,13 +1127,11 @@ server4_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_TRUNCATE_INFO, - "%" PRId64 - ": TRUNCATE %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_TRUNCATE_INFO, + "frame=%" PRId64, frame->root->unique, "TRUNCATE_path=%s", + state->loc.path, "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1204,14 +1165,12 @@ server4_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_FSTAT, op_errno), op_errno, - PS_MSG_STAT_INFO, - "%" PRId64 ": FSTAT %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FSTAT, op_errno), op_errno, + PS_MSG_STAT_INFO, "frame=%" PRId64, frame->root->unique, + "FSTAT_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1243,14 +1202,12 @@ server4_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FTRUNCATE, op_errno), op_errno, - PS_MSG_TRUNCATE_INFO, - "%" PRId64 ": FTRUNCATE %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FTRUNCATE, op_errno), op_errno, + PS_MSG_TRUNCATE_INFO, "frame=%" PRId64, frame->root->unique, + "FTRUNCATE_fd_no=%" PRId64, state->resolve.fd_no, + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1283,14 +1240,12 @@ server4_flush_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FLUSH, op_errno), op_errno, - PS_MSG_FLUSH_INFO, - "%" PRId64 ": FLUSH %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FLUSH, op_errno), op_errno, + PS_MSG_FLUSH_INFO, "frame=%" PRId64, frame->root->unique, + "FLUSH_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator: %s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1322,14 +1277,12 @@ server4_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FSYNC, op_errno), op_errno, - PS_MSG_SYNC_INFO, - "%" PRId64 ": FSYNC %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FSYNC, op_errno), op_errno, + PS_MSG_SYNC_INFO, "frame=%" PRId64, frame->root->unique, + "FSYNC_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator: %s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1363,14 +1316,12 @@ server4_writev_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_WRITE, op_errno), op_errno, - PS_MSG_WRITE_INFO, - "%" PRId64 ": WRITEV %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_WRITE, op_errno), op_errno, + PS_MSG_WRITE_INFO, "frame=%" PRId64, frame->root->unique, + "WRITEV_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1415,14 +1366,12 @@ server4_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_READ, op_errno), op_errno, - PS_MSG_READ_INFO, - "%" PRId64 ": READV %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_READ, op_errno), op_errno, + PS_MSG_READ_INFO, "frame=%" PRId64, frame->root->unique, + "READV_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1456,14 +1405,12 @@ server4_rchecksum_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_RCHECKSUM, op_errno), op_errno, - PS_MSG_CHKSUM_INFO, - "%" PRId64 ": RCHECKSUM %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_RCHECKSUM, op_errno), op_errno, + PS_MSG_CHKSUM_INFO, "frame=%" PRId64, frame->root->unique, + "RCHECKSUM_fd_no=%" PRId64, state->resolve.fd_no, + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1495,12 +1442,12 @@ server4_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_OPEN, op_errno), op_errno, - PS_MSG_OPEN_INFO, - "%" PRId64 ": OPEN %s (%s), client: %s, error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_OPEN, op_errno), op_errno, + PS_MSG_OPEN_INFO, "frame=%" PRId64, frame->root->unique, + "OPEN_path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1537,13 +1484,12 @@ server4_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_CREATE_INFO, - "%" PRId64 - ": CREATE %s (%s/%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg( + this->name, GF_LOG_INFO, op_errno, PS_MSG_CREATE_INFO, + "frame=%" PRId64, frame->root->unique, "path=%s", state->loc.path, + "uuid_utoa=%s", uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", STACK_CLIENT_NAME(frame->root), + "error-xlator=%s", STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1593,13 +1539,11 @@ server4_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, - "%" PRId64 - ": READLINK %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_LINK_INFO, + "frame=%" PRId64, frame->root->unique, "READLINK_path=%s", + state->loc.path, "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1634,12 +1578,12 @@ server4_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_STAT, op_errno), op_errno, - PS_MSG_STAT_INFO, - "%" PRId64 ": STAT %s (%s), client: %s, error-xlator: %s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_STAT, op_errno), op_errno, + PS_MSG_STAT_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", (state->loc.path) ? state->loc.path : "", + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1672,13 +1616,12 @@ server4_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SETATTR_INFO, - "%" PRId64 - ": SETATTR %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, (state->loc.path) ? state->loc.path : "", - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SETATTR_INFO, + "frame=%" PRId64, frame->root->unique, "path=%s", + (state->loc.path) ? state->loc.path : "", "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1712,14 +1655,12 @@ server4_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FSETATTR, op_errno), op_errno, - PS_MSG_SETATTR_INFO, - "%" PRId64 ": FSETATTR %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FSETATTR, op_errno), op_errno, + PS_MSG_SETATTR_INFO, "frame=%" PRId64, + "FSETATTR_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1753,14 +1694,12 @@ server4_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_XATTROP, op_errno), op_errno, - PS_MSG_XATTROP_INFO, - "%" PRId64 - ": XATTROP %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_XATTROP, op_errno), op_errno, + PS_MSG_XATTROP_INFO, "frame=%" PRId64, frame->root->unique, + "path=%s", state->loc.path, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1795,14 +1734,12 @@ server4_fxattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FXATTROP, op_errno), op_errno, - PS_MSG_XATTROP_INFO, - "%" PRId64 ": FXATTROP %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FXATTROP, op_errno), op_errno, + PS_MSG_XATTROP_INFO, "frame=%" PRId64, frame->root->unique, + "FXATTROP_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1841,14 +1778,12 @@ server4_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_READDIRP, op_errno), op_errno, - PS_MSG_DIR_INFO, - "%" PRId64 ": READDIRP %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_READDIRP, op_errno), op_errno, + PS_MSG_DIR_INFO, "frame=%" PRId64, frame->root->unique, + "READDIRP_fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1894,14 +1829,12 @@ server4_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_FALLOCATE, op_errno), op_errno, - PS_MSG_ALLOC_INFO, - "%" PRId64 ": FALLOCATE %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_FALLOCATE, op_errno), op_errno, + PS_MSG_ALLOC_INFO, "frame=%" PRId64, frame->root->unique, + "FALLOCATE_fd_no=%" PRId64, state->resolve.fd_no, + "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1935,14 +1868,12 @@ server4_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret) { state = CALL_STATE(frame); - gf_msg(this->name, fop_log_level(GF_FOP_DISCARD, op_errno), op_errno, - PS_MSG_DISCARD_INFO, - "%" PRId64 ": DISCARD %" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_DISCARD, op_errno), op_errno, + PS_MSG_DISCARD_INFO, "frame=%" PRId64, frame->root->unique, + "fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator: %s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -1978,14 +1909,12 @@ server4_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, dict_to_xdr(xdata, &rsp.xdata); if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_ZEROFILL, op_errno), op_errno, - PS_MSG_ZEROFILL_INFO, - "%" PRId64 ": ZEROFILL%" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_ZEROFILL, op_errno), op_errno, + PS_MSG_ZEROFILL_INFO, "frame=%" PRId64, frame->root->unique, + "fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -2019,13 +1948,12 @@ server4_ipc_cbk(call_frame_t *frame, void *cookie, xlator_t *this, dict_to_xdr(xdata, &rsp.xdata); if (op_ret) { - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SERVER_IPC_INFO, - "%" PRId64 ": IPC%" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SERVER_IPC_INFO, + "frame=%" PRId64, frame->root->unique, "IPC=%" PRId64, + state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -2057,14 +1985,12 @@ server4_seek_cbk(call_frame_t *frame, void *cookie, xlator_t *this, dict_to_xdr(xdata, &rsp.xdata); if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_SEEK, op_errno), op_errno, - PS_MSG_SEEK_INFO, - "%" PRId64 ": SEEK%" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, fop_log_level(GF_FOP_SEEK, op_errno), op_errno, + PS_MSG_SEEK_INFO, "frame=%" PRId64, frame->root->unique, + "fd_no=%" PRId64, state->resolve.fd_no, "uuid_utoa=%s", + uuid_utoa(state->resolve.gfid), "client=%s", + STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -2097,13 +2023,11 @@ server4_setactivelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, GF_LOG_INFO, op_errno, 0, - "%" PRId64 - ": SETACTIVELK %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_SETACTIVELK_INFO, + "frame=%" PRId64, frame->root->unique, "path==%s", + state->loc.path, "uuid_utoa=%s", uuid_utoa(state->resolve.gfid), + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -2172,9 +2096,10 @@ server4_icreate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_CREATE_INFO, - "%" PRId64 ": ICREATE [%s] ==> (%s)", frame->root->unique, - uuid_utoa(state->resolve.gfid), strerror(op_errno)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_CREATE_INFO, + "frame=%" PRId64, uuid_utoa(state->resolve.gfid), + "ICREATE_gfid=%s", uuid_utoa(state->resolve.gfid), + "op_errno=%s", strerror(op_errno), NULL); goto out; } @@ -2227,13 +2152,12 @@ server4_put_cbk(call_frame_t *frame, void *cookie, xlator_t *this, state = CALL_STATE(frame); if (op_ret < 0) { - gf_msg(this->name, GF_LOG_INFO, op_errno, PS_MSG_PUT_INFO, - "%" PRId64 - ": PUT %s (%s/%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.pargfid), state->resolve.bname, - STACK_CLIENT_NAME(frame->root), STACK_ERR_XL_NAME(frame->root)); + gf_smsg( + this->name, GF_LOG_INFO, op_errno, PS_MSG_PUT_INFO, + "frame=%" PRId64, frame->root->unique, "path=%s", state->loc.path, + "uuid_utoa=%s", uuid_utoa(state->resolve.pargfid), "bname=%s", + state->resolve.bname, "client=%s", STACK_CLIENT_NAME(frame->root), + "error-xlator=%s", STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -2259,6 +2183,63 @@ out: return 0; } +int +server4_copy_file_range_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, + struct iatt *stbuf, struct iatt *prebuf_dst, + struct iatt *postbuf_dst, dict_t *xdata) +{ + gfx_common_3iatt_rsp rsp = { + 0, + }; + server_state_t *state = NULL; + rpcsvc_request_t *req = NULL; + char in_gfid[GF_UUID_BUF_SIZE] = {0}; + char out_gfid[GF_UUID_BUF_SIZE] = {0}; + + dict_to_xdr(xdata, &rsp.xdata); + + if (op_ret < 0) { + state = CALL_STATE(frame); + + uuid_utoa_r(state->resolve.gfid, in_gfid); + uuid_utoa_r(state->resolve2.gfid, out_gfid); + + gf_smsg(this->name, fop_log_level(GF_FOP_COPY_FILE_RANGE, op_errno), + op_errno, PS_MSG_WRITE_INFO, "frame=%" PRId64, + frame->root->unique, "COPY_FILE_RANGE_fd_no=%" PRId64, + state->resolve.fd_no, "in_gfid=%s", in_gfid, + "resolve2_fd_no=%" PRId64, state->resolve2.fd_no, "out_gfid=%s", + out_gfid, "client=%s", STACK_CLIENT_NAME(frame->root), + "error-xlator=%s", STACK_ERR_XL_NAME(frame->root), NULL); + goto out; + } + + /* + * server4_post_common_3iatt (ex: used by server4_put_cbk and some + * other cbks) also performs inode linking along with copying of 3 + * iatt structures to the response. But, for copy_file_range, linking + * of inode is not needed. Therefore a new function is used to + * construct the response using 3 iatt structures. + * @stbuf: iatt or stat of the source file (or fd) + * @prebuf_dst: iatt or stat of destination file (or fd) before the fop + * @postbuf_dst: iatt or stat of destination file (or fd) after the fop + */ + server4_post_common_3iatt_noinode(&rsp, stbuf, prebuf_dst, postbuf_dst); + +out: + rsp.op_ret = op_ret; + rsp.op_errno = gf_errno_to_error(op_errno); + + req = frame->local; + server_submit_reply(frame, req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gfx_common_3iatt_rsp); + + GF_FREE(rsp.xdata.pairs.pairs_val); + + return 0; +} + /* Resume function section */ int @@ -2716,8 +2697,7 @@ server4_opendir_resume(call_frame_t *frame, xlator_t *bound_xl) state->fd = fd_create(state->loc.inode, frame->root->pid); if (!state->fd) { - gf_msg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, - "could not create the fd"); + gf_smsg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, NULL); goto err; } @@ -3080,9 +3060,9 @@ server4_create_resume(call_frame_t *frame, xlator_t *bound_xl) state->fd = fd_create(state->loc.inode, frame->root->pid); if (!state->fd) { - gf_msg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, - "fd creation for the inode %s failed", - state->loc.inode ? uuid_utoa(state->loc.inode->gfid) : NULL); + gf_smsg("server", GF_LOG_ERROR, 0, PS_MSG_FD_CREATE_FAILED, "inode=%s", + state->loc.inode ? uuid_utoa(state->loc.inode->gfid) : NULL, + NULL); state->resolve.op_ret = -1; state->resolve.op_errno = ENOMEM; goto err; @@ -3328,13 +3308,11 @@ server4_getactivelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret < 0) { state = CALL_STATE(frame); - gf_msg(this->name, GF_LOG_INFO, op_errno, 0, - "%" PRId64 - ": GETACTIVELK %s (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->loc.path, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); + gf_smsg(this->name, GF_LOG_INFO, op_errno, PS_MSG_GETACTIVELK_INFO, + "frame=%" PRId64, frame->root->unique, "path=%s", + state->loc.path, "gfid=%s", uuid_utoa(state->resolve.gfid), + "client=%s", STACK_CLIENT_NAME(frame->root), "error-xlator=%s", + STACK_ERR_XL_NAME(frame->root), NULL); goto out; } @@ -3448,6 +3426,29 @@ err: } int +server4_copy_file_range_resume(call_frame_t *frame, xlator_t *bound_xl) +{ + server_state_t *state = NULL; + + state = CALL_STATE(frame); + + if (state->resolve.op_ret != 0) + goto err; + + STACK_WIND(frame, server4_copy_file_range_cbk, bound_xl, + bound_xl->fops->copy_file_range, state->fd, state->off_in, + state->fd_out, state->off_out, state->size, state->flags, + state->xdata); + + return 0; +err: + server4_copy_file_range_cbk(frame, NULL, frame->this, state->resolve.op_ret, + state->resolve.op_errno, NULL, NULL, NULL, + NULL); + return 0; +} + +int server4_0_stat(rpcsvc_request_t *req) { server_state_t *state = NULL; @@ -3458,7 +3459,6 @@ server4_0_stat(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return 0; @@ -3473,16 +3473,16 @@ server4_0_stat(rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_stat_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3497,7 +3497,6 @@ server4_0_setattr(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return 0; @@ -3514,14 +3513,15 @@ server4_0_setattr(rpcsvc_request_t *req) gfx_stat_to_iattx(&args.stbuf, &state->stbuf); state->valid = args.valid; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_setattr_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); return ret; } @@ -3535,7 +3535,6 @@ server4_0_fallocate(rpcsvc_request_t *req) {0}, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3554,16 +3553,16 @@ server4_0_fallocate(rpcsvc_request_t *req) state->size = args.size; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fallocate_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3576,7 +3575,6 @@ server4_0_discard(rpcsvc_request_t *req) {0}, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3594,16 +3592,16 @@ server4_0_discard(rpcsvc_request_t *req) state->size = args.size; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_discard_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3635,7 +3633,10 @@ server4_0_zerofill(rpcsvc_request_t *req) state->size = args.size; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_zerofill_resume); @@ -3655,7 +3656,6 @@ server4_0_ipc(rpcsvc_request_t *req) 0, }; int ret = -1; - int op_errno = 0; xlator_t *bound_xl = NULL; if (!req) @@ -3664,21 +3664,20 @@ server4_0_ipc(rpcsvc_request_t *req) ret = rpc_receive_common(req, &frame, &state, NULL, &args, xdr_gfx_ipc_req, GF_FOP_IPC); if (ret != 0) { - op_errno = -1; goto out; } bound_xl = frame->root->client->bound_xl; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; STACK_WIND(frame, server4_ipc_cbk, bound_xl, bound_xl->fops->ipc, args.op, state->xdata); out: - if (op_errno) - req->rpc_err = GARBAGE_ARGS; - return ret; } @@ -3693,7 +3692,6 @@ server4_0_seek(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3711,15 +3709,15 @@ server4_0_seek(rpcsvc_request_t *req) state->what = args.what; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_seek_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3734,7 +3732,6 @@ server4_0_readlink(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3750,16 +3747,16 @@ server4_0_readlink(rpcsvc_request_t *req) state->size = args.size; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_readlink_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3774,7 +3771,6 @@ server4_0_create(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3798,7 +3794,10 @@ server4_0_create(rpcsvc_request_t *req) state->resolve.type = RESOLVE_DONTCARE; } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_create_resume); @@ -3806,9 +3805,6 @@ server4_0_create(rpcsvc_request_t *req) out: free(args.bname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3823,7 +3819,6 @@ server4_0_open(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3839,14 +3834,14 @@ server4_0_open(rpcsvc_request_t *req) state->flags = gf_flags_to_flags(args.flags); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_open_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3861,7 +3856,6 @@ server4_0_readv(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) goto out; @@ -3880,14 +3874,14 @@ server4_0_readv(rpcsvc_request_t *req) memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_readv_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3904,7 +3898,6 @@ server4_0_writev(rpcsvc_request_t *req) ssize_t len = 0; int i = 0; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -3937,7 +3930,10 @@ server4_0_writev(rpcsvc_request_t *req) GF_ASSERT(state->size == len); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } #ifdef GF_TESTING_IO_XDATA dict_dump_to_log(state->xdata); @@ -3947,9 +3943,6 @@ server4_0_writev(rpcsvc_request_t *req) resolve_and_resume(frame, server4_writev_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -3988,7 +3981,7 @@ server4_0_writev_vecsizer(int state, ssize_t *readsize, char *base_addr, /* need to round off to proper roof (%4), as XDR packing pads the end of opaque object with '0' */ - size = roof(write_req.xdata.xdr_size, 4); + size = gf_roof(write_req.xdata.xdr_size, 4); *readsize = size; @@ -4040,9 +4033,8 @@ server4_0_release(rpcsvc_request_t *req) serv_ctx = server_ctx_get(client, client->this); if (serv_ctx == NULL) { - gf_msg(req->trans->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED, - "server_ctx_get() " - "failed"); + gf_smsg(req->trans->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED, + NULL); req->rpc_err = SYSTEM_ERR; goto out; } @@ -4086,9 +4078,8 @@ server4_0_releasedir(rpcsvc_request_t *req) serv_ctx = server_ctx_get(client, client->this); if (serv_ctx == NULL) { - gf_msg(req->trans->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED, - "server_ctx_get() " - "failed"); + gf_smsg(req->trans->name, GF_LOG_INFO, 0, PS_MSG_SERVER_CTX_GET_FAILED, + NULL); req->rpc_err = SYSTEM_ERR; goto out; } @@ -4114,7 +4105,6 @@ server4_0_fsync(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4130,15 +4120,15 @@ server4_0_fsync(rpcsvc_request_t *req) state->flags = args.data; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fsync_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4153,7 +4143,6 @@ server4_0_flush(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4168,15 +4157,15 @@ server4_0_flush(rpcsvc_request_t *req) state->resolve.fd_no = args.fd; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_flush_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4191,7 +4180,6 @@ server4_0_ftruncate(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4207,15 +4195,15 @@ server4_0_ftruncate(rpcsvc_request_t *req) state->offset = args.offset; memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_ftruncate_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4230,7 +4218,6 @@ server4_0_fstat(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4245,15 +4232,15 @@ server4_0_fstat(rpcsvc_request_t *req) state->resolve.fd_no = args.fd; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fstat_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4268,7 +4255,6 @@ server4_0_truncate(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4283,15 +4269,15 @@ server4_0_truncate(rpcsvc_request_t *req) memcpy(state->resolve.gfid, args.gfid, 16); state->offset = args.offset; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_truncate_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4306,7 +4292,6 @@ server4_0_unlink(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4324,16 +4309,16 @@ server4_0_unlink(rpcsvc_request_t *req) state->flags = args.xflags; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_unlink_resume); out: free(args.bname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4348,7 +4333,6 @@ server4_0_setxattr(rpcsvc_request_t *req) }, }; int32_t ret = -1; - int32_t op_errno = 0; if (!req) return ret; @@ -4363,22 +4347,23 @@ server4_0_setxattr(rpcsvc_request_t *req) state->flags = args.flags; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - ret = xdr_to_dict(&args.dict, &state->dict); - if (ret) - gf_msg_debug(THIS->name, EINVAL, "dictionary not received"); + if (xdr_to_dict(&args.dict, &state->dict)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } /* There can be some commands hidden in key, check and proceed */ gf_server_check_setxattr_cmd(frame, state->dict); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_setxattr_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4393,7 +4378,6 @@ server4_0_fsetxattr(rpcsvc_request_t *req) }, }; int32_t ret = -1; - int32_t op_errno = 0; if (!req) return ret; @@ -4409,19 +4393,20 @@ server4_0_fsetxattr(rpcsvc_request_t *req) state->flags = args.flags; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - ret = xdr_to_dict(&args.dict, &state->dict); - if (ret) - gf_msg_debug(THIS->name, EINVAL, "dictionary not received"); + if (xdr_to_dict(&args.dict, &state->dict)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fsetxattr_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4436,7 +4421,6 @@ server4_0_fxattrop(rpcsvc_request_t *req) }, }; int32_t ret = -1; - int32_t op_errno = 0; if (!req) return ret; @@ -4452,19 +4436,20 @@ server4_0_fxattrop(rpcsvc_request_t *req) state->flags = args.flags; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - ret = xdr_to_dict(&args.dict, &state->dict); - if (ret) - gf_msg_debug(THIS->name, EINVAL, "dictionary not received"); + if (xdr_to_dict(&args.dict, &state->dict)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fxattrop_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4479,7 +4464,6 @@ server4_0_xattrop(rpcsvc_request_t *req) }, }; int32_t ret = -1; - int32_t op_errno = 0; if (!req) return ret; @@ -4494,19 +4478,20 @@ server4_0_xattrop(rpcsvc_request_t *req) state->flags = args.flags; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - ret = xdr_to_dict(&args.dict, &state->dict); - if (ret) - gf_msg_debug(THIS->name, EINVAL, "dictionary not received"); + if (xdr_to_dict(&args.dict, &state->dict)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_xattrop_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4521,7 +4506,6 @@ server4_0_getxattr(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4541,16 +4525,16 @@ server4_0_getxattr(rpcsvc_request_t *req) gf_server_check_getxattr_cmd(frame, state->name); } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_getxattr_resume); out: free(args.name); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4565,7 +4549,6 @@ server4_0_fgetxattr(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4582,16 +4565,16 @@ server4_0_fgetxattr(rpcsvc_request_t *req) if (args.namelen) state->name = gf_strdup(args.name); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fgetxattr_resume); out: free(args.name); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4606,7 +4589,6 @@ server4_0_removexattr(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4621,16 +4603,16 @@ server4_0_removexattr(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); state->name = gf_strdup(args.name); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_removexattr_resume); out: free(args.name); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4645,7 +4627,6 @@ server4_0_fremovexattr(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4661,16 +4642,16 @@ server4_0_fremovexattr(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); state->name = gf_strdup(args.name); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fremovexattr_resume); out: free(args.name); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4685,7 +4666,6 @@ server4_0_opendir(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4699,15 +4679,15 @@ server4_0_opendir(rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_opendir_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4723,7 +4703,6 @@ server4_0_readdirp(rpcsvc_request_t *req) }; size_t headers_size = 0; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4751,14 +4730,14 @@ server4_0_readdirp(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); /* here, dict itself works as xdata */ - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_readdirp_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4774,7 +4753,6 @@ server4_0_readdir(rpcsvc_request_t *req) }; size_t headers_size = 0; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4801,15 +4779,15 @@ server4_0_readdir(rpcsvc_request_t *req) state->offset = args.offset; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_readdir_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4824,7 +4802,6 @@ server4_0_fsyncdir(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4840,15 +4817,15 @@ server4_0_fsyncdir(rpcsvc_request_t *req) state->flags = args.data; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fsyncdir_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4863,7 +4840,6 @@ server4_0_mknod(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4883,7 +4859,10 @@ server4_0_mknod(rpcsvc_request_t *req) state->dev = args.dev; state->umask = args.umask; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_mknod_resume); @@ -4891,9 +4870,6 @@ server4_0_mknod(rpcsvc_request_t *req) out: free(args.bname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4908,7 +4884,6 @@ server4_0_mkdir(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4926,7 +4901,10 @@ server4_0_mkdir(rpcsvc_request_t *req) state->mode = args.mode; state->umask = args.umask; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_mkdir_resume); @@ -4934,9 +4912,6 @@ server4_0_mkdir(rpcsvc_request_t *req) out: free(args.bname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4951,7 +4926,6 @@ server4_0_rmdir(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -4968,16 +4942,16 @@ server4_0_rmdir(rpcsvc_request_t *req) state->flags = args.xflags; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_rmdir_resume); out: free(args.bname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -4993,7 +4967,6 @@ server4_0_inodelk(rpcsvc_request_t *req) }; int cmd = 0; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5037,7 +5010,10 @@ server4_0_inodelk(rpcsvc_request_t *req) break; } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_inodelk_resume); @@ -5046,9 +5022,6 @@ out: free(args.flock.lk_owner.lk_owner_val); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5063,7 +5036,6 @@ server4_0_finodelk(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5108,7 +5080,10 @@ server4_0_finodelk(rpcsvc_request_t *req) break; } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_finodelk_resume); @@ -5117,9 +5092,6 @@ out: free(args.flock.lk_owner.lk_owner_val); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5134,7 +5106,6 @@ server4_0_entrylk(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5155,7 +5126,10 @@ server4_0_entrylk(rpcsvc_request_t *req) state->cmd = args.cmd; state->type = args.type; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_entrylk_resume); @@ -5163,9 +5137,6 @@ out: free(args.volume); free(args.name); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5180,7 +5151,6 @@ server4_0_fentrylk(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5201,7 +5171,10 @@ server4_0_fentrylk(rpcsvc_request_t *req) state->name = gf_strdup(args.name); state->volume = gf_strdup(args.volume); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fentrylk_resume); @@ -5209,9 +5182,6 @@ out: free(args.volume); free(args.name); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5226,7 +5196,6 @@ server4_0_access(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5241,15 +5210,15 @@ server4_0_access(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); state->mask = args.mask; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_access_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5264,7 +5233,6 @@ server4_0_symlink(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5281,7 +5249,10 @@ server4_0_symlink(rpcsvc_request_t *req) state->name = gf_strdup(args.linkname); state->umask = args.umask; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_symlink_resume); @@ -5290,9 +5261,6 @@ out: free(args.bname); free(args.linkname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5307,7 +5275,6 @@ server4_0_link(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5326,16 +5293,16 @@ server4_0_link(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve2.pargfid, args.newgfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_link_resume); out: free(args.newbname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5350,7 +5317,6 @@ server4_0_rename(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5370,7 +5336,10 @@ server4_0_rename(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve2.pargfid, args.newgfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_rename_resume); @@ -5378,9 +5347,6 @@ out: free(args.oldbname); free(args.newbname); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5395,7 +5361,6 @@ server4_0_lease(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5410,15 +5375,15 @@ server4_0_lease(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); gf_proto_lease_to_lease(&args.lease, &state->lease); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_lease_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5433,7 +5398,6 @@ server4_0_lk(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5486,17 +5450,17 @@ server4_0_lk(rpcsvc_request_t *req) state->flock.l_type = F_UNLCK; break; default: - gf_msg(frame->root->client->bound_xl->name, GF_LOG_ERROR, 0, - PS_MSG_LOCK_ERROR, - "fd - %" PRId64 - " (%s): Unknown " - "lock type: %" PRId32 "!", - state->resolve.fd_no, uuid_utoa(state->fd->inode->gfid), - state->type); + gf_smsg(frame->root->client->bound_xl->name, GF_LOG_ERROR, 0, + PS_MSG_LOCK_ERROR, "fd=%" PRId64, state->resolve.fd_no, + "uuid_utoa=%s", uuid_utoa(state->fd->inode->gfid), + "lock type=" PRId32, state->type, NULL); break; } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_lk_resume); @@ -5504,9 +5468,6 @@ out: free(args.flock.lk_owner.lk_owner_val); - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5556,7 +5517,10 @@ server4_0_lookup(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); } - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto err; + } ret = 0; resolve_and_resume(frame, server4_lookup_resume); @@ -5578,7 +5542,6 @@ server4_0_statfs(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5592,15 +5555,15 @@ server4_0_statfs(rpcsvc_request_t *req) state->resolve.type = RESOLVE_MUST; set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_statfs_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5615,7 +5578,6 @@ server4_0_getactivelk(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5630,15 +5592,15 @@ server4_0_getactivelk(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); /* here, dict itself works as xdata */ - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_getactivelk_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5653,7 +5615,6 @@ server4_0_setactivelk(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5668,7 +5629,10 @@ server4_0_setactivelk(rpcsvc_request_t *req) set_resolve_gfid(frame->root->client, state->resolve.gfid, args.gfid); /* here, dict itself works as xdata */ - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = unserialize_req_locklist_v2(&args, &state->locklist); if (ret) @@ -5678,9 +5642,6 @@ server4_0_setactivelk(rpcsvc_request_t *req) resolve_and_resume(frame, server4_setactivelk_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5695,7 +5656,6 @@ server4_0_namelink(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5711,14 +5671,14 @@ server4_0_namelink(rpcsvc_request_t *req) state->resolve.type = RESOLVE_NOT; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_namelink_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5733,7 +5693,6 @@ server4_0_icreate(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; uuid_t gfid = { 0, }; @@ -5758,14 +5717,14 @@ server4_0_icreate(rpcsvc_request_t *req) state->resolve.type = RESOLVE_NOT; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_icreate_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5778,7 +5737,6 @@ server4_0_fsetattr(rpcsvc_request_t *req) {0}, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5796,14 +5754,14 @@ server4_0_fsetattr(rpcsvc_request_t *req) gfx_stat_to_iattx(&args.stbuf, &state->stbuf); state->valid = args.valid; - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_fsetattr_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5816,7 +5774,6 @@ server4_0_rchecksum(rpcsvc_request_t *req) {0}, }; int ret = -1; - int op_errno = 0; if (!req) return ret; @@ -5834,13 +5791,13 @@ server4_0_rchecksum(rpcsvc_request_t *req) memcpy(state->resolve.gfid, args.gfid, 16); - xdr_to_dict(&args.xdata, &state->xdata); + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); + goto out; + } ret = 0; resolve_and_resume(frame, server4_rchecksum_resume); out: - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } @@ -5855,7 +5812,6 @@ server4_0_put(rpcsvc_request_t *req) }, }; int ret = -1; - int op_errno = 0; ssize_t len = 0; int i = 0; @@ -5898,298 +5854,171 @@ server4_0_put(rpcsvc_request_t *req) state->resolve.type = RESOLVE_DONTCARE; } - xdr_to_dict(&args.xattr, &state->dict); - xdr_to_dict(&args.xdata, &state->xdata); - - ret = 0; - resolve_and_resume(frame, server4_put_resume); - -out: - free(args.bname); - - if (op_errno) + if (xdr_to_dict(&args.xattr, &state->dict)) { SERVER_REQ_SET_ERROR(req, ret); - - return ret; -} - -int -server4_compound_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, void *data, - dict_t *xdata) -{ - struct gfx_compound_rsp rsp = { - 0, - }; - server_state_t *state = NULL; - rpcsvc_request_t *req = NULL; - compound_args_cbk_t *args_cbk = data; - int i = 0; - - req = frame->local; - state = CALL_STATE(frame); - - dict_to_xdr(xdata, &rsp.xdata); - - if (op_ret) { - gf_msg(this->name, fop_log_level(GF_FOP_COMPOUND, op_errno), op_errno, - PS_MSG_COMPOUND_INFO, - "%" PRId64 ": COMPOUND%" PRId64 - " (%s), client: %s, " - "error-xlator: %s", - frame->root->unique, state->resolve.fd_no, - uuid_utoa(state->resolve.gfid), STACK_CLIENT_NAME(frame->root), - STACK_ERR_XL_NAME(frame->root)); - } - - /* TODO: I assume a single 10MB payload is large, if not, we need to - agree to valid payload */ - if ((args_cbk->fop_length <= 0) || - ((args_cbk->fop_length > (10 * 1024 * 1024)))) { - op_ret = -1; - op_errno = EINVAL; goto out; } - - rsp.compound_rsp_array.compound_rsp_array_val = GF_CALLOC( - args_cbk->fop_length, sizeof(compound_rsp_v2), - gf_server_mt_compound_rsp_t); - - if (!rsp.compound_rsp_array.compound_rsp_array_val) { - op_ret = -1; - op_errno = ENOMEM; + if (xdr_to_dict(&args.xdata, &state->xdata)) { + SERVER_REQ_SET_ERROR(req, ret); goto out; } - rsp.compound_rsp_array.compound_rsp_array_len = args_cbk->fop_length; - for (i = 0; i < args_cbk->fop_length; i++) { - op_ret = server_populate_compound_response_v2(this, &rsp, frame, - args_cbk, i); + ret = 0; + resolve_and_resume(frame, server4_put_resume); - if (op_ret) { - op_errno = op_ret; - op_ret = -1; - goto out; - } - } out: - rsp.op_ret = op_ret; - rsp.op_errno = gf_errno_to_error(op_errno); - - server_submit_reply(frame, req, &rsp, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_compound_rsp); - - server_compound_rsp_cleanup_v2(&rsp, args_cbk); - GF_FREE(rsp.xdata.pairs.pairs_val); + free(args.bname); - return 0; + return ret; } int -server4_compound_resume(call_frame_t *frame, xlator_t *bound_xl) +server4_0_compound(rpcsvc_request_t *req) { - server_state_t *state = NULL; - gfx_compound_req *req = NULL; - compound_args_t *args = NULL; - int i = 0; int ret = -1; - int length = 0; - int op_errno = ENOMEM; - compound_req_v2 *c_req = NULL; - - state = CALL_STATE(frame); - - if (state->resolve.op_ret != 0) { - ret = state->resolve.op_ret; - op_errno = state->resolve.op_errno; - goto err; - } - - req = &state->req_v2; - - length = req->compound_req_array.compound_req_array_len; - state->args = compound_fop_alloc(length, req->compound_fop_enum, - state->xdata); - args = state->args; - - if (!args) - goto err; - - for (i = 0; i < length; i++) { - c_req = &req->compound_req_array.compound_req_array_val[i]; - args->enum_list[i] = c_req->fop_enum; - - ret = server_populate_compound_request_v2(req, frame, - &args->req_list[i], i); - - if (ret) { - op_errno = ret; - ret = -1; - goto err; - } - } - - STACK_WIND(frame, server4_compound_cbk, bound_xl, bound_xl->fops->compound, - args, state->xdata); - - return 0; -err: - server4_compound_cbk(frame, NULL, frame->this, ret, op_errno, NULL, NULL); - + SERVER_REQ_SET_ERROR(req, ret); return ret; } + int -server4_0_compound(rpcsvc_request_t *req) +server4_0_copy_file_range(rpcsvc_request_t *req) { server_state_t *state = NULL; call_frame_t *frame = NULL; - gfx_compound_req args = { - 0, + gfx_copy_file_range_req args = { + { + 0, + }, }; ssize_t len = 0; - int length = 0; - int i = 0; int ret = -1; - int op_errno = 0; if (!req) return ret; ret = rpc_receive_common(req, &frame, &state, &len, &args, - xdr_gfx_compound_req, GF_FOP_COMPOUND); + xdr_gfx_copy_file_range_req, + GF_FOP_COPY_FILE_RANGE); if (ret != 0) { goto out; } - state->req_v2 = args; - state->iobref = iobref_ref(req->iobref); - - if (len < req->msg[0].iov_len) { - state->payload_vector[0].iov_base = (req->msg[0].iov_base + len); - state->payload_vector[0].iov_len = req->msg[0].iov_len - len; - state->payload_count = 1; - } - - for (i = 1; i < req->count; i++) { - state->payload_vector[state->payload_count++] = req->msg[i]; - } - - state->size = iov_length(state->payload_vector, state->payload_count); - - ret = server_get_compound_resolve_v2(state, &args); + state->resolve.type = RESOLVE_MUST; + state->resolve.fd_no = args.fd_in; + state->resolve2.type = RESOLVE_MUST; /*making this resolve must */ + state->resolve2.fd_no = args.fd_out; + state->off_in = args.off_in; + state->off_out = args.off_out; + state->size = args.size; + state->flags = args.flag; + memcpy(state->resolve.gfid, args.gfid1, 16); + memcpy(state->resolve2.gfid, args.gfid2, 16); - if (ret) { + if (xdr_to_dict(&args.xdata, &state->xdata)) { SERVER_REQ_SET_ERROR(req, ret); goto out; } - xdr_to_dict(&args.xdata, &state->xdata); - ret = 0; - resolve_and_resume(frame, server4_compound_resume); + resolve_and_resume(frame, server4_copy_file_range_resume); out: - length = args.compound_req_array.compound_req_array_len; - server_compound_req_cleanup_v2(&args, length); - free(args.compound_req_array.compound_req_array_val); - - if (op_errno) - SERVER_REQ_SET_ERROR(req, ret); - return ret; } -rpcsvc_actor_t glusterfs4_0_fop_actors[] = { - [GFS3_OP_NULL] = {"NULL", GFS3_OP_NULL, server_null, NULL, 0}, - [GFS3_OP_STAT] = {"STAT", GFS3_OP_STAT, server4_0_stat, NULL, 0}, - [GFS3_OP_READLINK] = {"READLINK", GFS3_OP_READLINK, server4_0_readlink, - NULL, 0}, - [GFS3_OP_MKNOD] = {"MKNOD", GFS3_OP_MKNOD, server4_0_mknod, NULL, 0}, - [GFS3_OP_MKDIR] = {"MKDIR", GFS3_OP_MKDIR, server4_0_mkdir, NULL, 0}, - [GFS3_OP_UNLINK] = {"UNLINK", GFS3_OP_UNLINK, server4_0_unlink, NULL, 0}, - [GFS3_OP_RMDIR] = {"RMDIR", GFS3_OP_RMDIR, server4_0_rmdir, NULL, 0}, - [GFS3_OP_SYMLINK] = {"SYMLINK", GFS3_OP_SYMLINK, server4_0_symlink, NULL, +static rpcsvc_actor_t glusterfs4_0_fop_actors[] = { + [GFS3_OP_NULL] = {"NULL", server_null, NULL, GFS3_OP_NULL, 0}, + [GFS3_OP_STAT] = {"STAT", server4_0_stat, NULL, GFS3_OP_STAT, 0}, + [GFS3_OP_READLINK] = {"READLINK", server4_0_readlink, NULL, + GFS3_OP_READLINK, 0}, + [GFS3_OP_MKNOD] = {"MKNOD", server4_0_mknod, NULL, GFS3_OP_MKNOD, 0}, + [GFS3_OP_MKDIR] = {"MKDIR", server4_0_mkdir, NULL, GFS3_OP_MKDIR, 0}, + [GFS3_OP_UNLINK] = {"UNLINK", server4_0_unlink, NULL, GFS3_OP_UNLINK, 0}, + [GFS3_OP_RMDIR] = {"RMDIR", server4_0_rmdir, NULL, GFS3_OP_RMDIR, 0}, + [GFS3_OP_SYMLINK] = {"SYMLINK", server4_0_symlink, NULL, GFS3_OP_SYMLINK, 0}, - [GFS3_OP_RENAME] = {"RENAME", GFS3_OP_RENAME, server4_0_rename, NULL, 0}, - [GFS3_OP_LINK] = {"LINK", GFS3_OP_LINK, server4_0_link, NULL, 0}, - [GFS3_OP_TRUNCATE] = {"TRUNCATE", GFS3_OP_TRUNCATE, server4_0_truncate, - NULL, 0}, - [GFS3_OP_OPEN] = {"OPEN", GFS3_OP_OPEN, server4_0_open, NULL, 0}, - [GFS3_OP_READ] = {"READ", GFS3_OP_READ, server4_0_readv, NULL, 0}, - [GFS3_OP_WRITE] = {"WRITE", GFS3_OP_WRITE, server4_0_writev, - server4_0_writev_vecsizer, 0}, - [GFS3_OP_STATFS] = {"STATFS", GFS3_OP_STATFS, server4_0_statfs, NULL, 0}, - [GFS3_OP_FLUSH] = {"FLUSH", GFS3_OP_FLUSH, server4_0_flush, NULL, 0}, - [GFS3_OP_FSYNC] = {"FSYNC", GFS3_OP_FSYNC, server4_0_fsync, NULL, 0}, - [GFS3_OP_GETXATTR] = {"GETXATTR", GFS3_OP_GETXATTR, server4_0_getxattr, - NULL, 0}, - [GFS3_OP_SETXATTR] = {"SETXATTR", GFS3_OP_SETXATTR, server4_0_setxattr, - NULL, 0}, - [GFS3_OP_REMOVEXATTR] = {"REMOVEXATTR", GFS3_OP_REMOVEXATTR, - server4_0_removexattr, NULL, 0}, - [GFS3_OP_OPENDIR] = {"OPENDIR", GFS3_OP_OPENDIR, server4_0_opendir, NULL, + [GFS3_OP_RENAME] = {"RENAME", server4_0_rename, NULL, GFS3_OP_RENAME, 0}, + [GFS3_OP_LINK] = {"LINK", server4_0_link, NULL, GFS3_OP_LINK, 0}, + [GFS3_OP_TRUNCATE] = {"TRUNCATE", server4_0_truncate, NULL, + GFS3_OP_TRUNCATE, 0}, + [GFS3_OP_OPEN] = {"OPEN", server4_0_open, NULL, GFS3_OP_OPEN, 0}, + [GFS3_OP_READ] = {"READ", server4_0_readv, NULL, GFS3_OP_READ, 0}, + [GFS3_OP_WRITE] = {"WRITE", server4_0_writev, server4_0_writev_vecsizer, + GFS3_OP_WRITE, 0}, + [GFS3_OP_STATFS] = {"STATFS", server4_0_statfs, NULL, GFS3_OP_STATFS, 0}, + [GFS3_OP_FLUSH] = {"FLUSH", server4_0_flush, NULL, GFS3_OP_FLUSH, 0}, + [GFS3_OP_FSYNC] = {"FSYNC", server4_0_fsync, NULL, GFS3_OP_FSYNC, 0}, + [GFS3_OP_GETXATTR] = {"GETXATTR", server4_0_getxattr, NULL, + GFS3_OP_GETXATTR, 0}, + [GFS3_OP_SETXATTR] = {"SETXATTR", server4_0_setxattr, NULL, + GFS3_OP_SETXATTR, 0}, + [GFS3_OP_REMOVEXATTR] = {"REMOVEXATTR", server4_0_removexattr, NULL, + GFS3_OP_REMOVEXATTR, 0}, + [GFS3_OP_OPENDIR] = {"OPENDIR", server4_0_opendir, NULL, GFS3_OP_OPENDIR, 0}, - [GFS3_OP_FSYNCDIR] = {"FSYNCDIR", GFS3_OP_FSYNCDIR, server4_0_fsyncdir, - NULL, 0}, - [GFS3_OP_ACCESS] = {"ACCESS", GFS3_OP_ACCESS, server4_0_access, NULL, 0}, - [GFS3_OP_CREATE] = {"CREATE", GFS3_OP_CREATE, server4_0_create, NULL, 0}, - [GFS3_OP_FTRUNCATE] = {"FTRUNCATE", GFS3_OP_FTRUNCATE, server4_0_ftruncate, - NULL, 0}, - [GFS3_OP_FSTAT] = {"FSTAT", GFS3_OP_FSTAT, server4_0_fstat, NULL, 0}, - [GFS3_OP_LK] = {"LK", GFS3_OP_LK, server4_0_lk, NULL, 0}, - [GFS3_OP_LOOKUP] = {"LOOKUP", GFS3_OP_LOOKUP, server4_0_lookup, NULL, 0}, - [GFS3_OP_READDIR] = {"READDIR", GFS3_OP_READDIR, server4_0_readdir, NULL, + [GFS3_OP_FSYNCDIR] = {"FSYNCDIR", server4_0_fsyncdir, NULL, + GFS3_OP_FSYNCDIR, 0}, + [GFS3_OP_ACCESS] = {"ACCESS", server4_0_access, NULL, GFS3_OP_ACCESS, 0}, + [GFS3_OP_CREATE] = {"CREATE", server4_0_create, NULL, GFS3_OP_CREATE, 0}, + [GFS3_OP_FTRUNCATE] = {"FTRUNCATE", server4_0_ftruncate, NULL, + GFS3_OP_FTRUNCATE, 0}, + [GFS3_OP_FSTAT] = {"FSTAT", server4_0_fstat, NULL, GFS3_OP_FSTAT, 0}, + [GFS3_OP_LK] = {"LK", server4_0_lk, NULL, GFS3_OP_LK, 0}, + [GFS3_OP_LOOKUP] = {"LOOKUP", server4_0_lookup, NULL, GFS3_OP_LOOKUP, 0}, + [GFS3_OP_READDIR] = {"READDIR", server4_0_readdir, NULL, GFS3_OP_READDIR, 0}, - [GFS3_OP_INODELK] = {"INODELK", GFS3_OP_INODELK, server4_0_inodelk, NULL, + [GFS3_OP_INODELK] = {"INODELK", server4_0_inodelk, NULL, GFS3_OP_INODELK, 0}, - [GFS3_OP_FINODELK] = {"FINODELK", GFS3_OP_FINODELK, server4_0_finodelk, - NULL, 0}, - [GFS3_OP_ENTRYLK] = {"ENTRYLK", GFS3_OP_ENTRYLK, server4_0_entrylk, NULL, + [GFS3_OP_FINODELK] = {"FINODELK", server4_0_finodelk, NULL, + GFS3_OP_FINODELK, 0}, + [GFS3_OP_ENTRYLK] = {"ENTRYLK", server4_0_entrylk, NULL, GFS3_OP_ENTRYLK, 0}, - [GFS3_OP_FENTRYLK] = {"FENTRYLK", GFS3_OP_FENTRYLK, server4_0_fentrylk, - NULL, 0}, - [GFS3_OP_XATTROP] = {"XATTROP", GFS3_OP_XATTROP, server4_0_xattrop, NULL, + [GFS3_OP_FENTRYLK] = {"FENTRYLK", server4_0_fentrylk, NULL, + GFS3_OP_FENTRYLK, 0}, + [GFS3_OP_XATTROP] = {"XATTROP", server4_0_xattrop, NULL, GFS3_OP_XATTROP, 0}, - [GFS3_OP_FXATTROP] = {"FXATTROP", GFS3_OP_FXATTROP, server4_0_fxattrop, - NULL, 0}, - [GFS3_OP_FGETXATTR] = {"FGETXATTR", GFS3_OP_FGETXATTR, server4_0_fgetxattr, - NULL, 0}, - [GFS3_OP_FSETXATTR] = {"FSETXATTR", GFS3_OP_FSETXATTR, server4_0_fsetxattr, - NULL, 0}, - [GFS3_OP_RCHECKSUM] = {"RCHECKSUM", GFS3_OP_RCHECKSUM, server4_0_rchecksum, - NULL, 0}, - [GFS3_OP_SETATTR] = {"SETATTR", GFS3_OP_SETATTR, server4_0_setattr, NULL, + [GFS3_OP_FXATTROP] = {"FXATTROP", server4_0_fxattrop, NULL, + GFS3_OP_FXATTROP, 0}, + [GFS3_OP_FGETXATTR] = {"FGETXATTR", server4_0_fgetxattr, NULL, + GFS3_OP_FGETXATTR, 0}, + [GFS3_OP_FSETXATTR] = {"FSETXATTR", server4_0_fsetxattr, NULL, + GFS3_OP_FSETXATTR, 0}, + [GFS3_OP_RCHECKSUM] = {"RCHECKSUM", server4_0_rchecksum, NULL, + GFS3_OP_RCHECKSUM, 0}, + [GFS3_OP_SETATTR] = {"SETATTR", server4_0_setattr, NULL, GFS3_OP_SETATTR, 0}, - [GFS3_OP_FSETATTR] = {"FSETATTR", GFS3_OP_FSETATTR, server4_0_fsetattr, - NULL, 0}, - [GFS3_OP_READDIRP] = {"READDIRP", GFS3_OP_READDIRP, server4_0_readdirp, - NULL, 0}, - [GFS3_OP_RELEASE] = {"RELEASE", GFS3_OP_RELEASE, server4_0_release, NULL, + [GFS3_OP_FSETATTR] = {"FSETATTR", server4_0_fsetattr, NULL, + GFS3_OP_FSETATTR, 0}, + [GFS3_OP_READDIRP] = {"READDIRP", server4_0_readdirp, NULL, + GFS3_OP_READDIRP, 0}, + [GFS3_OP_RELEASE] = {"RELEASE", server4_0_release, NULL, GFS3_OP_RELEASE, 0}, - [GFS3_OP_RELEASEDIR] = {"RELEASEDIR", GFS3_OP_RELEASEDIR, - server4_0_releasedir, NULL, 0}, - [GFS3_OP_FREMOVEXATTR] = {"FREMOVEXATTR", GFS3_OP_FREMOVEXATTR, - server4_0_fremovexattr, NULL, 0}, - [GFS3_OP_FALLOCATE] = {"FALLOCATE", GFS3_OP_FALLOCATE, server4_0_fallocate, - NULL, 0, DRC_NA}, - [GFS3_OP_DISCARD] = {"DISCARD", GFS3_OP_DISCARD, server4_0_discard, NULL, 0, - DRC_NA}, - [GFS3_OP_ZEROFILL] = {"ZEROFILL", GFS3_OP_ZEROFILL, server4_0_zerofill, - NULL, 0, DRC_NA}, - [GFS3_OP_IPC] = {"IPC", GFS3_OP_IPC, server4_0_ipc, NULL, 0, DRC_NA}, - [GFS3_OP_SEEK] = {"SEEK", GFS3_OP_SEEK, server4_0_seek, NULL, 0, DRC_NA}, - [GFS3_OP_LEASE] = {"LEASE", GFS3_OP_LEASE, server4_0_lease, NULL, 0, - DRC_NA}, - [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", GFS3_OP_GETACTIVELK, - server4_0_getactivelk, NULL, 0, DRC_NA}, - [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", GFS3_OP_SETACTIVELK, - server4_0_setactivelk, NULL, 0, DRC_NA}, - [GFS3_OP_COMPOUND] = {"COMPOUND", GFS3_OP_COMPOUND, server4_0_compound, - NULL, 0, DRC_NA}, - [GFS3_OP_ICREATE] = {"ICREATE", GFS3_OP_ICREATE, server4_0_icreate, NULL, 0, - DRC_NA}, - [GFS3_OP_NAMELINK] = {"NAMELINK", GFS3_OP_NAMELINK, server4_0_namelink, - NULL, 0, DRC_NA}, + [GFS3_OP_RELEASEDIR] = {"RELEASEDIR", server4_0_releasedir, NULL, + GFS3_OP_RELEASEDIR, 0}, + [GFS3_OP_FREMOVEXATTR] = {"FREMOVEXATTR", server4_0_fremovexattr, NULL, + GFS3_OP_FREMOVEXATTR, 0}, + [GFS3_OP_FALLOCATE] = {"FALLOCATE", server4_0_fallocate, NULL, DRC_NA, + GFS3_OP_FALLOCATE, 0}, + [GFS3_OP_DISCARD] = {"DISCARD", server4_0_discard, NULL, DRC_NA, + GFS3_OP_DISCARD, 0}, + [GFS3_OP_ZEROFILL] = {"ZEROFILL", server4_0_zerofill, NULL, DRC_NA, + GFS3_OP_ZEROFILL, 0}, + [GFS3_OP_IPC] = {"IPC", server4_0_ipc, NULL, DRC_NA, GFS3_OP_IPC, 0}, + [GFS3_OP_SEEK] = {"SEEK", server4_0_seek, NULL, DRC_NA, GFS3_OP_SEEK, 0}, + [GFS3_OP_LEASE] = {"LEASE", server4_0_lease, NULL, DRC_NA, GFS3_OP_LEASE, + 0}, + [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", server4_0_getactivelk, NULL, DRC_NA, + GFS3_OP_GETACTIVELK, 0}, + [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", server4_0_setactivelk, NULL, DRC_NA, + GFS3_OP_SETACTIVELK, 0}, + [GFS3_OP_COMPOUND] = {"COMPOUND", server4_0_compound, NULL, DRC_NA, + GFS3_OP_COMPOUND, 0}, + [GFS3_OP_ICREATE] = {"ICREATE", server4_0_icreate, NULL, DRC_NA, + GFS3_OP_ICREATE, 0}, + [GFS3_OP_NAMELINK] = {"NAMELINK", server4_0_namelink, NULL, DRC_NA, + GFS3_OP_NAMELINK, 0}, + [GFS3_OP_COPY_FILE_RANGE] = {"COPY-FILE-RANGE", server4_0_copy_file_range, + NULL, DRC_NA, GFS3_OP_COPY_FILE_RANGE, 0}, }; struct rpcsvc_program glusterfs4_0_fop_prog = { diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index a8664d7871e..721968004a0 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -14,15 +14,14 @@ #include "server.h" #include "server-helpers.h" #include "glusterfs3-xdr.h" -#include "call-stub.h" -#include "statedump.h" -#include "defaults.h" +#include <glusterfs/call-stub.h> +#include <glusterfs/statedump.h> +#include <glusterfs/defaults.h> #include "authenticate.h" -#include "gf-event.h" -#include "events.h" +#include <glusterfs/gf-event.h> +#include <glusterfs/events.h> #include "server-messages.h" #include "rpc-clnt.h" -#include "glusterfsd.h" rpcsvc_cbk_program_t server_cbk_prog = { .progname = "Gluster Callback", @@ -109,8 +108,7 @@ server_submit_reply(call_frame_t *frame, rpcsvc_request_t *req, void *arg, iob = gfs_serialize_reply(req, arg, &rsp, xdrproc); if (!iob) { - gf_msg("", GF_LOG_ERROR, 0, PS_MSG_SERIALIZE_REPLY_FAILED, - "Failed to serialize reply"); + gf_smsg("", GF_LOG_ERROR, 0, PS_MSG_SERIALIZE_REPLY_FAILED, NULL); goto ret; } @@ -133,7 +131,7 @@ server_submit_reply(call_frame_t *frame, rpcsvc_request_t *req, void *arg, "Reply submission failed"); if (frame && client) { server_connection_cleanup(frame->this, client, - INTERNAL_LOCKS | POSIX_LOCKS); + INTERNAL_LOCKS | POSIX_LOCKS, NULL); } else { gf_msg_callingfn("", GF_LOG_ERROR, 0, PS_MSG_REPLY_SUBMIT_FAILED, "Reply submission failed"); @@ -169,6 +167,7 @@ server_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname) char key[32] = { 0, }; + int keylen; int count = 0; int ret = -1; @@ -188,8 +187,8 @@ server_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname) (xprt->xl_private->bound_xl->name) && (brickname) && (!strcmp(brickname, xprt->xl_private->bound_xl->name))) { peerinfo = &xprt->peerinfo; - snprintf(key, sizeof(key), "client%d.hostname", count); - ret = dict_set_str(dict, key, peerinfo->identifier); + keylen = snprintf(key, sizeof(key), "client%d.hostname", count); + ret = dict_set_strn(dict, key, keylen, peerinfo->identifier); if (ret) goto unlock; @@ -208,8 +207,9 @@ server_priv_to_dict(xlator_t *this, dict_t *dict, char *brickname) if (ret) goto unlock; - snprintf(key, sizeof(key), "client%d.name", count); - ret = dict_set_str(dict, key, xprt->xl_private->client_name); + keylen = snprintf(key, sizeof(key), "client%d.name", count); + ret = dict_set_strn(dict, key, keylen, + xprt->xl_private->client_name); if (ret) goto unlock; @@ -222,7 +222,7 @@ unlock: if (ret) goto out; - ret = dict_set_int32(dict, "clientcount", count); + ret = dict_set_int32_sizen(dict, "clientcount", count); out: return ret; @@ -267,6 +267,8 @@ server_priv(xlator_t *this) gf_proc_dump_build_key(key, "server", "total-bytes-write"); gf_proc_dump_write(key, "%" PRIu64, total_write); + rpcsvc_statedump(conf->rpc); + ret = 0; out: if (ret) @@ -302,8 +304,7 @@ get_auth_types(dict_t *this, char *key, data_t *value, void *data) /* TODO: backward compatibility, remove when newer versions are available */ tmp = "addr"; - gf_msg("server", GF_LOG_WARNING, 0, PS_MSG_AUTH_IP_ERROR, - "assuming 'auth.ip' to be 'auth.addr'"); + gf_smsg("server", GF_LOG_WARNING, 0, PS_MSG_AUTH_IP_ERROR, NULL); } ret = dict_set_dynptr(auth_dict, tmp, NULL, 0); if (ret < 0) { @@ -332,8 +333,8 @@ _check_for_auth_option(dict_t *d, char *k, data_t *v, void *tmp) goto out; if (strncmp(tail, "addr.", 5) != 0) { - gf_msg(xl->name, GF_LOG_TRACE, 0, PS_MSG_SKIP_FORMAT_CHK, - "skip format check for non-addr auth option %s", k); + gf_smsg(xl->name, GF_LOG_TRACE, 0, PS_MSG_SKIP_FORMAT_CHK, "option=%s", + k, NULL); goto out; } @@ -355,10 +356,8 @@ _check_for_auth_option(dict_t *d, char *k, data_t *v, void *tmp) ret = xlator_option_validate_addr_list(xl, "auth-*", v->data, NULL, NULL); if (ret) - gf_msg(xl->name, GF_LOG_ERROR, 0, PS_MSG_INTERNET_ADDR_ERROR, - "internet address '%s' does not conform " - "to standards.", - v->data); + gf_smsg(xl->name, GF_LOG_ERROR, 0, PS_MSG_INTERNET_ADDR_ERROR, + "data=%s", v->data, NULL); } out: return ret; @@ -378,11 +377,8 @@ validate_auth_options(xlator_t *this, dict_t *dict) error = dict_foreach(dict, _check_for_auth_option, trav->xlator); if (-1 == error) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_AUTHENTICATE_ERROR, - "volume '%s' " - "defined as subvolume, but no authentication " - "defined for the same", - trav->xlator->name); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_AUTHENTICATE_ERROR, + "name=%s", trav->xlator->name, NULL); break; } trav = trav->next; @@ -392,6 +388,43 @@ out: return error; } +void +server_call_xlator_mem_cleanup(xlator_t *this, char *victim_name) +{ + pthread_t th_id = { + 0, + }; + int th_ret = -1; + server_cleanup_xprt_arg_t *arg = NULL; + + if (!victim_name) + return; + + gf_log(this->name, GF_LOG_INFO, "Create graph janitor thread for brick %s", + victim_name); + + arg = calloc(1, sizeof(*arg)); + arg->this = this; + arg->victim_name = strdup(victim_name); + if (!arg->victim_name) { + gf_smsg(this->name, GF_LOG_CRITICAL, ENOMEM, LG_MSG_NO_MEMORY, + "Memory allocation is failed"); + free(arg); + return; + } + + th_ret = gf_thread_create_detached(&th_id, server_graph_janitor_threads, + arg, "graphjanitor"); + if (th_ret) { + gf_log(this->name, GF_LOG_ERROR, + "graph janitor Thread" + " creation is failed for brick %s", + victim_name); + free(arg->victim_name); + free(arg); + } +} + int server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) { @@ -402,25 +435,20 @@ server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) client_t *client = NULL; char *auth_path = NULL; int ret = -1; - gf_boolean_t victim_found = _gf_false; char *xlator_name = NULL; - glusterfs_ctx_t *ctx = NULL; - xlator_t *top = NULL; - xlator_list_t **trav_p = NULL; - xlator_t *travxl = NULL; uint64_t xprtrefcount = 0; - struct _child_status *tmp = NULL; + gf_boolean_t fd_exist = _gf_false; - if (!xl || !data) { + this = xl; + trans = data; + + if (!this || !data || !this->ctx || !this->ctx->active) { gf_msg_callingfn("server", GF_LOG_WARNING, 0, PS_MSG_RPC_NOTIFY_ERROR, "Calling rpc_notify without initializing"); goto out; } - this = xl; - trans = data; conf = this->private; - ctx = this->ctx; switch (event) { case RPCSVC_EVENT_ACCEPT: { @@ -451,35 +479,38 @@ server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) break; } + /* Set the disconnect_progress flag to 1 to avoid races + during brick detach while brick mux is enabled + */ + GF_ATOMIC_INIT(trans->disconnect_progress, 1); /* transport has to be removed from the list upon disconnect * irrespective of whether lock self heal is off or on, since * new transport will be created upon reconnect. */ pthread_mutex_lock(&conf->mutex); client = trans->xl_private; - list_del_init(&trans->list); + if (!client) + list_del_init(&trans->list); pthread_mutex_unlock(&conf->mutex); if (!client) goto unref_transport; - gf_msg(this->name, GF_LOG_INFO, 0, PS_MSG_CLIENT_DISCONNECTING, - "disconnecting connection" - " from %s", - client->client_uid); + gf_smsg(this->name, GF_LOG_INFO, 0, PS_MSG_CLIENT_DISCONNECTING, + "client-uid=%s", client->client_uid, NULL); - ret = dict_get_str(this->options, "auth-path", &auth_path); + ret = dict_get_str_sizen(this->options, "auth-path", &auth_path); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_DICT_GET_FAILED, - "failed to get auth-path"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_DICT_GET_FAILED, + "type=auth-path", NULL); auth_path = NULL; } gf_client_ref(client); gf_client_put(client, &detached); if (detached) { - server_connection_cleanup(this, client, - INTERNAL_LOCKS | POSIX_LOCKS); + server_connection_cleanup( + this, client, INTERNAL_LOCKS | POSIX_LOCKS, &fd_exist); gf_event(EVENT_CLIENT_DISCONNECT, "client_uid=%s;" "client_identifier=%s;server_identifier=%s;" @@ -496,53 +527,36 @@ server_rpc_notify(rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, void *data) unref_transport: /* rpc_transport_unref() causes a RPCSVC_EVENT_TRANSPORT_DESTROY * to be called in blocking manner - * So no code should ideally be after this unref + * So no code should ideally be after this unref, Call + * rpc_transport_unref only while cleanup_starting flag is not set + * otherwise transport_unref will be call by either + * server_connection_cleanup_flush_cbk or server_submit_reply at the + * time of freeing state */ - rpc_transport_unref(trans); + if (!client || !detached || !fd_exist) + rpc_transport_unref(trans); break; case RPCSVC_EVENT_TRANSPORT_DESTROY: + pthread_mutex_lock(&conf->mutex); client = trans->xl_private; + list_del_init(&trans->list); + pthread_mutex_unlock(&conf->mutex); if (!client) break; - pthread_mutex_lock(&conf->mutex); - list_for_each_entry(tmp, &conf->child_status->status_list, - status_list) - { - if (tmp->name && client->bound_xl && - client->bound_xl->cleanup_starting && - !strcmp(tmp->name, client->bound_xl->name)) { - xprtrefcount = GF_ATOMIC_GET(tmp->xprtrefcnt); - if (xprtrefcount > 0) { - xprtrefcount = GF_ATOMIC_DEC(tmp->xprtrefcnt); - if (xprtrefcount == 0) - xlator_name = gf_strdup(client->bound_xl->name); - } - break; + + if (client->bound_xl && client->bound_xl->cleanup_starting) { + xprtrefcount = GF_ATOMIC_GET(client->bound_xl->xprtrefcnt); + if (xprtrefcount > 0) { + xprtrefcount = GF_ATOMIC_DEC(client->bound_xl->xprtrefcnt); + if (xprtrefcount == 0) + xlator_name = gf_strdup(client->bound_xl->name); } } - pthread_mutex_unlock(&conf->mutex); gf_client_unref(client); if (xlator_name) { - if (this->ctx->active) { - top = this->ctx->active->first; - LOCK(&ctx->volfile_lock); - for (trav_p = &top->children; *trav_p; - trav_p = &(*trav_p)->next) { - travxl = (*trav_p)->xlator; - if (!travxl->call_cleanup && - strcmp(travxl->name, xlator_name) == 0) { - victim_found = _gf_true; - break; - } - } - UNLOCK(&ctx->volfile_lock); - if (victim_found) { - xlator_mem_cleanup(travxl); - rpcsvc_autoscale_threads(ctx, conf->rpc, -1); - } - } + server_call_xlator_mem_cleanup(this, xlator_name); GF_FREE(xlator_name); } @@ -556,6 +570,71 @@ out: return 0; } +void * +server_graph_janitor_threads(void *data) +{ + xlator_t *victim = NULL; + xlator_t *this = NULL; + server_conf_t *conf = NULL; + glusterfs_ctx_t *ctx = NULL; + char *victim_name = NULL; + server_cleanup_xprt_arg_t *arg = NULL; + gf_boolean_t victim_found = _gf_false; + xlator_list_t **trav_p = NULL; + xlator_t *top = NULL; + uint32_t parent_down = 0; + + GF_ASSERT(data); + + arg = data; + this = arg->this; + victim_name = arg->victim_name; + THIS = arg->this; + conf = this->private; + + ctx = THIS->ctx; + GF_VALIDATE_OR_GOTO(this->name, ctx, out); + + top = this->ctx->active->first; + LOCK(&ctx->volfile_lock); + for (trav_p = &top->children; *trav_p; trav_p = &(*trav_p)->next) { + victim = (*trav_p)->xlator; + if (victim->cleanup_starting && + strcmp(victim->name, victim_name) == 0) { + parent_down = victim->parent_down; + victim->parent_down = 1; + if (!parent_down) + victim_found = _gf_true; + break; + } + } + if (victim_found) + glusterfs_delete_volfile_checksum(ctx, victim->volfile_id); + UNLOCK(&ctx->volfile_lock); + if (!victim_found) { + gf_log(this->name, GF_LOG_ERROR, + "victim brick %s is not" + " found in graph", + victim_name); + goto out; + } + + default_notify(victim, GF_EVENT_PARENT_DOWN, victim); + if (victim->notify_down) { + gf_log(THIS->name, GF_LOG_INFO, + "Start call fini for brick" + " %s stack", + victim->name); + xlator_mem_cleanup(victim); + rpcsvc_autoscale_threads(ctx, conf->rpc, -1); + } + +out: + free(arg->victim_name); + free(arg); + return NULL; +} + int32_t server_mem_acct_init(xlator_t *this) { @@ -566,8 +645,7 @@ server_mem_acct_init(xlator_t *this) ret = xlator_mem_acct_init(this, gf_server_mt_end + 1); if (ret != 0) { - gf_msg(this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, - "Memory accounting init failed"); + gf_smsg(this->name, GF_LOG_ERROR, ENOMEM, PS_MSG_NO_MEMORY, NULL); return ret; } out: @@ -623,7 +701,7 @@ server_check_event_threads(xlator_t *this, server_conf_t *conf, int32_t new) return 0; } - return event_reconfigure_threads(pool, target); + return gf_event_reconfigure_threads(pool, target); } int @@ -669,14 +747,15 @@ server_reconfigure(xlator_t *this, dict_t *options) * translator itself. */ kid = NULL; - if (dict_get_str(options, "auth-path", &auth_path) == 0) { + if (dict_get_str_sizen(options, "auth-path", &auth_path) == 0) { kid = get_xlator_by_name(this, auth_path); } if (!kid) { kid = this; } - if (dict_get_int32(options, "inode-lru-limit", &inode_lru_limit) == 0) { + if (dict_get_int32_sizen(options, "inode-lru-limit", &inode_lru_limit) == + 0) { conf->inode_lru_limit = inode_lru_limit; gf_msg_trace(this->name, 0, "Reconfigured inode-lru-limit to " @@ -691,13 +770,12 @@ server_reconfigure(xlator_t *this, dict_t *options) xlator_foreach(this, xlator_set_inode_lru_limit, &inode_lru_limit); } - data = dict_get(options, "trace"); + data = dict_get_sizen(options, "trace"); if (data) { ret = gf_string2boolean(data->data, &trace); if (ret != 0) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, - "'trace' takes on only " - "boolean values. Neglecting option"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, + NULL); ret = -1; goto out; } @@ -707,8 +785,7 @@ server_reconfigure(xlator_t *this, dict_t *options) GF_OPTION_RECONF("statedump-path", statedump_path, options, path, do_auth); if (!statedump_path) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_STATEDUMP_PATH_ERROR, - "Error while reconfiguring statedump path"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_STATEDUMP_PATH_ERROR, NULL); goto do_auth; } gf_path_strip_trailing_slashes(statedump_path); @@ -741,16 +818,14 @@ do_auth: GF_OPTION_RECONF("gid-timeout", conf->gid_cache_timeout, options, int32, do_rpc); if (gid_cache_reconf(&conf->gid_cache, conf->gid_cache_timeout) < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, - "Failed to reconfigure group cache."); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, NULL); goto do_rpc; } do_rpc: rpc_conf = conf->rpc; if (!rpc_conf) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, - "No rpc_conf !!!!"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, NULL); goto out; } @@ -794,8 +869,8 @@ do_rpc: * connections that are relevant to the brick * we're reconfiguring. */ - if (dict_get_str(xprt->clnt_options, "remote-subvolume", - &xprt_path) != 0) { + if (dict_get_str_sizen(xprt->clnt_options, "remote-subvolume", + &xprt_path) != 0) { continue; } if (strcmp(xprt_path, auth_path) != 0) { @@ -804,9 +879,8 @@ do_rpc: ret = gf_authenticate(xprt->clnt_options, options, conf->auth_modules); if (ret == AUTH_ACCEPT) { - gf_msg(kid->name, GF_LOG_TRACE, 0, PS_MSG_CLIENT_ACCEPTED, - "authorized client, hence we " - "continue with this connection"); + gf_smsg(kid->name, GF_LOG_TRACE, 0, PS_MSG_CLIENT_ACCEPTED, + NULL); } else { gf_event(EVENT_CLIENT_AUTH_REJECT, "client_uid=%s;" @@ -816,11 +890,10 @@ do_rpc: xprt->xl_private->client_uid, xprt->peerinfo.identifier, xprt->myinfo.identifier, auth_path); - gf_msg(this->name, GF_LOG_INFO, EACCES, - PS_MSG_AUTHENTICATE_ERROR, - "unauthorized client, hence " - "terminating the connection %s", - xprt->peerinfo.identifier); + gf_smsg(this->name, GF_LOG_INFO, EACCES, + PS_MSG_UNAUTHORIZED_CLIENT, + "peerinfo-identifier=%s", xprt->peerinfo.identifier, + NULL); rpc_transport_disconnect(xprt, _gf_false); } } @@ -831,8 +904,7 @@ do_rpc: ret = rpcsvc_set_outstanding_rpc_limit( rpc_conf, options, RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, - "Failed to reconfigure outstanding-rpc-limit"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RECONFIGURE_FAILED, NULL); goto out; } @@ -842,9 +914,8 @@ do_rpc: if (listeners->trans->reconfigure) listeners->trans->reconfigure(listeners->trans, options); else - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, - "Reconfigure " - "not found for transport"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, + NULL); } } @@ -860,12 +931,6 @@ do_rpc: if (ret) goto out; - /* rpcsvc thread reconfigure should be after events thread - * reconfigure - */ - new_nthread = ((struct event_pool *)(this->ctx->event_pool)) - ->eventthreadcount; - ret = rpcsvc_ownthread_reconf(rpc_conf, new_nthread); out: THIS = oldTHIS; gf_msg_debug("", 0, "returning %d", ret); @@ -910,9 +975,9 @@ server_dump_metrics(xlator_t *this, int fd) if (!client) continue; - dprintf(fd, "%s.total.rpc.%s.bytes_read %lu\n", this->name, + dprintf(fd, "%s.total.rpc.%s.bytes_read %" PRIu64 "\n", this->name, client->client_uid, xprt->total_bytes_read); - dprintf(fd, "%s.total.rpc.%s.bytes_write %lu\n", this->name, + dprintf(fd, "%s.total.rpc.%s.bytes_write %" PRIu64 "\n", this->name, client->client_uid, xprt->total_bytes_write); dprintf(fd, "%s.total.rpc.%s.outstanding %d\n", this->name, client->client_uid, xprt->outstanding_rpc_count); @@ -923,6 +988,49 @@ server_dump_metrics(xlator_t *this, int fd) return 0; } +void +server_cleanup(xlator_t *this, server_conf_t *conf) +{ + if (!this || !conf) + return; + + LOCK_DESTROY(&conf->itable_lock); + pthread_mutex_destroy(&conf->mutex); + + if (this->ctx->event_pool) { + /* Free the event pool */ + (void)gf_event_pool_destroy(this->ctx->event_pool); + } + + if (dict_get_sizen(this->options, "config-directory")) { + GF_FREE(conf->conf_dir); + conf->conf_dir = NULL; + } + + if (conf->child_status) { + GF_FREE(conf->child_status); + conf->child_status = NULL; + } + + if (this->ctx->statedump_path) { + GF_FREE(this->ctx->statedump_path); + this->ctx->statedump_path = NULL; + } + + if (conf->auth_modules) { + gf_auth_fini(conf->auth_modules); + dict_unref(conf->auth_modules); + } + + if (conf->rpc) { + (void)rpcsvc_destroy(conf->rpc); + conf->rpc = NULL; + } + + GF_FREE(conf); + this->private = NULL; +} + int server_init(xlator_t *this) { @@ -935,14 +1043,12 @@ server_init(xlator_t *this) GF_VALIDATE_OR_GOTO("init", this, out); if (this->children == NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_SUBVOL_NULL, - "protocol/server should have subvolume"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_SUBVOL_NULL, NULL); goto out; } if (this->parents != NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_PARENT_VOL_ERROR, - "protocol/server should not have parent volumes"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_PARENT_VOL_ERROR, NULL); goto out; } @@ -965,27 +1071,22 @@ server_init(xlator_t *this) if (ret) goto out; - ret = dict_get_str(this->options, "config-directory", &conf->conf_dir); + ret = dict_get_str_sizen(this->options, "config-directory", + &conf->conf_dir); if (ret) conf->conf_dir = CONFDIR; conf->child_status = GF_CALLOC(1, sizeof(struct _child_status), gf_server_mt_child_status); INIT_LIST_HEAD(&conf->child_status->status_list); - GF_ATOMIC_INIT(conf->child_status->xprtrefcnt, 0); - /*ret = dict_get_str (this->options, "statedump-path", &statedump_path); - if (!ret) { - gf_path_strip_trailing_slashes (statedump_path); - this->ctx->statedump_path = statedump_path; - }*/ GF_OPTION_INIT("statedump-path", statedump_path, path, out); if (statedump_path) { gf_path_strip_trailing_slashes(statedump_path); this->ctx->statedump_path = gf_strdup(statedump_path); } else { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_STATEDUMP_PATH_ERROR, - "Error setting statedump path"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_SET_STATEDUMP_PATH_ERROR, + NULL); ret = -1; goto out; } @@ -1004,6 +1105,7 @@ server_init(xlator_t *this) ret = gf_auth_init(this, conf->auth_modules); if (ret) { dict_unref(conf->auth_modules); + conf->auth_modules = NULL; goto out; } @@ -1015,8 +1117,7 @@ server_init(xlator_t *this) GF_OPTION_INIT("gid-timeout", conf->gid_cache_timeout, int32, out); if (gid_cache_init(&conf->gid_cache, conf->gid_cache_timeout) < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_GRP_CACHE_ERROR, - "Failed to initialize group cache."); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_INIT_GRP_CACHE_ERROR, NULL); goto out; } @@ -1035,9 +1136,7 @@ server_init(xlator_t *this) /* RPC related */ conf->rpc = rpcsvc_init(this, this->ctx, this->options, 0); if (conf->rpc == NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPCSVC_CREATE_FAILED, - "creation of rpcsvc " - "failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPCSVC_CREATE_FAILED, NULL); ret = -1; goto out; } @@ -1045,8 +1144,7 @@ server_init(xlator_t *this) ret = rpcsvc_set_outstanding_rpc_limit( conf->rpc, this->options, RPCSVC_DEFAULT_OUTSTANDING_RPC_LIMIT); if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONF_ERROR, - "Failed to configure outstanding-rpc-limit"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_RPC_CONFIGURE_FAILED, NULL); goto out; } @@ -1056,40 +1154,40 @@ server_init(xlator_t *this) */ this->ctx->secure_srvr = MGMT_SSL_COPY_IO; - ret = dict_get_str(this->options, "transport-type", &transport_type); + ret = dict_get_str_sizen(this->options, "transport-type", &transport_type); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, - "option transport-type not set"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_TYPE_NOT_SET, + NULL); ret = -1; goto out; } total_transport = rpc_transport_count(transport_type); if (total_transport <= 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_TRANSPORT_ERROR, - "failed to get total number of available tranpsorts"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_GET_TOTAL_AVAIL_TRANSPORT_FAILED, NULL); ret = -1; goto out; } + + ret = dict_set_int32_sizen(this->options, "notify-poller-death", 1); + ret = rpcsvc_create_listeners(conf->rpc, this->options, this->name); if (ret < 1) { - gf_msg(this->name, GF_LOG_WARNING, 0, - PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, - "creation of listener failed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, + PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, NULL); if (ret != -EADDRINUSE) ret = -1; goto out; } else if (ret < total_transport) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, - "creation of %d listeners failed, continuing with " - "succeeded transport", - (total_transport - ret)); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_RPCSVC_LISTENER_CREATE_FAILED, "number=%d", + "continuing with succeeded transport", (total_transport - ret), + NULL); } ret = rpcsvc_register_notify(conf->rpc, server_rpc_notify, this); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_RPCSVC_NOTIFY, - "registration of notify with rpcsvc failed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_RPCSVC_NOTIFY, NULL); goto out; } @@ -1099,11 +1197,10 @@ server_init(xlator_t *this) */ ret = rpcsvc_program_register(conf->rpc, &glusterfs3_3_fop_prog, _gf_true); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, - "registration of program (name:%s, prognum:%d, " - "progver:%d) failed", - glusterfs3_3_fop_prog.progname, glusterfs3_3_fop_prog.prognum, - glusterfs3_3_fop_prog.progver); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, "name=%s", + glusterfs3_3_fop_prog.progname, "prognum=%d", + glusterfs3_3_fop_prog.prognum, "progver=%d", + glusterfs3_3_fop_prog.progver, NULL); goto out; } @@ -1123,11 +1220,10 @@ server_init(xlator_t *this) ret = rpcsvc_program_register(conf->rpc, &gluster_handshake_prog, _gf_false); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, - "registration of program (name:%s, prognum:%d, " - "progver:%d) failed", - gluster_handshake_prog.progname, gluster_handshake_prog.prognum, - gluster_handshake_prog.progver); + gf_smsg(this->name, GF_LOG_WARNING, 0, PS_MSG_PGM_REG_FAILED, "name=%s", + gluster_handshake_prog.progname, "prognum=%d", + gluster_handshake_prog.prognum, "progver=%d", + gluster_handshake_prog.progver, NULL); rpcsvc_program_unregister(conf->rpc, &glusterfs3_3_fop_prog); rpcsvc_program_unregister(conf->rpc, &glusterfs4_0_fop_prog); goto out; @@ -1141,18 +1237,14 @@ server_init(xlator_t *this) lim.rlim_max = 1048576; if (setrlimit(RLIMIT_NOFILE, &lim) == -1) { - gf_msg(this->name, GF_LOG_WARNING, errno, PS_MSG_ULIMIT_SET_FAILED, - "WARNING: Failed to " - "set 'ulimit -n 1M': %s", - strerror(errno)); + gf_smsg(this->name, GF_LOG_WARNING, errno, PS_MSG_ULIMIT_SET_FAILED, + "errno=%s", strerror(errno), NULL); lim.rlim_cur = 65536; lim.rlim_max = 65536; if (setrlimit(RLIMIT_NOFILE, &lim) == -1) { - gf_msg(this->name, GF_LOG_WARNING, errno, PS_MSG_FD_NOT_FOUND, - "Failed to set " - "max open fd to 64k: %s", - strerror(errno)); + gf_smsg(this->name, GF_LOG_WARNING, errno, PS_MSG_FD_NOT_FOUND, + "errno=%s", strerror(errno), NULL); } else { gf_msg_trace(this->name, 0, "max open fd set " @@ -1164,9 +1256,8 @@ server_init(xlator_t *this) if (!this->ctx->cmd_args.volfile_id) { /* In some use cases this is a valid case, but document this to be annoying log in that case */ - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_VOL_FILE_OPEN_FAILED, - "volfile-id argument not given. " - "This is mandatory argument, defaulting to 'gluster'"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_VOL_FILE_OPEN_FAILED, + NULL); this->ctx->cmd_args.volfile_id = gf_strdup("gluster"); } FIRST_CHILD(this)->volfile_id = gf_strdup(this->ctx->cmd_args.volfile_id); @@ -1179,15 +1270,7 @@ out: if (this != NULL) { this->fini(this); } - - if (conf && conf->rpc) { - rpcsvc_listener_t *listener, *next; - list_for_each_entry_safe(listener, next, &conf->rpc->listeners, - list) - { - rpcsvc_listener_destroy(listener); - } - } + server_cleanup(this, conf); } return ret; @@ -1310,9 +1393,9 @@ server_process_event_upcall(xlator_t *this, void *data) xdrproc = (xdrproc_t)xdr_gfs4_entrylk_contention_req; break; default: - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PS_MSG_INVALID_ENTRY, - "Received invalid upcall event(%d)", - upcall_data->event_type); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, + PS_MSG_INVLAID_UPCALL_EVENT, "event-type=%d", + upcall_data->event_type, NULL); goto out; } @@ -1386,6 +1469,8 @@ server_process_child_event(xlator_t *this, int32_t event, void *data, INIT_LIST_HEAD(&tmp->status_list); tmp->name = gf_strdup(victim->name); tmp->child_up = _gf_true; + memcpy(tmp->volume_id, victim->graph->volume_id, + GF_UUID_BUF_SIZE); list_add_tail(&tmp->status_list, &conf->child_status->status_list); } @@ -1402,10 +1487,8 @@ server_process_child_event(xlator_t *this, int32_t event, void *data, } if (!tmp->name) - gf_msg(this->name, GF_LOG_ERROR, 0, PS_MSG_CHILD_STATUS_FAILED, - "No xlator %s is found in " - "child status list", - victim->name); + gf_smsg(this->name, GF_LOG_ERROR, 0, PS_MSG_CHILD_STATUS_FAILED, + "name=%s", victim->name, NULL); } list_for_each_entry(xprt, &conf->xprt_list, list) { @@ -1440,6 +1523,7 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) glusterfs_ctx_t *ctx = NULL; gf_boolean_t xprt_found = _gf_false; uint64_t totxprt = 0; + uint64_t totdisconnect = 0; GF_VALIDATE_OR_GOTO(THIS->name, this, out); conf = this->private; @@ -1453,9 +1537,8 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) ret = server_process_event_upcall(this, data); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, - "server_process_event_upcall failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_SERVER_EVENT_UPCALL_FAILED, NULL); goto out; } break; @@ -1474,9 +1557,8 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) ret = server_process_child_event(this, event, data, GF_CBK_CHILD_UP); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, - "server_process_child_event failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_SERVER_CHILD_EVENT_FAILED, NULL); goto out; } default_notify(this, event, data); @@ -1484,12 +1566,17 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) } case GF_EVENT_CHILD_DOWN: { + if (victim->cleanup_starting) { + victim->notify_down = 1; + gf_log(this->name, GF_LOG_INFO, + "Getting CHILD_DOWN event for brick %s", victim->name); + } + ret = server_process_child_event(this, event, data, GF_CBK_CHILD_DOWN); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - PS_MSG_SERVER_EVENT_UPCALL_FAILED, - "server_process_child_event failed"); + gf_smsg(this->name, GF_LOG_ERROR, 0, + PS_MSG_SERVER_CHILD_EVENT_FAILED, NULL); goto out; } default_notify(this, event, data); @@ -1507,6 +1594,10 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) if (!xprt->xl_private) { continue; } + + if (GF_ATOMIC_GET(xprt->disconnect_progress)) + continue; + if (xprt->xl_private->bound_xl == data) { totxprt++; } @@ -1517,7 +1608,7 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) { if (strcmp(tmp->name, victim->name) == 0) { tmp->child_up = _gf_false; - GF_ATOMIC_INIT(tmp->xprtrefcnt, totxprt); + GF_ATOMIC_INIT(victim->xprtrefcnt, totxprt); break; } } @@ -1533,14 +1624,22 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) if (!xprt->xl_private) { continue; } + + if (GF_ATOMIC_GET(xprt->disconnect_progress)) + continue; + if (xprt->xl_private->bound_xl == data) { gf_log(this->name, GF_LOG_INFO, "disconnecting %s", xprt->peerinfo.identifier); xprt_found = _gf_true; + totdisconnect++; rpc_transport_disconnect(xprt, _gf_false); } } + if (totxprt > totdisconnect) + GF_ATOMIC_SUB(victim->xprtrefcnt, (totxprt - totdisconnect)); + pthread_mutex_unlock(&conf->mutex); if (this->ctx->active) { top = this->ctx->active->first; @@ -1561,8 +1660,7 @@ server_notify(xlator_t *this, int32_t event, void *data, ...) rpc_clnt_mgmt_pmap_signout(ctx, victim->name); if (!xprt_found && victim_found) { - xlator_mem_cleanup(victim); - rpcsvc_autoscale_threads(ctx, conf->rpc, -1); + server_call_xlator_mem_cleanup(this, victim->name); } } break; @@ -1613,7 +1711,7 @@ struct volume_options server_options[] = { .type = GF_OPTION_TYPE_TIME, .min = 0, .max = 1013, - .default_value = "42", /* default like network.ping-timeout */ + .default_value = TOSTRING(GF_NETWORK_TIMEOUT), }, { .key = {"transport.*"}, @@ -1647,13 +1745,22 @@ struct volume_options server_options[] = { "as user bin or group staff.", .op_version = {2}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, + {.key = {"all-squash"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "Map requests from any uid/gid to the anonymous " + "uid/gid. Note that this does not apply to any other " + "uids or gids that might be equally sensitive, such " + "as user bin or group staff.", + .op_version = {GD_OP_VERSION_6_0}, + .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, {.key = {"anonuid"}, .type = GF_OPTION_TYPE_INT, .default_value = "65534", /* RPC_NOBODY_UID */ .min = 0, .max = (uint32_t)-1, .description = "value of the uid used for the anonymous " - "user/nfsnobody when root-squash is enabled.", + "user/nfsnobody when root-squash/all-squash is enabled.", .op_version = {3}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, {.key = {"anongid"}, @@ -1662,7 +1769,7 @@ struct volume_options server_options[] = { .min = 0, .max = (uint32_t)-1, .description = "value of the gid used for the anonymous " - "user/nfsnobody when root-squash is enabled.", + "user/nfsnobody when root-squash/all-squash is enabled.", .op_version = {3}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, {.key = {"statedump-path"}, @@ -1739,7 +1846,7 @@ struct volume_options server_options[] = { .type = GF_OPTION_TYPE_INT, .min = 1, .max = 1024, - .default_value = "1", + .default_value = "2", .description = "Specifies the number of event threads to execute " "in parallel. Larger values would help process" " responses faster, depending on available processing" diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index e6064af076e..821290b62d8 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -13,17 +13,17 @@ #include <pthread.h> -#include "fd.h" +#include <glusterfs/fd.h> #include "rpcsvc.h" -#include "fd.h" +#include <glusterfs/fd.h> #include "protocol-common.h" #include "server-mem-types.h" #include "glusterfs3.h" -#include "timer.h" -#include "client_t.h" -#include "gidcache.h" -#include "defaults.h" +#include <glusterfs/timer.h> +#include <glusterfs/client_t.h> +#include <glusterfs/gidcache.h> +#include <glusterfs/defaults.h> #include "authenticate.h" #define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */ @@ -31,55 +31,6 @@ #define GF_MAX_SOCKET_WINDOW_SIZE (1 * GF_UNIT_MB) #define GF_MIN_SOCKET_WINDOW_SIZE (0) -#define CPD_REQ_FIELD(v, f) ((v)->compound_req_u.compound_##f##_req) -#define CPD_RSP_FIELD(v, f) ((v)->compound_rsp_u.compound_##f##_rsp) - -#define SERVER_COMMON_RSP_CLEANUP(rsp, fop, i) \ - do { \ - compound_rsp *this_rsp = NULL; \ - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; \ - gf_common_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp, fop); \ - \ - GF_FREE(_this_rsp->xdata.xdata_val); \ - } while (0) - -#define SERVER_FOP_RSP_CLEANUP(rsp, fop, i) \ - do { \ - compound_rsp *this_rsp = NULL; \ - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; \ - gfs3_##fop##_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp, fop); \ - \ - GF_FREE(_this_rsp->xdata.xdata_val); \ - } while (0) - -#define SERVER_COMPOUND_FOP_CLEANUP(curr_req, fop) \ - do { \ - gfs3_##fop##_req *_req = &CPD_REQ_FIELD(curr_req, fop); \ - \ - free(_req->xdata.xdata_val); \ - } while (0) - -#define CPD4_REQ_FIELD(v, f) ((v)->compound_req_v2_u.compound_##f##_req) -#define CPD4_RSP_FIELD(v, f) ((v)->compound_rsp_v2_u.compound_##f##_rsp) - -#define SERVER4_COMMON_RSP_CLEANUP(rsp, fop, i) \ - do { \ - compound_rsp_v2 *this_rsp = NULL; \ - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; \ - gfx_common_rsp *_this_rsp = &CPD4_RSP_FIELD(this_rsp, fop); \ - \ - GF_FREE(_this_rsp->xdata.pairs.pairs_val); \ - } while (0) - -#define SERVER4_FOP_RSP_CLEANUP(rsp, fop, i, rsp_type) \ - do { \ - compound_rsp_v2 *this_rsp = NULL; \ - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; \ - gfx_##rsp_type##_rsp *_this_rsp = &CPD4_RSP_FIELD(this_rsp, fop); \ - \ - GF_FREE(_this_rsp->xdata.pairs.pairs_val); \ - } while (0) - typedef enum { INTERNAL_LOCKS = 1, POSIX_LOCKS = 2, @@ -99,8 +50,8 @@ struct _volfile_ctx { struct _child_status { struct list_head status_list; char *name; + char volume_id[GF_UUID_BUF_SIZE]; gf_boolean_t child_up; - gf_atomic_t xprtrefcnt; }; struct server_conf { rpcsvc_t *rpc; @@ -181,7 +132,12 @@ struct _server_state { struct iatt stbuf; int valid; + /* + * this fd is used in all the fd based operations PLUS + * as a source fd in copy_file_range + */ fd_t *fd; + fd_t *fd_out; /* destination fd in copy_file_range */ dict_t *params; int32_t flags; int wbflags; @@ -192,6 +148,15 @@ struct _server_state { size_t size; off_t offset; + /* + * According to the man page of copy_file_range, + * the offsets for source and destination file + * are of type loff_t. But the type loff_t is + * linux specific and is actual a typedef of + * off64_t. + */ + off64_t off_in; /* source offset in copy_file_range */ + off64_t off_out; /* destination offset in copy_file_range */ mode_t mode; dev_t dev; size_t nr_count; @@ -212,21 +177,11 @@ struct _server_state { mode_t umask; struct gf_lease lease; lock_migration_info_t locklist; - /* required for compound fops */ - gfs3_compound_req req; - /* TODO: having xdr definition here - is not a good idea, but not taking - up the functionality right now */ - gfx_compound_req req_v2; - - /* last length till which iovec for compound - * writes was processed */ - int write_length; + struct iovec rsp_vector[MAX_IOVEC]; int rsp_count; struct iobuf *rsp_iobuf; struct iobref *rsp_iobref; - compound_args_t *args; /* subdir mount */ client_t *client; @@ -241,6 +196,11 @@ typedef struct _server_ctx { fdtable_t *fdtable; } server_ctx_t; +typedef struct server_cleanup_xprt_arg { + xlator_t *this; + char *victim_name; +} server_cleanup_xprt_arg_t; + int server_submit_reply(call_frame_t *frame, rpcsvc_request_t *req, void *arg, struct iovec *payload, int payloadcount, @@ -254,6 +214,9 @@ gf_server_check_getxattr_cmd(call_frame_t *frame, const char *name); void forget_inode_if_no_dentry(inode_t *inode); +void * +server_graph_janitor_threads(void *); + server_ctx_t * server_ctx_get(client_t *client, xlator_t *xlator); #endif /* !_SERVER_H */ |
