summaryrefslogtreecommitdiffstats
path: root/xlators/features/barrier
diff options
context:
space:
mode:
authorggarg <ggarg@redhat.com>2014-05-27 17:08:53 +0530
committerKaushal M <kaushal@redhat.com>2014-11-06 22:42:34 -0800
commit1fe785152cc44e78fcd67da5091bc780eb42f1dd (patch)
treeec23e73b81c3816d7a7d8456824c4b2a83cf887b /xlators/features/barrier
parent97ccd45fb66a63c0b2436a0245dfb9490e2941b7 (diff)
barrier: Correct gfid in statedump of barriered fops
In brick statedump file the barriered fop's gfid was showing 0 when statedump was taken. This is because of statedump code was not referring to correct gfid. With this change statedump code will use correct gfid and gfid will not be 0 in statedump file when barrier is enable and user takes statedump of volume. Change-Id: Ia296cba7e132402df53c602daa160c1c2cd21245 BUG: 1099369 Reviewed-on: http://review.gluster.org/7893 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/features/barrier')
-rw-r--r--xlators/features/barrier/src/barrier.c146
-rw-r--r--xlators/features/barrier/src/barrier.h13
2 files changed, 145 insertions, 14 deletions
diff --git a/xlators/features/barrier/src/barrier.c b/xlators/features/barrier/src/barrier.c
index f2d8d96..d94953b 100644
--- a/xlators/features/barrier/src/barrier.c
+++ b/xlators/features/barrier/src/barrier.c
@@ -19,6 +19,134 @@
#include "statedump.h"
+void
+barrier_local_set_gfid (call_frame_t *frame, uuid_t gfid, xlator_t *this)
+{
+ if (gfid) {
+ uuid_t *id = GF_MALLOC (sizeof (uuid_t), gf_common_mt_uuid_t);
+ if (!id) {
+ gf_log (this->name, GF_LOG_WARNING, "Could not set gfid"
+ ". gfid will not be dumped in statedump file.");
+ return;
+ }
+ uuid_copy (*id, gfid);
+ frame->local = id;
+ }
+}
+
+void
+barrier_local_free_gfid (call_frame_t *frame)
+{
+ if (frame->local) {
+ GF_FREE (frame->local);
+ frame->local = NULL;
+ }
+}
+
+int32_t
+barrier_truncate_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf,
+ dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
+}
+
+int32_t
+barrier_ftruncate_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf,
+ dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno, prebuf,
+ postbuf, xdata);
+ return 0;
+}
+
+int32_t
+barrier_unlink_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (unlink, frame, op_ret, op_errno, preparent,
+ postparent, xdata);
+ return 0;
+}
+
+int32_t
+barrier_rmdir_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (rmdir, frame, op_ret, op_errno, preparent,
+ postparent, xdata);
+ return 0;
+}
+
+int32_t
+barrier_rename_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf,
+ struct iatt *preoldparent, struct iatt *postoldparent,
+ struct iatt *prenewparent, struct iatt *postnewparent,
+ dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (rename, frame, op_ret, op_errno, buf, preoldparent,
+ postoldparent, prenewparent, postnewparent, xdata);
+ return 0;
+}
+
+int32_t
+barrier_writev_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct iatt *prebuf, struct iatt *postbuf,
+ dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
+}
+
+int32_t
+barrier_fsync_cbk_resume (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (fsync, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
+}
+
+int32_t
+barrier_removexattr_cbk_resume (call_frame_t *frame, void *cookie,
+ xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, xdata);
+ return 0;
+}
+
+int32_t
+barrier_fremovexattr_cbk_resume (call_frame_t *frame, void *cookie,
+ xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xdata)
+{
+ barrier_local_free_gfid (frame);
+ STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno, xdata);
+ return 0;
+}
+
int32_t
barrier_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
@@ -133,6 +261,7 @@ barrier_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
return 0;
}
+ barrier_local_set_gfid (frame, fd->inode->gfid, this);
STACK_WIND (frame, barrier_writev_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->writev, fd, vector, count,
off, flags, iobref, xdata);
@@ -143,6 +272,7 @@ int32_t
barrier_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
const char *name, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, fd->inode->gfid, this);
STACK_WIND (frame, barrier_fremovexattr_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fremovexattr,
fd, name, xdata);
@@ -153,6 +283,7 @@ int32_t
barrier_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, loc->inode->gfid, this);
STACK_WIND (frame, barrier_removexattr_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->removexattr,
loc, name, xdata);
@@ -163,16 +294,19 @@ int32_t
barrier_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
off_t offset, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, loc->inode->gfid, this);
STACK_WIND (frame, barrier_truncate_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->truncate,
loc, offset, xdata);
return 0;
}
+
int32_t
barrier_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
loc_t *newloc, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, oldloc->inode->gfid, this);
STACK_WIND (frame, barrier_rename_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->rename,
oldloc, newloc, xdata);
@@ -183,6 +317,7 @@ int
barrier_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
dict_t *xdata)
{
+ barrier_local_set_gfid (frame, loc->inode->gfid, this);
STACK_WIND (frame, barrier_rmdir_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->rmdir,
loc, flags, xdata);
@@ -193,6 +328,7 @@ int32_t
barrier_unlink (call_frame_t *frame, xlator_t *this,
loc_t *loc, int xflag, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, loc->inode->gfid, this);
STACK_WIND (frame, barrier_unlink_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->unlink,
loc, xflag, xdata);
@@ -203,6 +339,7 @@ int32_t
barrier_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
off_t offset, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, fd->inode->gfid, this);
STACK_WIND (frame, barrier_ftruncate_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->ftruncate,
fd, offset, xdata);
@@ -213,6 +350,7 @@ int32_t
barrier_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t flags, dict_t *xdata)
{
+ barrier_local_set_gfid (frame, fd->inode->gfid, this);
STACK_WIND (frame, barrier_fsync_cbk, FIRST_CHILD (this),
FIRST_CHILD (this)->fops->fsync,
fd, flags, xdata);
@@ -552,9 +690,11 @@ barrier_dump_stub (call_stub_t *stub, char *prefix)
gf_proc_dump_build_key (key, prefix, "fop");
gf_proc_dump_write (key, "%s", gf_fop_list[stub->fop]);
- gf_proc_dump_build_key (key, prefix, "gfid");
- gf_proc_dump_write (key, "%s", uuid_utoa (stub->args.loc.gfid));
-
+ if (stub->frame->local) {
+ gf_proc_dump_build_key (key, prefix, "gfid");
+ gf_proc_dump_write (key, "%s",
+ uuid_utoa (*(uuid_t*)(stub->frame->local)));
+ }
if (stub->args.loc.path) {
gf_proc_dump_build_key (key, prefix, "path");
gf_proc_dump_write (key, "%s", stub->args.loc.path);
diff --git a/xlators/features/barrier/src/barrier.h b/xlators/features/barrier/src/barrier.h
index 8face9f..0d646f9 100644
--- a/xlators/features/barrier/src/barrier.h
+++ b/xlators/features/barrier/src/barrier.h
@@ -16,15 +16,6 @@
#include "timer.h"
#include "call-stub.h"
-#define BARRIER_SAFE_ASSIGN(lock, to, value) \
- do { \
- LOCK (&(lock)); \
- { \
- to = value; \
- } \
- UNLOCK (&(lock)); \
- } while (0)
-
#define BARRIER_FOP_CBK(fop_name, label, frame, this, params ...) \
do { \
barrier_priv_t *_priv = NULL; \
@@ -44,7 +35,7 @@
\
_stub = fop_##fop_name##_cbk_stub \
(frame, \
- default_##fop_name##_cbk_resume,\
+ barrier_##fop_name##_cbk_resume,\
params); \
if (!_stub) { \
__barrier_disable (this, &queue);\
@@ -67,7 +58,7 @@ unlock: \
#fop_name, strerror (ENOMEM)); \
barrier_dequeue_all (this, &queue); \
} \
- \
+ barrier_local_free_gfid (frame); \
STACK_UNWIND_STRICT (fop_name, frame, params); \
goto label; \
} while (0)