diff options
| author | Rajesh Amaravathi <rajesh@redhat.com> | 2013-06-21 11:31:11 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-06-21 10:33:49 -0700 | 
| commit | 3f72e52c936edf7d1477a69fa3a01f89e0576881 (patch) | |
| tree | 633d418eef5eef2677ba8db6a1d43e13f983a14b /rpc/rpc-lib/src/rpc-drc.h | |
| parent | 4cde70a0e5be0a5e49e42c48365f3c0b205f9741 (diff) | |
rpc: duplicate request cache for nfs
Duplicate request cache provides a mechanism for detecting
duplicate rpc requests from clients. DRC caches replies
and on duplicate requests, sends the cached reply instead of
re-processing the request.
Change-Id: I3d62a6c4aa86c92bf61f1038ca62a1a46bf1c303
BUG: 847624
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.org/4049
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'rpc/rpc-lib/src/rpc-drc.h')
| -rw-r--r-- | rpc/rpc-lib/src/rpc-drc.h | 100 | 
1 files changed, 100 insertions, 0 deletions
diff --git a/rpc/rpc-lib/src/rpc-drc.h b/rpc/rpc-lib/src/rpc-drc.h new file mode 100644 index 00000000000..0a1688992d5 --- /dev/null +++ b/rpc/rpc-lib/src/rpc-drc.h @@ -0,0 +1,100 @@ +/* +  Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com> +  This file is part of GlusterFS. + +  This file is licensed to you under your choice of the GNU Lesser +  General Public License, version 3 or any later version (LGPLv3 or +  later), or the GNU General Public License, version 2 (GPLv2), in all +  cases as published by the Free Software Foundation. +*/ + +#ifndef RPC_DRC_H +#define RPC_DRC_H + +#ifndef _CONFIG_H +#define _CONFIG_H +#include "config.h" +#endif + +#include "rpcsvc-common.h" +#include "rpcsvc.h" +#include "locking.h" +#include "dict.h" +#include "rb.h" + +/* per-client cache structure */ +struct drc_client { +        uint32_t                   ref; +        union gf_sock_union        sock_union; +        /* pointers to the cache */ +        struct rb_table           *rbtree; +        /* no. of ops currently cached */ +        uint32_t                   op_count; +        struct list_head           client_list; +}; + +struct drc_cached_op { +        drc_op_state_t                 state; +        uint32_t                       xid; +        int                            prognum; +        int                            progversion; +        int                            procnum; +        rpc_transport_msg_t            msg; +        drc_client_t                  *client; +        struct list_head               client_list; +        struct list_head               global_list; +        int32_t                        ref; +}; + +/* global drc definitions */ +enum drc_status { +        DRC_UNINITIATED, +        DRC_INITIATED +}; +typedef enum drc_status drc_status_t; + +struct drc_globals { +        /* allocator must be the first member since +         * it is used so in gf_libavl_allocator +         */ +        struct libavl_allocator   allocator; +        drc_type_t                type; +        /* configurable size parameter */ +        uint32_t                  global_cache_size; +        drc_lru_factor_t          lru_factor; +        gf_lock_t                 lock; +        drc_status_t              status; +        uint32_t                  op_count; +        uint64_t                  cache_hits; +        uint64_t                  intransit_hits; +        struct mem_pool          *mempool; +        struct list_head          cache_head; +        uint32_t                  client_count; +        struct list_head          clients_head; +}; + +int +rpcsvc_need_drc (rpcsvc_request_t *req); + +drc_cached_op_t * +rpcsvc_drc_lookup (rpcsvc_request_t *req); + +int +rpcsvc_send_cached_reply (rpcsvc_request_t *req, drc_cached_op_t *reply); + +int +rpcsvc_cache_reply (rpcsvc_request_t *req, struct iobref *iobref, +                    struct iovec *rpchdr, int rpchdrcount, +                    struct iovec *proghdr, int proghdrcount, +                    struct iovec *payload, int payloadcount); + +int +rpcsvc_cache_request (rpcsvc_request_t *req); + +int32_t +rpcsvc_drc_priv (rpcsvc_drc_globals_t *drc); + +int +rpcsvc_drc_init (rpcsvc_t *svc, dict_t *options); + +#endif /* RPC_DRC_H */  | 
