summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-01-27 16:53:35 +0530
committerNiels de Vos <ndevos@redhat.com>2015-02-23 04:51:43 -0800
commitbf22868f82c89e0ee68d394a2257869a36662eaa (patch)
tree575569c8fa8f50660cb8a760bd5e5c2f528d08e1
parent30357bcfcd4a7c92e0e59ff58a26d48c8416c564 (diff)
libglusterfs: Added support to set 'frame->root->lkowner'
This support can be used by the clients using SYNCOP framework, to pass unique owners for various locks taken on a file, so that the glusterfs-server can treat them as being locks from different owners. Change-Id: Ie88014053af40fc7913ad6c1f7730d54cc44ddab BUG: 1186713 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/9482 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--libglusterfs/src/syncop.c40
-rw-r--r--libglusterfs/src/syncop.h6
2 files changed, 46 insertions, 0 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 56042d6897e..f571a2ae8bd 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -209,6 +209,46 @@ out:
return ret;
}
+int
+syncopctx_setfslkowner (gf_lkowner_t *lk_owner)
+{
+ struct syncopctx *opctx = NULL;
+ int ret = 0;
+
+ /* In args check */
+ if (!lk_owner) {
+ ret = -1;
+ errno = EINVAL;
+ goto out;
+ }
+
+ opctx = syncopctx_getctx ();
+
+ /* alloc for this thread the first time */
+ if (!opctx) {
+ opctx = GF_CALLOC (1, sizeof (*opctx), gf_common_mt_syncopctx);
+ if (!opctx) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = syncopctx_setctx (opctx);
+ if (ret != 0) {
+ GF_FREE (opctx);
+ opctx = NULL;
+ goto out;
+ }
+ }
+
+out:
+ if (opctx && lk_owner) {
+ opctx->lk_owner = *lk_owner;
+ opctx->valid |= SYNCOPCTX_LKOWNER;
+ }
+
+ return ret;
+}
+
static void
__run (struct synctask *task)
{
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index 40ed0e865e3..3f751de6da5 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -32,6 +32,7 @@
#define SYNCOPCTX_GID 0x00000002
#define SYNCOPCTX_GROUPS 0x00000004
#define SYNCOPCTX_PID 0x00000008
+#define SYNCOPCTX_LKOWNER 0x00000010
struct synctask;
struct syncproc;
@@ -167,6 +168,7 @@ struct syncopctx {
int ngrps;
gid_t *groups;
pid_t pid;
+ gf_lkowner_t lk_owner;
};
#define __yawn(args) do { \
@@ -264,6 +266,7 @@ int syncopctx_setfsuid (void *uid);
int syncopctx_setfsgid (void *gid);
int syncopctx_setfsgroups (int count, const void *groups);
int syncopctx_setfspid (void *pid);
+int syncopctx_setfslkowner (gf_lkowner_t *lk_owner);
static inline call_frame_t *
syncop_create_frame (xlator_t *this)
@@ -324,6 +327,9 @@ syncop_create_frame (xlator_t *this)
}
}
+ if (opctx && (opctx->valid & SYNCOPCTX_LKOWNER))
+ frame->root->lk_owner = opctx->lk_owner;
+
return frame;
}