From af8db4cac8a47da28304b20d07cbeb7cb5a26f45 Mon Sep 17 00:00:00 2001
From: vmallika <vmallika@redhat.com>
Date: Tue, 7 Jul 2015 16:03:26 +0530
Subject: [PATCH 222/234] quota/marker: set lk_owner when taking lock on parent in rename
This is a backport of http://review.gluster.org/#/c/11561/
Before doing a rename operation marker takes inode lock on the file
parent,
here lk_owner is NULL and this can cause accounting problem with
multiple rename on the same directory
This patch fix the problem by setting lk_owner
> Change-Id: Ibb789e39b2833e425d0a5fca85282ff1465206cb
> BUG: 1240598
> Signed-off-by: vmallika <vmallika@redhat.com>
Change-Id: Ia9c8697b0bd5a9c2ee2df971acb23fa7a3a0403b
BUG: 1241048
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/52662
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
libglusterfs/src/lkowner.h | 19 +++++++++++++++++++
xlators/features/marker/src/marker.c | 3 +++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/libglusterfs/src/lkowner.h b/libglusterfs/src/lkowner.h
index 969d13e..cf1e471 100644
--- a/libglusterfs/src/lkowner.h
+++ b/libglusterfs/src/lkowner.h
@@ -80,4 +80,23 @@ is_same_lkowner (gf_lkowner_t *l1, gf_lkowner_t *l2)
return ((l1->len == l2->len) && !memcmp(l1->data, l2->data, l1->len));
}
+static inline int
+is_lk_owner_null (gf_lkowner_t *lkowner)
+{
+ int is_null = 1;
+ int i = 0;
+
+ if (lkowner == NULL || lkowner->len == 0)
+ goto out;
+
+ for (i = 0; i < lkowner->len; i++) {
+ if (lkowner->data[i] != 0) {
+ is_null = 0;
+ break;
+ }
+ }
+out:
+ return is_null;
+}
+
#endif /* _LK_OWNER_H */
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index 414177a..c7c9fd3 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -1598,6 +1598,9 @@ marker_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
local->xdata = dict_ref (xdata);
+ if (is_lk_owner_null (&frame->root->lk_owner))
+ set_lk_owner_from_ptr (&frame->root->lk_owner, frame->root);
+
STACK_WIND (frame,
marker_rename_inodelk_cbk,
FIRST_CHILD(this),
--
1.7.1