diff options
author | Poornima G <pgurusid@redhat.com> | 2015-04-29 13:03:52 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2015-05-08 15:37:54 -0700 |
commit | 1162bb36108ab8dba8303b86927a99835b791d79 (patch) | |
tree | d5a3261bfd0ed690ecd64a40124d8441e0d498af /api/src/glfs-mgmt.c | |
parent | 0950e6c29fc51ddcc5bb7e1e4187d54ff7c171d2 (diff) |
libgfapi: Store and restore THIS in every API exposed by libgfapi
Storing and restoring THIS:
When the APIs exposed by libgfapi are called by other xlators like
snapview server etc. the THIS value is overwritten to contain the
THIS of libgfapi(viz libgfapi master xlator). Hence using 'THIS'
in any xlator after calling libgfapi API will lead to issues.
One such issue was uncovered in snapview and the patch
http://review.gluster.org/#/c/9469/ was sent to workaround this issue.
Hence, storing and restoring THIS, at the entry and exit of every API
exposed by libgfapi.
Change-Id: I6f330dde25e7700fb26339d667a7ccd193ec6ba0
BUG: 1210934
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/9797
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: soumya k <skoduri@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'api/src/glfs-mgmt.c')
-rw-r--r-- | api/src/glfs-mgmt.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c index 81e9fd63fa0..2159d6795ad 100644 --- a/api/src/glfs-mgmt.c +++ b/api/src/glfs-mgmt.c @@ -339,6 +339,9 @@ pub_glfs_get_volumeid (struct glfs *fs, char *volid, size_t size) /* TODO: Define a global macro to store UUID size */ size_t uuid_size = 16; + DECLARE_OLD_THIS; + __GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs); + pthread_mutex_lock (&fs->mutex); { /* check if the volume uuid is initialized */ @@ -356,12 +359,13 @@ pub_glfs_get_volumeid (struct glfs *fs, char *volid, size_t size) gf_msg (THIS->name, GF_LOG_ERROR, EINVAL, API_MSG_FETCH_VOLUUID_FAILED, "Unable to fetch " "volume UUID"); - return -1; + goto out; } done: if (!volid || !size) { gf_msg_debug (THIS->name, 0, "volumeid/size is null"); + __GLFS_EXIT_FS; return uuid_size; } @@ -369,12 +373,20 @@ done: gf_msg (THIS->name, GF_LOG_ERROR, ERANGE, API_MSG_INSUFF_SIZE, "Insufficient size passed"); errno = ERANGE; - return -1; + goto out; } memcpy (volid, fs->vol_uuid, uuid_size); + __GLFS_EXIT_FS; + return uuid_size; + +out: + __GLFS_EXIT_FS; + +invalid_fs: + return -1; } GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_get_volumeid, 3.5.0); |