From 8f053f9d7270f1c6d50c0b3ab5d020503ceeb31a Mon Sep 17 00:00:00 2001 From: Poornima G Date: Mon, 11 Jul 2016 15:04:55 +0530 Subject: md-cache: Register the list of xattrs with cache-invalidation Issue: md-cache caches a specified list of xattrs, and when cache invalidation is enabled, it makes sense to recieve invalidation only when those xattrs are modified by other clients. But the current implementation of upcall is that, it will send invalidation when any of the on-disk xattrs is modified. Solution: md-cache sends a list of xattrs that it is interested in, to upcall by issuing an ipc(). The challenge here is to make sure everytime a brick goes offline and comes back up, the ipc() needs to be issued to the bricks. Hence ipc() is sent from md-cache every time there is a CHILD_UP/CHILD_MODIFIED event. TODO: There will be patches following, in cluster xlators, to implement ipc fop. Change-Id: I6efcf3df474f5ce6eabd3d6694c00c7bd89bc25d BUG: 1211863 Signed-off-by: Poornima G Reviewed-on: http://review.gluster.org/15002 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Rajesh Joseph NetBSD-regression: NetBSD Build System Reviewed-by: Prashanth Pai Reviewed-by: Raghavendra G --- libglusterfs/src/dict.c | 20 ++++++++++++++++++++ libglusterfs/src/dict.h | 2 ++ libglusterfs/src/syncop.h | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 6f7adb51589..96cb9e94bda 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -473,6 +473,26 @@ dict_get (dict_t *this, char *key) return NULL; } +int +dict_key_count (dict_t *this) +{ + int ret = -1; + + if (!this) { + gf_msg_callingfn ("dict", GF_LOG_WARNING, EINVAL, + LG_MSG_INVALID_ARG, "dict passed is NULL"); + return ret; + } + + LOCK (&this->lock); + { + ret = this->count; + } + UNLOCK (&this->lock); + + return ret; +} + void dict_del (dict_t *this, char *key) { diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h index 04f0ed9b164..a7fb6c78425 100644 --- a/libglusterfs/src/dict.h +++ b/libglusterfs/src/dict.h @@ -107,6 +107,8 @@ data_t *dict_get (dict_t *this, char *key); void dict_del (dict_t *this, char *key); int dict_reset (dict_t *dict); +int dict_key_count (dict_t *this); + int32_t dict_serialized_length (dict_t *dict); int32_t dict_serialize (dict_t *dict, char *buf); int32_t dict_unserialize (char *buf, int32_t size, dict_t **fill); diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index c2387e62cd2..0d0da58f4cf 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -258,6 +258,29 @@ struct syncopctx { } while (0) +/* + * syncop_xxx() calls are executed in two ways, one is inside a synctask where + * the executing function will do 'swapcontext' and the other is without + * synctask where the executing thread is made to wait using pthread_cond_wait. + * Executing thread may change when syncop_xxx() is executed inside a synctask. + * This leads to errno_location change i.e. errno may give errno of + * non-executing thread. So errno is not touched inside a synctask execution. + * All gfapi calls are executed using the second way of executing syncop_xxx() + * where the executing thread waits using pthread_cond_wait so it is ok to set + * errno in these cases. The following macro makes syncop_xxx() behave just + * like a system call, where -1 is returned and errno is set when a failure + * occurs. + */ +#define DECODE_SYNCOP_ERR(ret) do { \ + if (ret < 0) { \ + errno = -ret; \ + ret = -1; \ + } else { \ + errno = 0; \ + } \ + } while (0) + + #define SYNCENV_DEFAULT_STACKSIZE (2 * 1024 * 1024) struct syncenv * syncenv_new (size_t stacksize, int procmin, int procmax); -- cgit