📄 trace.c
字号:
this, loc, loc->path, loc->inode); } STACK_WIND (frame, trace_getxattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr, loc); return 0;}int32_t trace_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name){ ERR_EINVAL_NORETURN (!this || !loc || !name); if (fop_names[GF_FOP_REMOVEXATTR].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, loc=%p {path=%s, inode=%p}, name=%s)", this, loc, loc->path, loc->inode, name); } STACK_WIND (frame, trace_removexattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr, loc, name); return 0;}int32_t trace_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd){ ERR_EINVAL_NORETURN (!this || !loc ); if (fop_names[GF_FOP_OPENDIR].enabled) { gf_log (this->name, GF_LOG_NORMAL, "callid: %lld (*this=%p, loc=%p {path=%s, inode=%p}, fd=%p)", (long long) frame->root->unique, this, loc, loc->path, loc->inode, fd); } STACK_WIND (frame, trace_opendir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->opendir, loc, fd); return 0;}int32_t trace_getdents (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset, int32_t flag){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_GETDENTS].enabled) { gf_log (this->name, GF_LOG_NORMAL, "callid: %lld (*this=%p, fd=%p, size=%d, offset=%lld, flag=0x%x)", (long long) frame->root->unique, this, fd, size, offset, flag); } STACK_WIND (frame, trace_getdents_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->getdents, fd, size, offset, flag); return 0;}int32_t trace_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_READDIR].enabled) { gf_log (this->name, GF_LOG_NORMAL, "callid: %lld (fd=%p, size=%d, offset=%lld)", (long long) frame->root->unique, fd, size, offset); } STACK_WIND (frame, trace_readdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdir, fd, size, offset); return 0;}int32_t trace_closedir (call_frame_t *frame, xlator_t *this, fd_t *fd){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_CLOSEDIR].enabled) { gf_log (this->name, GF_LOG_NORMAL, "callid: %lld (*this=%p, *fd=%p)", (long long) frame->root->unique, this, fd); } STACK_WIND (frame, trace_closedir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->closedir, fd); return 0;}int32_t trace_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_FSYNCDIR].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, datasync=%d, *fd=%p)", this, datasync, fd); } STACK_WIND (frame, trace_fsyncdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsyncdir, fd, datasync); return 0;}int32_t trace_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask){ ERR_EINVAL_NORETURN (!this || !loc); if (fop_names[GF_FOP_ACCESS].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, *loc=%p {path=%s, inode=%p}, mask=%d)", this, loc, loc->path, loc->inode, mask); } STACK_WIND (frame, trace_access_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->access, loc, mask); return 0;}int32_t trace_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_FTRUNCATE].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, offset=%lld, *fd=%p)", this, offset, fd); } STACK_WIND (frame, trace_ftruncate_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->ftruncate, fd, offset); return 0;}int32_t trace_fchown (call_frame_t *frame, xlator_t *this, fd_t *fd, uid_t uid, gid_t gid){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_FCHOWN].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, *fd=%p, uid=%d, gid=%d)", this, fd, uid, gid); } STACK_WIND (frame, trace_fchown_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fchown, fd, uid, gid); return 0;}int32_t trace_fchmod (call_frame_t *frame, xlator_t *this, fd_t *fd, mode_t mode){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_FCHMOD].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, mode=%o, *fd=%p)", this, mode, fd); } STACK_WIND (frame, trace_fchmod_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fchmod, fd, mode); return 0;}int32_t trace_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_FSTAT].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, *fd=%p)", this, fd); } STACK_WIND (frame, trace_fstat_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat, fd); return 0;}int32_t trace_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, struct flock *lock){ ERR_EINVAL_NORETURN (!this || !fd); if (fop_names[GF_FOP_LK].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, *fd=%p, cmd=%d, lock=%p {l_type=%d, l_whence=%d, l_start=%lld, l_len=%lld, l_pid=%ld})", this, fd, cmd, lock, lock->l_type, lock->l_whence, lock->l_start, lock->l_len, lock->l_pid); } STACK_WIND (frame, trace_lk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lk, fd, cmd, lock); return 0;}int32_t trace_setdents (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dir_entry_t *entries, int32_t count){ if (fop_names[GF_FOP_SETDENTS].enabled) { gf_log (this->name, GF_LOG_NORMAL, "(*this=%p, *fd=%p, flags=%d, entries=%p count=%d", this, fd, flags, entries, count); } STACK_WIND (frame, trace_setdents_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->setdents, fd, flags, entries, count); return 0;}#ifndef GF_SOLARIS_HOST_OSvoidenable_all_calls (int enabled){ int i; for (i = 0; i < GF_FOP_MAXVALUE; i++) fop_names[i].enabled = enabled;}void enable_call (const char *name, int enabled){ int i; for (i = 0; i < GF_FOP_MAXVALUE; i++) if (!strcmp(fop_names[i].name, name)) fop_names[i].enabled = enabled;}/* include = 1 for "include" = 0 for "exclude" */voidprocess_call_list (const char *list, int include){ enable_all_calls (include ? 0 : 1); char *call = strsep ((char **)&list, ","); while (call) { enable_call (call, include); call = strsep ((char **)&list, ","); }}#endif /* GF_SOLARIS_HOST_OS */int32_t init (xlator_t *this){ dict_t *options = this->options; char *includes = NULL, *excludes = NULL; if (!this) return -1; if (!this->children) { gf_log (this->name, GF_LOG_ERROR, "trace translator requires one subvolume"); return -1; } if (this->children->next) { gf_log (this->name, GF_LOG_ERROR, "trace translator does not support more than one sub-volume"); return -1; }#ifndef GF_SOLARIS_HOST_OS includes = data_to_str (dict_get (options, "include")); excludes = data_to_str (dict_get (options, "exclude")); if (includes && excludes) { gf_log (this->name, GF_LOG_ERROR, "must specify only one of 'include' and 'exclude'"); return -1; } if (includes) process_call_list (includes, 1); if (excludes) process_call_list (excludes, 0);#endif /* GF_SOLARIS_HOST_OS */ gf_log_set_loglevel (GF_LOG_NORMAL); #if 0 void gf_log_xlator (xlator_t *this) { int32_t len; char *buf; if (!this) return; len = dict_serialized_length (this->options); buf = alloca (len); dict_serialize (this->options, buf); gf_log (this->name, GF_LOG_NORMAL, "init (xlator_t *this=%p {name=%s, *next=%p, *parent=%p, *children=%p {xlator=%p, next=%p}, *fops=%p {*open=%p, stat=%p, *readlink=%p, *mknod=%p, *mkdir=%p, *unlink=%p, *rmdir=%p, *symlink=%p, *rename=%p, *link=%p, *chmod=%p, *chown=%p, *truncate=%p, *utimens=%p, *read=%p, *write=%p, *statfs=%p, *flush=%p, *close=%p, *fsync=%p, *setxattr=%p, *getxattr=%p, *removexattr=%p, *opendir=%p, *readdir=%p, *closedir=%p, *fsyncdir=%p, *access=%p, *ftruncate=%p, *fstat=%p}, *mops=%p {*stats=%p, *fsck=%p, *lock=%p, *unlock=%p}, *fini()=%p, *init()=%p, *options=%p {%s}, *private=%p)", this, this->name, this->next, this->parent, this->children, this->children->xlator, this->children->next, this->fops, this->fops->open, this->fops->stat, this->fops->readlink, this->fops->mknod, this->fops->mkdir, this->fops->unlink, this->fops->rmdir, this->fops->symlink, this->fops->rename, this->fops->link, this->fops->chmod, this->fops->chown, this->fops->truncate, this->fops->utimens, this->fops->readv, this->fops->writev, this->fops->statfs, this->fops->flush, this->fops->close, this->fops->fsync, this->fops->setxattr, this->fops->getxattr, this->fops->removexattr, this->fops->opendir, this->fops->readdir, this->fops->closedir, this->fops->fsyncdir, this->fops->access, this->fops->ftruncate, this->fops->fstat, this->mops, this->mops->stats, this->mops->fsck, this->mops->lock, this->mops->unlock, this->fini, this->init, this->options, buf, this->private); } xlator_foreach (this, gf_log_xlator);#endif /* Set this translator's inode table pointer to child node's pointer. */ this->itable = FIRST_CHILD (this)->itable; return 0;}voidfini (xlator_t *this){ if (!this) return; gf_log (this->name, GF_LOG_NORMAL, "fini (xlator_t *this=%p)", this); /* Free up the dictionary options */ dict_destroy (FIRST_CHILD(this)->options); gf_log (this->name, GF_LOG_NORMAL, "trace translator unloaded"); return;}struct xlator_fops fops = { .stat = trace_stat, .readlink = trace_readlink, .mknod = trace_mknod, .mkdir = trace_mkdir, .unlink = trace_unlink, .rmdir = trace_rmdir, .symlink = trace_symlink, .rename = trace_rename, .link = trace_link, .chmod = trace_chmod, .chown = trace_chown, .truncate = trace_truncate, .utimens = trace_utimens, .open = trace_open, .readv = trace_readv, .writev = trace_writev, .statfs = trace_statfs, .flush = trace_flush, .close = trace_close, .fsync = trace_fsync, .setxattr = trace_setxattr, .getxattr = trace_getxattr, .removexattr = trace_removexattr, .opendir = trace_opendir, .readdir = trace_readdir, .closedir = trace_closedir, .fsyncdir = trace_fsyncdir, .access = trace_access, .ftruncate = trace_ftruncate, .fstat = trace_fstat, .create = trace_create, .fchown = trace_fchown, .fchmod = trace_fchmod, .lk = trace_lk, .lookup = trace_lookup, .forget = trace_forget, .setdents = trace_setdents, .getdents = trace_getdents,};int32_t trace_stats_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct xlator_stats *stats){ STACK_UNWIND (frame, op_ret, op_errno, stats); return 0;}int32_t trace_stats (call_frame_t *frame, xlator_t *this, int32_t flags){ ERR_EINVAL_NORETURN (!this); { gf_log (this->name, GF_LOG_NORMAL, "trace_stats (*this=%p, flags=%d\n", this, flags); STACK_WIND (frame, trace_stats_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->mops->stats, flags); } return 0;}int32_ttrace_checksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, uint8_t *fchecksum, uint8_t *dchecksum){ gf_log (this->name, GF_LOG_NORMAL, "op_ret (%d), op_errno(%d)", op_ret, op_errno); STACK_UNWIND (frame, op_ret, op_errno, fchecksum, dchecksum); return 0;}int32_ttrace_checksum (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flag){ gf_log (this->name, GF_LOG_NORMAL, "loc->path (%s) flag (%d)", loc->path, flag); STACK_WIND (frame, trace_checksum_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->mops->checksum, loc, flag); return 0;}struct xlator_mops mops = { .stats = trace_stats, .checksum = trace_checksum,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -