diff options
author | Soumya Koduri <skoduri@redhat.com> | 2015-06-12 13:45:09 +0530 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2015-06-27 16:22:51 -0700 |
commit | b68f671b2b8a0aafef8f98145aee7044edaa907d (patch) | |
tree | 96a8e2d6a252692887161b3e255aae2cf1db62ce /api | |
parent | 58a736111fa1db4f10c6646e81066434260f674f (diff) |
Upcall/gfapi: Return ENOTSUP when upcall feature is disabled
Changes to detect the list of upcall events enabled using GF_FOP_IPC
and return ENOTSUP to applications in case if they poll for any of
the events disabled.
Change-Id: Icc748054ef903598288119dbe99b1e337174662a
BUG: 1231132
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Reviewed-on: http://review.gluster.org/11196
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/src/glfs-handleops.c | 12 | ||||
-rw-r--r-- | api/src/glfs-handles.h | 1 | ||||
-rw-r--r-- | api/src/glfs-internal.h | 1 | ||||
-rw-r--r-- | api/src/glfs.c | 59 |
4 files changed, 72 insertions, 1 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index c010f0c9a0f..f458cb4bd58 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -1881,6 +1881,18 @@ pub_glfs_h_poll_upcall (struct glfs *fs, struct callback_arg *up_arg) __GLFS_ENTRY_VALIDATE_FS (fs, err); + /* check if upcalls are enabled */ + if (!fs->upcall_features) { + errno = ENOTSUP; + goto restore; + } + + /* check if GF_UPCALL_CACHE_INVALIDATION is supported */ + if (!(fs->upcall_features & (1 << GF_UPCALL_CACHE_INVALIDATION))) { + errno = ENOTSUP; + goto restore; + } + /* get the active volume */ subvol = glfs_active_subvol (fs); diff --git a/api/src/glfs-handles.h b/api/src/glfs-handles.h index 19c4e8f7a62..ddb11bf0bd5 100644 --- a/api/src/glfs-handles.h +++ b/api/src/glfs-handles.h @@ -293,6 +293,7 @@ glfs_h_access (struct glfs *fs, struct glfs_object *object, int mask) __THROW 0 : Success. -1 : Error condition, mostly due to out of memory. + 'errno' is set to ENOTSUP if upcall feature is not enabled. */ diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h index 71c83755ec3..5eb57d4b8e4 100644 --- a/api/src/glfs-internal.h +++ b/api/src/glfs-internal.h @@ -199,6 +199,7 @@ struct glfs { gf_boolean_t migration_in_progress; + uint32_t upcall_features; /* supported upcall events */ struct list_head upcall_list; pthread_mutex_t upcall_list_mutex; /* mutex for upcall entry list */ diff --git a/api/src/glfs.c b/api/src/glfs.c index fc392947e1e..7b9f1ed6d01 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -253,6 +253,58 @@ get_volfp (struct glfs *fs) } +static int +detect_upcall_features (struct glfs *fs) +{ + xlator_t *subvol = NULL; + int ret = -1; + dict_t *dict = NULL; + uint32_t features = 0; + + DECLARE_OLD_THIS; + __GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs); + + subvol = glfs_active_subvol (fs); + if (!subvol) { + ret = -1; + errno = EIO; + goto out; + } + + ret = syncop_ipc (subvol, GF_IPC_UPCALL_FEATURES, NULL, &dict); + DECODE_SYNCOP_ERR (ret); + + if (ret) + /* some real error occured */ + goto out; + + if (!dict) { + /* unavailable upcalls should not be an error */ + ret = 0; + goto out; + } + + ret = dict_get_uint32 (dict, GF_UPCALL_FEATURES, &features); + if (ret) { + /* unavailable upcalls should not be an error */ + ret = 0; + goto out; + } + + fs->upcall_features = features; + +out: + if (dict) + dict_unref (dict); + + glfs_subvol_done (fs, subvol); + __GLFS_EXIT_FS; + +invalid_fs: + return ret; +} + + int glfs_volumes_init (struct glfs *fs) { @@ -267,7 +319,7 @@ glfs_volumes_init (struct glfs *fs) if (cmd_args->volfile_server) { ret = glfs_mgmt_init (fs); - goto out; + goto finish; } fp = get_volfp (fs); @@ -284,6 +336,11 @@ glfs_volumes_init (struct glfs *fs) if (ret) goto out; +finish: + ret = detect_upcall_features (fs); + if (ret) + goto out; + out: return ret; } |