diff options
| author | Soumya Koduri <skoduri@redhat.com> | 2015-03-30 16:56:59 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-07 04:19:16 -0700 | 
| commit | ea8d9ebafa4a6afb99721022e638292fd475ed62 (patch) | |
| tree | 3419bbcd116abd6b8361a3b0a997081cddc82139 /api/src/glfs-fops.c | |
| parent | 14011cb0383ac19b98b02f0caec5a1977ecd7c35 (diff) | |
Upcall: Process each of the upcall events separately
As suggested during the code-review of Bug1200262, have modified
GF_CBK_UPCALL to be exlusively GF_CBK_CACHE_INVALIDATION.
Thus, for any new upcall event, a new CBK procedure will be added.
Also made changes to store upcall data separately based on the
upcall event type received.
BUG: 1217711
Change-Id: I0f5e53d6f5ece16aecb514a0a426dca40fa1c755
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Reviewed-on: http://review.gluster.org/10049
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/10562
Tested-by: NetBSD Build System
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'api/src/glfs-fops.c')
| -rw-r--r-- | api/src/glfs-fops.c | 74 | 
1 files changed, 67 insertions, 7 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index ba95e021ee2..0e32ec2ee78 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -14,6 +14,7 @@  #include "glfs-mem-types.h"  #include "syncop.h"  #include "glfs.h" +#include "gfapi-messages.h"  #include "compat-errno.h"  #include <limits.h>  #include "glusterfs3.h" @@ -26,6 +27,48 @@  #define READDIRBUF_SIZE (sizeof(struct dirent) + GF_NAME_MAX + 1) +/* + * This routine is called when an upcall event of type + * 'GF_UPCALL_CACHE_INVALIDATION' is received. + * It makes a copy of the contents of the upcall cache-invalidation + * data received into an entry which is stored in the upcall list + * maintained by gfapi. + */ +int +glfs_get_upcall_cache_invalidation (struct gf_upcall *to_up_data, +                                    struct gf_upcall *from_up_data) +{ + +        struct gf_upcall_cache_invalidation *ca_data = NULL; +        struct gf_upcall_cache_invalidation *f_ca_data = NULL; +        int                                 ret      = -1; + +        GF_VALIDATE_OR_GOTO (THIS->name, to_up_data, out); +        GF_VALIDATE_OR_GOTO (THIS->name, from_up_data, out); + +        f_ca_data = from_up_data->data; +        GF_VALIDATE_OR_GOTO (THIS->name, f_ca_data, out); + +        ca_data = GF_CALLOC (1, sizeof(*ca_data), +                            glfs_mt_upcall_entry_t); + +        if (!ca_data) { +                gf_msg (THIS->name, GF_LOG_ERROR, errno, +                        API_MSG_ALLOC_FAILED, +                        "Upcall entry allocation failed."); +                goto out; +        } + +        to_up_data->data = ca_data; + +        ca_data->flags = f_ca_data->flags; +        ca_data->expire_time_attr = f_ca_data->expire_time_attr; + +        ret = 0; +out: +        return ret; +} +  int  glfs_loc_link (loc_t *loc, struct iatt *iatt)  { @@ -3492,7 +3535,6 @@ void  priv_glfs_process_upcall_event (struct glfs *fs, void *data)  {          int                ret             = -1; -        inode_t            *inode          = NULL;          uuid_t             gfid;          upcall_entry       *u_list         = NULL;          glusterfs_ctx_t    *ctx            = NULL; @@ -3522,12 +3564,12 @@ priv_glfs_process_upcall_event (struct glfs *fs, void *data)          }          pthread_mutex_unlock (&fs->mutex); +          upcall_data = (struct gf_upcall *)data; -        gf_log (THIS->name, GF_LOG_DEBUG, "Upcall gfapi gfid = %s" +        gf_log (THIS->name, GF_LOG_TRACE, "Upcall gfapi gfid = %s"                  "ret = %d", (char *)(upcall_data->gfid), ret); -        memcpy(gfid, (char *)(upcall_data->gfid), 16);          u_list = GF_CALLOC (1, sizeof(*u_list),                              glfs_mt_upcall_entry_t); @@ -3539,10 +3581,24 @@ priv_glfs_process_upcall_event (struct glfs *fs, void *data)          INIT_LIST_HEAD (&u_list->upcall_list); -        gf_uuid_copy (u_list->gfid, gfid); -        u_list->event_type = upcall_data->event_type; -        u_list->flags = (uint32_t)(upcall_data->flags); -        u_list->expire_time_attr = upcall_data->expire_time_attr; +        gf_uuid_copy (u_list->upcall_data.gfid, upcall_data->gfid); +        u_list->upcall_data.event_type = upcall_data->event_type; + +        switch (upcall_data->event_type) { +        case GF_UPCALL_CACHE_INVALIDATION: +                ret = glfs_get_upcall_cache_invalidation (&u_list->upcall_data, +                                                          upcall_data); +                break; +        default: +                goto out; +        } + +        if (ret) { +                gf_msg (THIS->name, GF_LOG_ERROR, errno, +                        API_MSG_INVALID_ENTRY, +                        "Upcall entry validation failed."); +                goto out; +        }          pthread_mutex_lock (&fs->upcall_list_mutex);          { @@ -3556,7 +3612,11 @@ priv_glfs_process_upcall_event (struct glfs *fs, void *data)                  fs->pin_refcnt--;          }          pthread_mutex_unlock (&fs->mutex); + +        ret = 0;  out: +        if (ret && u_list) +                GF_FREE(u_list);          return;  }  | 
