From 66b8462719bee337db85abc5b2ed8657b71f073c Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Tue, 30 May 2017 18:01:26 +0530 Subject: debug/trace: Implement seek fop Change-Id: Idd1b92201348a76a6145b38799a3a46cab730540 BUG: 1458193 Signed-off-by: Krutika Dhananjay Reviewed-on: https://review.gluster.org/17437 Smoke: Gluster Build System Reviewed-by: Niels de Vos NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/debug/trace/src/trace.c | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index 555147aec47..451ef9a0fe7 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -2168,6 +2168,51 @@ out: return 0; } +static int +trace_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, off_t offset, dict_t *xdata) +{ + trace_conf_t *conf = this->private; + + if (!conf->log_file && !conf->log_history) + goto out; + if (trace_fop_names[GF_FOP_SEEK].enabled) { + char string[4096] = {0,}; + snprintf (string, sizeof (string), + "%"PRId64": gfid=%s op_ret=%d op_errno=%d, " + "offset=%"PRId64"", frame->root->unique, + uuid_utoa (frame->local), op_ret, op_errno, offset); + LOG_ELEMENT (conf, string); + } +out: + TRACE_STACK_UNWIND (seek, frame, op_ret, op_errno, offset, xdata); + return 0; +} + +static int +trace_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, + off_t offset, gf_seek_what_t what, dict_t *xdata) +{ + trace_conf_t *conf = this->private; + + if (!conf->log_file && !conf->log_history) + goto out; + if (trace_fop_names[GF_FOP_SEEK].enabled) { + char string[4096] = {0,}; + snprintf (string, sizeof (string), "%"PRId64": gfid=%s fd=%p " + "offset=%"PRId64" what=%d", frame->root->unique, + uuid_utoa (fd->inode->gfid), fd, offset, what); + + frame->local = fd->inode->gfid; + LOG_ELEMENT (conf, string); + } +out: + STACK_WIND (frame, trace_seek_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->seek, fd, offset, what, xdata); + + return 0; +} + int trace_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, dict_t *xdata) @@ -3280,6 +3325,7 @@ struct xlator_fops fops = { .fxattrop = trace_fxattrop, .setattr = trace_setattr, .fsetattr = trace_fsetattr, + .seek = trace_seek, }; struct xlator_cbks cbks = { -- cgit