diff options
author | Amar Tumballi <amarts@redhat.com> | 2019-04-20 11:55:12 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-04-29 05:29:44 +0000 |
commit | 48d160756813875cf1889b4ce96493d25f96c726 (patch) | |
tree | 92349106820659f831f295e214335a0297a4ba48 | |
parent | 88418f400507fba109971f169ce0a2c4243a31c9 (diff) |
protocol: remove compound fop
Compound fops are kept on wire as a backward compatibility with
older AFR modules. The AFR module used beyond 4.x releases are
not using compound fops. Hence removing the compound fop in the
protocol code.
Note that, compound-fops was already an 'option' in AFR, and
completely removed since 4.1.x releases.
So, point to note is, with this change, we have 2 ways to upgrade
when clients of 3.x series are present.
i) set 'use-compound-fops' option to 'false' on any volume which
is of replica type. And then upgrade the servers.
ii) Do a two step upgrade. First from current version (which will
already be EOL if it's using compound) to a 4.1..6.x version,
and then an upgrade to 7.x.
Consider the overall code which we are removing for the option
seems quite high, I believe it is worth it.
updates: bz#1693692
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Change-Id: I0a8876d0367a15e1410ec845f251d5d3097ee593
-rw-r--r-- | rpc/xdr/src/glusterfs3-xdr.x | 120 | ||||
-rw-r--r-- | rpc/xdr/src/glusterfs4-xdr.x | 120 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-helpers.c | 2292 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 218 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-rpc-fops_v2.c | 212 | ||||
-rw-r--r-- | xlators/protocol/client/src/client.h | 131 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.c | 4166 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-helpers.h | 33 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-rpc-fops.c | 190 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-rpc-fops_v2.c | 185 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 61 |
11 files changed, 5 insertions, 7723 deletions
diff --git a/rpc/xdr/src/glusterfs3-xdr.x b/rpc/xdr/src/glusterfs3-xdr.x index 5e598869801..9db0a311159 100644 --- a/rpc/xdr/src/glusterfs3-xdr.x +++ b/rpc/xdr/src/glusterfs3-xdr.x @@ -859,126 +859,6 @@ struct gf_getsnap_name_uuid_rsp { opaque dict<>; }; -union compound_req switch (glusterfs_fop_t fop_enum) { - case GF_FOP_STAT: gfs3_stat_req compound_stat_req; - case GF_FOP_READLINK: gfs3_readlink_req compound_readlink_req; - case GF_FOP_MKNOD: gfs3_mknod_req compound_mknod_req; - case GF_FOP_MKDIR: gfs3_mkdir_req compound_mkdir_req; - case GF_FOP_UNLINK: gfs3_unlink_req compound_unlink_req; - case GF_FOP_RMDIR: gfs3_rmdir_req compound_rmdir_req; - case GF_FOP_SYMLINK: gfs3_symlink_req compound_symlink_req; - case GF_FOP_RENAME: gfs3_rename_req compound_rename_req; - case GF_FOP_LINK: gfs3_link_req compound_link_req; - case GF_FOP_TRUNCATE: gfs3_truncate_req compound_truncate_req; - case GF_FOP_OPEN: gfs3_open_req compound_open_req; - case GF_FOP_READ: gfs3_read_req compound_read_req; - case GF_FOP_WRITE: gfs3_write_req compound_write_req; - case GF_FOP_STATFS: gfs3_statfs_req compound_statfs_req; - case GF_FOP_FLUSH: gfs3_flush_req compound_flush_req; - case GF_FOP_FSYNC: gfs3_fsync_req compound_fsync_req; - case GF_FOP_GETXATTR: gfs3_getxattr_req compound_getxattr_req; - case GF_FOP_SETXATTR: gfs3_setxattr_req compound_setxattr_req; - case GF_FOP_REMOVEXATTR: gfs3_removexattr_req compound_removexattr_req; - case GF_FOP_OPENDIR: gfs3_opendir_req compound_opendir_req; - case GF_FOP_FSYNCDIR: gfs3_fsyncdir_req compound_fsyncdir_req; - case GF_FOP_ACCESS: gfs3_access_req compound_access_req; - case GF_FOP_CREATE: gfs3_create_req compound_create_req; - case GF_FOP_FTRUNCATE: gfs3_ftruncate_req compound_ftruncate_req; - case GF_FOP_FSTAT: gfs3_fstat_req compound_fstat_req; - case GF_FOP_LK: gfs3_lk_req compound_lk_req; - case GF_FOP_LOOKUP: gfs3_lookup_req compound_lookup_req; - case GF_FOP_READDIR: gfs3_readdir_req compound_readdir_req; - case GF_FOP_INODELK: gfs3_inodelk_req compound_inodelk_req; - case GF_FOP_FINODELK: gfs3_finodelk_req compound_finodelk_req; - case GF_FOP_ENTRYLK: gfs3_entrylk_req compound_entrylk_req; - case GF_FOP_FENTRYLK: gfs3_fentrylk_req compound_fentrylk_req; - case GF_FOP_XATTROP: gfs3_xattrop_req compound_xattrop_req; - case GF_FOP_FXATTROP: gfs3_fxattrop_req compound_fxattrop_req; - case GF_FOP_FGETXATTR: gfs3_fgetxattr_req compound_fgetxattr_req; - case GF_FOP_FSETXATTR: gfs3_fsetxattr_req compound_fsetxattr_req; - case GF_FOP_RCHECKSUM: gfs3_rchecksum_req compound_rchecksum_req; - case GF_FOP_SETATTR: gfs3_setattr_req compound_setattr_req; - case GF_FOP_FSETATTR: gfs3_fsetattr_req compound_fsetattr_req; - case GF_FOP_READDIRP: gfs3_readdirp_req compound_readdirp_req; - case GF_FOP_RELEASE: gfs3_release_req compound_release_req; - case GF_FOP_RELEASEDIR: gfs3_releasedir_req compound_releasedir_req; - case GF_FOP_FREMOVEXATTR: gfs3_fremovexattr_req compound_fremovexattr_req; - case GF_FOP_FALLOCATE: gfs3_fallocate_req compound_fallocate_req; - case GF_FOP_DISCARD: gfs3_discard_req compound_discard_req; - case GF_FOP_ZEROFILL: gfs3_zerofill_req compound_zerofill_req; - case GF_FOP_IPC: gfs3_ipc_req compound_ipc_req; - case GF_FOP_SEEK: gfs3_seek_req compound_seek_req; - case GF_FOP_LEASE: gfs3_lease_req compound_lease_req; - default: void; -}; - -struct gfs3_compound_req { - int compound_version; - glusterfs_compound_fop_t compound_fop_enum; - compound_req compound_req_array<>; - opaque xdata<>; -}; - -union compound_rsp switch (glusterfs_fop_t fop_enum) { - case GF_FOP_STAT: gfs3_stat_rsp compound_stat_rsp; - case GF_FOP_READLINK: gfs3_readlink_rsp compound_readlink_rsp; - case GF_FOP_MKNOD: gfs3_mknod_rsp compound_mknod_rsp; - case GF_FOP_MKDIR: gfs3_mkdir_rsp compound_mkdir_rsp; - case GF_FOP_UNLINK: gfs3_unlink_rsp compound_unlink_rsp; - case GF_FOP_RMDIR: gfs3_rmdir_rsp compound_rmdir_rsp; - case GF_FOP_SYMLINK: gfs3_symlink_rsp compound_symlink_rsp; - case GF_FOP_RENAME: gfs3_rename_rsp compound_rename_rsp; - case GF_FOP_LINK: gfs3_link_rsp compound_link_rsp; - case GF_FOP_TRUNCATE: gfs3_truncate_rsp compound_truncate_rsp; - case GF_FOP_OPEN: gfs3_open_rsp compound_open_rsp; - case GF_FOP_READ: gfs3_read_rsp compound_read_rsp; - case GF_FOP_WRITE: gfs3_write_rsp compound_write_rsp; - case GF_FOP_STATFS: gfs3_statfs_rsp compound_statfs_rsp; - case GF_FOP_FLUSH: gf_common_rsp compound_flush_rsp; - case GF_FOP_FSYNC: gfs3_fsync_rsp compound_fsync_rsp; - case GF_FOP_GETXATTR: gfs3_getxattr_rsp compound_getxattr_rsp; - case GF_FOP_SETXATTR: gf_common_rsp compound_setxattr_rsp; - case GF_FOP_REMOVEXATTR: gf_common_rsp compound_removexattr_rsp; - case GF_FOP_OPENDIR: gfs3_opendir_rsp compound_opendir_rsp; - case GF_FOP_FSYNCDIR: gf_common_rsp compound_fsyncdir_rsp; - case GF_FOP_ACCESS: gf_common_rsp compound_access_rsp; - case GF_FOP_CREATE: gfs3_create_rsp compound_create_rsp; - case GF_FOP_FTRUNCATE: gfs3_ftruncate_rsp compound_ftruncate_rsp; - case GF_FOP_FSTAT: gfs3_fstat_rsp compound_fstat_rsp; - case GF_FOP_LK: gfs3_lk_rsp compound_lk_rsp; - case GF_FOP_LOOKUP: gfs3_lookup_rsp compound_lookup_rsp; - case GF_FOP_READDIR: gfs3_readdir_rsp compound_readdir_rsp; - case GF_FOP_INODELK: gf_common_rsp compound_inodelk_rsp; - case GF_FOP_FINODELK: gf_common_rsp compound_finodelk_rsp; - case GF_FOP_ENTRYLK: gf_common_rsp compound_entrylk_rsp; - case GF_FOP_FENTRYLK: gf_common_rsp compound_fentrylk_rsp; - case GF_FOP_XATTROP: gfs3_xattrop_rsp compound_xattrop_rsp; - case GF_FOP_FXATTROP: gfs3_fxattrop_rsp compound_fxattrop_rsp; - case GF_FOP_FGETXATTR: gfs3_fgetxattr_rsp compound_fgetxattr_rsp; - case GF_FOP_FSETXATTR: gf_common_rsp compound_fsetxattr_rsp; - case GF_FOP_RCHECKSUM: gfs3_rchecksum_rsp compound_rchecksum_rsp; - case GF_FOP_SETATTR: gfs3_setattr_rsp compound_setattr_rsp; - case GF_FOP_FSETATTR: gfs3_fsetattr_rsp compound_fsetattr_rsp; - case GF_FOP_READDIRP: gfs3_readdirp_rsp compound_readdirp_rsp; - case GF_FOP_RELEASE: gf_common_rsp compound_release_rsp; - case GF_FOP_RELEASEDIR: gf_common_rsp compound_releasedir_rsp; - case GF_FOP_FREMOVEXATTR: gf_common_rsp compound_fremovexattr_rsp; - case GF_FOP_FALLOCATE: gfs3_fallocate_rsp compound_fallocate_rsp; - case GF_FOP_DISCARD: gfs3_discard_rsp compound_discard_rsp; - case GF_FOP_ZEROFILL: gfs3_zerofill_rsp compound_zerofill_rsp; - case GF_FOP_IPC: gfs3_ipc_rsp compound_ipc_rsp; - case GF_FOP_SEEK: gfs3_seek_rsp compound_seek_rsp; - case GF_FOP_LEASE: gfs3_lease_rsp compound_lease_rsp; - default: void; -}; - -struct gfs3_compound_rsp { - int op_ret; - int op_errno; - compound_rsp compound_rsp_array<>; - opaque xdata<>; -}; - struct gfs3_locklist { gf_proto_flock flock; string client_uid<>; diff --git a/rpc/xdr/src/glusterfs4-xdr.x b/rpc/xdr/src/glusterfs4-xdr.x index bec0872ec0e..6d13aafc9eb 100644 --- a/rpc/xdr/src/glusterfs4-xdr.x +++ b/rpc/xdr/src/glusterfs4-xdr.x @@ -769,126 +769,6 @@ struct gfx_setactivelk_req { gfx_dict xdata; }; -union compound_req_v2 switch (glusterfs_fop_t fop_enum) { - case GF_FOP_STAT: gfx_stat_req compound_stat_req; - case GF_FOP_READLINK: gfx_readlink_req compound_readlink_req; - case GF_FOP_MKNOD: gfx_mknod_req compound_mknod_req; - case GF_FOP_MKDIR: gfx_mkdir_req compound_mkdir_req; - case GF_FOP_UNLINK: gfx_unlink_req compound_unlink_req; - case GF_FOP_RMDIR: gfx_rmdir_req compound_rmdir_req; - case GF_FOP_SYMLINK: gfx_symlink_req compound_symlink_req; - case GF_FOP_RENAME: gfx_rename_req compound_rename_req; - case GF_FOP_LINK: gfx_link_req compound_link_req; - case GF_FOP_TRUNCATE: gfx_truncate_req compound_truncate_req; - case GF_FOP_OPEN: gfx_open_req compound_open_req; - case GF_FOP_READ: gfx_read_req compound_read_req; - case GF_FOP_WRITE: gfx_write_req compound_write_req; - case GF_FOP_STATFS: gfx_statfs_req compound_statfs_req; - case GF_FOP_FLUSH: gfx_flush_req compound_flush_req; - case GF_FOP_FSYNC: gfx_fsync_req compound_fsync_req; - case GF_FOP_GETXATTR: gfx_getxattr_req compound_getxattr_req; - case GF_FOP_SETXATTR: gfx_setxattr_req compound_setxattr_req; - case GF_FOP_REMOVEXATTR: gfx_removexattr_req compound_removexattr_req; - case GF_FOP_OPENDIR: gfx_opendir_req compound_opendir_req; - case GF_FOP_FSYNCDIR: gfx_fsyncdir_req compound_fsyncdir_req; - case GF_FOP_ACCESS: gfx_access_req compound_access_req; - case GF_FOP_CREATE: gfx_create_req compound_create_req; - case GF_FOP_FTRUNCATE: gfx_ftruncate_req compound_ftruncate_req; - case GF_FOP_FSTAT: gfx_fstat_req compound_fstat_req; - case GF_FOP_LK: gfx_lk_req compound_lk_req; - case GF_FOP_LOOKUP: gfx_lookup_req compound_lookup_req; - case GF_FOP_READDIR: gfx_readdir_req compound_readdir_req; - case GF_FOP_INODELK: gfx_inodelk_req compound_inodelk_req; - case GF_FOP_FINODELK: gfx_finodelk_req compound_finodelk_req; - case GF_FOP_ENTRYLK: gfx_entrylk_req compound_entrylk_req; - case GF_FOP_FENTRYLK: gfx_fentrylk_req compound_fentrylk_req; - case GF_FOP_XATTROP: gfx_xattrop_req compound_xattrop_req; - case GF_FOP_FXATTROP: gfx_fxattrop_req compound_fxattrop_req; - case GF_FOP_FGETXATTR: gfx_fgetxattr_req compound_fgetxattr_req; - case GF_FOP_FSETXATTR: gfx_fsetxattr_req compound_fsetxattr_req; - case GF_FOP_RCHECKSUM: gfx_rchecksum_req compound_rchecksum_req; - case GF_FOP_SETATTR: gfx_setattr_req compound_setattr_req; - case GF_FOP_FSETATTR: gfx_fsetattr_req compound_fsetattr_req; - case GF_FOP_READDIRP: gfx_readdirp_req compound_readdirp_req; - case GF_FOP_RELEASE: gfx_release_req compound_release_req; - case GF_FOP_RELEASEDIR: gfx_releasedir_req compound_releasedir_req; - case GF_FOP_FREMOVEXATTR: gfx_fremovexattr_req compound_fremovexattr_req; - case GF_FOP_FALLOCATE: gfx_fallocate_req compound_fallocate_req; - case GF_FOP_DISCARD: gfx_discard_req compound_discard_req; - case GF_FOP_ZEROFILL: gfx_zerofill_req compound_zerofill_req; - case GF_FOP_IPC: gfx_ipc_req compound_ipc_req; - case GF_FOP_SEEK: gfx_seek_req compound_seek_req; - case GF_FOP_LEASE: gfx_lease_req compound_lease_req; - default: void; -}; - -struct gfx_compound_req { - int compound_version; - glusterfs_compound_fop_t compound_fop_enum; - compound_req_v2 compound_req_array<>; - gfx_dict xdata; -}; - -union compound_rsp_v2 switch (glusterfs_fop_t fop_enum) { - case GF_FOP_STAT: gfx_common_iatt_rsp compound_stat_rsp; - case GF_FOP_READLINK: gfx_readlink_rsp compound_readlink_rsp; - case GF_FOP_MKNOD: gfx_common_3iatt_rsp compound_mknod_rsp; - case GF_FOP_MKDIR: gfx_common_3iatt_rsp compound_mkdir_rsp; - case GF_FOP_UNLINK: gfx_common_2iatt_rsp compound_unlink_rsp; - case GF_FOP_RMDIR: gfx_common_2iatt_rsp compound_rmdir_rsp; - case GF_FOP_SYMLINK: gfx_common_3iatt_rsp compound_symlink_rsp; - case GF_FOP_RENAME: gfx_rename_rsp compound_rename_rsp; - case GF_FOP_LINK: gfx_common_3iatt_rsp compound_link_rsp; - case GF_FOP_TRUNCATE: gfx_common_2iatt_rsp compound_truncate_rsp; - case GF_FOP_OPEN: gfx_open_rsp compound_open_rsp; - case GF_FOP_READ: gfx_read_rsp compound_read_rsp; - case GF_FOP_WRITE: gfx_common_2iatt_rsp compound_write_rsp; - case GF_FOP_STATFS: gfx_statfs_rsp compound_statfs_rsp; - case GF_FOP_FLUSH: gfx_common_rsp compound_flush_rsp; - case GF_FOP_FSYNC: gfx_common_2iatt_rsp compound_fsync_rsp; - case GF_FOP_GETXATTR: gfx_common_dict_rsp compound_getxattr_rsp; - case GF_FOP_SETXATTR: gfx_common_rsp compound_setxattr_rsp; - case GF_FOP_REMOVEXATTR: gfx_common_rsp compound_removexattr_rsp; - case GF_FOP_OPENDIR: gfx_open_rsp compound_opendir_rsp; - case GF_FOP_FSYNCDIR: gfx_common_rsp compound_fsyncdir_rsp; - case GF_FOP_ACCESS: gfx_common_rsp compound_access_rsp; - case GF_FOP_CREATE: gfx_create_rsp compound_create_rsp; - case GF_FOP_FTRUNCATE: gfx_common_2iatt_rsp compound_ftruncate_rsp; - case GF_FOP_FSTAT: gfx_common_iatt_rsp compound_fstat_rsp; - case GF_FOP_LK: gfx_lk_rsp compound_lk_rsp; - case GF_FOP_LOOKUP: gfx_common_2iatt_rsp compound_lookup_rsp; - case GF_FOP_READDIR: gfx_readdir_rsp compound_readdir_rsp; - case GF_FOP_INODELK: gfx_common_rsp compound_inodelk_rsp; - case GF_FOP_FINODELK: gfx_common_rsp compound_finodelk_rsp; - case GF_FOP_ENTRYLK: gfx_common_rsp compound_entrylk_rsp; - case GF_FOP_FENTRYLK: gfx_common_rsp compound_fentrylk_rsp; - case GF_FOP_XATTROP: gfx_common_dict_rsp compound_xattrop_rsp; - case GF_FOP_FXATTROP: gfx_common_dict_rsp compound_fxattrop_rsp; - case GF_FOP_FGETXATTR: gfx_common_dict_rsp compound_fgetxattr_rsp; - case GF_FOP_FSETXATTR: gfx_common_rsp compound_fsetxattr_rsp; - case GF_FOP_RCHECKSUM: gfx_rchecksum_rsp compound_rchecksum_rsp; - case GF_FOP_SETATTR: gfx_common_2iatt_rsp compound_setattr_rsp; - case GF_FOP_FSETATTR: gfx_common_2iatt_rsp compound_fsetattr_rsp; - case GF_FOP_READDIRP: gfx_readdirp_rsp compound_readdirp_rsp; - case GF_FOP_RELEASE: gfx_common_rsp compound_release_rsp; - case GF_FOP_RELEASEDIR: gfx_common_rsp compound_releasedir_rsp; - case GF_FOP_FREMOVEXATTR: gfx_common_rsp compound_fremovexattr_rsp; - case GF_FOP_FALLOCATE: gfx_common_2iatt_rsp compound_fallocate_rsp; - case GF_FOP_DISCARD: gfx_common_2iatt_rsp compound_discard_rsp; - case GF_FOP_ZEROFILL: gfx_common_2iatt_rsp compound_zerofill_rsp; - case GF_FOP_IPC: gfx_common_rsp compound_ipc_rsp; - case GF_FOP_SEEK: gfx_seek_rsp compound_seek_rsp; - case GF_FOP_LEASE: gfx_lease_rsp compound_lease_rsp; - default: void; -}; - -struct gfx_compound_rsp { - int op_ret; - int op_errno; - compound_rsp_v2 compound_rsp_array<>; - gfx_dict xdata; -}; - struct gfs4_inodelk_contention_req { opaque gfid[16]; struct gf_proto_flock flock; diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index 42b5410ba07..5873d67b486 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -129,7 +129,6 @@ client_local_wipe(clnt_local_t *local) } GF_FREE(local->name); - local->compound_args = NULL; mem_put(local); } @@ -491,1140 +490,6 @@ out: return ret; } -int -client_process_response(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfs3_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index) -{ - int ret = 0; - dict_t *xdata = NULL; - dict_t *xattr = NULL; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - gf_dirent_t entries; - default_args_cbk_t *this_args_cbk = &args_cbk->rsp_list[index]; - clnt_local_t *local = frame->local; - compound_rsp *this_rsp = NULL; - compound_args_t *args = local->compound_args; - - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index]; - args_cbk->enum_list[index] = this_rsp->fop_enum; - - INIT_LIST_HEAD(&entries.list); - - switch (args_cbk->enum_list[index]) { - case GF_FOP_STAT: { - gfs3_stat_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_stat_rsp; - - client_post_stat(this, tmp_rsp, &this_args_cbk->stat, &xdata); - - CLIENT_POST_FOP_TYPE(stat, this_rsp, this_args_cbk, - &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_READLINK: { - gfs3_readlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_readlink_rsp; - - client_post_readlink(this, tmp_rsp, &this_args_cbk->stat, &xdata); - CLIENT_POST_FOP_TYPE(readlink, this_rsp, this_args_cbk, - tmp_rsp->path, &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_MKNOD: { - gfs3_mknod_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_mknod_rsp; - - client_post_mknod(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(mknod, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_MKDIR: { - gfs3_mkdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_mkdir_rsp; - - client_post_mkdir(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(mkdir, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_UNLINK: { - gfs3_unlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_unlink_rsp; - - client_post_unlink(this, tmp_rsp, &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(unlink, this_rsp, this_args_cbk, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_RMDIR: { - gfs3_rmdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_rmdir_rsp; - - client_post_rmdir(this, tmp_rsp, &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(rmdir, this_rsp, this_args_cbk, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_SYMLINK: { - gfs3_symlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_symlink_rsp; - - client_post_symlink(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE( - symlink, this_rsp, this_args_cbk, NULL, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_RENAME: { - gfs3_rename_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_rename_rsp; - - client_post_rename( - this, tmp_rsp, &this_args_cbk->stat, &this_args_cbk->preparent, - &this_args_cbk->postparent, &this_args_cbk->preparent2, - &this_args_cbk->postparent2, &xdata); - CLIENT_POST_FOP_TYPE( - rename, this_rsp, this_args_cbk, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - &this_args_cbk->preparent2, &this_args_cbk->postparent2, xdata); - break; - } - case GF_FOP_LINK: { - gfs3_link_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_link_rsp; - - client_post_link(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE( - link, this_rsp, this_args_cbk, NULL, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_TRUNCATE: { - gfs3_truncate_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_truncate_rsp; - - client_post_truncate(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - CLIENT_POST_FOP_TYPE(truncate, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_OPEN: { - gfs3_open_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_open_rsp; - - client_post_open(this, tmp_rsp, &xdata); - CLIENT_POST_FOP_TYPE(open, this_rsp, this_args_cbk, local->fd, - xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_READ: { - gfs3_read_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_read_rsp; - - client_post_readv(this, tmp_rsp, &this_args_cbk->iobref, - req->rsp_iobref, &this_args_cbk->stat, vector, - &req->rsp[1], &this_args_cbk->count, &xdata); - - /* Each read should be given read response that only - * corresponds to its request. - * Modify the iovecs accordingly. - * After each read, store the length of data already read - * so that the next ones can continue from there. - */ - if (local->read_length) { - vector[0].iov_base += local->read_length; - local->read_length += tmp_rsp->op_ret; - } else { - local->read_length = tmp_rsp->op_ret; - } - - args_readv_cbk_store(this_args_cbk, tmp_rsp->op_ret, - gf_error_to_errno(tmp_rsp->op_errno), vector, - this_args_cbk->count, &this_args_cbk->stat, - this_args_cbk->iobref, xdata); - - if (tmp_rsp->op_ret >= 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - - break; - } - case GF_FOP_WRITE: { - gfs3_write_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_write_rsp; - - client_post_writev(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - args_writev_cbk_store(this_args_cbk, tmp_rsp->op_ret, - gf_error_to_errno(tmp_rsp->op_errno), - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - - if (tmp_rsp->op_ret == 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - break; - } - case GF_FOP_STATFS: { - gfs3_statfs_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_statfs_rsp; - - client_post_statfs(this, tmp_rsp, &this_args_cbk->statvfs, &xdata); - - CLIENT_POST_FOP_TYPE(statfs, this_rsp, this_args_cbk, - &this_args_cbk->statvfs, xdata); - break; - } - case GF_FOP_FLUSH: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_flush_rsp; - - client_post_flush(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(flush, this_rsp, this_args_cbk, xdata); - if (this_args_cbk->op_ret >= 0 && !fd_is_anonymous(local->fd)) { - /* Delete all saved locks of the owner issuing flush */ - ret = delete_granted_locks_owner(local->fd, &local->owner); - gf_msg_trace(this->name, 0, - "deleting locks of owner (%s) returned %d", - lkowner_utoa(&local->owner), ret); - } - break; - } - case GF_FOP_FSYNC: { - gfs3_fsync_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsync_rsp; - - client_post_fsync(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(fsync, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_SETXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_setxattr_rsp; - - client_post_setxattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(setxattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_getxattr_rsp; - - client_post_getxattr(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(getxattr, this_rsp, this_args_cbk, xattr, - xdata); - break; - } - case GF_FOP_REMOVEXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_removexattr_rsp; - - client_post_removexattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(removexattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_OPENDIR: { - gfs3_opendir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_opendir_rsp; - - client_post_opendir(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP_TYPE(opendir, this_rsp, this_args_cbk, local->fd, - xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_FSYNCDIR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsyncdir_rsp; - - client_post_fsyncdir(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fsyncdir, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_ACCESS: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_access_rsp; - - client_post_access(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(access, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_CREATE: { - gfs3_create_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_create_rsp; - - client_post_create(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, local, &xdata); - - CLIENT_POST_FOP_TYPE(create, this_rsp, this_args_cbk, local->fd, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_FTRUNCATE: { - gfs3_ftruncate_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_ftruncate_rsp; - - client_post_ftruncate(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - CLIENT_POST_FOP_TYPE(ftruncate, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_FSTAT: { - gfs3_fstat_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fstat_rsp; - - client_post_fstat(this, tmp_rsp, &this_args_cbk->stat, &xdata); - - CLIENT_POST_FOP_TYPE(fstat, this_rsp, this_args_cbk, - &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_LK: { - gfs3_lk_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_lk_rsp; - - client_post_lk(this, tmp_rsp, &this_args_cbk->lock, &xdata); - - CLIENT_POST_FOP_TYPE(lk, this_rsp, this_args_cbk, - &this_args_cbk->lock, xdata); - break; - } - case GF_FOP_LOOKUP: { - gfs3_lookup_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_lookup_rsp; - - client_post_lookup(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(lookup, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, xdata, - &this_args_cbk->postparent); - break; - } - case GF_FOP_READDIR: { - gfs3_readdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_readdir_rsp; - - client_post_readdir(this, tmp_rsp, &entries, &xdata); - - CLIENT_POST_FOP_TYPE(readdir, this_rsp, this_args_cbk, &entries, - xdata); - break; - } - case GF_FOP_INODELK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_inodelk_rsp; - - client_post_inodelk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(inodelk, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_FINODELK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_finodelk_rsp; - - client_post_finodelk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(finodelk, this_rsp, this_args_cbk, xdata); - if (tmp_rsp->op_ret == 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - break; - } - case GF_FOP_ENTRYLK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_entrylk_rsp; - - client_post_entrylk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(entrylk, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_FENTRYLK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fentrylk_rsp; - - client_post_fentrylk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fentrylk, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_XATTROP: { - gfs3_xattrop_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_xattrop_rsp; - - client_post_xattrop(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(xattrop, this_rsp, this_args_cbk, xattr, - xdata); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fxattrop_rsp; - - client_post_fxattrop(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(fxattrop, this_rsp, this_args_cbk, xattr, - xdata); - if (rsp->op_ret == 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fgetxattr_rsp; - - client_post_fgetxattr(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(fgetxattr, this_rsp, this_args_cbk, xattr, - xdata); - break; - } - case GF_FOP_FSETXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsetxattr_rsp; - - client_post_fsetxattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fsetxattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_RCHECKSUM: { - gfs3_rchecksum_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_rchecksum_rsp; - - client_post_rchecksum(this, tmp_rsp, &xdata); - - break; - CLIENT_POST_FOP_TYPE( - rchecksum, this_rsp, this_args_cbk, tmp_rsp->weak_checksum, - (uint8_t *)tmp_rsp->strong_checksum.strong_checksum_val, xdata); - break; - } - case GF_FOP_SETATTR: { - gfs3_setattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_setattr_rsp; - - client_post_setattr(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(setattr, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_FSETATTR: { - gfs3_fsetattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsetattr_rsp; - - client_post_fsetattr(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(fsetattr, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_READDIRP: { - gfs3_readdirp_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_readdirp_rsp; - - client_post_readdirp(this, tmp_rsp, local->fd, &entries, &xdata); - - CLIENT_POST_FOP_TYPE(readdirp, this_rsp, this_args_cbk, &entries, - xdata); - break; - } - case GF_FOP_FREMOVEXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fremovexattr_rsp; - - client_post_fremovexattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fremovexattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_FALLOCATE: { - gfs3_fallocate_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fallocate_rsp; - - client_post_fallocate(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(fallocate, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_DISCARD: { - gfs3_discard_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_discard_rsp; - - client_post_discard(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(discard, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_ZEROFILL: { - gfs3_zerofill_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_zerofill_rsp; - - client_post_zerofill(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(zerofill, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_IPC: { - gfs3_ipc_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_ipc_rsp; - - client_post_ipc(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP_TYPE(ipc, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_SEEK: { - gfs3_seek_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_seek_rsp; - - client_post_seek(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP_TYPE(seek, this_rsp, this_args_cbk, tmp_rsp->offset, - xdata); - break; - } - case GF_FOP_LEASE: { - gfs3_lease_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_lease_rsp; - - client_post_lease(this, tmp_rsp, &this_args_cbk->lease, &xdata); - - CLIENT_POST_FOP_TYPE(lease, this_rsp, this_args_cbk, - &this_args_cbk->lease, xdata); - break; - } - default: - return -ENOTSUP; - } - - if (xdata) - dict_unref(xdata); - if (xattr) - dict_unref(xattr); - gf_dirent_free(&entries); - return 0; -} - -int -client_handle_fop_requirements( - xlator_t *this, call_frame_t *frame, gfs3_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index) -{ - int ret = 0; - int op_errno = ENOMEM; - struct iobuf *rsp_iobuf = NULL; - int64_t remote_fd = -1; - compound_req *this_req = &req->compound_req_array - .compound_req_array_val[index]; - - this_req->fop_enum = fop_enum; - - switch (fop_enum) { - case GF_FOP_STAT: - CLIENT_PRE_FOP(stat, this, - &this_req->compound_req_u.compound_stat_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_READLINK: - CLIENT_PRE_FOP(readlink, this, - &this_req->compound_req_u.compound_readlink_req, - op_errno, out, &args->loc, args->size, args->xdata); - break; - case GF_FOP_MKNOD: - CLIENT_PRE_FOP(mknod, this, - &this_req->compound_req_u.compound_mknod_req, - op_errno, out, &args->loc, args->mode, args->rdev, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_MKDIR: - CLIENT_PRE_FOP(mkdir, this, - &this_req->compound_req_u.compound_mkdir_req, - op_errno, out, &args->loc, args->mode, args->umask, - args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_UNLINK: - CLIENT_PRE_FOP(unlink, this, - &this_req->compound_req_u.compound_unlink_req, - op_errno, out, &args->loc, args->xflag, args->xdata); - break; - case GF_FOP_RMDIR: - CLIENT_PRE_FOP(rmdir, this, - &this_req->compound_req_u.compound_rmdir_req, - op_errno, out, &args->loc, args->flags, args->xdata); - break; - case GF_FOP_SYMLINK: - CLIENT_PRE_FOP(symlink, this, - &this_req->compound_req_u.compound_symlink_req, - op_errno, out, &args->loc, args->linkname, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_RENAME: - CLIENT_PRE_FOP(rename, this, - &this_req->compound_req_u.compound_rename_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_LINK: - CLIENT_PRE_FOP(link, this, - &this_req->compound_req_u.compound_link_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_TRUNCATE: - CLIENT_PRE_FOP( - truncate, this, &this_req->compound_req_u.compound_truncate_req, - op_errno, out, &args->loc, args->offset, args->xdata); - break; - case GF_FOP_OPEN: - CLIENT_PRE_FOP( - open, this, &this_req->compound_req_u.compound_open_req, - op_errno, out, &args->loc, args->fd, args->flags, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_READ: - op_errno = client_pre_readv( - this, &this_req->compound_req_u.compound_read_req, args->fd, - args->size, args->offset, args->flags, args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - rsp_iobuf = iobuf_get2(this->ctx->iobuf_pool, args->size); - if (rsp_iobuf == NULL) { - op_errno = ENOMEM; - goto out; - } - - if (!*rsp_iobref) { - *rsp_iobref = iobref_new(); - if (*rsp_iobref == NULL) { - op_errno = ENOMEM; - goto out; - } - } - - if (*rsp_count + 1 >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - rsp_vector[*rsp_count].iov_base = iobuf_ptr(rsp_iobuf); - rsp_vector[*rsp_count].iov_len = iobuf_pagesize(rsp_iobuf); - iobref_add(*rsp_iobref, rsp_iobuf); - iobuf_unref(rsp_iobuf); - rsp_iobuf = NULL; - if (args->size > rsp_vector[*rsp_count].iov_len) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "read-size (%lu) is bigger than iobuf size " - "(%lu)", - (unsigned long)args->size, - (unsigned long)rsp_vector[*rsp_count].iov_len); - op_errno = EINVAL; - goto out; - } - *rsp_count += 1; - - break; - case GF_FOP_WRITE: - op_errno = client_pre_writev( - this, &this_req->compound_req_u.compound_write_req, args->fd, - iov_length(args->vector, args->count), args->offset, - args->flags, &args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - - if (*req_count + args->count >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - memcpy(&req_vector[*req_count], args->vector, - (args->count * sizeof(req_vector[0]))); - *req_count += args->count; - - if (!*req_iobref) - *req_iobref = args->iobref; - else if (iobref_merge(*req_iobref, args->iobref)) - goto out; - break; - case GF_FOP_STATFS: - CLIENT_PRE_FOP(statfs, this, - &this_req->compound_req_u.compound_statfs_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_FLUSH: - CLIENT_PRE_FOP(flush, this, - &this_req->compound_req_u.compound_flush_req, - op_errno, out, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_FSYNC: - CLIENT_PRE_FOP( - fsync, this, &this_req->compound_req_u.compound_fsync_req, - op_errno, out, args->fd, args->datasync, args->xdata); - break; - case GF_FOP_SETXATTR: - CLIENT_PRE_FOP(setxattr, this, - &this_req->compound_req_u.compound_setxattr_req, - op_errno, out, &args->loc, args->xattr, args->flags, - args->xdata); - break; - case GF_FOP_GETXATTR: - CLIENT_PRE_FOP(getxattr, this, - &this_req->compound_req_u.compound_getxattr_req, - op_errno, out, &args->loc, args->name, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_REMOVEXATTR: - CLIENT_PRE_FOP(removexattr, this, - &this_req->compound_req_u.compound_removexattr_req, - op_errno, out, &args->loc, args->name, args->xdata); - break; - case GF_FOP_OPENDIR: - CLIENT_PRE_FOP(opendir, this, - &this_req->compound_req_u.compound_opendir_req, - op_errno, out, &args->loc, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FSYNCDIR: - CLIENT_PRE_FOP( - fsyncdir, this, &this_req->compound_req_u.compound_fsyncdir_req, - op_errno, out, args->fd, args->datasync, args->xdata); - break; - case GF_FOP_ACCESS: - CLIENT_PRE_FOP(access, this, - &this_req->compound_req_u.compound_access_req, - op_errno, out, &args->loc, args->mask, args->xdata); - break; - case GF_FOP_CREATE: - CLIENT_PRE_FOP(create, this, - &this_req->compound_req_u.compound_create_req, - op_errno, out, &args->loc, args->fd, args->mode, - args->flags, args->umask, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FTRUNCATE: - CLIENT_PRE_FOP(ftruncate, this, - &this_req->compound_req_u.compound_ftruncate_req, - op_errno, out, args->fd, args->offset, args->xdata); - break; - case GF_FOP_FSTAT: - CLIENT_PRE_FOP(fstat, this, - &this_req->compound_req_u.compound_fstat_req, - op_errno, out, args->fd, args->xdata); - break; - case GF_FOP_LK: - CLIENT_PRE_FOP(lk, this, &this_req->compound_req_u.compound_lk_req, - op_errno, out, args->cmd, &args->lock, args->fd, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_LOOKUP: - CLIENT_PRE_FOP(lookup, this, - &this_req->compound_req_u.compound_lookup_req, - op_errno, out, &args->loc, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_READDIR: - CLIENT_PRE_FOP( - readdir, this, &this_req->compound_req_u.compound_readdir_req, - op_errno, out, args->fd, args->size, args->offset, args->xdata); - break; - case GF_FOP_INODELK: - CLIENT_PRE_FOP(inodelk, this, - &this_req->compound_req_u.compound_inodelk_req, - op_errno, out, &args->loc, args->cmd, &args->lock, - args->volume, args->xdata); - break; - case GF_FOP_FINODELK: - CLIENT_PRE_FOP(finodelk, this, - &this_req->compound_req_u.compound_finodelk_req, - op_errno, out, args->fd, args->cmd, &args->lock, - args->volume, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_ENTRYLK: - CLIENT_PRE_FOP( - entrylk, this, &this_req->compound_req_u.compound_entrylk_req, - op_errno, out, &args->loc, args->entrylkcmd, args->entrylktype, - args->volume, args->name, args->xdata); - break; - case GF_FOP_FENTRYLK: - CLIENT_PRE_FOP( - fentrylk, this, &this_req->compound_req_u.compound_fentrylk_req, - op_errno, out, args->fd, args->entrylkcmd, args->entrylktype, - args->volume, args->name, args->xdata); - break; - case GF_FOP_XATTROP: - CLIENT_PRE_FOP(xattrop, this, - &this_req->compound_req_u.compound_xattrop_req, - op_errno, out, &args->loc, args->xattr, args->optype, - args->xdata); - break; - case GF_FOP_FXATTROP: - CLIENT_PRE_FOP(fxattrop, this, - &this_req->compound_req_u.compound_fxattrop_req, - op_errno, out, args->fd, args->xattr, args->optype, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_FGETXATTR: - CLIENT_PRE_FOP(fgetxattr, this, - &this_req->compound_req_u.compound_fgetxattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FSETXATTR: - CLIENT_PRE_FOP(fsetxattr, this, - &this_req->compound_req_u.compound_fsetxattr_req, - op_errno, out, args->fd, args->flags, args->xattr, - args->xdata); - break; - case GF_FOP_RCHECKSUM: - CLIENT_PRE_FOP(rchecksum, this, - &this_req->compound_req_u.compound_rchecksum_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - break; - case GF_FOP_SETATTR: - CLIENT_PRE_FOP(setattr, this, - &this_req->compound_req_u.compound_setattr_req, - op_errno, out, &args->loc, args->valid, &args->stat, - args->xdata); - break; - case GF_FOP_FSETATTR: - CLIENT_PRE_FOP( - fsetattr, this, &this_req->compound_req_u.compound_fsetattr_req, - op_errno, out, args->fd, args->valid, &args->stat, args->xdata); - break; - case GF_FOP_READDIRP: - CLIENT_PRE_FOP( - readdirp, this, &this_req->compound_req_u.compound_readdirp_req, - op_errno, out, args->fd, args->size, args->offset, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT_PRE_FOP(fremovexattr, this, - &this_req->compound_req_u.compound_fremovexattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FALLOCATE: - CLIENT_PRE_FOP(fallocate, this, - &this_req->compound_req_u.compound_fallocate_req, - op_errno, out, args->fd, args->flags, args->offset, - args->size, args->xdata); - break; - case GF_FOP_DISCARD: - CLIENT_PRE_FOP( - discard, this, &this_req->compound_req_u.compound_discard_req, - op_errno, out, args->fd, args->offset, args->size, args->xdata); - break; - case GF_FOP_ZEROFILL: - CLIENT_PRE_FOP( - zerofill, this, &this_req->compound_req_u.compound_zerofill_req, - op_errno, out, args->fd, args->offset, args->size, args->xdata); - break; - case GF_FOP_IPC: - CLIENT_PRE_FOP(ipc, this, - &this_req->compound_req_u.compound_ipc_req, op_errno, - out, args->cmd, args->xdata); - break; - case GF_FOP_SEEK: - CLIENT_PRE_FOP( - seek, this, &this_req->compound_req_u.compound_seek_req, - op_errno, out, args->fd, args->offset, args->what, args->xdata); - break; - case GF_FOP_LEASE: - CLIENT_PRE_FOP( - lease, this, &this_req->compound_req_u.compound_lease_req, - op_errno, out, &args->loc, &args->lease, args->xdata); - break; - default: - return ENOTSUP; - } - return 0; -out: - return op_errno; -} - -void -compound_request_cleanup(gfs3_compound_req *req) -{ - int i = 0; - int length = req->compound_req_array.compound_req_array_len; - compound_req *curr_req = NULL; - - if (!req->compound_req_array.compound_req_array_val) - return; - - for (i = 0; i < length; i++) { - curr_req = &req->compound_req_array.compound_req_array_val[i]; - - switch (curr_req->fop_enum) { - case GF_FOP_STAT: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, stat); - break; - case GF_FOP_READLINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, readlink); - break; - case GF_FOP_MKNOD: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, mknod); - break; - case GF_FOP_MKDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, mkdir); - break; - case GF_FOP_UNLINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, unlink); - break; - case GF_FOP_RMDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, rmdir); - break; - case GF_FOP_SYMLINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, symlink); - break; - case GF_FOP_RENAME: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, rename); - break; - case GF_FOP_LINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, link); - break; - case GF_FOP_TRUNCATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, truncate); - break; - case GF_FOP_OPEN: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, open); - break; - case GF_FOP_READ: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, read); - break; - case GF_FOP_WRITE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, write); - break; - case GF_FOP_STATFS: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, statfs); - break; - case GF_FOP_FLUSH: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, flush); - break; - case GF_FOP_FSYNC: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsync); - break; - case GF_FOP_SETXATTR: { - gfs3_setxattr_req *args = &CPD_REQ_FIELD(curr_req, setxattr); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, setxattr); - break; - } - case GF_FOP_GETXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, getxattr); - break; - case GF_FOP_REMOVEXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, removexattr); - break; - case GF_FOP_OPENDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, opendir); - break; - case GF_FOP_FSYNCDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsyncdir); - break; - case GF_FOP_ACCESS: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, access); - break; - case GF_FOP_CREATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, create); - break; - case GF_FOP_FTRUNCATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, ftruncate); - break; - case GF_FOP_FSTAT: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fstat); - break; - case GF_FOP_LK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, lk); - break; - case GF_FOP_LOOKUP: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, lookup); - break; - case GF_FOP_READDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, readdir); - break; - case GF_FOP_INODELK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, inodelk); - break; - case GF_FOP_FINODELK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, finodelk); - break; - case GF_FOP_ENTRYLK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, entrylk); - break; - case GF_FOP_FENTRYLK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fentrylk); - break; - case GF_FOP_XATTROP: { - gfs3_xattrop_req *args = &CPD_REQ_FIELD(curr_req, xattrop); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, xattrop); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_req *args = &CPD_REQ_FIELD(curr_req, fxattrop); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fxattrop); - break; - } - case GF_FOP_FGETXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fgetxattr); - break; - case GF_FOP_FSETXATTR: { - gfs3_fsetxattr_req *args = &CPD_REQ_FIELD(curr_req, fsetxattr); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsetxattr); - break; - } - case GF_FOP_RCHECKSUM: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, rchecksum); - break; - case GF_FOP_SETATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, setattr); - break; - case GF_FOP_FSETATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsetattr); - break; - case GF_FOP_READDIRP: { - gfs3_readdirp_req *args = &CPD_REQ_FIELD(curr_req, readdirp); - GF_FREE(args->dict.dict_val); - break; - } - case GF_FOP_FREMOVEXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fremovexattr); - break; - case GF_FOP_FALLOCATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fallocate); - break; - case GF_FOP_DISCARD: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, discard); - break; - case GF_FOP_ZEROFILL: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, zerofill); - break; - case GF_FOP_IPC: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, ipc); - break; - case GF_FOP_SEEK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, seek); - break; - default: - break; - } - } - - GF_FREE(req->compound_req_array.compound_req_array_val); - return; -} - void clnt_getactivelk_rsp_cleanup(gfs3_getactivelk_rsp *rsp) { @@ -1894,1163 +759,6 @@ out: return ret; } -void -client_compound_rsp_cleanup(gfs3_compound_rsp *rsp, int len) -{ - int i = 0; - compound_rsp *this_rsp = NULL; - - for (i = 0; i < len; i++) { - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; - switch (this_rsp->fop_enum) { - case GF_FOP_STAT: - CLIENT_FOP_RSP_CLEANUP(rsp, stat, i); - break; - case GF_FOP_MKNOD: - CLIENT_FOP_RSP_CLEANUP(rsp, mknod, i); - break; - case GF_FOP_MKDIR: - CLIENT_FOP_RSP_CLEANUP(rsp, mkdir, i); - break; - case GF_FOP_UNLINK: - CLIENT_FOP_RSP_CLEANUP(rsp, unlink, i); - break; - case GF_FOP_RMDIR: - CLIENT_FOP_RSP_CLEANUP(rsp, rmdir, i); - break; - case GF_FOP_SYMLINK: - CLIENT_FOP_RSP_CLEANUP(rsp, symlink, i); - break; - case GF_FOP_RENAME: - CLIENT_FOP_RSP_CLEANUP(rsp, rename, i); - break; - case GF_FOP_LINK: - CLIENT_FOP_RSP_CLEANUP(rsp, link, i); - break; - case GF_FOP_TRUNCATE: - CLIENT_FOP_RSP_CLEANUP(rsp, truncate, i); - break; - case GF_FOP_OPEN: - CLIENT_FOP_RSP_CLEANUP(rsp, open, i); - break; - case GF_FOP_READ: - CLIENT_FOP_RSP_CLEANUP(rsp, read, i); - break; - case GF_FOP_WRITE: - CLIENT_FOP_RSP_CLEANUP(rsp, write, i); - break; - case GF_FOP_STATFS: - CLIENT_FOP_RSP_CLEANUP(rsp, statfs, i); - break; - case GF_FOP_FSYNC: - CLIENT_FOP_RSP_CLEANUP(rsp, fsync, i); - break; - case GF_FOP_OPENDIR: - CLIENT_FOP_RSP_CLEANUP(rsp, opendir, i); - break; - case GF_FOP_CREATE: - CLIENT_FOP_RSP_CLEANUP(rsp, create, i); - break; - case GF_FOP_FTRUNCATE: - CLIENT_FOP_RSP_CLEANUP(rsp, ftruncate, i); - break; - case GF_FOP_FSTAT: - CLIENT_FOP_RSP_CLEANUP(rsp, fstat, i); - break; - case GF_FOP_LOOKUP: - CLIENT_FOP_RSP_CLEANUP(rsp, lookup, i); - break; - case GF_FOP_SETATTR: - CLIENT_FOP_RSP_CLEANUP(rsp, setattr, i); - break; - case GF_FOP_FSETATTR: - CLIENT_FOP_RSP_CLEANUP(rsp, fsetattr, i); - break; - case GF_FOP_FALLOCATE: - CLIENT_FOP_RSP_CLEANUP(rsp, fallocate, i); - break; - case GF_FOP_DISCARD: - CLIENT_FOP_RSP_CLEANUP(rsp, discard, i); - break; - case GF_FOP_ZEROFILL: - CLIENT_FOP_RSP_CLEANUP(rsp, zerofill, i); - break; - case GF_FOP_IPC: - CLIENT_FOP_RSP_CLEANUP(rsp, ipc, i); - break; - case GF_FOP_SEEK: - CLIENT_FOP_RSP_CLEANUP(rsp, seek, i); - break; - case GF_FOP_LEASE: - CLIENT_FOP_RSP_CLEANUP(rsp, lease, i); - break; - /* fops that use gf_common_rsp */ - case GF_FOP_FLUSH: - CLIENT_COMMON_RSP_CLEANUP(rsp, flush, i); - break; - case GF_FOP_SETXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, setxattr, i); - break; - case GF_FOP_REMOVEXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, removexattr, i); - break; - case GF_FOP_FSETXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, fsetxattr, i); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, fremovexattr, i); - break; - case GF_FOP_FSYNCDIR: - CLIENT_COMMON_RSP_CLEANUP(rsp, fsyncdir, i); - break; - case GF_FOP_ACCESS: - CLIENT_COMMON_RSP_CLEANUP(rsp, access, i); - break; - case GF_FOP_INODELK: - CLIENT_COMMON_RSP_CLEANUP(rsp, inodelk, i); - break; - case GF_FOP_FINODELK: - CLIENT_COMMON_RSP_CLEANUP(rsp, finodelk, i); - break; - case GF_FOP_ENTRYLK: - CLIENT_COMMON_RSP_CLEANUP(rsp, entrylk, i); - break; - case GF_FOP_FENTRYLK: - CLIENT_COMMON_RSP_CLEANUP(rsp, fentrylk, i); - break; - /* fops that need extra cleanup */ - case GF_FOP_LK: { - CLIENT_FOP_RSP_CLEANUP(rsp, lk, i); - gfs3_lk_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, lk); - free(tmp_rsp->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_READLINK: { - CLIENT_FOP_RSP_CLEANUP(rsp, readlink, i); - gfs3_readlink_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readlink); - free(tmp_rsp->path); - break; - } - case GF_FOP_XATTROP: { - CLIENT_FOP_RSP_CLEANUP(rsp, xattrop, i); - gfs3_xattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, xattrop); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_FXATTROP: { - CLIENT_FOP_RSP_CLEANUP(rsp, fxattrop, i); - gfs3_fxattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, fxattrop); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_READDIR: { - CLIENT_FOP_RSP_CLEANUP(rsp, readdir, i); - gfs3_readdir_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readdir); - clnt_readdir_rsp_cleanup(tmp_rsp); - break; - } - case GF_FOP_READDIRP: { - CLIENT_FOP_RSP_CLEANUP(rsp, readdirp, i); - gfs3_readdirp_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readdirp); - clnt_readdirp_rsp_cleanup(tmp_rsp); - break; - } - case GF_FOP_GETXATTR: { - CLIENT_FOP_RSP_CLEANUP(rsp, getxattr, i); - gfs3_getxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, getxattr); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_FGETXATTR: { - CLIENT_FOP_RSP_CLEANUP(rsp, fgetxattr, i); - gfs3_fgetxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, - fgetxattr); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_RCHECKSUM: { - CLIENT_FOP_RSP_CLEANUP(rsp, rchecksum, i); - gfs3_rchecksum_rsp *rck = &CPD_RSP_FIELD(this_rsp, rchecksum); - if (rck->strong_checksum.strong_checksum_val) { - free(rck->strong_checksum.strong_checksum_val); - } - break; - } - default: - break; - } - } - return; -} - -/* compound v2 */ -int -client_handle_fop_requirements_v2( - xlator_t *this, call_frame_t *frame, gfx_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index) -{ - int ret = 0; - int op_errno = ENOMEM; - struct iobuf *rsp_iobuf = NULL; - int64_t remote_fd = -1; - compound_req_v2 *this_req = &req->compound_req_array - .compound_req_array_val[index]; - - this_req->fop_enum = fop_enum; - - switch (fop_enum) { - case GF_FOP_STAT: - CLIENT4_PRE_FOP(stat, this, - &this_req->compound_req_v2_u.compound_stat_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_READLINK: - CLIENT4_PRE_FOP(readlink, this, - &this_req->compound_req_v2_u.compound_readlink_req, - op_errno, out, &args->loc, args->size, args->xdata); - break; - case GF_FOP_MKNOD: - CLIENT4_PRE_FOP(mknod, this, - &this_req->compound_req_v2_u.compound_mknod_req, - op_errno, out, &args->loc, args->mode, args->rdev, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_MKDIR: - CLIENT4_PRE_FOP(mkdir, this, - &this_req->compound_req_v2_u.compound_mkdir_req, - op_errno, out, &args->loc, args->mode, args->umask, - args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_UNLINK: - CLIENT4_PRE_FOP( - unlink, this, &this_req->compound_req_v2_u.compound_unlink_req, - op_errno, out, &args->loc, args->xflag, args->xdata); - break; - case GF_FOP_RMDIR: - CLIENT4_PRE_FOP( - rmdir, this, &this_req->compound_req_v2_u.compound_rmdir_req, - op_errno, out, &args->loc, args->flags, args->xdata); - break; - case GF_FOP_SYMLINK: - CLIENT4_PRE_FOP(symlink, this, - &this_req->compound_req_v2_u.compound_symlink_req, - op_errno, out, &args->loc, args->linkname, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_RENAME: - CLIENT4_PRE_FOP( - rename, this, &this_req->compound_req_v2_u.compound_rename_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_LINK: - CLIENT4_PRE_FOP( - link, this, &this_req->compound_req_v2_u.compound_link_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_TRUNCATE: - CLIENT4_PRE_FOP(truncate, this, - &this_req->compound_req_v2_u.compound_truncate_req, - op_errno, out, &args->loc, args->offset, - args->xdata); - break; - case GF_FOP_OPEN: - CLIENT4_PRE_FOP( - open, this, &this_req->compound_req_v2_u.compound_open_req, - op_errno, out, &args->loc, args->fd, args->flags, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_READ: - op_errno = client_pre_readv_v2( - this, &this_req->compound_req_v2_u.compound_read_req, args->fd, - args->size, args->offset, args->flags, args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - rsp_iobuf = iobuf_get2(this->ctx->iobuf_pool, args->size); - if (rsp_iobuf == NULL) { - op_errno = ENOMEM; - goto out; - } - - if (!*rsp_iobref) { - *rsp_iobref = iobref_new(); - if (*rsp_iobref == NULL) { - op_errno = ENOMEM; - goto out; - } - } - - if (*rsp_count + 1 >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - rsp_vector[*rsp_count].iov_base = iobuf_ptr(rsp_iobuf); - rsp_vector[*rsp_count].iov_len = iobuf_pagesize(rsp_iobuf); - iobref_add(*rsp_iobref, rsp_iobuf); - iobuf_unref(rsp_iobuf); - rsp_iobuf = NULL; - if (args->size > rsp_vector[*rsp_count].iov_len) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "read-size (%lu) is bigger than iobuf size " - "(%lu)", - (unsigned long)args->size, - (unsigned long)rsp_vector[*rsp_count].iov_len); - op_errno = EINVAL; - goto out; - } - *rsp_count += 1; - - break; - case GF_FOP_WRITE: - op_errno = client_pre_writev_v2( - this, &this_req->compound_req_v2_u.compound_write_req, args->fd, - iov_length(args->vector, args->count), args->offset, - args->flags, &args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - - if (*req_count + args->count >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - memcpy(&req_vector[*req_count], args->vector, - (args->count * sizeof(req_vector[0]))); - *req_count += args->count; - - if (!*req_iobref) - *req_iobref = args->iobref; - else if (iobref_merge(*req_iobref, args->iobref)) - goto out; - break; - case GF_FOP_STATFS: - CLIENT4_PRE_FOP(statfs, this, - &this_req->compound_req_v2_u.compound_statfs_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_FLUSH: - CLIENT4_PRE_FOP(flush, this, - &this_req->compound_req_v2_u.compound_flush_req, - op_errno, out, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_FSYNC: - CLIENT4_PRE_FOP( - fsync, this, &this_req->compound_req_v2_u.compound_fsync_req, - op_errno, out, args->fd, args->datasync, args->xdata); - break; - case GF_FOP_SETXATTR: - CLIENT4_PRE_FOP(setxattr, this, - &this_req->compound_req_v2_u.compound_setxattr_req, - op_errno, out, &args->loc, args->xattr, args->flags, - args->xdata); - break; - case GF_FOP_GETXATTR: - CLIENT4_PRE_FOP(getxattr, this, - &this_req->compound_req_v2_u.compound_getxattr_req, - op_errno, out, &args->loc, args->name, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_REMOVEXATTR: - CLIENT4_PRE_FOP( - removexattr, this, - &this_req->compound_req_v2_u.compound_removexattr_req, op_errno, - out, &args->loc, args->name, args->xdata); - break; - case GF_FOP_OPENDIR: - CLIENT4_PRE_FOP(opendir, this, - &this_req->compound_req_v2_u.compound_opendir_req, - op_errno, out, &args->loc, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FSYNCDIR: - CLIENT4_PRE_FOP(fsyncdir, this, - &this_req->compound_req_v2_u.compound_fsyncdir_req, - op_errno, out, args->fd, args->datasync, - args->xdata); - break; - case GF_FOP_ACCESS: - CLIENT4_PRE_FOP(access, this, - &this_req->compound_req_v2_u.compound_access_req, - op_errno, out, &args->loc, args->mask, args->xdata); - break; - case GF_FOP_CREATE: - CLIENT4_PRE_FOP(create, this, - &this_req->compound_req_v2_u.compound_create_req, - op_errno, out, &args->loc, args->fd, args->mode, - args->flags, args->umask, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FTRUNCATE: - CLIENT4_PRE_FOP(ftruncate, this, - &this_req->compound_req_v2_u.compound_ftruncate_req, - op_errno, out, args->fd, args->offset, args->xdata); - break; - case GF_FOP_FSTAT: - CLIENT4_PRE_FOP(fstat, this, - &this_req->compound_req_v2_u.compound_fstat_req, - op_errno, out, args->fd, args->xdata); - break; - case GF_FOP_LK: - CLIENT4_PRE_FOP( - lk, this, &this_req->compound_req_v2_u.compound_lk_req, - op_errno, out, args->cmd, &args->lock, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_LOOKUP: - CLIENT4_PRE_FOP(lookup, this, - &this_req->compound_req_v2_u.compound_lookup_req, - op_errno, out, &args->loc, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_READDIR: - CLIENT4_PRE_FOP(readdir, this, - &this_req->compound_req_v2_u.compound_readdir_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - break; - case GF_FOP_INODELK: - CLIENT4_PRE_FOP(inodelk, this, - &this_req->compound_req_v2_u.compound_inodelk_req, - op_errno, out, &args->loc, args->cmd, &args->lock, - args->volume, args->xdata); - break; - case GF_FOP_FINODELK: - CLIENT4_PRE_FOP(finodelk, this, - &this_req->compound_req_v2_u.compound_finodelk_req, - op_errno, out, args->fd, args->cmd, &args->lock, - args->volume, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_ENTRYLK: - CLIENT4_PRE_FOP(entrylk, this, - &this_req->compound_req_v2_u.compound_entrylk_req, - op_errno, out, &args->loc, args->entrylkcmd, - args->entrylktype, args->volume, args->name, - args->xdata); - break; - case GF_FOP_FENTRYLK: - CLIENT4_PRE_FOP(fentrylk, this, - &this_req->compound_req_v2_u.compound_fentrylk_req, - op_errno, out, args->fd, args->entrylkcmd, - args->entrylktype, args->volume, args->name, - args->xdata); - break; - case GF_FOP_XATTROP: - CLIENT4_PRE_FOP(xattrop, this, - &this_req->compound_req_v2_u.compound_xattrop_req, - op_errno, out, &args->loc, args->xattr, - args->optype, args->xdata); - break; - case GF_FOP_FXATTROP: - CLIENT4_PRE_FOP(fxattrop, this, - &this_req->compound_req_v2_u.compound_fxattrop_req, - op_errno, out, args->fd, args->xattr, args->optype, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_FGETXATTR: - CLIENT4_PRE_FOP(fgetxattr, this, - &this_req->compound_req_v2_u.compound_fgetxattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FSETXATTR: - CLIENT4_PRE_FOP(fsetxattr, this, - &this_req->compound_req_v2_u.compound_fsetxattr_req, - op_errno, out, args->fd, args->flags, args->xattr, - args->xdata); - break; - case GF_FOP_RCHECKSUM: - CLIENT4_PRE_FOP(rchecksum, this, - &this_req->compound_req_v2_u.compound_rchecksum_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - break; - case GF_FOP_SETATTR: - CLIENT4_PRE_FOP(setattr, this, - &this_req->compound_req_v2_u.compound_setattr_req, - op_errno, out, &args->loc, args->valid, &args->stat, - args->xdata); - break; - case GF_FOP_FSETATTR: - CLIENT4_PRE_FOP(fsetattr, this, - &this_req->compound_req_v2_u.compound_fsetattr_req, - op_errno, out, args->fd, args->valid, &args->stat, - args->xdata); - break; - case GF_FOP_READDIRP: - CLIENT4_PRE_FOP(readdirp, this, - &this_req->compound_req_v2_u.compound_readdirp_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT4_PRE_FOP( - fremovexattr, this, - &this_req->compound_req_v2_u.compound_fremovexattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FALLOCATE: - CLIENT4_PRE_FOP(fallocate, this, - &this_req->compound_req_v2_u.compound_fallocate_req, - op_errno, out, args->fd, args->flags, args->offset, - args->size, args->xdata); - break; - case GF_FOP_DISCARD: - CLIENT4_PRE_FOP(discard, this, - &this_req->compound_req_v2_u.compound_discard_req, - op_errno, out, args->fd, args->offset, args->size, - args->xdata); - break; - case GF_FOP_ZEROFILL: - CLIENT4_PRE_FOP(zerofill, this, - &this_req->compound_req_v2_u.compound_zerofill_req, - op_errno, out, args->fd, args->offset, args->size, - args->xdata); - break; - case GF_FOP_IPC: - CLIENT4_PRE_FOP(ipc, this, - &this_req->compound_req_v2_u.compound_ipc_req, - op_errno, out, args->cmd, args->xdata); - break; - case GF_FOP_SEEK: - CLIENT4_PRE_FOP( - seek, this, &this_req->compound_req_v2_u.compound_seek_req, - op_errno, out, args->fd, args->offset, args->what, args->xdata); - break; - case GF_FOP_LEASE: - CLIENT4_PRE_FOP( - lease, this, &this_req->compound_req_v2_u.compound_lease_req, - op_errno, out, &args->loc, &args->lease, args->xdata); - break; - case GF_FOP_COPY_FILE_RANGE: - /* - * Not going to handle the copy_file_range fop in compound - * operation. This is because, compound operation is going - * to be removed. In fact, AFR one of the heavy consumer of - * compound operations has stopped using that. - * https://github.com/gluster/glusterfs/issues/414 - * Therefore, sending ENOTSUP error for this fop coming as - * comound request. Though, there was no need of handling - * "case GF_FOP_COPY_FILE_RANGE" technically, this comment - * under the label of GF_FOP_COPY_FILE_RANGE will help in - * understanding that this fop does not handle the compund - * request and why. - */ - default: - return ENOTSUP; - } - return 0; -out: - return op_errno; -} - -void -compound_request_cleanup_v2(gfx_compound_req *req) -{ - int i = 0; - int length = req->compound_req_array.compound_req_array_len; - compound_req_v2 *curr_req = NULL; - - if (!req->compound_req_array.compound_req_array_val) - return; - - for (i = 0; i < length; i++) { - curr_req = &req->compound_req_array.compound_req_array_val[i]; - - switch (curr_req->fop_enum) { - case GF_FOP_STAT: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, stat); - break; - case GF_FOP_READLINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, readlink); - break; - case GF_FOP_MKNOD: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, mknod); - break; - case GF_FOP_MKDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, mkdir); - break; - case GF_FOP_UNLINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, unlink); - break; - case GF_FOP_RMDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, rmdir); - break; - case GF_FOP_SYMLINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, symlink); - break; - case GF_FOP_RENAME: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, rename); - break; - case GF_FOP_LINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, link); - break; - case GF_FOP_TRUNCATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, truncate); - break; - case GF_FOP_OPEN: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, open); - break; - case GF_FOP_READ: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, read); - break; - case GF_FOP_WRITE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, write); - break; - case GF_FOP_STATFS: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, statfs); - break; - case GF_FOP_FLUSH: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, flush); - break; - case GF_FOP_FSYNC: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsync); - break; - case GF_FOP_SETXATTR: { - gfx_setxattr_req *args = &CPD4_REQ_FIELD(curr_req, setxattr); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, setxattr); - break; - } - case GF_FOP_GETXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, getxattr); - break; - case GF_FOP_REMOVEXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, removexattr); - break; - case GF_FOP_OPENDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, opendir); - break; - case GF_FOP_FSYNCDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsyncdir); - break; - case GF_FOP_ACCESS: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, access); - break; - case GF_FOP_CREATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, create); - break; - case GF_FOP_FTRUNCATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, ftruncate); - break; - case GF_FOP_FSTAT: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fstat); - break; - case GF_FOP_LK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, lk); - break; - case GF_FOP_LOOKUP: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, lookup); - break; - case GF_FOP_READDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, readdir); - break; - case GF_FOP_INODELK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, inodelk); - break; - case GF_FOP_FINODELK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, finodelk); - break; - case GF_FOP_ENTRYLK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, entrylk); - break; - case GF_FOP_FENTRYLK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fentrylk); - break; - case GF_FOP_XATTROP: { - gfx_xattrop_req *args = &CPD4_REQ_FIELD(curr_req, xattrop); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, xattrop); - break; - } - case GF_FOP_FXATTROP: { - gfx_fxattrop_req *args = &CPD4_REQ_FIELD(curr_req, fxattrop); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fxattrop); - break; - } - case GF_FOP_FGETXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fgetxattr); - break; - case GF_FOP_FSETXATTR: { - gfx_fsetxattr_req *args = &CPD4_REQ_FIELD(curr_req, fsetxattr); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsetxattr); - break; - } - case GF_FOP_RCHECKSUM: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, rchecksum); - break; - case GF_FOP_SETATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, setattr); - break; - case GF_FOP_FSETATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsetattr); - break; - case GF_FOP_READDIRP: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, readdirp); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fremovexattr); - break; - case GF_FOP_FALLOCATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fallocate); - break; - case GF_FOP_DISCARD: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, discard); - break; - case GF_FOP_ZEROFILL: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, zerofill); - break; - case GF_FOP_IPC: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, ipc); - break; - case GF_FOP_SEEK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, seek); - break; - case GF_FOP_COPY_FILE_RANGE: - /* - * This fop is not handled in compund operations. - * Check the comment added under this fop's section - * in the compound_request_cleanup_v2. Therefore - * keeping this label only as a placeholder with - * a message that, this fop is not handled. - */ - default: - break; - } - } - - GF_FREE(req->compound_req_array.compound_req_array_val); - return; -} - -void -client_compound_rsp_cleanup_v2(gfx_compound_rsp *rsp, int len) -{ - int i = 0; - compound_rsp_v2 *this_rsp = NULL; - - for (i = 0; i < len; i++) { - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; - switch (this_rsp->fop_enum) { - /* fops that need extra cleanup */ - case GF_FOP_LK: { - gfx_lk_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, lk); - free(tmp_rsp->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readlink); - free(tmp_rsp->path); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readdir); - clnt_readdir_rsp_cleanup_v2(tmp_rsp); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readdirp); - clnt_readdirp_rsp_cleanup_v2(tmp_rsp); - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_rsp *rck = &CPD4_RSP_FIELD(this_rsp, rchecksum); - if (rck->strong_checksum.strong_checksum_val) { - free(rck->strong_checksum.strong_checksum_val); - } - break; - } - default: - break; - } - } - return; -} - -int -client_process_response_v2(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfx_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index) -{ - int ret = 0; - dict_t *xdata = NULL; - dict_t *xattr = NULL; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - gf_dirent_t entries; - default_args_cbk_t *this_args_cbk = &args_cbk->rsp_list[index]; - clnt_local_t *local = frame->local; - compound_rsp_v2 *this_rsp = NULL; - compound_args_t *args = local->compound_args; - - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index]; - args_cbk->enum_list[index] = this_rsp->fop_enum; - - INIT_LIST_HEAD(&entries.list); - - switch (args_cbk->enum_list[index]) { - case GF_FOP_STAT: - case GF_FOP_FSTAT: { - gfx_common_iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_stat_rsp; - - client_post_common_iatt(this, tmp_rsp, &this_args_cbk->stat, - &xdata); - - CLIENT4_POST_FOP_TYPE(stat, common_iatt, this_rsp, this_args_cbk, - &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_readlink_rsp; - - gfx_stat_to_iattx(&tmp_rsp->buf, &this_args_cbk->stat); - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(readlink, readlink, this_rsp, this_args_cbk, - tmp_rsp->path, &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_MKDIR: - case GF_FOP_MKNOD: - case GF_FOP_SYMLINK: - case GF_FOP_LINK: { - gfx_common_3iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_mknod_rsp; - - client_post_common_3iatt(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT4_POST_FOP_TYPE(mknod, common_3iatt, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_UNLINK: - case GF_FOP_RMDIR: { - gfx_common_2iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_unlink_rsp; - - client_post_common_2iatt(this, tmp_rsp, &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT4_POST_FOP_TYPE(unlink, common_2iatt, this_rsp, this_args_cbk, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_RENAME: { - gfx_rename_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_rename_rsp; - - client_post_rename_v2( - this, tmp_rsp, &this_args_cbk->stat, &this_args_cbk->preparent, - &this_args_cbk->postparent, &this_args_cbk->preparent2, - &this_args_cbk->postparent2, &xdata); - CLIENT4_POST_FOP_TYPE( - rename, rename, this_rsp, this_args_cbk, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - &this_args_cbk->preparent2, &this_args_cbk->postparent2, xdata); - break; - } - case GF_FOP_WRITE: - case GF_FOP_TRUNCATE: - case GF_FOP_FTRUNCATE: - case GF_FOP_FSYNC: - case GF_FOP_ZEROFILL: - case GF_FOP_DISCARD: - case GF_FOP_FALLOCATE: - case GF_FOP_FSETATTR: - case GF_FOP_SETATTR: { - gfx_common_2iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_truncate_rsp; - - client_post_common_2iatt(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - CLIENT4_POST_FOP_TYPE(truncate, common_2iatt, this_rsp, - this_args_cbk, &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_OPEN: { - gfx_open_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_open_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - CLIENT4_POST_FOP_TYPE(open, open, this_rsp, this_args_cbk, - local->fd, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_READ: { - gfx_read_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_read_rsp; - - client_post_readv_v2(this, tmp_rsp, &this_args_cbk->iobref, - req->rsp_iobref, &this_args_cbk->stat, vector, - &req->rsp[1], &this_args_cbk->count, &xdata); - - /* Each read should be given read response that only - * corresponds to its request. - * Modify the iovecs accordingly. - * After each read, store the length of data already read - * so that the next ones can continue from there. - */ - if (local->read_length) { - vector[0].iov_base += local->read_length; - local->read_length += tmp_rsp->op_ret; - } else { - local->read_length = tmp_rsp->op_ret; - } - - args_readv_cbk_store(this_args_cbk, tmp_rsp->op_ret, - gf_error_to_errno(tmp_rsp->op_errno), vector, - this_args_cbk->count, &this_args_cbk->stat, - this_args_cbk->iobref, xdata); - - if (tmp_rsp->op_ret >= 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - - break; - } - case GF_FOP_STATFS: { - gfx_statfs_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_statfs_rsp; - - gf_statfs_to_statfs(&tmp_rsp->statfs, &this_args_cbk->statvfs); - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(statfs, statfs, this_rsp, this_args_cbk, - &this_args_cbk->statvfs, xdata); - break; - } - case GF_FOP_FLUSH: { - gfx_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_flush_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP(flush, this_rsp, this_args_cbk, xdata); - if (this_args_cbk->op_ret >= 0 && !fd_is_anonymous(local->fd)) { - /* Delete all saved locks of the owner issuing flush */ - ret = delete_granted_locks_owner(local->fd, &local->owner); - gf_msg_trace(this->name, 0, - "deleting locks of owner (%s) returned %d", - lkowner_utoa(&local->owner), ret); - } - break; - } - case GF_FOP_FSYNCDIR: - case GF_FOP_ACCESS: - case GF_FOP_REMOVEXATTR: - case GF_FOP_FREMOVEXATTR: - case GF_FOP_FSETXATTR: - case GF_FOP_SETXATTR: - case GF_FOP_INODELK: - case GF_FOP_FINODELK: - case GF_FOP_ENTRYLK: - case GF_FOP_FENTRYLK: - case GF_FOP_IPC: { - gfx_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_setxattr_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP(setxattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_GETXATTR: - case GF_FOP_FGETXATTR: - case GF_FOP_XATTROP: - case GF_FOP_FXATTROP: { - gfx_common_dict_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_getxattr_rsp; - - ret = client_post_common_dict(this, tmp_rsp, &xattr, &xdata); - if (ret) { - tmp_rsp->op_errno = -ret; - goto out; - } - - CLIENT4_POST_FOP_TYPE(getxattr, common_dict, this_rsp, - this_args_cbk, xattr, xdata); - break; - } - case GF_FOP_OPENDIR: { - gfx_open_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_opendir_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(opendir, open, this_rsp, this_args_cbk, - local->fd, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_CREATE: { - gfx_create_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_create_rsp; - - client_post_create_v2(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, local, &xdata); - - CLIENT4_POST_FOP_TYPE( - create, create, this_rsp, this_args_cbk, local->fd, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_LK: { - gfx_lk_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_lk_rsp; - - client_post_lk_v2(this, tmp_rsp, &this_args_cbk->lock, &xdata); - - CLIENT4_POST_FOP_TYPE(lk, lk, this_rsp, this_args_cbk, - &this_args_cbk->lock, xdata); - break; - } - case GF_FOP_LOOKUP: { - gfx_common_2iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_lookup_rsp; - - client_post_common_2iatt(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->postparent, &xdata); - CLIENT4_POST_FOP_TYPE(lookup, common_2iatt, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, xdata, - &this_args_cbk->postparent); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_readdir_rsp; - - client_post_readdir_v2(this, tmp_rsp, &entries, &xdata); - - CLIENT4_POST_FOP_TYPE(readdir, readdir, this_rsp, this_args_cbk, - &entries, xdata); - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_rchecksum_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE( - rchecksum, rchecksum, this_rsp, this_args_cbk, - tmp_rsp->weak_checksum, - (uint8_t *)tmp_rsp->strong_checksum.strong_checksum_val, xdata); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_readdirp_rsp; - - client_post_readdirp_v2(this, tmp_rsp, local->fd, &entries, &xdata); - - CLIENT4_POST_FOP_TYPE(readdirp, readdirp, this_rsp, this_args_cbk, - &entries, xdata); - break; - } - case GF_FOP_SEEK: { - gfx_seek_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_seek_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(seek, seek, this_rsp, this_args_cbk, - tmp_rsp->offset, xdata); - break; - } - case GF_FOP_LEASE: { - gfx_lease_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_lease_rsp; - - client_post_lease_v2(this, tmp_rsp, &this_args_cbk->lease, &xdata); - - CLIENT4_POST_FOP_TYPE(lease, lease, this_rsp, this_args_cbk, - &this_args_cbk->lease, xdata); - break; - } - case GF_FOP_COPY_FILE_RANGE: - /* - * Not handling this fop. Returning ENOTSUP. Check - * the comment added for this fop in the function - * client_handle_fop_requirements_v2. - */ - default: - return -ENOTSUP; - } - -out: - if (xdata) - dict_unref(xdata); - if (xattr) - dict_unref(xattr); - gf_dirent_free(&entries); - return 0; -} - extern int client3_3_releasedir_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe); diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 1c8b31b15c5..8ca6cbedc85 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -16,7 +16,6 @@ #include "client-messages.h" #include <glusterfs/defaults.h> #include "client-common.h" -#include <glusterfs/compound-fop-utils.h> int32_t client3_getspec(call_frame_t *frame, xlator_t *this, void *data); @@ -3050,84 +3049,6 @@ out: return 0; } -int -client3_3_compound_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gfs3_compound_rsp rsp = { - 0, - }; - compound_args_cbk_t *args_cbk = NULL; - call_frame_t *frame = NULL; - xlator_t *this = NULL; - dict_t *xdata = NULL; - clnt_local_t *local = NULL; - int i = 0; - int length = 0; - int ret = -1; - - this = THIS; - - frame = myframe; - local = frame->local; - - if (-1 == req->rpc_status) { - rsp.op_ret = -1; - rsp.op_errno = ENOTCONN; - goto out; - } - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_compound_rsp); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED, - "XDR decoding failed"); - rsp.op_ret = -1; - rsp.op_errno = EINVAL; - goto out; - } - - length = local->length; - - GF_PROTOCOL_DICT_UNSERIALIZE(this, xdata, (rsp.xdata.xdata_val), - (rsp.xdata.xdata_len), rsp.op_ret, - rsp.op_errno, out); - - args_cbk = compound_args_cbk_alloc(length, xdata); - if (!args_cbk) { - rsp.op_ret = -1; - rsp.op_errno = ENOMEM; - goto out; - } - - /* TODO: see https://bugzilla.redhat.com/show_bug.cgi?id=1376328 */ - for (i = 0; i < args_cbk->fop_length; i++) { - ret = client_process_response(frame, this, req, &rsp, args_cbk, i); - if (ret) { - rsp.op_ret = -1; - rsp.op_errno = -ret; - goto out; - } - } - rsp.op_ret = 0; -out: - if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); - } - CLIENT_STACK_UNWIND(compound, frame, rsp.op_ret, - gf_error_to_errno(rsp.op_errno), args_cbk, xdata); - - free(rsp.xdata.xdata_val); - client_compound_rsp_cleanup(&rsp, length); - free(rsp.compound_rsp_array.compound_rsp_array_val); - - if (xdata) - dict_unref(xdata); - - compound_args_cbk_cleanup(args_cbk); - return 0; -} - int32_t client3_3_releasedir(call_frame_t *frame, xlator_t *this, void *data) { @@ -5952,143 +5873,6 @@ unwind: return 0; } -/* Brief explanation of gfs3_compound_req structure : - * 1) It consists of version of compounding. - * 2) A compound-fop enum, new enum for compound fops - * 3) A 'compound_req_arrray' structure that has - * a) array len - based on the number of fops compounded - * b) compound_req_array_val - pointer to an array of compound_req's - * 4) compound_req - structure that contains: - * a) fop enum of type glusterfs_fop_t - * b) union of structures of xdr requests of all fops. - */ - -int32_t -client3_3_compound(call_frame_t *frame, xlator_t *this, void *data) -{ - clnt_conf_t *conf = NULL; - compound_args_t *c_args = data; - gfs3_compound_req req = { - 0, - }; - clnt_local_t *local = NULL; - int op_errno = ENOMEM; - int ret = 0; - int i = 0; - int rsp_count = 0; - struct iovec rsp_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec req_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - struct iovec *rsphdr = NULL; - struct iobref *req_iobref = NULL; - struct iobref *rsp_iobref = NULL; - struct iobref *rsphdr_iobref = NULL; - struct iobuf *rsphdr_iobuf = NULL; - int rsphdr_count = 0; - int req_count = 0; - dict_t *xdata = c_args->xdata; - - GF_ASSERT(frame); - - if (!this) - goto unwind; - - memset(req_vector, 0, sizeof(req_vector)); - memset(rsp_vector, 0, sizeof(rsp_vector)); - - conf = this->private; - - local = mem_get0(this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - - local->length = c_args->fop_length; - local->compound_args = c_args; - - rsphdr_iobref = iobref_new(); - if (rsphdr_iobref == NULL) { - goto unwind; - } - - /* TODO: what is the size we should send ? */ - rsphdr_iobuf = iobuf_get(this->ctx->iobuf_pool); - if (rsphdr_iobuf == NULL) { - goto unwind; - } - - rsphdr = &vector[0]; - rsphdr->iov_base = iobuf_ptr(rsphdr_iobuf); - rsphdr->iov_len = iobuf_pagesize(rsphdr_iobuf); - rsphdr_count = 1; - iobref_add(rsphdr_iobref, rsphdr_iobuf); - iobuf_unref(rsphdr_iobuf); - rsphdr_iobuf = NULL; - - req.compound_fop_enum = c_args->fop_enum; - req.compound_req_array.compound_req_array_len = c_args->fop_length; - req.compound_version = 0; - if (xdata) { - GF_PROTOCOL_DICT_SERIALIZE(this, xdata, (&req.xdata.xdata_val), - req.xdata.xdata_len, op_errno, unwind); - } - - req.compound_req_array.compound_req_array_val = GF_CALLOC( - local->length, sizeof(compound_req), gf_client_mt_compound_req_t); - - if (!req.compound_req_array.compound_req_array_val) { - op_errno = ENOMEM; - goto unwind; - } - - for (i = 0; i < local->length; i++) { - ret = client_handle_fop_requirements( - this, frame, &req, local, &req_iobref, &rsp_iobref, req_vector, - rsp_vector, &req_count, &rsp_count, &c_args->req_list[i], - c_args->enum_list[i], i); - if (ret) { - op_errno = ret; - goto unwind; - } - } - - local->iobref = rsp_iobref; - rsp_iobref = NULL; - - ret = client_submit_compound_request( - this, &req, frame, conf->fops, GFS3_OP_COMPOUND, client3_3_compound_cbk, - req_vector, req_count, req_iobref, rsphdr, rsphdr_count, rsp_vector, - rsp_count, local->iobref, (xdrproc_t)xdr_gfs3_compound_req); - - GF_FREE(req.xdata.xdata_val); - - iobref_unref(rsphdr_iobref); - - compound_request_cleanup(&req); - return 0; -unwind: - CLIENT_STACK_UNWIND(compound, frame, -1, op_errno, NULL, NULL); - - if (rsp_iobref) - iobref_unref(rsp_iobref); - - if (rsphdr_iobref) - iobref_unref(rsphdr_iobref); - - GF_FREE(req.xdata.xdata_val); - - compound_request_cleanup(&req); - return 0; -} - static int32_t client3_3_getactivelk(call_frame_t *frame, xlator_t *this, void *data) { @@ -6259,7 +6043,7 @@ rpc_clnt_procedure_t clnt3_3_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_LEASE] = {"LEASE", client3_3_lease}, [GF_FOP_GETACTIVELK] = {"GETACTIVELK", client3_3_getactivelk}, [GF_FOP_SETACTIVELK] = {"SETACTIVELK", client3_3_setactivelk}, - [GF_FOP_COMPOUND] = {"COMPOUND", client3_3_compound}, + [GF_FOP_COMPOUND] = {"COMPOUND", NULL}, }; /* Used From RPC-CLNT library to log proper name of procedure based on number */ diff --git a/xlators/protocol/client/src/client-rpc-fops_v2.c b/xlators/protocol/client/src/client-rpc-fops_v2.c index 2673b6e0237..880d4240ed4 100644 --- a/xlators/protocol/client/src/client-rpc-fops_v2.c +++ b/xlators/protocol/client/src/client-rpc-fops_v2.c @@ -16,7 +16,6 @@ #include "client-messages.h" #include <glusterfs/defaults.h> #include "client-common.h" -#include <glusterfs/compound-fop-utils.h> extern int32_t client3_getspec(call_frame_t *frame, xlator_t *this, void *data); @@ -6090,215 +6089,6 @@ unwind: return 0; } -int -client4_0_compound_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gfx_compound_rsp rsp = { - 0, - }; - compound_args_cbk_t *args_cbk = NULL; - call_frame_t *frame = NULL; - xlator_t *this = NULL; - dict_t *xdata = NULL; - clnt_local_t *local = NULL; - int i = 0; - int length = 0; - int ret = -1; - - this = THIS; - - frame = myframe; - local = frame->local; - - if (-1 == req->rpc_status) { - rsp.op_ret = -1; - rsp.op_errno = ENOTCONN; - goto out; - } - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_compound_rsp); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED, - "XDR decoding failed"); - rsp.op_ret = -1; - rsp.op_errno = EINVAL; - goto out; - } - - length = local->length; - - xdr_to_dict(&rsp.xdata, &xdata); - - args_cbk = compound_args_cbk_alloc(length, xdata); - if (!args_cbk) { - rsp.op_ret = -1; - rsp.op_errno = ENOMEM; - goto out; - } - - /* TODO: see https://bugzilla.redhat.com/show_bug.cgi?id=1376328 */ - for (i = 0; i < args_cbk->fop_length; i++) { - ret = client_process_response_v2(frame, this, req, &rsp, args_cbk, i); - if (ret) { - rsp.op_ret = -1; - rsp.op_errno = -ret; - goto out; - } - } - rsp.op_ret = 0; -out: - if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); - } - CLIENT_STACK_UNWIND(compound, frame, rsp.op_ret, - gf_error_to_errno(rsp.op_errno), args_cbk, xdata); - - client_compound_rsp_cleanup_v2(&rsp, length); - free(rsp.compound_rsp_array.compound_rsp_array_val); - - if (xdata) - dict_unref(xdata); - - compound_args_cbk_cleanup(args_cbk); - return 0; -} - -/* Brief explanation of gfs3_compound_req structure : - * 1) It consists of version of compounding. - * 2) A compound-fop enum, new enum for compound fops - * 3) A 'compound_req_arrray' structure that has - * a) array len - based on the number of fops compounded - * b) compound_req_array_val - pointer to an array of compound_req's - * 4) compound_req - structure that contains: - * a) fop enum of type glusterfs_fop_t - * b) union of structures of xdr requests of all fops. - */ - -int32_t -client4_0_compound(call_frame_t *frame, xlator_t *this, void *data) -{ - clnt_conf_t *conf = NULL; - compound_args_t *c_args = data; - gfx_compound_req req = { - 0, - }; - clnt_local_t *local = NULL; - int op_errno = ENOMEM; - int ret = 0; - int i = 0; - int rsp_count = 0; - struct iovec rsp_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec req_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - struct iovec *rsphdr = NULL; - struct iobref *req_iobref = NULL; - struct iobref *rsp_iobref = NULL; - struct iobref *rsphdr_iobref = NULL; - struct iobuf *rsphdr_iobuf = NULL; - int rsphdr_count = 0; - int req_count = 0; - dict_t *xdata = c_args->xdata; - - GF_ASSERT(frame); - - if (!this) - goto unwind; - - memset(req_vector, 0, sizeof(req_vector)); - memset(rsp_vector, 0, sizeof(rsp_vector)); - - conf = this->private; - - local = mem_get0(this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - - local->length = c_args->fop_length; - local->compound_args = c_args; - - rsphdr_iobref = iobref_new(); - if (rsphdr_iobref == NULL) { - goto unwind; - } - - /* TODO: what is the size we should send ? */ - rsphdr_iobuf = iobuf_get(this->ctx->iobuf_pool); - if (rsphdr_iobuf == NULL) { - goto unwind; - } - - rsphdr = &vector[0]; - rsphdr->iov_base = iobuf_ptr(rsphdr_iobuf); - rsphdr->iov_len = iobuf_pagesize(rsphdr_iobuf); - rsphdr_count = 1; - iobref_add(rsphdr_iobref, rsphdr_iobuf); - iobuf_unref(rsphdr_iobuf); - rsphdr_iobuf = NULL; - - req.compound_fop_enum = c_args->fop_enum; - req.compound_req_array.compound_req_array_len = c_args->fop_length; - req.compound_version = 0; - dict_to_xdr(xdata, &req.xdata); - - req.compound_req_array.compound_req_array_val = GF_CALLOC( - local->length, sizeof(compound_req_v2), gf_client_mt_compound_req_t); - - if (!req.compound_req_array.compound_req_array_val) { - op_errno = ENOMEM; - goto unwind; - } - - for (i = 0; i < local->length; i++) { - ret = client_handle_fop_requirements_v2( - this, frame, &req, local, &req_iobref, &rsp_iobref, req_vector, - rsp_vector, &req_count, &rsp_count, &c_args->req_list[i], - c_args->enum_list[i], i); - if (ret) { - op_errno = ret; - goto unwind; - } - } - - local->iobref = rsp_iobref; - rsp_iobref = NULL; - - ret = client_submit_compound_request( - this, &req, frame, conf->fops, GFS3_OP_COMPOUND, client4_0_compound_cbk, - req_vector, req_count, req_iobref, rsphdr, rsphdr_count, rsp_vector, - rsp_count, local->iobref, (xdrproc_t)xdr_gfx_compound_req); - - GF_FREE(req.xdata.pairs.pairs_val); - - iobref_unref(rsphdr_iobref); - - compound_request_cleanup_v2(&req); - return 0; -unwind: - CLIENT_STACK_UNWIND(compound, frame, -1, op_errno, NULL, NULL); - - if (rsp_iobref) - iobref_unref(rsp_iobref); - - if (rsphdr_iobref) - iobref_unref(rsphdr_iobref); - - GF_FREE(req.xdata.pairs.pairs_val); - - compound_request_cleanup_v2(&req); - return 0; -} - /* Used From RPC-CLNT library to log proper name of procedure based on number */ char *clnt4_0_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_NULL] = "NULL", @@ -6412,7 +6202,7 @@ rpc_clnt_procedure_t clnt4_0_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_LEASE] = {"LEASE", client4_0_lease}, [GF_FOP_GETACTIVELK] = {"GETACTIVELK", client4_0_getactivelk}, [GF_FOP_SETACTIVELK] = {"SETACTIVELK", client4_0_setactivelk}, - [GF_FOP_COMPOUND] = {"COMPOUND", client4_0_compound}, + [GF_FOP_COMPOUND] = {"COMPOUND", NULL}, [GF_FOP_ICREATE] = {"ICREATE", client4_0_icreate}, [GF_FOP_NAMELINK] = {"NAMELINK", client4_0_namelink}, [GF_FOP_COPY_FILE_RANGE] = {"COPY-FILE-RANGE", client4_0_copy_file_range}, diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index 8dcd72f1643..e4bab46ebc6 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -36,9 +36,6 @@ typedef enum { FALLBACK_TO_ANON_FD = 1 } clnt_remote_fd_flags_t; -#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 CLIENT_POST_FOP(fop, this_rsp_u, this_args_cbk, params...) \ do { \ gf_common_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp_u, fop); \ @@ -61,43 +58,6 @@ typedef enum { args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ } while (0) -#define CLIENT_PRE_FOP(fop, xl, compound_req, op_errno, label, params...) \ - do { \ - gfs3_##fop##_req *_req = (gfs3_##fop##_req *)compound_req; \ - int _ret = 0; \ - \ - _ret = client_pre_##fop(xl, _req, params); \ - if (_ret < 0) { \ - op_errno = -ret; \ - goto label; \ - } \ - } while (0) - -#define CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fop) \ - do { \ - gfs3_##fop##_req *_req = &CPD_REQ_FIELD(curr_req, fop); \ - \ - GF_FREE(_req->xdata.xdata_val); \ - } while (0) - -#define CLIENT_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); \ - \ - free(_this_rsp->xdata.xdata_val); \ - } while (0) - -#define CLIENT_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); \ - \ - free(_this_rsp->xdata.xdata_val); \ - } while (0) - #define CLIENT_GET_REMOTE_FD(xl, fd, flags, remote_fd, op_errno, label) \ do { \ int _ret = 0; \ @@ -126,52 +86,6 @@ typedef enum { client_local_wipe(__local); \ } while (0) -/* compound v2 */ -#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 CLIENT4_POST_FOP(fop, this_rsp_u, this_args_cbk, params...) \ - do { \ - gfx_common_rsp *_this_rsp = &CPD4_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ - \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ - args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ - } while (0) - -#define CLIENT4_POST_FOP_TYPE(fop, rsp_type, this_rsp_u, this_args_cbk, \ - params...) \ - do { \ - gfx_##rsp_type##_rsp *_this_rsp = &CPD4_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ - \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ - args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ - } while (0) - -#define CLIENT4_PRE_FOP(fop, xl, compound_req, op_errno, label, params...) \ - do { \ - gfx_##fop##_req *_req = (gfx_##fop##_req *)compound_req; \ - int _ret = 0; \ - \ - _ret = client_pre_##fop##_v2(xl, _req, params); \ - if (_ret < 0) { \ - op_errno = -ret; \ - goto label; \ - } \ - } while (0) - -#define CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fop) \ - do { \ - gfx_##fop##_req *_req = &CPD4_REQ_FIELD(curr_req, fop); \ - \ - GF_FREE(_req->xdata.pairs.pairs_val); \ - } while (0) - struct clnt_options { char *remote_subvolume; int ping_timeout; @@ -292,11 +206,6 @@ typedef struct client_local { * only for copy_file_range fop */ gf_boolean_t attempt_reopen_out; - /* required for compound fops */ - compound_args_t *compound_args; - unsigned int length; /* length of a compound fop */ - unsigned int - read_length; /* defines the last processed length for a compound read */ } clnt_local_t; typedef struct client_args { @@ -379,15 +288,6 @@ client_submit_request(xlator_t *this, void *req, call_frame_t *frame, client_payload_t *cp, xdrproc_t xdrproc); int -client_submit_compound_request(xlator_t *this, void *req, call_frame_t *frame, - rpc_clnt_prog_t *prog, int procnum, - fop_cbk_fn_t cbkfn, struct iovec *req_vector, - int req_count, struct iobref *iobref, - struct iovec *rsphdr, int rsphdr_count, - struct iovec *rsp_payload, int rsp_payload_count, - struct iobref *rsp_iobref, xdrproc_t xdrproc); - -int unserialize_rsp_dirent(xlator_t *this, struct gfs3_readdir_rsp *rsp, gf_dirent_t *entries); int @@ -449,19 +349,6 @@ int client_add_fd_to_saved_fds(xlator_t *this, fd_t *fd, loc_t *loc, int32_t flags, int64_t remote_fd, int is_dir); int -client_handle_fop_requirements( - xlator_t *this, call_frame_t *frame, gfs3_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index); -int -client_process_response(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfs3_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index); -void -compound_request_cleanup(gfs3_compound_req *req); - -int clnt_unserialize_rsp_locklist(xlator_t *this, struct gfs3_getactivelk_rsp *rsp, lock_migration_info_t *lmi); void @@ -475,9 +362,6 @@ serialize_req_locklist(lock_migration_info_t *locklist, gfs3_setactivelk_req *req); void -client_compound_rsp_cleanup(gfs3_compound_rsp *rsp, int len); - -void clnt_getactivelk_rsp_cleanup_v2(gfx_getactivelk_rsp *rsp); void @@ -504,19 +388,4 @@ clnt_readdir_rsp_cleanup_v2(gfx_readdir_rsp *rsp); int clnt_readdirp_rsp_cleanup_v2(gfx_readdirp_rsp *rsp); -int -client_handle_fop_requirements_v2( - xlator_t *this, call_frame_t *frame, gfx_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index); -int -client_process_response_v2(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfx_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index); -void -compound_request_cleanup_v2(gfx_compound_req *req); -void -client_compound_rsp_cleanup_v2(gfx_compound_rsp *rsp, int len); - #endif /* !_CLIENT_H */ diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c index 1a34239d8b9..f6edf3f5120 100644 --- a/xlators/protocol/server/src/server-helpers.c +++ b/xlators/protocol/server/src/server-helpers.c @@ -19,7 +19,6 @@ #include <fnmatch.h> #include <pwd.h> -#include <glusterfs/compound-fop-utils.h> /* based on nfs_fix_aux_groups() */ int @@ -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 @@ -1540,4166 +1537,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 = 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 = - 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 = 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 = 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 = 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 = 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 = - 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 = 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 = 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 = - 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 = 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 = 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 = 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 = 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 = 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 = 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 = - 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 = - 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 = - 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 = - 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 = - 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 = 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 = 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 = - 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 = 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 = 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 = 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = 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 = 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; - } - case GF_FOP_COPY_FILE_RANGE: - /* Not handling this fop. */ - 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 = 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 = - 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 = 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 = 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 = - 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 = 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 = - 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 = - 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 = 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 = - 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 = 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 = 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 = 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 = - 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 = 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 = 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = 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 = 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = - 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 = 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 = array[i] - .compound_req_v2_u.compound_lease_req; - - state->resolve.type = RESOLVE_MUST; - memcpy(state->resolve.gfid, this_req.gfid, 16); - break; - } - case GF_FOP_COPY_FILE_RANGE: - /* - * Compound operations is not being used anymore and - * planned for subsequent removal. Hence not handling - * this fop here. - */ - 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 7dea40e3eb1..837fdc84f17 100644 --- a/xlators/protocol/server/src/server-helpers.h +++ b/xlators/protocol/server/src/server-helpers.h @@ -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-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index 3b028b49962..49bffb824e9 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -21,7 +21,6 @@ #include <glusterfs/default-args.h> #include "server-common.h" #include <glusterfs/xlator.h> -#include <glusterfs/compound-fop-utils.h> #include "xdr-nfs3.h" @@ -2261,83 +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) { - op_ret = -1; - goto out; - } - - 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); - if (args_cbk) - server_compound_rsp_cleanup(&rsp, args_cbk); - GF_FREE(rsp.xdata.xdata_val); - - return 0; -} - /* Resume function section */ int @@ -3458,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, @@ -6094,64 +5962,8 @@ 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; } diff --git a/xlators/protocol/server/src/server-rpc-fops_v2.c b/xlators/protocol/server/src/server-rpc-fops_v2.c index cb0e2474e0e..fa5db087a08 100644 --- a/xlators/protocol/server/src/server-rpc-fops_v2.c +++ b/xlators/protocol/server/src/server-rpc-fops_v2.c @@ -21,7 +21,6 @@ #include <glusterfs/default-args.h> #include "server-common.h" #include <glusterfs/xlator.h> -#include <glusterfs/compound-fop-utils.h> #include "xdr-nfs3.h" @@ -5958,192 +5957,10 @@ out: } 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) { - op_ret = -1; - goto out; - } - - 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; - 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); - - 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); - if (args_cbk) - server_compound_rsp_cleanup_v2(&rsp, args_cbk); - GF_FREE(rsp.xdata.pairs.pairs_val); - - return 0; -} - -int -server4_compound_resume(call_frame_t *frame, xlator_t *bound_xl) -{ - 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); - - return ret; -} -int server4_0_compound(rpcsvc_request_t *req) { - server_state_t *state = NULL; - call_frame_t *frame = NULL; - gfx_compound_req args = { - 0, - }; - ssize_t len = 0; - int length = 0; - int i = 0; int ret = -1; - - if (!req) - return ret; - - ret = rpc_receive_common(req, &frame, &state, &len, &args, - xdr_gfx_compound_req, GF_FOP_COMPOUND); - 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); - - if (ret) { - SERVER_REQ_SET_ERROR(req, ret); - goto out; - } - - if (xdr_to_dict(&args.xdata, &state->xdata)) { - SERVER_REQ_SET_ERROR(req, ret); - goto out; - } - - ret = 0; - resolve_and_resume(frame, server4_compound_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); - + SERVER_REQ_SET_ERROR(req, ret); return ret; } diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index bdf98c96f1c..ab05b4ffe6d 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -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, @@ -225,21 +176,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; |