diff options
Diffstat (limited to 'xlators/protocol/client/src/client.h')
| -rw-r--r-- | xlators/protocol/client/src/client.h | 222 |
1 files changed, 65 insertions, 157 deletions
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index c63e3a290d6..ab799c41755 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -15,15 +15,15 @@ #include <stdint.h> #include "rpc-clnt.h" -#include "list.h" -#include "inode.h" +#include <glusterfs/list.h> +#include <glusterfs/inode.h> #include "client-mem-types.h" #include "protocol-common.h" #include "glusterfs3.h" #include "glusterfs3-xdr.h" -#include "fd-lk.h" -#include "defaults.h" -#include "default-args.h" +#include <glusterfs/fd-lk.h> +#include <glusterfs/defaults.h> +#include <glusterfs/default-args.h> #include "client-messages.h" /* FIXME: Needs to be defined in a common file */ @@ -36,68 +36,24 @@ 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); \ - int _op_ret = 0; \ - int _op_errno = 0; \ \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ + int _op_ret = _this_rsp->op_ret; \ + int _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 CLIENT_POST_FOP_TYPE(fop, this_rsp_u, this_args_cbk, params...) \ do { \ gfs3_##fop##_rsp *_this_rsp = &CPD_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); \ + int _op_ret = _this_rsp->op_ret; \ + int _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 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; \ @@ -107,10 +63,8 @@ typedef enum { goto label; \ } \ if (remote_fd == -1) { \ - gf_msg(xl->name, GF_LOG_WARNING, EBADFD, PC_MSG_BAD_FD, \ - " (%s) " \ - "remote_fd is -1. EBADFD", \ - uuid_utoa(fd->inode->gfid)); \ + gf_smsg(xl->name, GF_LOG_WARNING, EBADFD, PC_MSG_BAD_FD, \ + "gfid=%s", uuid_utoa(fd->inode->gfid), NULL); \ op_errno = EBADFD; \ goto label; \ } \ @@ -126,52 +80,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; @@ -235,6 +143,22 @@ typedef struct clnt_conf { * up, disconnects can be * logged */ + + gf_boolean_t old_protocol; /* used only for old-protocol testing */ + pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini + compltely, ie client_fini_complete + to return*/ + gf_boolean_t fini_completed; + gf_boolean_t strict_locks; /* When set, doesn't reopen saved fds after + reconnect if POSIX locks are held on them. + Hence subsequent operations on these fds will + fail. This is necessary for stricter lock + complaince as bricks cleanup any granted + locks when a client disconnects. + */ + + gf_boolean_t connection_to_brick; /*True from attempt to connect to brick + till disconnection to brick*/ } clnt_conf_t; typedef struct _client_fd_ctx { @@ -269,6 +193,7 @@ typedef struct client_local { loc_t loc; loc_t loc2; fd_t *fd; + fd_t *fd_out; /* used in copy_file_range */ clnt_fd_ctx_t *fdctx; uint32_t flags; struct iobref *iobref; @@ -280,16 +205,22 @@ typedef struct client_local { pthread_mutex_t mutex; char *name; gf_boolean_t attempt_reopen; - /* 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 */ + /* + * The below boolean variable is used + * only for copy_file_range fop + */ + gf_boolean_t attempt_reopen_out; } clnt_local_t; typedef struct client_args { loc_t *loc; + /* + * This is the source fd for copy_file_range and + * the default fd for any other fd based fop which + * requires only one fd (i.e. opetates on one fd) + */ fd_t *fd; + fd_t *fd_out; /* this is the destination fd for copy_file_range */ const char *linkname; struct iobref *iobref; struct iovec *vector; @@ -301,7 +232,17 @@ typedef struct client_args { struct gf_flock *flock; const char *volume; const char *basename; + off_t offset; + /* + * According to the man page of copy_file_range, + * the offsets for source and destination file + * are of type loff_t. But the type loff_t is + * linux specific and is actual a typedef of + * off64_t. + */ + off64_t off_in; /* used in copy_file_range for source fd */ + off64_t off_out; /* used in copy_file_range for dst fd */ int32_t mask; int32_t cmd; size_t size; @@ -323,6 +264,17 @@ typedef struct client_args { lock_migration_info_t *locklist; } clnt_args_t; +typedef struct client_payload { + struct iobref *iobref; + struct iovec *payload; + struct iovec *rsphdr; + struct iovec *rsp_payload; + struct iobref *rsp_iobref; + int payload_cnt; + int rsphdr_cnt; + int rsp_payload_cnt; +} client_payload_t; + typedef ssize_t (*gfs_serialize_t)(struct iovec outmsg, void *args); clnt_fd_ctx_t * @@ -337,19 +289,7 @@ client_local_wipe(clnt_local_t *local); int client_submit_request(xlator_t *this, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbk, - struct iobref *iobref, struct iovec *rsphdr, - int rsphdr_count, struct iovec *rsp_payload, - int rsp_count, struct iobref *rsp_iobref, - 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); + client_payload_t *cp, xdrproc_t xdrproc); int unserialize_rsp_dirent(xlator_t *this, struct gfs3_readdir_rsp *rsp, @@ -374,8 +314,6 @@ void client_save_number_fds(clnt_conf_t *conf, int count); int dump_client_locks(inode_t *inode); -int -client_notify_parents_child_up(xlator_t *this); int32_t is_client_dump_locks_cmd(char *name); int32_t @@ -383,12 +321,6 @@ client_dump_locks(char *name, inode_t *inode, dict_t *dict); int client_fdctx_destroy(xlator_t *this, clnt_fd_ctx_t *fdctx); -int32_t -client_type_to_gf_type(short l_type); - -int -client_mark_fd_bad(xlator_t *this); - int client_fd_lk_list_empty(fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock); void @@ -413,19 +345,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 @@ -439,9 +358,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 @@ -469,18 +385,10 @@ 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); +client_add_lock_for_recovery(fd_t *fd, struct gf_flock *flock, + gf_lkowner_t *owner, int32_t cmd); + 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); +client_is_setlk(int32_t cmd); #endif /* !_CLIENT_H */ |
