diff options
author | Poornima G <pgurusid@redhat.com> | 2015-04-29 13:03:52 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-09 06:52:46 -0700 |
commit | 5fd6b3b7e2881d21a1b19fb22366e905314d71bc (patch) | |
tree | 7531a8c062fae1599aebbf4506af4ccf930e2413 /api/src/glfs-internal.h | |
parent | 972458a74780923e7e867b9362dda1830eeefe5e (diff) |
libgfapi: Store and restore THIS in every API exposed by libgfapi
Backport of http://review.gluster.org/#/c/9797
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>
(cherry picked from commit 1162bb36108ab8dba8303b86927a99835b791d79)
Reviewed-on: http://review.gluster.org/10414
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'api/src/glfs-internal.h')
-rw-r--r-- | api/src/glfs-internal.h | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h index 3c83fe848ff..84935f50cc9 100644 --- a/api/src/glfs-internal.h +++ b/api/src/glfs-internal.h @@ -199,18 +199,32 @@ int glfs_first_lookup (xlator_t *subvol); void glfs_process_upcall_event (struct glfs *fs, void *data); GFAPI_PRIVATE(glfs_process_upcall_event, 3.7.0); -static inline void -__glfs_entry_fs (struct glfs *fs) -{ - THIS = fs->ctx->master; -} - - -static inline void -__glfs_entry_fd (struct glfs_fd *fd) -{ - THIS = fd->fd->inode->table->xl->ctx->master; -} +#define DECLARE_OLD_THIS xlator_t *old_THIS = NULL + +#define __GLFS_ENTRY_VALIDATE_FS(fs, label) \ +do { \ + if (!fs) { \ + errno = EINVAL; \ + goto label; \ + } \ + old_THIS = THIS; \ + THIS = fs->ctx->master; \ +} while (0) + +#define __GLFS_EXIT_FS \ +do { \ + THIS = old_THIS; \ +} while (0) + +#define __GLFS_ENTRY_VALIDATE_FD(glfd, label) \ +do { \ + if (!glfd) { \ + errno = EINVAL; \ + goto label; \ + } \ + old_THIS = THIS; \ + THIS = glfd->fd->inode->table->xl->ctx->master; \ +} while (0) /* |