summaryrefslogtreecommitdiffstats
path: root/xlators/features/upcall/src/upcall.h
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-02-15 23:35:56 +0530
committerKaleb KEITHLEY <kkeithle@redhat.com>2015-03-17 05:08:07 -0700
commit2b97b57cd8c71cb07b7002cf3483e9cfc9403c58 (patch)
tree9fc96451b469e213348f3065ca07e7a7c5a96ec0 /xlators/features/upcall/src/upcall.h
parent79009691c01f2b32b523d91a159aadd0e414f31b (diff)
Upcall: New xlator to store various states and send cbk events
Framework on the server-side, to handle certain state of the files accessed and send notifications to the clients connected. A generic and extensible framework, used to maintain states in the glusterfsd process for each of the files accessed (including the clients info doing the fops) and send notifications to the respective glusterfs clients incase of any change in that state. This patch handles "Inode Update/Invalidation" upcall event. Feature page: URL: http://www.gluster.org/community/documentation/index.php/Features/Upcall-infrastructure Below link has a writeup which explains the code changes done - URL: https://soumyakoduri.wordpress.com/2015/02/25/glusterfs-understanding-upcall-infrastructure-and-cache-invalidation-support/ Change-Id: Ie3d724be9a3419fcf18901a753e8ec2df2ac802f BUG: 1200262 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/9535 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/upcall/src/upcall.h')
-rw-r--r--xlators/features/upcall/src/upcall.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/xlators/features/upcall/src/upcall.h b/xlators/features/upcall/src/upcall.h
new file mode 100644
index 00000000000..a5aff9d091e
--- /dev/null
+++ b/xlators/features/upcall/src/upcall.h
@@ -0,0 +1,134 @@
+/*
+ Copyright (c) 2015 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 __UPCALL_H__
+#define __UPCALL_H__
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "compat-errno.h"
+#include "stack.h"
+#include "call-stub.h"
+#include "upcall-mem-types.h"
+#include "client_t.h"
+#include "rpcsvc.h"
+#include "lkowner.h"
+#include "locking.h"
+#include "upcall-messages.h"
+#include "upcall-cache-invalidation.h"
+
+#define EXIT_IF_UPCALL_OFF(label) do { \
+ if (!(ON_CACHE_INVALIDATION)) \
+ goto label; \
+} while (0)
+
+#define UPCALL_STACK_UNWIND(fop, frame, params ...) do { \
+ upcall_local_t *__local = NULL; \
+ xlator_t *__xl = NULL; \
+ if (frame) { \
+ __xl = frame->this; \
+ __local = frame->local; \
+ frame->local = NULL; \
+ } \
+ STACK_UNWIND_STRICT (fop, frame, params); \
+ upcall_local_wipe (__xl, __local); \
+ } while (0)
+
+#define UPCALL_STACK_DESTROY(frame) do { \
+ upcall_local_t *__local = NULL; \
+ xlator_t *__xl = NULL; \
+ __xl = frame->this; \
+ __local = frame->local; \
+ frame->local = NULL; \
+ STACK_DESTROY (frame->root); \
+ upcall_local_wipe (__xl, __local); \
+ } while (0)
+
+struct _upcalls_private_t {
+ int client_id; /* Not sure if reqd */
+};
+typedef struct _upcalls_private_t upcalls_private_t;
+
+enum _upcall_event_type_t {
+ EVENT_NULL,
+ CACHE_INVALIDATION,
+};
+typedef enum _upcall_event_type_t upcall_event_type_t;
+
+struct _upcall_client_t {
+ struct list_head client_list;
+ /* strdup to store client_uid, strdup. Free it explicitly */
+ char *client_uid;
+ time_t access_time; /* time last accessed */
+ /* the amount of time which client can cache this entry */
+ uint32_t expire_time_attr;
+};
+typedef struct _upcall_client_t upcall_client_t;
+
+/* Upcall entries are maintained in inode_ctx */
+struct _upcall_inode_ctx_t {
+ struct list_head client_list;
+ pthread_mutex_t client_list_lock; /* mutex for clients list
+ of this upcall entry */
+};
+typedef struct _upcall_inode_ctx_t upcall_inode_ctx_t;
+
+struct _notify_event_data {
+ uuid_t gfid;
+ upcall_client_t *client_entry;
+ upcall_event_type_t event_type;
+ uint32_t invalidate_flags;
+ /* any extra data needed, like inode flags
+ * to be invalidated incase of cache invalidation,
+ * may be fd for lease recalls */
+ void *extra;
+};
+typedef struct _notify_event_data notify_event_data_t;
+
+struct upcall_local {
+ /* XXX: need to check if we can store
+ * pointers in 'local' which may get freed
+ * in future by other thread
+ */
+ upcall_inode_ctx_t *upcall_inode_ctx;
+ inode_t *inode;
+};
+typedef struct upcall_local upcall_local_t;
+
+void upcall_local_wipe (xlator_t *this, upcall_local_t *local);
+upcall_local_t *upcall_local_init (call_frame_t *frame, xlator_t *this, inode_t *inode);
+
+upcall_client_t *add_upcall_client (call_frame_t *frame, uuid_t gfid,
+ client_t *client,
+ upcall_inode_ctx_t *up_inode_ctx);
+upcall_client_t *__add_upcall_client (call_frame_t *frame, uuid_t gfid,
+ client_t *client,
+ upcall_inode_ctx_t *up_inode_ctx);
+upcall_client_t *__get_upcall_client (call_frame_t *frame, uuid_t gfid,
+ client_t *client,
+ upcall_inode_ctx_t *up_inode_ctx);
+int __upcall_cleanup_client_entry (upcall_client_t *up_client);
+
+int __upcall_inode_ctx_set (inode_t *inode, xlator_t *this);
+upcall_inode_ctx_t *__upcall_inode_ctx_get (inode_t *inode, xlator_t *this);
+upcall_inode_ctx_t *upcall_inode_ctx_get (inode_t *inode, xlator_t *this);
+int upcall_cleanup_inode_ctx (xlator_t *this, inode_t *inode);
+
+void upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client,
+ inode_t *inode, uint32_t flags);
+void upcall_client_cache_invalidate (xlator_t *xl, uuid_t gfid,
+ upcall_client_t *up_client_entry,
+ uint32_t flags);
+void upcall_cache_forget (xlator_t *this, inode_t *inode,
+ upcall_inode_ctx_t *up_inode_ctx);
+
+#endif /* __UPCALL_H__ */