diff options
author | Amar Tumballi <amarts@redhat.com> | 2018-12-06 12:29:25 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-12-13 17:10:00 +0000 |
commit | 8293d21280fd6ddfc9bb54068cf87794fc6be207 (patch) | |
tree | 39729fb407b436ed0cc3e4a9f4e5bbd29036a9db /xlators/features | |
parent | af7e957b4954bd84b8f7df6bfbd59c939092ead2 (diff) |
all: remove code which is not being considered in build
These xlators are now removed from build as per discussion/announcement
done at https://lists.gluster.org/pipermail/gluster-users/2018-July/034400.html
* move rot-13 to playground, as it is used only as demo
purpose, and is documented in many places.
* Removed code of below xlators:
- cluster/stripe
- cluster/tier
- features/changetimerecorder
- features/glupy
- performance/symlink-cache
- encryption/crypt
- storage/bd
- experimental/posix2
- experimental/dht2
- experimental/fdl
- experimental/jbr
updates: bz#1635688
Change-Id: I1d2d63c32535e149bc8dcb2daa76236c707996e8
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/features')
26 files changed, 0 insertions, 8551 deletions
diff --git a/xlators/features/changetimerecorder/Makefile.am b/xlators/features/changetimerecorder/Makefile.am deleted file mode 100644 index a985f42a877..00000000000 --- a/xlators/features/changetimerecorder/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = src - -CLEANFILES = diff --git a/xlators/features/changetimerecorder/src/Makefile.am b/xlators/features/changetimerecorder/src/Makefile.am deleted file mode 100644 index 620017e3309..00000000000 --- a/xlators/features/changetimerecorder/src/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features - -# changetimerecorder can only get build when libgfdb is enabled -if BUILD_GFDB - xlator_LTLIBRARIES = changetimerecorder.la -endif - -changetimerecorder_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) - -changetimerecorder_la_SOURCES = changetimerecorder.c \ - ctr-helper.c ctr-xlator-ctx.c - -changetimerecorder_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la\ - $(top_builddir)/libglusterfs/src/gfdb/libgfdb.la - -noinst_HEADERS = ctr-messages.h changetimerecorder.h ctr_mem_types.h \ - ctr-helper.h ctr-xlator-ctx.h - -AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ - -I$(top_srcdir)/libglusterfs/src/gfdb \ - -I$(top_srcdir)/rpc/xdr/src -I$(top_builddir)/rpc/xdr/src \ - -DDATADIR=\"$(localstatedir)\" - -AM_CFLAGS = -Wall $(GF_CFLAGS) $(SQLITE_CFLAGS) - -CLEANFILES = diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.c b/xlators/features/changetimerecorder/src/changetimerecorder.c deleted file mode 100644 index 1d8068c4f4e..00000000000 --- a/xlators/features/changetimerecorder/src/changetimerecorder.c +++ /dev/null @@ -1,2357 +0,0 @@ -/* - Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ -#include <ctype.h> -#include <sys/uio.h> - -#include "gfdb_sqlite3.h" -#include "ctr-helper.h" -#include "ctr-messages.h" -#include <glusterfs/syscall.h> - -#include "changetimerecorder.h" -#include "tier-ctr-interface.h" - -/*******************************inode forget***********************************/ -int -ctr_forget(xlator_t *this, inode_t *inode) -{ - fini_ctr_xlator_ctx(this, inode); - return 0; -} - -/************************** Look up heal **************************************/ -/* -Problem: The CTR xlator records file meta (heat/hardlinks) -into the data. This works fine for files which are created -after ctr xlator is switched ON. But for files which were -created before CTR xlator is ON, CTR xlator is not able to -record either of the meta i.e heat or hardlinks. Thus making -those files immune to promotions/demotions. - -Solution: The solution that is implemented in this patch is -do ctr-db heal of all those pre-existent files, using named lookup. -For this purpose we use the inode-xlator context variable option -in gluster. -The inode-xlator context variable for ctr xlator will have the -following, - a. A Lock for the context variable - b. A hardlink list: This list represents the successful looked - up hardlinks. -These are the scenarios when the hardlink list is updated: -1) Named-Lookup: Whenever a named lookup happens on a file, in the - wind path we copy all required hardlink and inode information to - ctr_db_record structure, which resides in the frame->local variable. - We don't update the database in wind. During the unwind, we read the - information from the ctr_db_record and , - Check if the inode context variable is created, if not we create it. - Check if the hard link is there in the hardlink list. - If its not there we add it to the list and send a update to the - database using libgfdb. - Please note: The database transaction can fail(and we ignore) as there - already might be a record in the db. This update to the db is to heal - if its not there. - If its there in the list we ignore it. -2) Inode Forget: Whenever an inode forget hits we clear the hardlink list in - the inode context variable and delete the inode context variable. - Please note: An inode forget may happen for two reason, - a. when the inode is delete. - b. the in-memory inode is evicted from the inode table due to cache limits. -3) create: whenever a create happens we create the inode context variable and - add the hardlink. The database updation is done as usual by ctr. -4) link: whenever a hardlink is created for the inode, we create the inode - context variable, if not present, and add the hardlink to the list. -5) unlink: whenever a unlink happens we delete the hardlink from the list. -6) mknod: same as create. -7) rename: whenever a rename happens we update the hardlink in list. if the - hardlink was not present for updation, we add the hardlink to the list. - -What is pending: -1) This solution will only work for named lookups. -2) We don't track afr-self-heal/dht-rebalancer traffic for healing. - -*/ - -/* This function does not write anything to the db, - * just created the local variable - * for the frame and sets values for the ctr_db_record */ -static int -ctr_lookup_wind(call_frame_t *frame, xlator_t *this, - gf_ctr_inode_context_t *ctr_inode_cx) -{ - int ret = -1; - gf_ctr_private_t *_priv = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - GF_ASSERT(this); - IS_CTR_INODE_CX_SANE(ctr_inode_cx); - - _priv = this->private; - GF_ASSERT(_priv); - - if (_priv->ctr_record_wind && ctr_inode_cx->ia_type != IA_IFDIR) { - frame->local = init_ctr_local_t(this); - if (!frame->local) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - "WIND: Error while creating ctr local"); - goto out; - }; - ctr_local = frame->local; - /*Definitely no internal fops will reach here*/ - ctr_local->is_internal_fop = _gf_false; - /*Don't record counters*/ - CTR_DB_REC(ctr_local).do_record_counters = _gf_false; - /*Don't record time at all*/ - CTR_DB_REC(ctr_local).do_record_times = _gf_false; - - /* Copy gfid into db record*/ - gf_uuid_copy(CTR_DB_REC(ctr_local).gfid, *(ctr_inode_cx->gfid)); - - /* Set fop_path and fop_type, required by libgfdb to make - * decision while inserting the record */ - CTR_DB_REC(ctr_local).gfdb_fop_path = ctr_inode_cx->fop_path; - CTR_DB_REC(ctr_local).gfdb_fop_type = ctr_inode_cx->fop_type; - - /* Copy hard link info*/ - gf_uuid_copy(CTR_DB_REC(ctr_local).pargfid, - *((NEW_LINK_CX(ctr_inode_cx))->pargfid)); - if (snprintf(CTR_DB_REC(ctr_local).file_name, - sizeof(CTR_DB_REC(ctr_local).file_name), "%s", - NEW_LINK_CX(ctr_inode_cx)->basename) >= - sizeof(CTR_DB_REC(ctr_local).file_name)) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - "WIND: Error copying filename of ctr local"); - goto out; - } - /* Since we are in lookup we can ignore errors while - * Inserting in the DB, because there may be many - * to write to the DB attempts for healing. - * We don't want to log all failed attempts and - * bloat the log*/ - ctr_local->gfdb_db_record.ignore_errors = _gf_true; - } - - ret = 0; - -out: - - if (ret) { - free_ctr_local(ctr_local); - frame->local = NULL; - } - - return ret; -} - -/* This function inserts the ctr_db_record populated by ctr_lookup_wind - * in to the db. It also destroys the frame->local created by ctr_lookup_wind */ -static int -ctr_lookup_unwind(call_frame_t *frame, xlator_t *this) -{ - int ret = -1; - gf_ctr_private_t *_priv = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(this); - - _priv = this->private; - GF_ASSERT(_priv); - - GF_ASSERT(_priv->_db_conn); - - ctr_local = frame->local; - - if (ctr_local && (ctr_local->ia_inode_type != IA_IFDIR)) { - ret = insert_record(_priv->_db_conn, &ctr_local->gfdb_db_record); - if (ret == -1) { - gf_msg(this->name, - _gfdb_log_level(GF_LOG_ERROR, - ctr_local->gfdb_db_record.ignore_errors), - 0, CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, - "UNWIND: Error filling ctr local"); - goto out; - } - } - ret = 0; -out: - free_ctr_local(ctr_local); - frame->local = NULL; - return ret; -} - -/****************************************************************************** - * - * FOPS HANDLING BELOW - * - * ***************************************************************************/ - -/****************************LOOKUP********************************************/ - -int32_t -ctr_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, dict_t *dict, struct iatt *postparent) -{ - int ret = -1; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - gf_ctr_local_t *ctr_local = NULL; - ctr_heal_ret_val_t ret_val = CTR_CTX_ERROR; - gf_boolean_t _is_heal_needed = _gf_false; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - - /* if the lookup failed lookup don't do anything*/ - if (op_ret == -1) { - gf_msg_trace(this->name, 0, "lookup failed with %s", - strerror(op_errno)); - goto out; - } - - /* Ignore directory lookups */ - if (inode->ia_type == IA_IFDIR) { - goto out; - } - - /* if frame local was not set by the ctr_lookup() - * so don't so anything*/ - if (!frame->local) { - goto out; - } - - /* if the lookup is for dht link donot record*/ - if (dht_is_linkfile(buf, dict)) { - gf_msg_trace(this->name, 0, - "Ignoring Lookup " - "for dht link file"); - goto out; - } - - ctr_local = frame->local; - /*Assign the proper inode type*/ - ctr_local->ia_inode_type = inode->ia_type; - - /* Copy gfid directly from inode */ - gf_uuid_copy(CTR_DB_REC(ctr_local).gfid, inode->gfid); - - /* Checking if gfid and parent gfid is valid */ - if (gf_uuid_is_null(CTR_DB_REC(ctr_local).gfid) || - gf_uuid_is_null(CTR_DB_REC(ctr_local).pargfid)) { - gf_msg_trace(this->name, 0, "Invalid GFID"); - goto out; - } - - /* if its a first entry - * then mark the ctr_record for create - * A create will attempt a file and a hard link created in the db*/ - ctr_xlator_ctx = get_ctr_xlator_ctx(this, inode); - if (!ctr_xlator_ctx) { - /* This marks inode heal */ - CTR_DB_REC(ctr_local).gfdb_fop_type = GFDB_FOP_CREATE_WRITE; - _is_heal_needed = _gf_true; - } - - /* Copy the correct gfid from resolved inode */ - gf_uuid_copy(CTR_DB_REC(ctr_local).gfid, inode->gfid); - - /* Add hard link to the list */ - ret_val = add_hard_link_ctx(frame, this, inode); - if (ret_val == CTR_CTX_ERROR) { - gf_msg_trace(this->name, 0, "Failed adding hardlink to list"); - goto out; - } - /* If inode needs healing then heal the hardlink also */ - else if (ret_val & CTR_TRY_INODE_HEAL) { - /* This marks inode heal */ - CTR_DB_REC(ctr_local).gfdb_fop_type = GFDB_FOP_CREATE_WRITE; - _is_heal_needed = _gf_true; - } - /* If hardlink needs healing */ - else if (ret_val & CTR_TRY_HARDLINK_HEAL) { - _is_heal_needed = _gf_true; - } - - /* If lookup heal needed */ - if (!_is_heal_needed) - goto out; - - /* FINALLY HEAL : Inserts the ctr_db_record populated by ctr_lookup_wind - * in to the db. It also destroys the frame->local - * created by ctr_lookup_wind */ - ret = ctr_lookup_unwind(frame, this); - if (ret) { - gf_msg_trace(this->name, 0, "Failed healing/inserting link"); - } - -out: - free_ctr_local((gf_ctr_local_t *)frame->local); - frame->local = NULL; - - STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf, dict, - postparent); - - return 0; -} - -int32_t -ctr_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) -{ - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - gf_ctr_link_context_t ctr_link_cx; - gf_ctr_link_context_t *_link_cx = &ctr_link_cx; - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - - /* Don't handle nameless lookups*/ - if (!loc->parent || !loc->name) - goto out; - - /*fill ctr link context*/ - FILL_CTR_LINK_CX(_link_cx, loc->parent->gfid, loc->name, out); - - /* Fill ctr inode context*/ - /* IA_IFREG : We assume its a file in the wind - * but in the unwind we are sure what the inode is a file - * or directory - * gfid: we are just filling loc->gfid which is not correct. - * In unwind we fill the correct gfid for successful lookup*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, IA_IFREG, loc->gfid, _link_cx, NULL, - GFDB_FOP_DENTRY_WRITE, GFDB_FOP_WIND); - - /* Create the frame->local and populate ctr_db_record - * No writing to the db yet */ - ret = ctr_lookup_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_LINK_WIND_FAILED, - "Failed to insert link wind"); - } - -out: - STACK_WIND(frame, ctr_lookup_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->lookup, loc, xdata); - return 0; -} - -/****************************WRITEV********************************************/ -int32_t -ctr_writev_cbk(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) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_WRITEV_UNWIND_FAILED, - "Failed to insert writev unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf, - xdata); - - return 0; -} - -int32_t -ctr_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t off, uint32_t flags, struct iobref *iobref, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_WRITEV_WIND_FAILED, - "Failed to insert writev wind"); - } - -out: - STACK_WIND(frame, ctr_writev_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->writev, fd, vector, count, off, flags, - iobref, xdata); - - return 0; -} - -/******************************setattr*****************************************/ - -int32_t -ctr_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *preop_stbuf, - struct iatt *postop_stbuf, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_SETATTR_UNWIND_FAILED, - "Failed to insert setattr unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(setattr, frame, op_ret, op_errno, preop_stbuf, - postop_stbuf, xdata); - - return 0; -} - -int32_t -ctr_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf, - int32_t valid, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, loc->inode->gfid, - NULL, NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_SETATTR_WIND_FAILED, - "Failed to insert setattr wind"); - } -out: - - STACK_WIND(frame, ctr_setattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata); - - return 0; -} - -/*************************** fsetattr ***************************************/ -int32_t -ctr_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *preop_stbuf, - struct iatt *postop_stbuf, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_SETATTR_UNWIND_FAILED, - "Failed to insert fsetattr unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(fsetattr, frame, op_ret, op_errno, preop_stbuf, - postop_stbuf, xdata); - - return 0; -} - -int32_t -ctr_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, - int32_t valid, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_SETATTR_WIND_FAILED, - "Failed to insert fsetattr wind"); - } -out: - STACK_WIND(frame, ctr_fsetattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata); - - return 0; -} -/****************************fremovexattr************************************/ - -int32_t -ctr_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED, - "Failed to insert fremovexattr unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(fremovexattr, frame, op_ret, op_errno, xdata); - - return 0; -} - -int32_t -ctr_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, - const char *name, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED, - "Failed to insert fremovexattr wind"); - } - -out: - STACK_WIND(frame, ctr_fremovexattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fremovexattr, fd, name, xdata); - return 0; -} - -/****************************removexattr*************************************/ - -int32_t -ctr_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED, - "Failed to insert removexattr unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(removexattr, frame, op_ret, op_errno, xdata); - - return 0; -} - -int32_t -ctr_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, loc->inode->gfid, - NULL, NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED, - "Failed to insert removexattr wind"); - } - -out: - STACK_WIND(frame, ctr_removexattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->removexattr, loc, name, xdata); - return 0; -} - -/****************************truncate****************************************/ - -int32_t -ctr_truncate_cbk(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) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED, - "Failed to insert truncate unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf, - xdata); - - return 0; -} - -int32_t -ctr_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, loc->inode->gfid, - NULL, NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_TRUNCATE_WIND_FAILED, - "Failed to insert truncate wind"); - } -out: - STACK_WIND(frame, ctr_truncate_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->truncate, loc, offset, xdata); - return 0; -} - -/****************************ftruncate***************************************/ - -int32_t -ctr_ftruncate_cbk(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) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED, - "Failed to insert ftruncate unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf, - xdata); - - return 0; -} - -int32_t -ctr_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED, - "Failed to insert ftruncate wind"); - } - -out: - STACK_WIND(frame, ctr_ftruncate_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata); - return 0; -} - -/****************************rename******************************************/ -int32_t -ctr_rename_cbk(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) -{ - int ret = -1; - uint32_t remaining_links = -1; - gf_ctr_local_t *ctr_local = NULL; - gfdb_fop_type_t fop_type = GFDB_FOP_INVALID_OP; - gfdb_fop_path_t fop_path = GFDB_FOP_INVALID; - - GF_ASSERT(frame); - GF_ASSERT(this); - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, - GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_RENAME_UNWIND_FAILED, - "Failed to insert rename unwind"); - goto out; - } - - if (!xdata) - goto out; - /* - * - * Extracting GF_RESPONSE_LINK_COUNT_XDATA from POSIX Xlator - * This is only set when we are overwriting hardlinks. - * - * */ - ret = dict_get_uint32(xdata, GF_RESPONSE_LINK_COUNT_XDATA, - &remaining_links); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - "Failed to getting GF_RESPONSE_LINK_COUNT_XDATA"); - remaining_links = -1; - goto out; - } - - ctr_local = frame->local; - if (!ctr_local) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_NULL_LOCAL, - "ctr_local is NULL."); - goto out; - } - - /* This is not the only link */ - if (remaining_links > 1) { - fop_type = GFDB_FOP_DENTRY_WRITE; - fop_path = GFDB_FOP_UNDEL; - } - /* Last link that was deleted */ - else if (remaining_links == 1) { - fop_type = GFDB_FOP_DENTRY_WRITE; - fop_path = GFDB_FOP_UNDEL_ALL; - } else { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_RENAME_UNWIND_FAILED, - "Invalid link count from posix"); - goto out; - } - - ret = ctr_delete_hard_link_from_db( - this, CTR_DB_REC(ctr_local).old_gfid, CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name, fop_type, fop_path); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, - "Failed to delete records of %s", - CTR_DB_REC(ctr_local).old_file_name); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(rename, frame, op_ret, op_errno, buf, preoldparent, - postoldparent, prenewparent, postnewparent, xdata); - - return 0; -} - -int32_t -ctr_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - gf_ctr_link_context_t new_link_cx, old_link_cx; - gf_ctr_link_context_t *_nlink_cx = &new_link_cx; - gf_ctr_link_context_t *_olink_cx = &old_link_cx; - int is_dict_created = 0; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - /*Fill old link context*/ - FILL_CTR_LINK_CX(_olink_cx, oldloc->pargfid, oldloc->name, out); - - /*Fill new link context*/ - FILL_CTR_LINK_CX(_nlink_cx, newloc->pargfid, newloc->name, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, oldloc->inode->ia_type, - oldloc->inode->gfid, _nlink_cx, _olink_cx, - GFDB_FOP_DENTRY_WRITE, GFDB_FOP_WIND); - - /* If the rename is a overwrite of hardlink - * rename ("file1", "file2") - * file1 is hardlink for gfid say 00000000-0000-0000-0000-00000000000A - * file2 is hardlink for gfid say 00000000-0000-0000-0000-00000000000B - * so we are saving file2 gfid in old_gfid so that we delete entries - * from the db during rename callback if the fop is successful - * */ - if (newloc->inode) { - /* This is the GFID from where the newloc hardlink will be - * unlinked */ - _inode_cx->old_gfid = &newloc->inode->gfid; - } - - /* Is a metatdata fop */ - _inode_cx->is_metadata_fop = _gf_true; - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_RENAME_WIND_FAILED, - "Failed to insert rename wind"); - } else { - /* We are doing updation of hard link in inode context in wind - * As we don't get the "inode" in the call back for rename */ - ret = update_hard_link_ctx(frame, this, oldloc->inode); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_UPDATE_HARDLINK_FAILED, - "Failed " - "updating hard link in ctr inode context"); - goto out; - } - - /* If the newloc has an inode. i.e acquiring hardlink of an - * exisitng file i.e overwritting a file. - * */ - if (newloc->inode) { - /* Getting the ctr inode context variable for - * inode whose hardlink will be acquired during - * the rename - * */ - ctr_xlator_ctx = get_ctr_xlator_ctx(this, newloc->inode); - if (!ctr_xlator_ctx) { - /* Since there is no ctr inode context - * so nothing more to do */ - ret = 0; - goto out; - } - - /* Deleting hardlink from context variable */ - ret = ctr_delete_hard_link(this, ctr_xlator_ctx, newloc->pargfid, - newloc->name); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed to delete hard link"); - goto out; - } - - /* Requesting for number of hardlinks on the newloc - * inode from POSIX. - * */ - is_dict_created = set_posix_link_request(this, &xdata); - if (is_dict_created == -1) { - ret = -1; - goto out; - } - } - } - -out: - STACK_WIND(frame, ctr_rename_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rename, oldloc, newloc, xdata); - - if (is_dict_created == 1) { - dict_unref(xdata); - } - - return 0; -} - -/****************************unlink******************************************/ -int32_t -ctr_unlink_cbk(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) -{ - int ret = -1; - uint32_t remaining_links = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - if (!xdata) - goto out; - - /* - * - * Extracting GF_RESPONSE_LINK_COUNT_XDATA from POSIX Xlator - * - * */ - ret = dict_get_uint32(xdata, GF_RESPONSE_LINK_COUNT_XDATA, - &remaining_links); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - "Failed to getting GF_RESPONSE_LINK_COUNT_XDATA"); - remaining_links = -1; - } - - /*This is not the only link*/ - if (remaining_links != 1) { - ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, - GFDB_FOP_UNDEL); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, - "Failed to insert unlink unwind"); - } - } - /*Last link that was deleted*/ - else if (remaining_links == 1) { - ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, - GFDB_FOP_UNDEL_ALL); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, - "Failed to insert unlink unwind"); - } - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno, preparent, postparent, - xdata); - - return 0; -} - -int32_t -ctr_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - gf_ctr_link_context_t ctr_link_cx; - gf_ctr_link_context_t *_link_cx = &ctr_link_cx; - gf_boolean_t is_xdata_created = _gf_false; - struct iatt dummy_stat = {0}; - - GF_ASSERT(frame); - - CTR_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill link context*/ - FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, loc->inode->gfid, - _link_cx, NULL, GFDB_FOP_DENTRY_WRITE, - GFDB_FOP_WDEL); - - /*Internal FOP*/ - _inode_cx->is_internal_fop = is_internal_fop(frame, xdata); - - /* Is a metadata FOP */ - _inode_cx->is_metadata_fop = _gf_true; - - /* If its a internal FOP and dht link file donot record*/ - if (_inode_cx->is_internal_fop && dht_is_linkfile(&dummy_stat, xdata)) { - goto out; - } - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, - "Failed to insert unlink wind"); - } else { - /* We are doing delete of hard link in inode context in wind - * As we don't get the "inode" in the call back for rename */ - ret = delete_hard_link_ctx(frame, this, loc->inode); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed " - "deleting hard link from ctr inode context"); - } - } - - /* - * - * Sending GF_REQUEST_LINK_COUNT_XDATA - * to POSIX Xlator to send link count in unwind path - * - * */ - /*create xdata if NULL*/ - if (!xdata) { - xdata = dict_new(); - is_xdata_created = (xdata) ? _gf_true : _gf_false; - } - if (!xdata) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_XDATA_NULL, - "xdata is NULL :Cannot send " - "GF_REQUEST_LINK_COUNT_XDATA to posix"); - goto out; - } - - ret = dict_set_int32(xdata, GF_REQUEST_LINK_COUNT_XDATA, 1); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - "Failed setting GF_REQUEST_LINK_COUNT_XDATA"); - if (is_xdata_created) { - dict_unref(xdata); - } - goto out; - } - -out: - STACK_WIND(frame, ctr_unlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata); - - if (is_xdata_created) - dict_unref(xdata); - - return 0; -} - -/****************************fsync******************************************/ -int32_t -ctr_fsync_cbk(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) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, - "Failed to insert fsync unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(fsync, frame, op_ret, op_errno, prebuf, postbuf, xdata); - - return 0; -} - -int32_t -ctr_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_FSYNC_WIND_FAILED, - "Failed to insert fsync wind"); - } - -out: - STACK_WIND(frame, ctr_fsync_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fsync, fd, flags, xdata); - return 0; -} - -/****************************setxattr****************************************/ - -int -ctr_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, - "Failed to insert setxattr unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno, xdata); - - return 0; -} - -int -ctr_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr, - int flags, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, loc->inode->gfid, - NULL, NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_SETATTR_WIND_FAILED, - "Failed to insert setxattr wind"); - } - -out: - STACK_WIND(frame, ctr_setxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->setxattr, loc, xattr, flags, xdata); - return 0; -} -/**************************** fsetxattr *************************************/ -int32_t -ctr_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_WRITE, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, - "Failed to insert fsetxattr unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(fsetxattr, frame, op_ret, op_errno, xdata); - - return 0; -} - -int32_t -ctr_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, - int32_t flags, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_SETATTR_WIND_FAILED, - "Failed to insert fsetxattr wind"); - } - -out: - STACK_WIND(frame, ctr_fsetxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, xdata); - return 0; -} -/****************************mknod*******************************************/ - -int32_t -ctr_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - int ret = -1; - ctr_heal_ret_val_t ret_val = CTR_CTX_ERROR; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - /* Add hard link to the list */ - ret_val = add_hard_link_ctx(frame, this, inode); - if (ret_val == CTR_CTX_ERROR) { - gf_msg_trace(this->name, 0, "Failed adding hard link"); - } - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_CREATE_WRITE, - GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_MKNOD_UNWIND_FAILED, - "Failed to insert mknod unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(mknod, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - - return 0; -} - -int -ctr_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, - dev_t rdev, mode_t umask, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - gf_ctr_link_context_t ctr_link_cx; - gf_ctr_link_context_t *_link_cx = &ctr_link_cx; - uuid_t gfid = { - 0, - }; - uuid_t *ptr_gfid = &gfid; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - - /*get gfid from xdata dict*/ - ret = dict_get_gfuuid(xdata, "gfid-req", &gfid); - if (ret) { - gf_msg_debug(this->name, 0, "failed to get gfid from dict"); - goto out; - } - - /*fill ctr link context*/ - FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, *ptr_gfid, _link_cx, - NULL, GFDB_FOP_CREATE_WRITE, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_MKNOD_WIND_FAILED, - "Failed to insert mknod wind"); - } - -out: - STACK_WIND(frame, ctr_mknod_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->mknod, loc, mode, rdev, umask, xdata); - return 0; -} - -/****************************create******************************************/ -int -ctr_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, - int op_errno, fd_t *fd, inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = add_hard_link_ctx(frame, this, inode); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_ADD_HARDLINK_FAILED, - "Failed adding hard link"); - } - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_CREATE_WRITE, - GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_CREATE_UNWIND_FAILED, - "Failed to insert create unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, stbuf, - preparent, postparent, xdata); - - return 0; -} - -int -ctr_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, - mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - gf_ctr_link_context_t ctr_link_cx; - gf_ctr_link_context_t *_link_cx = &ctr_link_cx; - uuid_t gfid = { - 0, - }; - uuid_t *ptr_gfid = &gfid; - struct iatt dummy_stat = {0}; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - - /*Get GFID from Xdata dict*/ - ret = dict_get_gfuuid(xdata, "gfid-req", &gfid); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_GET_GFID_FROM_DICT_FAILED, - "failed to get gfid from dict"); - goto out; - } - - /*fill ctr link context*/ - FILL_CTR_LINK_CX(_link_cx, loc->pargfid, loc->name, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, loc->inode->ia_type, *ptr_gfid, _link_cx, - NULL, GFDB_FOP_CREATE_WRITE, GFDB_FOP_WIND); - - /*Internal FOP*/ - _inode_cx->is_internal_fop = is_internal_fop(frame, xdata); - - /* If its a internal FOP and dht link file donot record*/ - if (_inode_cx->is_internal_fop && dht_is_linkfile(&dummy_stat, xdata)) { - goto out; - } - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, &ctr_inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_CREATE_WIND_FAILED, - "Failed to insert create wind"); - } -out: - STACK_WIND(frame, ctr_create_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->create, loc, flags, mode, umask, fd, - xdata); - return 0; -} - -/****************************link********************************************/ - -int -ctr_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, - int op_errno, inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - /* Add hard link to the list */ - ret = add_hard_link_ctx(frame, this, inode); - if (ret) { - gf_msg_trace(this->name, 0, "Failed adding hard link"); - } - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_DENTRY_WRITE, - GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_CREATE_UNWIND_FAILED, - "Failed to insert create unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, stbuf, preparent, - postparent, xdata); - return 0; -} - -int -ctr_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, - dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - gf_ctr_link_context_t ctr_link_cx; - gf_ctr_link_context_t *_link_cx = &ctr_link_cx; - struct iatt dummy_stat = {0}; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - - /*fill ctr link context*/ - FILL_CTR_LINK_CX(_link_cx, newloc->pargfid, newloc->name, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, oldloc->inode->ia_type, - oldloc->inode->gfid, _link_cx, NULL, - GFDB_FOP_DENTRY_WRITE, GFDB_FOP_WIND); - - /*Internal FOP*/ - _inode_cx->is_internal_fop = is_internal_fop(frame, xdata); - - /* Is a metadata fop */ - _inode_cx->is_metadata_fop = _gf_true; - - /* If its a internal FOP and dht link file donot record*/ - if (_inode_cx->is_internal_fop && dht_is_linkfile(&dummy_stat, xdata)) { - goto out; - } - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_LINK_WIND_FAILED, - "Failed to insert link wind"); - } - -out: - STACK_WIND(frame, ctr_link_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata); - return 0; -} - -/******************************readv*****************************************/ -int -ctr_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, - int op_errno, struct iovec *vector, int count, struct iatt *stbuf, - struct iobref *iobref, dict_t *xdata) -{ - int ret = -1; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, out); - - ret = ctr_insert_unwind(frame, this, GFDB_FOP_INODE_READ, GFDB_FOP_UNWIND); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_CREATE_UNWIND_FAILED, - "Failed to insert create unwind"); - } - -out: - ctr_free_frame_local(frame); - - STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count, stbuf, - iobref, xdata); - return 0; -} - -int -ctr_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t off, - uint32_t flags, dict_t *xdata) -{ - int ret = -1; - gf_ctr_inode_context_t ctr_inode_cx; - gf_ctr_inode_context_t *_inode_cx = &ctr_inode_cx; - - CTR_IS_DISABLED_THEN_GOTO(this, out); - CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, xdata, out); - - /*Fill ctr inode context*/ - FILL_CTR_INODE_CONTEXT(_inode_cx, fd->inode->ia_type, fd->inode->gfid, NULL, - NULL, GFDB_FOP_INODE_READ, GFDB_FOP_WIND); - - /*record into the database*/ - ret = ctr_insert_wind(frame, this, _inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_READV_WIND_FAILED, - "Failed to insert readv wind"); - } - -out: - STACK_WIND(frame, ctr_readv_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readv, fd, size, off, flags, xdata); - return 0; -} - -/*******************************ctr_ipc****************************************/ - -/*This is the call back function per record/file from data base*/ -static int -ctr_db_query_callback(gfdb_query_record_t *gfdb_query_record, void *args) -{ - int ret = -1; - ctr_query_cbk_args_t *query_cbk_args = args; - - GF_VALIDATE_OR_GOTO("ctr", query_cbk_args, out); - - ret = gfdb_write_query_record(query_cbk_args->query_fd, gfdb_query_record); - if (ret) { - gf_msg("ctr", GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "Failed to write to query file"); - goto out; - } - - query_cbk_args->count++; - - ret = 0; -out: - return ret; -} - -/* This function does all the db queries related to tiering and - * generates/populates new/existing query file - * inputs: - * xlator_t *this : CTR Translator - * void *conn_node : Database connection - * char *query_file: the query file that needs to be updated - * gfdb_ipc_ctr_params_t *ipc_ctr_params: the query parameters - * Return: - * On success 0 - * On failure -1 - * */ -int -ctr_db_query(xlator_t *this, void *conn_node, char *query_file, - gfdb_ipc_ctr_params_t *ipc_ctr_params) -{ - int ret = -1; - ctr_query_cbk_args_t query_cbk_args = {0}; - - GF_VALIDATE_OR_GOTO("ctr", this, out); - GF_VALIDATE_OR_GOTO(this->name, conn_node, out); - GF_VALIDATE_OR_GOTO(this->name, query_file, out); - GF_VALIDATE_OR_GOTO(this->name, ipc_ctr_params, out); - - /*Query for eligible files from db*/ - query_cbk_args.query_fd = open(query_file, O_WRONLY | O_CREAT | O_APPEND, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (query_cbk_args.query_fd < 0) { - gf_msg(this->name, GF_LOG_ERROR, errno, CTR_MSG_FATAL_ERROR, - "Failed to open query file %s", query_file); - goto out; - } - if (!ipc_ctr_params->is_promote) { - if (ipc_ctr_params->emergency_demote) { - /* emergency demotion mode */ - ret = find_all(conn_node, ctr_db_query_callback, - (void *)&query_cbk_args, - ipc_ctr_params->query_limit); - } else { - if (ipc_ctr_params->write_freq_threshold == 0 && - ipc_ctr_params->read_freq_threshold == 0) { - ret = find_unchanged_for_time(conn_node, ctr_db_query_callback, - (void *)&query_cbk_args, - &ipc_ctr_params->time_stamp); - } else { - ret = find_unchanged_for_time_freq( - conn_node, ctr_db_query_callback, (void *)&query_cbk_args, - &ipc_ctr_params->time_stamp, - ipc_ctr_params->write_freq_threshold, - ipc_ctr_params->read_freq_threshold, _gf_false); - } - } - } else { - if (ipc_ctr_params->write_freq_threshold == 0 && - ipc_ctr_params->read_freq_threshold == 0) { - ret = find_recently_changed_files(conn_node, ctr_db_query_callback, - (void *)&query_cbk_args, - &ipc_ctr_params->time_stamp); - } else { - ret = find_recently_changed_files_freq( - conn_node, ctr_db_query_callback, (void *)&query_cbk_args, - &ipc_ctr_params->time_stamp, - ipc_ctr_params->write_freq_threshold, - ipc_ctr_params->read_freq_threshold, _gf_false); - } - } - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: query from db failed"); - goto out; - } - - ret = clear_files_heat(conn_node); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: Failed to clear db entries"); - goto out; - } - - ret = 0; -out: - - if (!ret) - ret = query_cbk_args.count; - - if (query_cbk_args.query_fd >= 0) { - sys_close(query_cbk_args.query_fd); - query_cbk_args.query_fd = -1; - } - - return ret; -} - -void * -ctr_compact_thread(void *args) -{ - int ret = -1; - void *db_conn = NULL; - - xlator_t *this = NULL; - gf_ctr_private_t *priv = NULL; - gf_boolean_t compact_active = _gf_false; - gf_boolean_t compact_mode_switched = _gf_false; - - this = (xlator_t *)args; - - GF_VALIDATE_OR_GOTO("ctr", this, out); - - priv = this->private; - - db_conn = priv->_db_conn; - compact_active = priv->compact_active; - compact_mode_switched = priv->compact_mode_switched; - - gf_msg("ctr-compact", GF_LOG_INFO, 0, CTR_MSG_SET, "Starting compaction"); - - ret = compact_db(db_conn, compact_active, compact_mode_switched); - - if (ret) { - gf_msg("ctr-compact", GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to perform the compaction"); - } - - ret = pthread_mutex_lock(&priv->compact_lock); - - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to acquire lock"); - goto out; - } - - /* We are done compaction on this brick. Set all flags to false */ - priv->compact_active = _gf_false; - priv->compact_mode_switched = _gf_false; - - ret = pthread_mutex_unlock(&priv->compact_lock); - - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to release lock"); - goto out; - } - -out: - return NULL; -} - -int -ctr_ipc_helper(xlator_t *this, dict_t *in_dict, dict_t *out_dict) -{ - int ret = -1; - char *ctr_ipc_ops = NULL; - gf_ctr_private_t *priv = NULL; - char *db_version = NULL; - char *db_param_key = NULL; - char *db_param = NULL; - char *query_file = NULL; - gfdb_ipc_ctr_params_t *ipc_ctr_params = NULL; - int result = 0; - pthread_t compact_thread; - - GF_VALIDATE_OR_GOTO("ctr", this, out); - GF_VALIDATE_OR_GOTO(this->name, this->private, out); - priv = this->private; - GF_VALIDATE_OR_GOTO(this->name, priv->_db_conn, out); - GF_VALIDATE_OR_GOTO(this->name, in_dict, out); - GF_VALIDATE_OR_GOTO(this->name, out_dict, out); - - GET_DB_PARAM_FROM_DICT(this->name, in_dict, GFDB_IPC_CTR_KEY, ctr_ipc_ops, - out); - - /*if its a db clear operation */ - if (strncmp(ctr_ipc_ops, GFDB_IPC_CTR_CLEAR_OPS, - SLEN(GFDB_IPC_CTR_CLEAR_OPS)) == 0) { - ret = clear_files_heat(priv->_db_conn); - if (ret) - goto out; - - } /* if its a query operation, in which case its query + clear db*/ - else if (strncmp(ctr_ipc_ops, GFDB_IPC_CTR_QUERY_OPS, - SLEN(GFDB_IPC_CTR_QUERY_OPS)) == 0) { - ret = dict_get_str(in_dict, GFDB_IPC_CTR_GET_QFILE_PATH, &query_file); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed extracting query file path"); - goto out; - } - - ret = dict_get_bin(in_dict, GFDB_IPC_CTR_GET_QUERY_PARAMS, - (void *)&ipc_ctr_params); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed extracting query parameters"); - goto out; - } - - ret = ctr_db_query(this, priv->_db_conn, query_file, ipc_ctr_params); - - ret = dict_set_int32(out_dict, GFDB_IPC_CTR_RET_QUERY_COUNT, ret); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed setting query reply"); - goto out; - } - - } /* if its a query for db version */ - else if (strncmp(ctr_ipc_ops, GFDB_IPC_CTR_GET_DB_VERSION_OPS, - SLEN(GFDB_IPC_CTR_GET_DB_VERSION_OPS)) == 0) { - ret = get_db_version(priv->_db_conn, &db_version); - if (ret == -1 || !db_version) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed extracting db version "); - goto out; - } - - SET_DB_PARAM_TO_DICT(this->name, out_dict, GFDB_IPC_CTR_RET_DB_VERSION, - db_version, ret, error); - - } /* if its a query for a db setting */ - else if (strncmp(ctr_ipc_ops, GFDB_IPC_CTR_GET_DB_PARAM_OPS, - SLEN(GFDB_IPC_CTR_GET_DB_PARAM_OPS)) == 0) { - ret = dict_get_str(in_dict, GFDB_IPC_CTR_GET_DB_KEY, &db_param_key); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed extracting db param key"); - goto out; - } - - ret = get_db_params(priv->_db_conn, db_param_key, &db_param); - if (ret == -1 || !db_param) { - goto out; - } - - SET_DB_PARAM_TO_DICT(this->name, out_dict, db_param_key, db_param, ret, - error); - } /* if its an attempt to compact the database */ - else if (strncmp(ctr_ipc_ops, GFDB_IPC_CTR_SET_COMPACT_PRAGMA, - SLEN(GFDB_IPC_CTR_SET_COMPACT_PRAGMA)) == 0) { - ret = pthread_mutex_lock(&priv->compact_lock); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to acquire lock for compaction"); - goto out; - } - - if ((priv->compact_active || priv->compact_mode_switched)) { - /* Compaction in progress. LEAVE */ - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Compaction already in progress."); - pthread_mutex_unlock(&priv->compact_lock); - goto out; - } - /* At this point, we should be the only one on the brick */ - /* compacting */ - - /* Grab the arguments from the dictionary */ - ret = dict_get_int32(in_dict, "compact_active", &result); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to get compaction type"); - goto out; - } - - if (result) { - priv->compact_active = _gf_true; - } - - ret = dict_get_int32(in_dict, "compact_mode_switched", &result); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to see if compaction switched"); - goto out; - } - - if (result) { - priv->compact_mode_switched = _gf_true; - gf_msg("ctr-compact", GF_LOG_TRACE, 0, CTR_MSG_SET, - "Pre-thread: Compact mode switch is true"); - } else { - gf_msg("ctr-compact", GF_LOG_TRACE, 0, CTR_MSG_SET, - "Pre-thread: Compact mode switch is false"); - } - - ret = pthread_mutex_unlock(&priv->compact_lock); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to release lock for compaction"); - goto out; - } - - ret = gf_thread_create(&compact_thread, NULL, ctr_compact_thread, - (void *)this, "ctrcomp"); - - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed to spawn compaction thread"); - goto out; - } - - goto out; - } /* default case */ - else { - goto out; - } - - ret = 0; - goto out; -error: - GF_FREE(db_param_key); - GF_FREE(db_param); - GF_FREE(db_version); -out: - return ret; -} - -/* IPC Call from tier migrator to clear the heat on the DB */ -int32_t -ctr_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *in_dict) -{ - int ret = -1; - gf_ctr_private_t *priv = NULL; - dict_t *out_dict = NULL; - - GF_ASSERT(this); - priv = this->private; - GF_ASSERT(priv); - GF_ASSERT(priv->_db_conn); - GF_VALIDATE_OR_GOTO(this->name, in_dict, wind); - - if (op != GF_IPC_TARGET_CTR) - goto wind; - - out_dict = dict_new(); - if (!out_dict) { - goto out; - } - - ret = ctr_ipc_helper(this, in_dict, out_dict); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_SET, - "Failed in ctr_ipc_helper"); - } -out: - - STACK_UNWIND_STRICT(ipc, frame, ret, 0, out_dict); - - if (out_dict) - dict_unref(out_dict); - - return 0; - -wind: - STACK_WIND(frame, default_ipc_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->ipc, op, in_dict); - - return 0; -} - -/* Call to initialize db for ctr xlator while ctr is enabled */ -int32_t -initialize_ctr_resource(xlator_t *this, gf_ctr_private_t *priv) -{ - int ret_db = -1; - dict_t *params_dict = NULL; - - if (!priv) - goto error; - - /* For compaction */ - priv->compact_active = _gf_false; - priv->compact_mode_switched = _gf_false; - ret_db = pthread_mutex_init(&priv->compact_lock, NULL); - - if (ret_db) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: Failed initializing compaction mutex"); - goto error; - } - - params_dict = dict_new(); - if (!params_dict) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INIT_DB_PARAMS_FAILED, - "DB Params cannot initialized!"); - goto error; - } - - /*Extract db params options*/ - ret_db = extract_db_params(this, params_dict, priv->gfdb_db_type); - if (ret_db) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED, - "Failed extracting db params options"); - goto error; - } - - /*Create a memory pool for ctr xlator*/ - this->local_pool = mem_pool_new(gf_ctr_local_t, 64); - if (!this->local_pool) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED, - "failed to create local memory pool"); - goto error; - } - - /*Initialize Database Connection*/ - priv->_db_conn = init_db(params_dict, priv->gfdb_db_type); - if (!priv->_db_conn) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: Failed initializing data base"); - goto error; - } - - ret_db = 0; - goto out; - -error: - if (this) - mem_pool_destroy(this->local_pool); - - if (priv) { - GF_FREE(priv->ctr_db_path); - } - GF_FREE(priv); - ret_db = -1; -out: - if (params_dict) - dict_unref(params_dict); - - return ret_db; -} - -/******************************************************************************/ -int -reconfigure(xlator_t *this, dict_t *options) -{ - char *temp_str = NULL; - int ret = 0; - gf_ctr_private_t *priv = NULL; - - priv = this->private; - - if (dict_get_str(options, "changetimerecorder.frequency", &temp_str)) { - gf_msg(this->name, GF_LOG_TRACE, 0, CTR_MSG_SET, "set"); - } - - GF_OPTION_RECONF("ctr-enabled", priv->enabled, options, bool, out); - if (!priv->enabled) { - gf_msg(GFDB_DATA_STORE, GF_LOG_INFO, 0, CTR_MSG_XLATOR_DISABLED, - "CTR Xlator is not enabled so skip ctr reconfigure"); - goto out; - } - - /* If ctr is enabled after skip init for ctr xlator then call - initialize_ctr_resource during reconfigure phase to allocate resources - for xlator - */ - if (priv->enabled && !priv->_db_conn) { - ret = initialize_ctr_resource(this, priv); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: Failed ctr initialize resource"); - goto out; - } - } - - GF_OPTION_RECONF("record-counters", priv->ctr_record_counter, options, bool, - out); - - GF_OPTION_RECONF("ctr-record-metadata-heat", priv->ctr_record_metadata_heat, - options, bool, out); - - GF_OPTION_RECONF("ctr_link_consistency", priv->ctr_link_consistency, - options, bool, out); - - GF_OPTION_RECONF("ctr_lookupheal_inode_timeout", - priv->ctr_lookupheal_inode_timeout, options, uint64, out); - - GF_OPTION_RECONF("ctr_lookupheal_link_timeout", - priv->ctr_lookupheal_link_timeout, options, uint64, out); - - GF_OPTION_RECONF("record-exit", priv->ctr_record_unwind, options, bool, - out); - - GF_OPTION_RECONF("record-entry", priv->ctr_record_wind, options, bool, out); - - /* If database is sqlite */ - if (priv->gfdb_db_type == GFDB_SQLITE3) { - /* AUTOCHECKPOINT */ - if (dict_get_str(options, GFDB_SQL_PARAM_WAL_AUTOCHECK, &temp_str) == - 0) { - ret = set_db_params(priv->_db_conn, "wal_autocheckpoint", temp_str); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, - "Failed to set %s", GFDB_SQL_PARAM_WAL_AUTOCHECK); - } - } - - /* CACHE_SIZE */ - if (dict_get_str(options, GFDB_SQL_PARAM_CACHE_SIZE, &temp_str) == 0) { - ret = set_db_params(priv->_db_conn, "cache_size", temp_str); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, - "Failed to set %s", GFDB_SQL_PARAM_CACHE_SIZE); - } - } - } - - ret = 0; - -out: - - return ret; -} - -/****************************init********************************************/ - -int32_t -init(xlator_t *this) -{ - gf_ctr_private_t *priv = NULL; - int ret_db = -1; - - if (!this) { - gf_msg("ctr", GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: ctr this is not initialized"); - return -1; - } - - if (!this->children || this->children->next) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: ctr should have exactly one child"); - return -1; - } - - if (!this->parents) { - gf_msg(this->name, GF_LOG_WARNING, 0, CTR_MSG_DANGLING_VOLUME, - "dangling volume. check volfile "); - } - - priv = GF_CALLOC(1, sizeof(*priv), gf_ctr_mt_private_t); - if (!priv) { - gf_msg(this->name, GF_LOG_ERROR, ENOMEM, CTR_MSG_CALLOC_FAILED, - "Calloc did not work!!!"); - return -1; - } - - /*Default values for the translator*/ - priv->ctr_record_wind = _gf_true; - priv->ctr_record_unwind = _gf_false; - priv->ctr_hot_brick = _gf_false; - priv->gfdb_db_type = GFDB_SQLITE3; - priv->gfdb_sync_type = GFDB_DB_SYNC; - priv->_db_conn = NULL; - priv->ctr_lookupheal_link_timeout = CTR_DEFAULT_HARDLINK_EXP_PERIOD; - priv->ctr_lookupheal_inode_timeout = CTR_DEFAULT_INODE_EXP_PERIOD; - - /*Extract ctr xlator options*/ - ret_db = extract_ctr_options(this, priv); - if (ret_db) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED, - "Failed extracting ctr xlator options"); - GF_FREE(priv); - return -1; - } - - if (!priv->enabled) { - gf_msg(GFDB_DATA_STORE, GF_LOG_INFO, 0, CTR_MSG_XLATOR_DISABLED, - "CTR Xlator is not enabled so skip ctr init"); - goto out; - } - - ret_db = initialize_ctr_resource(this, priv); - if (ret_db) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_FATAL_ERROR, - "FATAL: Failed ctr initialize resource"); - return -1; - } - -out: - this->private = (void *)priv; - return 0; -} - -int -notify(xlator_t *this, int event, void *data, ...) -{ - gf_ctr_private_t *priv = NULL; - int ret = 0; - - priv = this->private; - - if (!priv) - goto out; - - ret = default_notify(this, event, data); - -out: - return ret; -} - -int32_t -mem_acct_init(xlator_t *this) -{ - int ret = -1; - - GF_VALIDATE_OR_GOTO("ctr", this, out); - - ret = xlator_mem_acct_init(this, gf_ctr_mt_end + 1); - - if (ret != 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_MEM_ACC_INIT_FAILED, - "Memory accounting init" - "failed"); - return ret; - } -out: - return ret; -} - -void -fini(xlator_t *this) -{ - gf_ctr_private_t *priv = NULL; - - priv = this->private; - - if (priv && priv->enabled) { - if (fini_db(priv->_db_conn)) { - gf_msg(this->name, GF_LOG_WARNING, 0, CTR_MSG_CLOSE_DB_CONN_FAILED, - "Failed closing " - "db connection"); - } - - if (priv->_db_conn) - priv->_db_conn = NULL; - - GF_FREE(priv->ctr_db_path); - if (pthread_mutex_destroy(&priv->compact_lock)) { - gf_msg(this->name, GF_LOG_WARNING, 0, CTR_MSG_CLOSE_DB_CONN_FAILED, - "Failed to " - "destroy the compaction mutex"); - } - } - GF_FREE(priv); - mem_pool_destroy(this->local_pool); - this->local_pool = NULL; - - return; -} - -struct xlator_fops fops = { - /*lookup*/ - .lookup = ctr_lookup, - /*write fops */ - .mknod = ctr_mknod, - .create = ctr_create, - .truncate = ctr_truncate, - .ftruncate = ctr_ftruncate, - .setxattr = ctr_setxattr, - .fsetxattr = ctr_fsetxattr, - .removexattr = ctr_removexattr, - .fremovexattr = ctr_fremovexattr, - .unlink = ctr_unlink, - .link = ctr_link, - .rename = ctr_rename, - .writev = ctr_writev, - .setattr = ctr_setattr, - .fsetattr = ctr_fsetattr, - /*read fops*/ - .readv = ctr_readv, - /* IPC call*/ - .ipc = ctr_ipc}; - -struct xlator_cbks cbks = {.forget = ctr_forget}; - -struct volume_options options[] = { - {.key = - { - "ctr-enabled", - }, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "off", - .description = "Enables the CTR", - .flags = OPT_FLAG_SETTABLE}, - {.key = {"record-entry"}, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "on"}, - {.key = {"record-exit"}, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "off"}, - {.key = {"record-counters"}, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "off", - .op_version = {GD_OP_VERSION_3_7_0}, - .flags = OPT_FLAG_SETTABLE, - .tags = {}}, - {.key = {"ctr-record-metadata-heat"}, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "off", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {"ctr_link_consistency"}, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "off", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {"ctr_lookupheal_link_timeout"}, - .type = GF_OPTION_TYPE_INT, - .default_value = "300", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_2}, - .tags = {}}, - {.key = {"ctr_lookupheal_inode_timeout"}, - .type = GF_OPTION_TYPE_INT, - .default_value = "300", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_2}, - .tags = {}}, - {.key = {"hot-brick"}, - .type = GF_OPTION_TYPE_BOOL, - .value = {"on", "off"}, - .default_value = "off"}, - {.key = {"db-type"}, - .type = GF_OPTION_TYPE_STR, - .value = {"hashfile", "rocksdb", "changelog", "sqlite3", "hyperdex"}, - .default_value = "sqlite3", - .op_version = {GD_OP_VERSION_3_7_0}, - .flags = OPT_FLAG_SETTABLE, - .tags = {}}, - {.key = {"db-sync"}, - .type = GF_OPTION_TYPE_STR, - .value = {"sync", "async"}, - .default_value = "sync"}, - {.key = {"db-path"}, .type = GF_OPTION_TYPE_PATH}, - {.key = {"db-name"}, .type = GF_OPTION_TYPE_STR}, - {.key = {GFDB_SQL_PARAM_SYNC}, - .type = GF_OPTION_TYPE_STR, - .value = {"off", "normal", "full"}, - .default_value = "normal"}, - {.key = {GFDB_SQL_PARAM_JOURNAL_MODE}, - .type = GF_OPTION_TYPE_STR, - .value = {"delete", "truncate", "persist", "memory", "wal", "off"}, - .default_value = "wal", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {GFDB_SQL_PARAM_AUTO_VACUUM}, - .type = GF_OPTION_TYPE_STR, - .value = {"off", "full", "incr"}, - .default_value = "off", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {GFDB_SQL_PARAM_WAL_AUTOCHECK}, - .type = GF_OPTION_TYPE_INT, - .default_value = "25000", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {GFDB_SQL_PARAM_CACHE_SIZE}, - .type = GF_OPTION_TYPE_INT, - .default_value = "12500", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {GFDB_SQL_PARAM_PAGE_SIZE}, - .type = GF_OPTION_TYPE_INT, - .default_value = "4096", - .flags = OPT_FLAG_SETTABLE, - .op_version = {GD_OP_VERSION_3_7_0}, - .tags = {}}, - {.key = {NULL}}, -}; diff --git a/xlators/features/changetimerecorder/src/changetimerecorder.h b/xlators/features/changetimerecorder/src/changetimerecorder.h deleted file mode 100644 index 0150a1c91bc..00000000000 --- a/xlators/features/changetimerecorder/src/changetimerecorder.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - Copyright (c) 2006-2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef __CTR_H -#define __CTR_H - -#include <glusterfs/glusterfs.h> -#include <glusterfs/xlator.h> -#include <glusterfs/logging.h> -#include <glusterfs/common-utils.h> -#include "ctr_mem_types.h" -#include "ctr-helper.h" - -#endif /* __CTR_H */ diff --git a/xlators/features/changetimerecorder/src/ctr-helper.c b/xlators/features/changetimerecorder/src/ctr-helper.c deleted file mode 100644 index e1e65735cef..00000000000 --- a/xlators/features/changetimerecorder/src/ctr-helper.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#include "gfdb_sqlite3.h" -#include "ctr-helper.h" -#include "ctr-messages.h" - -/******************************************************************************* - * - * Fill unwind into db record - * - ******************************************************************************/ -int -fill_db_record_for_unwind(xlator_t *this, gf_ctr_local_t *ctr_local, - gfdb_fop_type_t fop_type, gfdb_fop_path_t fop_path) -{ - int ret = -1; - gfdb_time_t *ctr_uwtime = NULL; - gf_ctr_private_t *_priv = NULL; - - GF_ASSERT(this); - _priv = this->private; - GF_ASSERT(_priv); - - GF_ASSERT(ctr_local); - - /*If not unwind path error*/ - if (!isunwindpath(fop_path)) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_WRONG_FOP_PATH, - "Wrong fop_path. Should be unwind"); - goto out; - } - - ctr_uwtime = &CTR_DB_REC(ctr_local).gfdb_unwind_change_time; - CTR_DB_REC(ctr_local).gfdb_fop_path = fop_path; - CTR_DB_REC(ctr_local).gfdb_fop_type = fop_type; - - ret = gettimeofday(ctr_uwtime, NULL); - if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, errno, - CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, - "Error " - "filling unwind time record %s", - strerror(errno)); - goto out; - } - - /* Special case i.e if its a tier rebalance - * + cold tier brick - * + its a create/mknod FOP - * we record unwind time as zero */ - if (ctr_local->client_pid == GF_CLIENT_PID_TIER_DEFRAG && - (!_priv->ctr_hot_brick) && isdentrycreatefop(fop_type)) { - memset(ctr_uwtime, 0, sizeof(*ctr_uwtime)); - } - ret = 0; -out: - return ret; -} - -/******************************************************************************* - * - * Fill wind into db record - * - ******************************************************************************/ -int -fill_db_record_for_wind(xlator_t *this, gf_ctr_local_t *ctr_local, - gf_ctr_inode_context_t *ctr_inode_cx) -{ - int ret = -1; - gfdb_time_t *ctr_wtime = NULL; - gf_ctr_private_t *_priv = NULL; - - GF_ASSERT(this); - _priv = this->private; - GF_ASSERT(_priv); - GF_ASSERT(ctr_local); - IS_CTR_INODE_CX_SANE(ctr_inode_cx); - - /*if not wind path error!*/ - if (!iswindpath(ctr_inode_cx->fop_path)) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_WRONG_FOP_PATH, - "Wrong fop_path. Should be wind"); - goto out; - } - - ctr_wtime = &CTR_DB_REC(ctr_local).gfdb_wind_change_time; - CTR_DB_REC(ctr_local).gfdb_fop_path = ctr_inode_cx->fop_path; - CTR_DB_REC(ctr_local).gfdb_fop_type = ctr_inode_cx->fop_type; - CTR_DB_REC(ctr_local).link_consistency = _priv->ctr_link_consistency; - - ret = gettimeofday(ctr_wtime, NULL); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, errno, - CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, - "Error filling wind time record %s", strerror(errno)); - goto out; - } - - /* Special case i.e if its a tier rebalance - * + cold tier brick - * + its a create/mknod FOP - * we record wind time as zero */ - if (ctr_local->client_pid == GF_CLIENT_PID_TIER_DEFRAG && - (!_priv->ctr_hot_brick) && isdentrycreatefop(ctr_inode_cx->fop_type)) { - memset(ctr_wtime, 0, sizeof(*ctr_wtime)); - } - - /* Copy gfid into db record */ - gf_uuid_copy(CTR_DB_REC(ctr_local).gfid, *(ctr_inode_cx->gfid)); - - /* Copy older gfid if any */ - if (ctr_inode_cx->old_gfid && - (!gf_uuid_is_null(*(ctr_inode_cx->old_gfid)))) { - gf_uuid_copy(CTR_DB_REC(ctr_local).old_gfid, *(ctr_inode_cx->old_gfid)); - } - - /*Hard Links*/ - if (isdentryfop(ctr_inode_cx->fop_type)) { - /*new link fop*/ - if (NEW_LINK_CX(ctr_inode_cx)) { - gf_uuid_copy(CTR_DB_REC(ctr_local).pargfid, - *((NEW_LINK_CX(ctr_inode_cx))->pargfid)); - strcpy(CTR_DB_REC(ctr_local).file_name, - NEW_LINK_CX(ctr_inode_cx)->basename); - } - /*rename fop*/ - if (OLD_LINK_CX(ctr_inode_cx)) { - gf_uuid_copy(CTR_DB_REC(ctr_local).old_pargfid, - *((OLD_LINK_CX(ctr_inode_cx))->pargfid)); - strcpy(CTR_DB_REC(ctr_local).old_file_name, - OLD_LINK_CX(ctr_inode_cx)->basename); - } - } - - ret = 0; -out: - /*On error roll back and clean the record*/ - if (ret == -1) { - CLEAR_CTR_DB_RECORD(ctr_local); - } - return ret; -} - -/****************************************************************************** - * - * CTR xlator init related functions - * - * - * ****************************************************************************/ -static int -extract_sql_params(xlator_t *this, dict_t *params_dict) -{ - int ret = -1; - char *db_path = NULL; - char *db_name = NULL; - char *db_full_path = NULL; - - GF_ASSERT(this); - GF_ASSERT(params_dict); - - /*Extract the path of the db*/ - db_path = NULL; - GET_DB_PARAM_FROM_DICT_DEFAULT(this->name, this->options, "db-path", - db_path, "/var/run/gluster/"); - - /*Extract the name of the db*/ - db_name = NULL; - GET_DB_PARAM_FROM_DICT_DEFAULT(this->name, this->options, "db-name", - db_name, "gf_ctr_db.db"); - - /*Construct full path of the db*/ - ret = gf_asprintf(&db_full_path, "%s/%s", db_path, db_name); - if (ret < 0) { - gf_msg(GFDB_DATA_STORE, GF_LOG_ERROR, 0, - CTR_MSG_CONSTRUCT_DB_PATH_FAILED, - "Construction of full db path failed!"); - goto out; - } - - /*Setting the SQL DB Path*/ - SET_DB_PARAM_TO_DICT(this->name, params_dict, GFDB_SQL_PARAM_DBPATH, - db_full_path, ret, out); - - /*Extract rest of the sql params*/ - ret = gfdb_set_sql_params(this->name, this->options, params_dict); - if (ret) { - gf_msg(GFDB_DATA_STORE, GF_LOG_ERROR, 0, - CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, - "Failed setting values to sql param dict!"); - } - - ret = 0; - -out: - if (ret) - GF_FREE(db_full_path); - return ret; -} - -int -extract_db_params(xlator_t *this, dict_t *params_dict, gfdb_db_type_t db_type) -{ - int ret = -1; - - GF_ASSERT(this); - GF_ASSERT(params_dict); - - switch (db_type) { - case GFDB_SQLITE3: - ret = extract_sql_params(this, params_dict); - if (ret) - goto out; - break; - case GFDB_ROCKS_DB: - case GFDB_HYPERDEX: - case GFDB_HASH_FILE_STORE: - case GFDB_INVALID_DB: - case GFDB_DB_END: - goto out; - } - ret = 0; -out: - return ret; -} - -int -extract_ctr_options(xlator_t *this, gf_ctr_private_t *_priv) -{ - int ret = -1; - char *_val_str = NULL; - - GF_ASSERT(this); - GF_ASSERT(_priv); - - /*Checking if the CTR Translator is enabled. By default its disabled*/ - _priv->enabled = _gf_false; - GF_OPTION_INIT("ctr-enabled", _priv->enabled, bool, out); - if (!_priv->enabled) { - gf_msg(GFDB_DATA_STORE, GF_LOG_INFO, 0, CTR_MSG_XLATOR_DISABLED, - "CTR Xlator is disabled."); - ret = 0; - goto out; - } - - /*Extract db type*/ - GF_OPTION_INIT("db-type", _val_str, str, out); - _priv->gfdb_db_type = gf_string2gfdbdbtype(_val_str); - - /*Extract flag for record on wind*/ - GF_OPTION_INIT("record-entry", _priv->ctr_record_wind, bool, out); - - /*Extract flag for record on unwind*/ - GF_OPTION_INIT("record-exit", _priv->ctr_record_unwind, bool, out); - - /*Extract flag for record on counters*/ - GF_OPTION_INIT("record-counters", _priv->ctr_record_counter, bool, out); - - /* Extract flag for record metadata heat */ - GF_OPTION_INIT("ctr-record-metadata-heat", _priv->ctr_record_metadata_heat, - bool, out); - - /*Extract flag for link consistency*/ - GF_OPTION_INIT("ctr_link_consistency", _priv->ctr_link_consistency, bool, - out); - - /*Extract ctr_lookupheal_inode_timeout */ - GF_OPTION_INIT("ctr_lookupheal_inode_timeout", - _priv->ctr_lookupheal_inode_timeout, uint64, out); - - /*Extract ctr_lookupheal_link_timeout*/ - GF_OPTION_INIT("ctr_lookupheal_link_timeout", - _priv->ctr_lookupheal_link_timeout, uint64, out); - - /*Extract flag for hot tier brick*/ - GF_OPTION_INIT("hot-brick", _priv->ctr_hot_brick, bool, out); - - /*Extract flag for sync mode*/ - GF_OPTION_INIT("db-sync", _val_str, str, out); - _priv->gfdb_sync_type = gf_string2gfdbdbsync(_val_str); - - ret = 0; - -out: - return ret; -} diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h deleted file mode 100644 index 517fbb0b7de..00000000000 --- a/xlators/features/changetimerecorder/src/ctr-helper.h +++ /dev/null @@ -1,854 +0,0 @@ -/* - Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef __CTR_HELPER_H -#define __CTR_HELPER_H - -#include <glusterfs/xlator.h> -#include "ctr_mem_types.h" -#include <glusterfs/iatt.h> -#include <glusterfs/glusterfs.h> -#include <glusterfs/xlator.h> -#include <glusterfs/defaults.h> -#include <glusterfs/logging.h> -#include <glusterfs/common-utils.h> -#include <time.h> -#include <sys/time.h> -#include <pthread.h> - -#include "gfdb_data_store.h" -#include "ctr-xlator-ctx.h" -#include "ctr-messages.h" - -#define CTR_DEFAULT_HARDLINK_EXP_PERIOD 300 /* Five mins */ -#define CTR_DEFAULT_INODE_EXP_PERIOD 300 /* Five mins */ - -typedef struct ctr_query_cbk_args { - int query_fd; - int count; -} ctr_query_cbk_args_t; - -/*CTR Xlator Private structure*/ -typedef struct gf_ctr_private { - gf_boolean_t enabled; - char *ctr_db_path; - gf_boolean_t ctr_hot_brick; - gf_boolean_t ctr_record_wind; - gf_boolean_t ctr_record_unwind; - gf_boolean_t ctr_record_counter; - gf_boolean_t ctr_record_metadata_heat; - gf_boolean_t ctr_link_consistency; - gfdb_db_type_t gfdb_db_type; - gfdb_sync_type_t gfdb_sync_type; - gfdb_conn_node_t *_db_conn; - uint64_t ctr_lookupheal_link_timeout; - uint64_t ctr_lookupheal_inode_timeout; - gf_boolean_t compact_active; - gf_boolean_t compact_mode_switched; - pthread_mutex_t compact_lock; -} gf_ctr_private_t; - -/* - * gf_ctr_local_t is the ctr xlator local data structure that is stored in - * the call_frame of each FOP. - * - * gfdb_db_record: The gf_ctr_local contains a gfdb_db_record object, which is - * used by the insert_record() api from the libgfdb. The gfdb_db_record object - * will contain all the inode and hardlink(only for dentry fops: create, - * mknod,link, unlink, rename).The ctr_local is keep alive till the unwind - * call and will be release during the unwind. The same gfdb_db_record will - * used for the unwind insert_record() api, to record unwind in the database. - * - * ia_inode_type in gf_ctr_local will tell the type of the inode. This is - * important for during the unwind path. As we will not have the inode during - * the unwind path. We would have include this in the gfdb_db_record itself - * but currently we record only file inode information. - * - * is_internal_fop in gf_ctr_local will tell us if this is a internal fop and - * take special/no action. We don't record change/access times or increement - * heat counter for internal fops from rebalancer. - * */ -typedef struct gf_ctr_local { - gfdb_db_record_t gfdb_db_record; - ia_type_t ia_inode_type; - gf_boolean_t is_internal_fop; - gf_special_pid_t client_pid; -} gf_ctr_local_t; -/* - * Easy access of gfdb_db_record of ctr_local - * */ -#define CTR_DB_REC(ctr_local) (ctr_local->gfdb_db_record) - -/*Clear db record*/ -#define CLEAR_CTR_DB_RECORD(ctr_local) \ - do { \ - ctr_local->gfdb_db_record.gfdb_fop_path = GFDB_FOP_INVALID; \ - memset(&(ctr_local->gfdb_db_record.gfdb_wind_change_time), 0, \ - sizeof(gfdb_time_t)); \ - memset(&(ctr_local->gfdb_db_record.gfdb_unwind_change_time), 0, \ - sizeof(gfdb_time_t)); \ - gf_uuid_clear(ctr_local->gfdb_db_record.gfid); \ - gf_uuid_clear(ctr_local->gfdb_db_record.pargfid); \ - memset(ctr_local->gfdb_db_record.file_name, 0, GF_NAME_MAX + 1); \ - memset(ctr_local->gfdb_db_record.old_file_name, 0, GF_NAME_MAX + 1); \ - ctr_local->gfdb_db_record.gfdb_fop_type = GFDB_FOP_INVALID_OP; \ - ctr_local->ia_inode_type = IA_INVAL; \ - } while (0) - -static gf_ctr_local_t * -init_ctr_local_t(xlator_t *this) -{ - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(this); - - ctr_local = mem_get0(this->local_pool); - if (!ctr_local) { - gf_msg(GFDB_DATA_STORE, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - "Error while creating ctr local"); - goto out; - } - - CLEAR_CTR_DB_RECORD(ctr_local); -out: - return ctr_local; -} - -static void -free_ctr_local(gf_ctr_local_t *ctr_local) -{ - if (ctr_local) - mem_put(ctr_local); -} - -/****************************************************************************** - * - * - * Context Carrier Structures - * - * - * ****************************************************************************/ - -/* - * Context Carrier structures are used to carry relevant information about - * inodes and links from the fops calls to the ctr_insert_wind. - * These structure just have pointers to the original data and donot - * do a deep copy of any data. This info is deep copied to - * ctr_local->gfdb_db_record and passed to insert_record() api of libgfdb. This - * info remains persistent for the unwind in ctr_local->gfdb_db_record - * and once used will be destroyed. - * - * gf_ctr_link_context_t : Context structure for hard links - * gf_ctr_inode_context_t : Context structure for inodes - * - * */ - -/*Context Carrier Structure for hard links*/ -typedef struct gf_ctr_link_context { - uuid_t *pargfid; - const char *basename; -} gf_ctr_link_context_t; - -/*Context Carrier Structure for inodes*/ -typedef struct gf_ctr_inode_context { - ia_type_t ia_type; - uuid_t *gfid; - uuid_t *old_gfid; - gf_ctr_link_context_t *new_link_cx; - gf_ctr_link_context_t *old_link_cx; - gfdb_fop_type_t fop_type; - gfdb_fop_path_t fop_path; - gf_boolean_t is_internal_fop; - /* Indicating metadata fops */ - gf_boolean_t is_metadata_fop; -} gf_ctr_inode_context_t; - -/*******************Util Macros for Context Carrier Structures*****************/ - -/*Checks if ctr_link_cx is sane!*/ -#define IS_CTR_LINK_CX_SANE(ctr_link_cx) \ - do { \ - if (ctr_link_cx) { \ - if (ctr_link_cx->pargfid) \ - GF_ASSERT(*(ctr_link_cx->pargfid)); \ - GF_ASSERT(ctr_link_cx->basename); \ - }; \ - } while (0) - -/*Clear and fill the ctr_link_context with values*/ -#define FILL_CTR_LINK_CX(ctr_link_cx, _pargfid, _basename, label) \ - do { \ - GF_VALIDATE_OR_GOTO("ctr", ctr_link_cx, label); \ - GF_VALIDATE_OR_GOTO("ctr", _pargfid, label); \ - GF_VALIDATE_OR_GOTO("ctr", _basename, label); \ - memset(ctr_link_cx, 0, sizeof(*ctr_link_cx)); \ - ctr_link_cx->pargfid = &_pargfid; \ - ctr_link_cx->basename = _basename; \ - } while (0) - -#define NEW_LINK_CX(ctr_inode_cx) ctr_inode_cx->new_link_cx - -#define OLD_LINK_CX(ctr_inode_cx) ctr_inode_cx->old_link_cx - -/*Checks if ctr_inode_cx is sane!*/ -#define IS_CTR_INODE_CX_SANE(ctr_inode_cx) \ - do { \ - GF_ASSERT(ctr_inode_cx); \ - GF_ASSERT(ctr_inode_cx->gfid); \ - GF_ASSERT(*(ctr_inode_cx->gfid)); \ - GF_ASSERT(ctr_inode_cx->fop_type != GFDB_FOP_INVALID_OP); \ - GF_ASSERT(ctr_inode_cx->fop_path != GFDB_FOP_INVALID); \ - IS_CTR_LINK_CX_SANE(NEW_LINK_CX(ctr_inode_cx)); \ - IS_CTR_LINK_CX_SANE(OLD_LINK_CX(ctr_inode_cx)); \ - } while (0) - -/*Clear and fill the ctr_inode_context with values*/ -#define FILL_CTR_INODE_CONTEXT(ctr_inode_cx, _ia_type, _gfid, _new_link_cx, \ - _old_link_cx, _fop_type, _fop_path) \ - do { \ - GF_ASSERT(ctr_inode_cx); \ - GF_ASSERT(_gfid); \ - GF_ASSERT(_fop_type != GFDB_FOP_INVALID_OP); \ - GF_ASSERT(_fop_path != GFDB_FOP_INVALID); \ - memset(ctr_inode_cx, 0, sizeof(*ctr_inode_cx)); \ - ctr_inode_cx->ia_type = _ia_type; \ - ctr_inode_cx->gfid = &_gfid; \ - IS_CTR_LINK_CX_SANE(NEW_LINK_CX(ctr_inode_cx)); \ - if (_new_link_cx) \ - NEW_LINK_CX(ctr_inode_cx) = _new_link_cx; \ - IS_CTR_LINK_CX_SANE(OLD_LINK_CX(ctr_inode_cx)); \ - if (_old_link_cx) \ - OLD_LINK_CX(ctr_inode_cx) = _old_link_cx; \ - ctr_inode_cx->fop_type = _fop_type; \ - ctr_inode_cx->fop_path = _fop_path; \ - } while (0) - -/****************************************************************************** - * - * Util functions or macros used by - * insert wind and insert unwind - * - * ****************************************************************************/ -/* Free ctr frame local */ -static inline void -ctr_free_frame_local(call_frame_t *frame) -{ - if (frame) { - free_ctr_local((gf_ctr_local_t *)frame->local); - frame->local = NULL; - } -} - -/* Setting GF_REQUEST_LINK_COUNT_XDATA in dict - * that has to be sent to POSIX Xlator to send - * link count in unwind path. - * return 0 for success with not creation of dict - * return 1 for success with creation of dict - * return -1 for failure. - * */ -static inline int -set_posix_link_request(xlator_t *this, dict_t **xdata) -{ - int ret = -1; - gf_boolean_t is_created = _gf_false; - - GF_VALIDATE_OR_GOTO("ctr", this, out); - GF_VALIDATE_OR_GOTO(this->name, xdata, out); - - /*create xdata if NULL*/ - if (!*xdata) { - *xdata = dict_new(); - is_created = _gf_true; - ret = 1; - } else { - ret = 0; - } - - if (!*xdata) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_XDATA_NULL, - "xdata is NULL :Cannot send " - "GF_REQUEST_LINK_COUNT_XDATA to posix"); - ret = -1; - goto out; - } - - ret = dict_set_int32(*xdata, GF_REQUEST_LINK_COUNT_XDATA, 1); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - "Failed setting GF_REQUEST_LINK_COUNT_XDATA"); - ret = -1; - goto out; - } - ret = 0; -out: - if (ret == -1) { - if (*xdata && is_created) { - dict_unref(*xdata); - } - } - return ret; -} - -/* - * If a bitrot fop - * */ -#define BITROT_FOP(frame) \ - (frame->root->pid == GF_CLIENT_PID_BITD || \ - frame->root->pid == GF_CLIENT_PID_SCRUB) - -/* - * If a rebalancer fop - * */ -#define REBALANCE_FOP(frame) (frame->root->pid == GF_CLIENT_PID_DEFRAG) - -/* - * If its a tiering rebalancer fop - * */ -#define TIER_REBALANCE_FOP(frame) \ - (frame->root->pid == GF_CLIENT_PID_TIER_DEFRAG) - -/* - * If its a AFR SELF HEAL - * */ -#define AFR_SELF_HEAL_FOP(frame) (frame->root->pid == GF_CLIENT_PID_SELF_HEALD) - -/* - * if a rebalancer fop goto - * */ -#define CTR_IF_REBALANCE_FOP_THEN_GOTO(frame, label) \ - do { \ - if (REBALANCE_FOP(frame)) \ - goto label; \ - } while (0) - -/* - * Internal fop - * - * */ -static inline gf_boolean_t -is_internal_fop(call_frame_t *frame, dict_t *xdata) -{ - gf_boolean_t ret = _gf_false; - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - - if (AFR_SELF_HEAL_FOP(frame)) { - ret = _gf_true; - } - if (BITROT_FOP(frame)) { - ret = _gf_true; - } - if (REBALANCE_FOP(frame) || TIER_REBALANCE_FOP(frame)) { - ret = _gf_true; - if (xdata && dict_get(xdata, CTR_ATTACH_TIER_LOOKUP)) { - ret = _gf_false; - } - } - if (xdata && dict_get(xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { - ret = _gf_true; - } - - return ret; -} - -#define CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, dict, label) \ - do { \ - if (is_internal_fop(frame, dict)) \ - goto label; \ - } while (0) - -/* if fop has failed exit */ -#define CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, label) \ - do { \ - if (op_ret == -1) { \ - gf_msg_trace(this->name, 0, "Failed fop with %s", \ - strerror(op_errno)); \ - goto label; \ - }; \ - } while (0) - -/* - * IS CTR Xlator is disabled then goto to label - * */ -#define CTR_IS_DISABLED_THEN_GOTO(this, label) \ - do { \ - gf_ctr_private_t *_priv = NULL; \ - GF_ASSERT(this); \ - GF_ASSERT(this->private); \ - _priv = this->private; \ - if (!_priv->_db_conn) \ - goto label; \ - } while (0) - -/* - * IS CTR record metadata heat is disabled then goto to label - * */ -#define CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, label) \ - do { \ - gf_ctr_private_t *_priv = NULL; \ - GF_ASSERT(this); \ - GF_ASSERT(this->private); \ - _priv = this->private; \ - if (!_priv->ctr_record_metadata_heat) \ - goto label; \ - } while (0) - -int -fill_db_record_for_unwind(xlator_t *this, gf_ctr_local_t *ctr_local, - gfdb_fop_type_t fop_type, gfdb_fop_path_t fop_path); - -int -fill_db_record_for_wind(xlator_t *this, gf_ctr_local_t *ctr_local, - gf_ctr_inode_context_t *ctr_inode_cx); - -/******************************************************************************* - * CTR INSERT WIND - * ***************************************************************************** - * Function used to insert/update record into the database during a wind fop - * This function creates ctr_local structure into the frame of the fop - * call. - * ****************************************************************************/ - -static inline int -ctr_insert_wind(call_frame_t *frame, xlator_t *this, - gf_ctr_inode_context_t *ctr_inode_cx) -{ - int ret = -1; - gf_ctr_private_t *_priv = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - GF_ASSERT(this); - IS_CTR_INODE_CX_SANE(ctr_inode_cx); - - _priv = this->private; - GF_ASSERT(_priv); - - GF_ASSERT(_priv->_db_conn); - - /*If record_wind option of CTR is on record wind for - * regular files only*/ - if (_priv->ctr_record_wind && ctr_inode_cx->ia_type != IA_IFDIR) { - frame->local = init_ctr_local_t(this); - if (!frame->local) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - "WIND: Error while creating ctr local"); - goto out; - }; - ctr_local = frame->local; - ctr_local->client_pid = frame->root->pid; - ctr_local->is_internal_fop = ctr_inode_cx->is_internal_fop; - - /* Decide whether to record counters or not */ - CTR_DB_REC(ctr_local).do_record_counters = _gf_false; - /* If record counter is enabled */ - if (_priv->ctr_record_counter) { - /* If not a internal fop */ - if (!(ctr_local->is_internal_fop)) { - /* If its a metadata fop AND - * record metadata heat - * OR - * its NOT a metadata fop */ - if ((ctr_inode_cx->is_metadata_fop && - _priv->ctr_record_metadata_heat) || - (!ctr_inode_cx->is_metadata_fop)) { - CTR_DB_REC(ctr_local).do_record_counters = _gf_true; - } - } - } - - /* Decide whether to record times or not - * For non internal FOPS record times as usual*/ - CTR_DB_REC(ctr_local).do_record_times = _gf_false; - if (!ctr_local->is_internal_fop) { - /* If its a metadata fop AND - * record metadata heat - * OR - * its NOT a metadata fop */ - if ((ctr_inode_cx->is_metadata_fop && - _priv->ctr_record_metadata_heat) || - (!ctr_inode_cx->is_metadata_fop)) { - CTR_DB_REC(ctr_local).do_record_times = - (_priv->ctr_record_wind || _priv->ctr_record_unwind); - } - } - /* when its a internal FOPS*/ - else { - /* Record times only for create - * i.e when the inode is created */ - CTR_DB_REC(ctr_local).do_record_times = (isdentrycreatefop( - ctr_inode_cx->fop_type)) - ? _gf_true - : _gf_false; - } - - /*Fill the db record for insertion*/ - ret = fill_db_record_for_wind(this, ctr_local, ctr_inode_cx); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, - "WIND: Error filling ctr local"); - goto out; - } - - /*Insert the db record*/ - ret = insert_record(_priv->_db_conn, &ctr_local->gfdb_db_record); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_RECORD_WIND_FAILED, - "WIND: Inserting of record failed!"); - goto out; - } - } - ret = 0; -out: - - if (ret) { - free_ctr_local(ctr_local); - frame->local = NULL; - } - - return ret; -} - -/******************************************************************************* - * CTR INSERT UNWIND - * ***************************************************************************** - * Function used to insert/update record into the database during a unwind fop - * This function destroys ctr_local structure into the frame of the fop - * call at the end. - * ****************************************************************************/ -static inline int -ctr_insert_unwind(call_frame_t *frame, xlator_t *this, gfdb_fop_type_t fop_type, - gfdb_fop_path_t fop_path) -{ - int ret = -1; - gf_ctr_private_t *_priv = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(this); - - _priv = this->private; - GF_ASSERT(_priv); - - GF_ASSERT(_priv->_db_conn); - - ctr_local = frame->local; - - if (ctr_local && (_priv->ctr_record_unwind || isdentryfop(fop_type)) && - (ctr_local->ia_inode_type != IA_IFDIR)) { - CTR_DB_REC(ctr_local).do_record_uwind_time = _priv->ctr_record_unwind; - - ret = fill_db_record_for_unwind(this, ctr_local, fop_type, fop_path); - if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, - "UNWIND: Error filling ctr local"); - goto out; - } - - ret = insert_record(_priv->_db_conn, &ctr_local->gfdb_db_record); - if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, - "UNWIND: Error filling ctr local"); - goto out; - } - } - ret = 0; -out: - return ret; -} - -/****************************************************************************** - * Delete file/flink record/s from db - * ****************************************************************************/ -static inline int -ctr_delete_hard_link_from_db(xlator_t *this, uuid_t gfid, uuid_t pargfid, - char *basename, gfdb_fop_type_t fop_type, - gfdb_fop_path_t fop_path) -{ - int ret = -1; - gfdb_db_record_t gfdb_db_record; - gf_ctr_private_t *_priv = NULL; - - _priv = this->private; - GF_VALIDATE_OR_GOTO(this->name, _priv, out); - GF_VALIDATE_OR_GOTO(this->name, (!gf_uuid_is_null(gfid)), out); - GF_VALIDATE_OR_GOTO(this->name, (!gf_uuid_is_null(pargfid)), out); - GF_VALIDATE_OR_GOTO(this->name, (fop_type == GFDB_FOP_DENTRY_WRITE), out); - GF_VALIDATE_OR_GOTO( - this->name, (fop_path == GFDB_FOP_UNDEL || GFDB_FOP_UNDEL_ALL), out); - - /* Set gfdb_db_record to 0 */ - memset(&gfdb_db_record, 0, sizeof(gfdb_db_record)); - - /* Copy basename */ - if (snprintf(gfdb_db_record.file_name, GF_NAME_MAX, "%s", basename) >= - GF_NAME_MAX) - goto out; - - /* Copy gfid into db record */ - gf_uuid_copy(gfdb_db_record.gfid, gfid); - - /* Copy pargid into db record */ - gf_uuid_copy(gfdb_db_record.pargfid, pargfid); - - gfdb_db_record.gfdb_fop_path = fop_path; - gfdb_db_record.gfdb_fop_type = fop_type; - - /*send delete request to db*/ - ret = insert_record(_priv->_db_conn, &gfdb_db_record); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_RECORD_WIND_FAILED, - "Failed to delete record. %s", basename); - goto out; - } - - ret = 0; -out: - return ret; -} - -/******************************* Hard link function ***************************/ - -static inline gf_boolean_t -__is_inode_expired(ctr_xlator_ctx_t *ctr_xlator_ctx, gf_ctr_private_t *_priv, - gfdb_time_t *current_time) -{ - gf_boolean_t ret = _gf_false; - uint64_t time_diff = 0; - - GF_ASSERT(ctr_xlator_ctx); - GF_ASSERT(_priv); - GF_ASSERT(current_time); - - time_diff = current_time->tv_sec - ctr_xlator_ctx->inode_heal_period; - - ret = (time_diff >= _priv->ctr_lookupheal_inode_timeout) ? _gf_true - : _gf_false; - return ret; -} - -static inline gf_boolean_t -__is_hardlink_expired(ctr_hard_link_t *ctr_hard_link, gf_ctr_private_t *_priv, - gfdb_time_t *current_time) -{ - gf_boolean_t ret = _gf_false; - uint64_t time_diff = 0; - - GF_ASSERT(ctr_hard_link); - GF_ASSERT(_priv); - GF_ASSERT(current_time); - - time_diff = current_time->tv_sec - ctr_hard_link->hardlink_heal_period; - - ret = ret || (time_diff >= _priv->ctr_lookupheal_link_timeout) ? _gf_true - : _gf_false; - - return ret; -} - -/* Return values of heal*/ -typedef enum ctr_heal_ret_val { - CTR_CTX_ERROR = -1, - /* No healing required */ - CTR_TRY_NO_HEAL = 0, - /* Try healing hard link */ - CTR_TRY_HARDLINK_HEAL = 1, - /* Try healing inode */ - CTR_TRY_INODE_HEAL = 2, -} ctr_heal_ret_val_t; - -/** - * @brief Function to add hard link to the inode context variable. - * The inode context maintainences a in-memory list. This is used - * smart healing of database. - * @param frame of the FOP - * @param this is the Xlator instant - * @param inode - * @return Return ctr_heal_ret_val_t - */ - -static inline ctr_heal_ret_val_t -add_hard_link_ctx(call_frame_t *frame, xlator_t *this, inode_t *inode) -{ - ctr_heal_ret_val_t ret_val = CTR_TRY_NO_HEAL; - int ret = -1; - gf_ctr_local_t *ctr_local = NULL; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - ctr_hard_link_t *ctr_hard_link = NULL; - gf_ctr_private_t *_priv = NULL; - gfdb_time_t current_time = {0}; - - GF_ASSERT(frame); - GF_ASSERT(this); - GF_ASSERT(inode); - GF_ASSERT(this->private); - - _priv = this->private; - - ctr_local = frame->local; - if (!ctr_local) { - goto out; - } - - ctr_xlator_ctx = init_ctr_xlator_ctx(this, inode); - if (!ctr_xlator_ctx) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, - "Failed accessing ctr inode context"); - goto out; - } - - LOCK(&ctr_xlator_ctx->lock); - - /* Check if the hard link already exists - * in the ctr inode context*/ - ctr_hard_link = ctr_search_hard_link_ctx(this, ctr_xlator_ctx, - CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name); - /* if there then ignore */ - if (ctr_hard_link) { - ret = gettimeofday(¤t_time, NULL); - if (ret == -1) { - gf_log(this->name, GF_LOG_ERROR, "Failed to get current time"); - ret_val = CTR_CTX_ERROR; - goto unlock; - } - - if (__is_hardlink_expired(ctr_hard_link, _priv, ¤t_time)) { - ctr_hard_link->hardlink_heal_period = current_time.tv_sec; - ret_val = ret_val | CTR_TRY_HARDLINK_HEAL; - } - - if (__is_inode_expired(ctr_xlator_ctx, _priv, ¤t_time)) { - ctr_xlator_ctx->inode_heal_period = current_time.tv_sec; - ret_val = ret_val | CTR_TRY_INODE_HEAL; - } - - goto unlock; - } - - /* Add the hard link to the list*/ - ret = ctr_add_hard_link(this, ctr_xlator_ctx, CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, - "Failed to add hardlink to the ctr inode context"); - ret_val = CTR_CTX_ERROR; - goto unlock; - } - - ret_val = CTR_TRY_NO_HEAL; -unlock: - UNLOCK(&ctr_xlator_ctx->lock); -out: - return ret_val; -} - -static inline int -delete_hard_link_ctx(call_frame_t *frame, xlator_t *this, inode_t *inode) -{ - int ret = -1; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(this); - GF_ASSERT(inode); - - ctr_local = frame->local; - if (!ctr_local) { - goto out; - } - - ctr_xlator_ctx = get_ctr_xlator_ctx(this, inode); - if (!ctr_xlator_ctx) { - /* Since there is no ctr inode context so nothing more to do */ - ret = 0; - goto out; - } - - ret = ctr_delete_hard_link(this, ctr_xlator_ctx, - CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed to delete hard link"); - goto out; - } - - ret = 0; - -out: - return ret; -} - -static inline int -update_hard_link_ctx(call_frame_t *frame, xlator_t *this, inode_t *inode) -{ - int ret = -1; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(this); - GF_ASSERT(inode); - - ctr_local = frame->local; - if (!ctr_local) { - goto out; - } - - ctr_xlator_ctx = init_ctr_xlator_ctx(this, inode); - if (!ctr_xlator_ctx) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, - "Failed accessing ctr inode context"); - goto out; - } - - ret = ctr_update_hard_link( - this, ctr_xlator_ctx, CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name, CTR_DB_REC(ctr_local).old_pargfid, - CTR_DB_REC(ctr_local).old_file_name); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed to delete hard link"); - goto out; - } - - ret = 0; - -out: - return ret; -} - -/****************************************************************************** - * - * CTR xlator init related functions - * - * - * ****************************************************************************/ -int -extract_db_params(xlator_t *this, dict_t *params_dict, gfdb_db_type_t db_type); - -int -extract_ctr_options(xlator_t *this, gf_ctr_private_t *_priv); - -#endif diff --git a/xlators/features/changetimerecorder/src/ctr-messages.h b/xlators/features/changetimerecorder/src/ctr-messages.h deleted file mode 100644 index 23adf0aec09..00000000000 --- a/xlators/features/changetimerecorder/src/ctr-messages.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. - */ - -#ifndef _CTR_MESSAGES_H_ -#define _CTR_MESSAGES_H_ - -#include <glusterfs/glfs-message-id.h> - -/* To add new message IDs, append new identifiers at the end of the list. - * - * Never remove a message ID. If it's not used anymore, you can rename it or - * leave it as it is, but not delete it. This is to prevent reutilization of - * IDs by other messages. - * - * The component name must match one of the entries defined in - * glfs-message-id.h. - */ - -GLFS_MSGID( - CTR, CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, - CTR_MSG_INSERT_LINK_WIND_FAILED, CTR_MSG_INSERT_WRITEV_WIND_FAILED, - CTR_MSG_INSERT_WRITEV_UNWIND_FAILED, CTR_MSG_INSERT_SETATTR_WIND_FAILED, - CTR_MSG_INSERT_SETATTR_UNWIND_FAILED, - CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED, - CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED, - CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED, - CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED, - CTR_MSG_INSERT_TRUNCATE_WIND_FAILED, CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED, - CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED, - CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED, CTR_MSG_INSERT_RENAME_WIND_FAILED, - CTR_MSG_INSERT_RENAME_UNWIND_FAILED, - CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, CTR_MSG_ADD_HARDLINK_FAILED, - CTR_MSG_DELETE_HARDLINK_FAILED, CTR_MSG_UPDATE_HARDLINK_FAILED, - CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, CTR_MSG_INSERT_UNLINK_WIND_FAILED, - CTR_MSG_XDATA_NULL, CTR_MSG_INSERT_FSYNC_WIND_FAILED, - CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, CTR_MSG_INSERT_MKNOD_UNWIND_FAILED, - CTR_MSG_INSERT_MKNOD_WIND_FAILED, CTR_MSG_INSERT_CREATE_WIND_FAILED, - CTR_MSG_INSERT_CREATE_UNWIND_FAILED, CTR_MSG_INSERT_RECORD_WIND_FAILED, - CTR_MSG_INSERT_READV_WIND_FAILED, CTR_MSG_GET_GFID_FROM_DICT_FAILED, - CTR_MSG_SET, CTR_MSG_FATAL_ERROR, CTR_MSG_DANGLING_VOLUME, - CTR_MSG_CALLOC_FAILED, CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED, - CTR_MSG_INIT_DB_PARAMS_FAILED, CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED, - CTR_MSG_MEM_ACC_INIT_FAILED, CTR_MSG_CLOSE_DB_CONN_FAILED, - CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, CTR_MSG_WRONG_FOP_PATH, - CTR_MSG_CONSTRUCT_DB_PATH_FAILED, CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, - CTR_MSG_XLATOR_DISABLED, CTR_MSG_HARDLINK_MISSING_IN_LIST, - CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED, CTR_MSG_INIT_LOCK_FAILED, - CTR_MSG_COPY_FAILED, CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED, - CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, CTR_MSG_NULL_LOCAL); - -#endif /* !_CTR_MESSAGES_H_ */ diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c deleted file mode 100644 index b6b66d56731..00000000000 --- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#include "ctr-xlator-ctx.h" -#include "ctr-messages.h" -#include <time.h> -#include <sys/time.h> - -#define IS_THE_ONLY_HARDLINK(ctr_hard_link) \ - (ctr_hard_link->list.next == ctr_hard_link->list.prev) - -static void -fini_ctr_hard_link(ctr_hard_link_t **ctr_hard_link) -{ - GF_ASSERT(ctr_hard_link); - - if (*ctr_hard_link) - return; - GF_FREE((*ctr_hard_link)->base_name); - GF_FREE(*ctr_hard_link); - *ctr_hard_link = NULL; -} - -/* Please lock the ctr_xlator_ctx before using this function */ -ctr_hard_link_t * -ctr_search_hard_link_ctx(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name) -{ - ctr_hard_link_t *_hard_link = NULL; - ctr_hard_link_t *searched_hardlink = NULL; - - GF_ASSERT(this); - GF_ASSERT(ctr_xlator_ctx); - - if (pgfid == NULL || base_name == NULL) - goto out; - - /*linear search*/ - list_for_each_entry(_hard_link, &ctr_xlator_ctx->hardlink_list, list) - { - if (gf_uuid_compare(_hard_link->pgfid, pgfid) == 0 && - _hard_link->base_name && - strcmp(_hard_link->base_name, base_name) == 0) { - searched_hardlink = _hard_link; - break; - } - } - -out: - return searched_hardlink; -} - -/* Please lock the ctr_xlator_ctx before using this function */ -int -ctr_add_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name) -{ - int ret = -1; - ctr_hard_link_t *ctr_hard_link = NULL; - struct timeval current_time = {0}; - - GF_ASSERT(this); - GF_ASSERT(ctr_xlator_ctx); - - if (pgfid == NULL || base_name == NULL) - goto out; - - ctr_hard_link = GF_CALLOC(1, sizeof(*ctr_hard_link), gf_ctr_mt_hard_link_t); - if (!ctr_hard_link) { - gf_msg(this->name, GF_LOG_ERROR, ENOMEM, CTR_MSG_CALLOC_FAILED, - "Failed allocating " - "ctr_hard_link"); - goto out; - } - - /*Initialize the ctr_hard_link object and - * Assign the values : parent GFID and basename*/ - INIT_LIST_HEAD(&ctr_hard_link->list); - gf_uuid_copy(ctr_hard_link->pgfid, pgfid); - ret = gf_asprintf(&ctr_hard_link->base_name, "%s", base_name); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_COPY_FAILED, - "Failed copying basename" - "to ctr_hard_link"); - goto error; - } - - ret = gettimeofday(¤t_time, NULL); - if (ret == -1) { - gf_log(this->name, GF_LOG_ERROR, "Failed to get current time"); - goto error; - } - - /*Add the hard link to the list*/ - list_add_tail(&ctr_hard_link->list, &ctr_xlator_ctx->hardlink_list); - - ctr_hard_link->hardlink_heal_period = current_time.tv_sec; - - /*aal izz well!*/ - ret = 0; - goto out; -error: - GF_FREE(ctr_hard_link); -out: - return ret; -} - -static void -__delete_hard_link_from_list(ctr_hard_link_t **ctr_hard_link) -{ - GF_ASSERT(ctr_hard_link); - GF_ASSERT(*ctr_hard_link); - - /*Remove hard link from list*/ - list_del(&(*ctr_hard_link)->list); - fini_ctr_hard_link(ctr_hard_link); -} - -int -ctr_delete_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name) -{ - int ret = -1; - ctr_hard_link_t *ctr_hard_link = NULL; - - GF_ASSERT(this); - GF_ASSERT(ctr_xlator_ctx); - - LOCK(&ctr_xlator_ctx->lock); - - /*Check if the hard link is present */ - ctr_hard_link = ctr_search_hard_link_ctx(this, ctr_xlator_ctx, pgfid, - base_name); - if (!ctr_hard_link) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_HARDLINK_MISSING_IN_LIST, - "Hard link doesn't exist in the list"); - goto out; - } - - __delete_hard_link_from_list(&ctr_hard_link); - ctr_hard_link = NULL; - - ret = 0; -out: - UNLOCK(&ctr_xlator_ctx->lock); - - return ret; -} - -int -ctr_update_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name, uuid_t old_pgfid, - const char *old_base_name) -{ - int ret = -1; - ctr_hard_link_t *ctr_hard_link = NULL; - struct timeval current_time = {0}; - - GF_ASSERT(this); - GF_ASSERT(ctr_xlator_ctx); - - LOCK(&ctr_xlator_ctx->lock); - - /*Check if the hard link is present */ - ctr_hard_link = ctr_search_hard_link_ctx(this, ctr_xlator_ctx, old_pgfid, - old_base_name); - if (!ctr_hard_link) { - gf_msg_trace(this->name, 0, - "Hard link doesn't exist" - " in the list"); - /* Since the hard link is not present in the list - * we add it to the list */ - ret = ctr_add_hard_link(this, ctr_xlator_ctx, pgfid, base_name); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED, - "Failed adding hard link to the list"); - goto out; - } - ret = 0; - goto out; - } - - /* update the hard link */ - gf_uuid_copy(ctr_hard_link->pgfid, pgfid); - GF_FREE(ctr_hard_link->base_name); - ret = gf_asprintf(&ctr_hard_link->base_name, "%s", base_name); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_COPY_FAILED, - "Failed copying basename" - "to ctr_hard_link"); - /* delete the corrupted entry */ - __delete_hard_link_from_list(&ctr_hard_link); - ctr_hard_link = NULL; - goto out; - } - - ret = gettimeofday(¤t_time, NULL); - if (ret == -1) { - gf_log(this->name, GF_LOG_ERROR, "Failed to get current time"); - ctr_hard_link->hardlink_heal_period = 0; - } else { - ctr_hard_link->hardlink_heal_period = current_time.tv_sec; - } - - ret = 0; - -out: - UNLOCK(&ctr_xlator_ctx->lock); - - return ret; -} - -/* Delete all hardlinks */ -static int -ctr_delete_all_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx) -{ - int ret = -1; - ctr_hard_link_t *ctr_hard_link = NULL; - ctr_hard_link_t *tmp = NULL; - - GF_ASSERT(ctr_xlator_ctx); - - LOCK(&ctr_xlator_ctx->lock); - - list_for_each_entry_safe(ctr_hard_link, tmp, &ctr_xlator_ctx->hardlink_list, - list) - { - /*Remove hard link from list*/ - __delete_hard_link_from_list(&ctr_hard_link); - ctr_hard_link = NULL; - } - - UNLOCK(&ctr_xlator_ctx->lock); - - ret = 0; - - return ret; -} - -/* Please lock the inode before using this function */ -static ctr_xlator_ctx_t * -__get_ctr_xlator_ctx(xlator_t *this, inode_t *inode) -{ - int ret = 0; - uint64_t _addr = 0; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - - GF_ASSERT(this); - GF_ASSERT(inode); - - ret = __inode_ctx_get(inode, this, &_addr); - if (ret < 0) - _addr = 0; - if (_addr != 0) { - ctr_xlator_ctx = (ctr_xlator_ctx_t *)(long)_addr; - } - - return ctr_xlator_ctx; -} - -ctr_xlator_ctx_t * -init_ctr_xlator_ctx(xlator_t *this, inode_t *inode) -{ - int ret = -1; - uint64_t _addr = 0; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - struct timeval current_time = {0}; - - GF_ASSERT(this); - GF_ASSERT(inode); - - LOCK(&inode->lock); - { - ctr_xlator_ctx = __get_ctr_xlator_ctx(this, inode); - if (ctr_xlator_ctx) { - ret = 0; - goto out; - } - ctr_xlator_ctx = GF_CALLOC(1, sizeof(*ctr_xlator_ctx), - gf_ctr_mt_xlator_ctx); - if (!ctr_xlator_ctx) - goto out; - - ret = LOCK_INIT(&ctr_xlator_ctx->lock); - if (ret) { - gf_msg(this->name, GF_LOG_ERROR, ret, CTR_MSG_INIT_LOCK_FAILED, - "Failed init lock %s", strerror(ret)); - goto out; - } - _addr = (uint64_t)(uintptr_t)ctr_xlator_ctx; - - ret = __inode_ctx_set(inode, this, &_addr); - if (ret) { - goto out; - } - - INIT_LIST_HEAD(&ctr_xlator_ctx->hardlink_list); - - ret = gettimeofday(¤t_time, NULL); - if (ret == -1) { - gf_log(this->name, GF_LOG_ERROR, "Failed to get current time"); - goto out; - } - - ctr_xlator_ctx->inode_heal_period = current_time.tv_sec; - } - ret = 0; -out: - if (ret) { - GF_FREE(ctr_xlator_ctx); - ctr_xlator_ctx = NULL; - } - - UNLOCK(&inode->lock); - - return ctr_xlator_ctx; -} - -void -fini_ctr_xlator_ctx(xlator_t *this, inode_t *inode) -{ - int ret = 0; - uint64_t _addr = 0; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - - inode_ctx_del(inode, this, &_addr); - if (!_addr) - return; - - ctr_xlator_ctx = (ctr_xlator_ctx_t *)(long)_addr; - - ret = ctr_delete_all_hard_link(this, ctr_xlator_ctx); - if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed deleting all " - "hard links from inode context"); - } - - LOCK_DESTROY(&ctr_xlator_ctx->lock); - - GF_FREE(ctr_xlator_ctx); -} - -ctr_xlator_ctx_t * -get_ctr_xlator_ctx(xlator_t *this, inode_t *inode) -{ - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - - LOCK(&inode->lock); - ctr_xlator_ctx = __get_ctr_xlator_ctx(this, inode); - UNLOCK(&inode->lock); - - return ctr_xlator_ctx; -} diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h deleted file mode 100644 index 4e3bf7e2798..00000000000 --- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef __CTR_XLATOR_CTX_H -#define __CTR_XLATOR_CTX_H - -#include <glusterfs/xlator.h> -#include "ctr_mem_types.h" -#include <glusterfs/iatt.h> -#include <glusterfs/glusterfs.h> -#include <glusterfs/xlator.h> -#include <glusterfs/logging.h> -#include <glusterfs/locking.h> -#include <glusterfs/common-utils.h> -#include <time.h> -#include <sys/time.h> - -typedef struct ctr_hard_link { - uuid_t pgfid; - char *base_name; - /* Hardlink expiry : Defines the expiry period after which a - * database heal is attempted. */ - uint64_t hardlink_heal_period; - struct list_head list; -} ctr_hard_link_t; - -typedef struct ctr_xlator_ctx { - /* This represents the looked up hardlinks - * NOTE: This doesn't represent all physical hardlinks of the inode*/ - struct list_head hardlink_list; - uint64_t inode_heal_period; - gf_lock_t lock; -} ctr_xlator_ctx_t; - -ctr_hard_link_t * -ctr_search_hard_link_ctx(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name); - -int -ctr_add_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name); - -int -ctr_delete_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name); - -int -ctr_update_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, const char *base_name, uuid_t old_pgfid, - const char *old_base_name); - -ctr_xlator_ctx_t * -get_ctr_xlator_ctx(xlator_t *this, inode_t *inode); - -ctr_xlator_ctx_t * -init_ctr_xlator_ctx(xlator_t *this, inode_t *inode); - -void -fini_ctr_xlator_ctx(xlator_t *this, inode_t *inode); - -#endif diff --git a/xlators/features/changetimerecorder/src/ctr_mem_types.h b/xlators/features/changetimerecorder/src/ctr_mem_types.h deleted file mode 100644 index 7b8f531ddec..00000000000 --- a/xlators/features/changetimerecorder/src/ctr_mem_types.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (c) 2008-2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef __CTR_MEM_TYPES_H__ -#define __CTR_MEM_TYPES_H__ - -#include "gfdb_mem-types.h" - -enum gf_ctr_mem_types_ { - gf_ctr_mt_private_t = gfdb_mt_end + 1, - gf_ctr_mt_xlator_ctx, - gf_ctr_mt_hard_link_t, - gf_ctr_mt_end -}; -#endif diff --git a/xlators/features/glupy/Makefile.am b/xlators/features/glupy/Makefile.am deleted file mode 100644 index 060429ecf0f..00000000000 --- a/xlators/features/glupy/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = src examples - -CLEANFILES = diff --git a/xlators/features/glupy/doc/README.md b/xlators/features/glupy/doc/README.md deleted file mode 100644 index 4b8b863ef39..00000000000 --- a/xlators/features/glupy/doc/README.md +++ /dev/null @@ -1,44 +0,0 @@ -This is just the very start for a GlusterFS[1] meta-translator that will -allow translator code to be written in Python. It's based on the standard -Python embedding (not extending) techniques, plus a dash of the ctypes module. -The interface is a pretty minimal adaptation of the dispatches and callbacks -from the C API[2] to Python, as follows: - -* Dispatch functions and callbacks must be defined on an "xlator" class - derived from gluster.Translator so that they'll be auto-registered with - the C translator during initialization. - -* For each dispatch or callback function you want to intercept, you define a - Python function using the xxx\_fop\_t or xxx\_cbk\_t decorator. - -* The arguments for each operation are different, so you'll need to refer to - the C API. GlusterFS-specific types are used (though only loc\_t is fully - defined so far) and type correctness is enforced by ctypes. - -* If you do intercept a dispatch function, it is your responsibility to call - xxx\_wind (like STACK\_WIND in the C API but operation-specific) to pass - the request to the next translator. If you do not intercept a function, it - will default the same way as for C (pass through to the same operation with - the same arguments on the first child translator). - -* If you intercept a callback function, it is your responsibility to call - xxx\_unwind (like STACK\_UNWIND\_STRICT in the C API) to pass the request back - to the caller. - -So far only the lookup and create operations are handled this way, to support -the "negative lookup" example. Now that the basic infrastructure is in place, -adding more functions should be very quick, though with that much boilerplate I -might pause to write a code generator. I also plan to add structure -definitions and interfaces for some of the utility functions in libglusterfs -(especially those having to do with inode and fd context) in the fairly near -future. Note that you can also use ctypes to get at anything not explicitly -exposed to Python already. - -_If you're coming here because of the Linux Journal article, please note that -the code has evolved since that was written. The version that matches the -article is here:_ - -https://github.com/jdarcy/glupy/tree/4bbae91ba459ea46ef32f2966562492e4ca9187a - -[1] http://www.gluster.org -[2] http://pl.atyp.us/hekafs.org/dist/xlator_api_2.html diff --git a/xlators/features/glupy/doc/TESTING b/xlators/features/glupy/doc/TESTING deleted file mode 100644 index e05f17f498f..00000000000 --- a/xlators/features/glupy/doc/TESTING +++ /dev/null @@ -1,9 +0,0 @@ -Loading a translator written in Python using the glupy meta translator -------------------------------------------------------------------------------- -'test.vol' is a simple volfile with the debug-trace Python translator on top -of a brick. The volfile can be mounted using the following command. - -$ glusterfs --debug -f test.vol /path/to/mntpt - -If then file operations are performed on the newly mounted file system, log -output would be printed by the Python translator on the standard output. diff --git a/xlators/features/glupy/doc/test.vol b/xlators/features/glupy/doc/test.vol deleted file mode 100644 index 0751a488c1f..00000000000 --- a/xlators/features/glupy/doc/test.vol +++ /dev/null @@ -1,10 +0,0 @@ -volume vol-posix - type storage/posix - option directory /path/to/brick -end-volume - -volume vol-glupy - type features/glupy - option module-name debug-trace - subvolumes vol-posix -end-volume diff --git a/xlators/features/glupy/examples/Makefile.am b/xlators/features/glupy/examples/Makefile.am deleted file mode 100644 index c26abeaafb6..00000000000 --- a/xlators/features/glupy/examples/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features - -glupyexamplesdir = $(xlatordir)/glupy - -glupyexamples_PYTHON = negative.py helloworld.py debug-trace.py diff --git a/xlators/features/glupy/examples/debug-trace.py b/xlators/features/glupy/examples/debug-trace.py deleted file mode 100644 index 6e012f6c547..00000000000 --- a/xlators/features/glupy/examples/debug-trace.py +++ /dev/null @@ -1,777 +0,0 @@ - -from __future__ import print_function -import sys -import stat -from uuid import UUID -from time import strftime, localtime -from gluster.glupy import * - -# This translator was written primarily to test the fop entry point definitions -# and structure definitions in 'glupy.py'. - -# It is similar to the C language debug-trace translator, which logs the -# arguments passed to the fops and their corresponding cbk functions. - -dl.get_id.restype = c_long -dl.get_id.argtypes = [ POINTER(call_frame_t) ] - -dl.get_rootunique.restype = c_uint64 -dl.get_rootunique.argtypes = [ POINTER(call_frame_t) ] - -def uuid2str (gfid): - return str(UUID(''.join(map("{0:02x}".format, gfid)))) - - -def st_mode_from_ia (prot, filetype): - st_mode = 0 - type_bit = 0 - prot_bit = 0 - - if filetype == IA_IFREG: - type_bit = stat.S_IFREG - elif filetype == IA_IFDIR: - type_bit = stat.S_IFDIR - elif filetype == IA_IFLNK: - type_bit = stat.S_IFLNK - elif filetype == IA_IFBLK: - type_bit = stat.S_IFBLK - elif filetype == IA_IFCHR: - type_bit = stat.S_IFCHR - elif filetype == IA_IFIFO: - type_bit = stat.S_IFIFO - elif filetype == IA_IFSOCK: - type_bit = stat.S_IFSOCK - elif filetype == IA_INVAL: - pass - - - if prot.suid: - prot_bit |= stat.S_ISUID - if prot.sgid: - prot_bit |= stat.S_ISGID - if prot.sticky: - prot_bit |= stat.S_ISVTX - - if prot.owner.read: - prot_bit |= stat.S_IRUSR - if prot.owner.write: - prot_bit |= stat.S_IWUSR - if prot.owner.execn: - prot_bit |= stat.S_IXUSR - - if prot.group.read: - prot_bit |= stat.S_IRGRP - if prot.group.write: - prot_bit |= stat.S_IWGRP - if prot.group.execn: - prot_bit |= stat.S_IXGRP - - if prot.other.read: - prot_bit |= stat.S_IROTH - if prot.other.write: - prot_bit |= stat.S_IWOTH - if prot.other.execn: - prot_bit |= stat.S_IXOTH - - st_mode = (type_bit | prot_bit) - - return st_mode - - -def trace_stat2str (buf): - gfid = uuid2str(buf.contents.ia_gfid) - mode = st_mode_from_ia(buf.contents.ia_prot, buf.contents.ia_type) - atime_buf = strftime("[%b %d %H:%M:%S]", - localtime(buf.contents.ia_atime)) - mtime_buf = strftime("[%b %d %H:%M:%S]", - localtime(buf.contents.ia_mtime)) - ctime_buf = strftime("[%b %d %H:%M:%S]", - localtime(buf.contents.ia_ctime)) - return ("(gfid={0:s}, ino={1:d}, mode={2:o}, nlink={3:d}, uid ={4:d}, "+ - "gid ={5:d}, size={6:d}, blocks={7:d}, atime={8:s}, mtime={9:s}, "+ - "ctime={10:s})").format(gfid, buf.contents.ia_no, mode, - buf.contents.ia_nlink, - buf.contents.ia_uid, - buf.contents.ia_gid, - buf.contents.ia_size, - buf.contents.ia_blocks, - atime_buf, mtime_buf, - ctime_buf) - -class xlator(Translator): - - def __init__(self, c_this): - Translator.__init__(self, c_this) - self.gfids = {} - - def lookup_fop(self, frame, this, loc, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.gfid) - print(("GLUPY TRACE LOOKUP FOP- {0:d}: gfid={1:s}; " + - "path={2:s}").format(unique, gfid, loc.contents.path)) - self.gfids[key] = gfid - dl.wind_lookup(frame, POINTER(xlator_t)(), loc, xdata) - return 0 - - def lookup_cbk(self, frame, cookie, this, op_ret, op_errno, - inode, buf, xdata, postparent): - unique =dl.get_rootunique(frame) - key =dl.get_id(frame) - if op_ret == 0: - gfid = uuid2str(buf.contents.ia_gfid) - statstr = trace_stat2str(buf) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE LOOKUP CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; *buf={3:s}; " + - "*postparent={4:s}").format(unique, gfid, - op_ret, statstr, - postparentstr)) - else: - gfid = self.gfids[key] - print(("GLUPY TRACE LOOKUP CBK - {0:d}: gfid={1:s};" + - " op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_lookup(frame, cookie, this, op_ret, op_errno, - inode, buf, xdata, postparent) - return 0 - - def create_fop(self, frame, this, loc, flags, mode, umask, fd, - xdata): - unique = dl.get_rootunique(frame) - gfid = uuid2str(loc.contents.gfid) - print(("GLUPY TRACE CREATE FOP- {0:d}: gfid={1:s}; path={2:s}; " + - "fd={3:s}; flags=0{4:o}; mode=0{5:o}; " + - "umask=0{6:o}").format(unique, gfid, loc.contents.path, - fd, flags, mode, umask)) - dl.wind_create(frame, POINTER(xlator_t)(), loc, flags, mode, - umask, fd, xdata) - return 0 - - def create_cbk(self, frame, cookie, this, op_ret, op_errno, fd, - inode, buf, preparent, postparent, xdata): - unique = dl.get_rootunique(frame) - if op_ret >= 0: - gfid = uuid2str(inode.contents.gfid) - statstr = trace_stat2str(buf) - preparentstr = trace_stat2str(preparent) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE CREATE CBK- {0:d}: gfid={1:s};" + - " op_ret={2:d}; fd={3:s}; *stbuf={4:s}; " + - "*preparent={5:s};" + - " *postparent={6:s}").format(unique, gfid, op_ret, - fd, statstr, - preparentstr, - postparentstr)) - else: - print(("GLUPY TRACE CREATE CBK- {0:d}: op_ret={1:d}; " + - "op_errno={2:d}").format(unique, op_ret, op_errno)) - dl.unwind_create(frame, cookie, this, op_ret, op_errno, fd, - inode, buf, preparent, postparent, xdata) - return 0 - - def open_fop(self, frame, this, loc, flags, fd, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE OPEN FOP- {0:d}: gfid={1:s}; path={2:s}; "+ - "flags={3:d}; fd={4:s}").format(unique, gfid, - loc.contents.path, flags, - fd)) - self.gfids[key] = gfid - dl.wind_open(frame, POINTER(xlator_t)(), loc, flags, fd, xdata) - return 0 - - def open_cbk(self, frame, cookie, this, op_ret, op_errno, fd, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE OPEN CBK- {0:d}: gfid={1:s}; op_ret={2:d}; " - "op_errno={3:d}; *fd={4:s}").format(unique, gfid, - op_ret, op_errno, fd)) - del self.gfids[key] - dl.unwind_open(frame, cookie, this, op_ret, op_errno, fd, - xdata) - return 0 - - def readv_fop(self, frame, this, fd, size, offset, flags, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE READV FOP- {0:d}: gfid={1:s}; "+ - "fd={2:s}; size ={3:d}; offset={4:d}; " + - "flags=0{5:x}").format(unique, gfid, fd, size, offset, - flags)) - self.gfids[key] = gfid - dl.wind_readv (frame, POINTER(xlator_t)(), fd, size, offset, - flags, xdata) - return 0 - - def readv_cbk(self, frame, cookie, this, op_ret, op_errno, vector, - count, buf, iobref, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret >= 0: - statstr = trace_stat2str(buf) - print(("GLUPY TRACE READV CBK- {0:d}: gfid={1:s}, "+ - "op_ret={2:d}; *buf={3:s};").format(unique, gfid, - op_ret, - statstr)) - - else: - print(("GLUPY TRACE READV CBK- {0:d}: gfid={1:s}, "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_readv (frame, cookie, this, op_ret, op_errno, - vector, count, buf, iobref, xdata) - return 0 - - def writev_fop(self, frame, this, fd, vector, count, offset, flags, - iobref, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE WRITEV FOP- {0:d}: gfid={1:s}; " + - "fd={2:s}; count={3:d}; offset={4:d}; " + - "flags=0{5:x}").format(unique, gfid, fd, count, offset, - flags)) - self.gfids[key] = gfid - dl.wind_writev(frame, POINTER(xlator_t)(), fd, vector, count, - offset, flags, iobref, xdata) - return 0 - - def writev_cbk(self, frame, cookie, this, op_ret, op_errno, prebuf, - postbuf, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - if op_ret >= 0: - preopstr = trace_stat2str(prebuf) - postopstr = trace_stat2str(postbuf) - print(("GLUPY TRACE WRITEV CBK- {0:d}: op_ret={1:d}; " + - "*prebuf={2:s}; " + - "*postbuf={3:s}").format(unique, op_ret, preopstr, - postopstr)) - else: - gfid = self.gfids[key] - print(("GLUPY TRACE WRITEV CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_writev (frame, cookie, this, op_ret, op_errno, - prebuf, postbuf, xdata) - return 0 - - def opendir_fop(self, frame, this, loc, fd, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE OPENDIR FOP- {0:d}: gfid={1:s}; path={2:s}; "+ - "fd={3:s}").format(unique, gfid, loc.contents.path, fd)) - self.gfids[key] = gfid - dl.wind_opendir(frame, POINTER(xlator_t)(), loc, fd, xdata) - return 0 - - def opendir_cbk(self, frame, cookie, this, op_ret, op_errno, fd, - xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE OPENDIR CBK- {0:d}: gfid={1:s}; op_ret={2:d};"+ - " op_errno={3:d}; fd={4:s}").format(unique, gfid, op_ret, - op_errno, fd)) - del self.gfids[key] - dl.unwind_opendir(frame, cookie, this, op_ret, op_errno, - fd, xdata) - return 0 - - def readdir_fop(self, frame, this, fd, size, offset, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE READDIR FOP- {0:d}: gfid={1:s}; fd={2:s}; " + - "size={3:d}; offset={4:d}").format(unique, gfid, fd, size, - offset)) - self.gfids[key] = gfid - dl.wind_readdir(frame, POINTER(xlator_t)(), fd, size, offset, - xdata) - return 0 - - def readdir_cbk(self, frame, cookie, this, op_ret, op_errno, buf, - xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE READDIR CBK- {0:d}: gfid={1:s}; op_ret={2:d};"+ - " op_errno={3:d}").format(unique, gfid, op_ret, op_errno)) - del self.gfids[key] - dl.unwind_readdir(frame, cookie, this, op_ret, op_errno, buf, - xdata) - return 0 - - def readdirp_fop(self, frame, this, fd, size, offset, dictionary): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE READDIRP FOP- {0:d}: gfid={1:s}; fd={2:s}; "+ - " size={3:d}; offset={4:d}").format(unique, gfid, fd, size, - offset)) - self.gfids[key] = gfid - dl.wind_readdirp(frame, POINTER(xlator_t)(), fd, size, offset, - dictionary) - return 0 - - def readdirp_cbk(self, frame, cookie, this, op_ret, op_errno, buf, - xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE READDIRP CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, gfid, - op_ret, op_errno)) - del self.gfids[key] - dl.unwind_readdirp(frame, cookie, this, op_ret, op_errno, buf, - xdata) - return 0 - - def mkdir_fop(self, frame, this, loc, mode, umask, xdata): - unique = dl.get_rootunique(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE MKDIR FOP- {0:d}: gfid={1:s}; path={2:s}; " + - "mode={3:d}; umask=0{4:o}").format(unique, gfid, - loc.contents.path, mode, - umask)) - dl.wind_mkdir(frame, POINTER(xlator_t)(), loc, mode, umask, - xdata) - return 0 - - def mkdir_cbk(self, frame, cookie, this, op_ret, op_errno, inode, buf, - preparent, postparent, xdata): - unique = dl.get_rootunique(frame) - if op_ret == 0: - gfid = uuid2str(inode.contents.gfid) - statstr = trace_stat2str(buf) - preparentstr = trace_stat2str(preparent) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE MKDIR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; *stbuf={3:s}; *prebuf={4:s}; "+ - "*postbuf={5:s} ").format(unique, gfid, op_ret, - statstr, - preparentstr, - postparentstr)) - else: - print(("GLUPY TRACE MKDIR CBK- {0:d}: op_ret={1:d}; "+ - "op_errno={2:d}").format(unique, op_ret, op_errno)) - dl.unwind_mkdir(frame, cookie, this, op_ret, op_errno, inode, - buf, preparent, postparent, xdata) - return 0 - - def rmdir_fop(self, frame, this, loc, flags, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE RMDIR FOP- {0:d}: gfid={1:s}; path={2:s}; "+ - "flags={3:d}").format(unique, gfid, loc.contents.path, - flags)) - self.gfids[key] = gfid - dl.wind_rmdir(frame, POINTER(xlator_t)(), loc, flags, xdata) - return 0 - - def rmdir_cbk(self, frame, cookie, this, op_ret, op_errno, preparent, - postparent, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - preparentstr = trace_stat2str(preparent) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE RMDIR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; *prebuf={3:s}; "+ - "*postbuf={4:s}").format(unique, gfid, op_ret, - preparentstr, - postparentstr)) - else: - print(("GLUPY TRACE RMDIR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_rmdir(frame, cookie, this, op_ret, op_errno, - preparent, postparent, xdata) - return 0 - - def stat_fop(self, frame, this, loc, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE STAT FOP- {0:d}: gfid={1:s}; " + - " path={2:s}").format(unique, gfid, loc.contents.path)) - self.gfids[key] = gfid - dl.wind_stat(frame, POINTER(xlator_t)(), loc, xdata) - return 0 - - def stat_cbk(self, frame, cookie, this, op_ret, op_errno, buf, - xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - statstr = trace_stat2str(buf) - print(("GLUPY TRACE STAT CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; *buf={3:s};").format(unique, - gfid, - op_ret, - statstr)) - else: - print(("GLUPY TRACE STAT CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_stat(frame, cookie, this, op_ret, op_errno, - buf, xdata) - return 0 - - def fstat_fop(self, frame, this, fd, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE FSTAT FOP- {0:d}: gfid={1:s}; " + - "fd={2:s}").format(unique, gfid, fd)) - self.gfids[key] = gfid - dl.wind_fstat(frame, POINTER(xlator_t)(), fd, xdata) - return 0 - - def fstat_cbk(self, frame, cookie, this, op_ret, op_errno, buf, - xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - statstr = trace_stat2str(buf) - print(("GLUPY TRACE FSTAT CBK- {0:d}: gfid={1:s} "+ - " op_ret={2:d}; *buf={3:s}").format(unique, - gfid, - op_ret, - statstr)) - else: - print(("GLUPY TRACE FSTAT CBK- {0:d}: gfid={1:s} "+ - "op_ret={2:d}; op_errno={3:d}").format(unique. - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_fstat(frame, cookie, this, op_ret, op_errno, - buf, xdata) - return 0 - - def statfs_fop(self, frame, this, loc, xdata): - unique = dl.get_rootunique(frame) - if loc.contents.inode: - gfid = uuid2str(loc.contents.inode.contents.gfid) - else: - gfid = "0" - print(("GLUPY TRACE STATFS FOP- {0:d}: gfid={1:s}; "+ - "path={2:s}").format(unique, gfid, loc.contents.path)) - dl.wind_statfs(frame, POINTER(xlator_t)(), loc, xdata) - return 0 - - def statfs_cbk(self, frame, cookie, this, op_ret, op_errno, buf, - xdata): - unique = dl.get_rootunique(frame) - if op_ret == 0: - #TBD: print buf (pointer to an iovec type object) - print(("GLUPY TRACE STATFS CBK {0:d}: "+ - "op_ret={1:d}").format(unique, op_ret)) - else: - print(("GLUPY TRACE STATFS CBK- {0:d}"+ - "op_ret={1:d}; op_errno={2:d}").format(unique, - op_ret, - op_errno)) - dl.unwind_statfs(frame, cookie, this, op_ret, op_errno, - buf, xdata) - return 0 - - def getxattr_fop(self, frame, this, loc, name, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE GETXATTR FOP- {0:d}: gfid={1:s}; path={2:s};"+ - " name={3:s}").format(unique, gfid, loc.contents.path, - name)) - self.gfids[key]=gfid - dl.wind_getxattr(frame, POINTER(xlator_t)(), loc, name, xdata) - return 0 - - def getxattr_cbk(self, frame, cookie, this, op_ret, op_errno, - dictionary, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE GETXATTR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}; "+ - " dictionary={4:s}").format(unique, gfid, op_ret, op_errno, - dictionary)) - del self.gfids[key] - dl.unwind_getxattr(frame, cookie, this, op_ret, op_errno, - dictionary, xdata) - return 0 - - def fgetxattr_fop(self, frame, this, fd, name, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE FGETXATTR FOP- {0:d}: gfid={1:s}; fd={2:s}; "+ - "name={3:s}").format(unique, gfid, fd, name)) - self.gfids[key] = gfid - dl.wind_fgetxattr(frame, POINTER(xlator_t)(), fd, name, xdata) - return 0 - - def fgetxattr_cbk(self, frame, cookie, this, op_ret, op_errno, - dictionary, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE FGETXATTR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d};"+ - " dictionary={4:s}").format(unique, gfid, op_ret, - op_errno, dictionary)) - del self.gfids[key] - dl.unwind_fgetxattr(frame, cookie, this, op_ret, op_errno, - dictionary, xdata) - return 0 - - def setxattr_fop(self, frame, this, loc, dictionary, flags, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE SETXATTR FOP- {0:d}: gfid={1:s}; path={2:s};"+ - " flags={3:d}").format(unique, gfid, loc.contents.path, - flags)) - self.gfids[key] = gfid - dl.wind_setxattr(frame, POINTER(xlator_t)(), loc, dictionary, - flags, xdata) - return 0 - - def setxattr_cbk(self, frame, cookie, this, op_ret, op_errno, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE SETXATTR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, gfid, - op_ret, op_errno)) - del self.gfids[key] - dl.unwind_setxattr(frame, cookie, this, op_ret, op_errno, - xdata) - return 0 - - def fsetxattr_fop(self, frame, this, fd, dictionary, flags, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(fd.contents.inode.contents.gfid) - print(("GLUPY TRACE FSETXATTR FOP- {0:d}: gfid={1:s}; fd={2:p}; "+ - "flags={3:d}").format(unique, gfid, fd, flags)) - self.gfids[key] = gfid - dl.wind_fsetxattr(frame, POINTER(xlator_t)(), fd, dictionary, - flags, xdata) - return 0 - - def fsetxattr_cbk(self, frame, cookie, this, op_ret, op_errno, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE FSETXATTR CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, gfid, - op_ret, op_errno)) - del self.gfids[key] - dl.unwind_fsetxattr(frame, cookie, this, op_ret, op_errno, - xdata) - return 0 - - def removexattr_fop(self, frame, this, loc, name, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE REMOVEXATTR FOP- {0:d}: gfid={1:s}; "+ - "path={2:s}; name={3:s}").format(unique, gfid, - loc.contents.path, - name)) - self.gfids[key] = gfid - dl.wind_removexattr(frame, POINTER(xlator_t)(), loc, name, - xdata) - return 0 - - def removexattr_cbk(self, frame, cookie, this, op_ret, op_errno, - xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - print(("GLUPY TRACE REMOVEXATTR CBK- {0:d}: gfid={1:s} "+ - " op_ret={2:d}; op_errno={3:d}").format(unique, gfid, - op_ret, op_errno)) - del self.gfids[key] - dl.unwind_removexattr(frame, cookie, this, op_ret, op_errno, - xdata) - return 0 - - def link_fop(self, frame, this, oldloc, newloc, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - if (newloc.contents.inode): - newgfid = uuid2str(newloc.contents.inode.contents.gfid) - else: - newgfid = "0" - oldgfid = uuid2str(oldloc.contents.inode.contents.gfid) - print(("GLUPY TRACE LINK FOP-{0:d}: oldgfid={1:s}; oldpath={2:s};"+ - "newgfid={3:s};"+ - "newpath={4:s}").format(unique, oldgfid, - oldloc.contents.path, - newgfid, - newloc.contents.path)) - self.gfids[key] = oldgfid - dl.wind_link(frame, POINTER(xlator_t)(), oldloc, newloc, - xdata) - return 0 - - def link_cbk(self, frame, cookie, this, op_ret, op_errno, inode, buf, - preparent, postparent, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - statstr = trace_stat2str(buf) - preparentstr = trace_stat2str(preparent) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE LINK CBK- {0:d}: op_ret={1:d} "+ - "*stbuf={2:s}; *prebuf={3:s}; "+ - "*postbuf={4:s} ").format(unique, op_ret, statstr, - preparentstr, - postparentstr)) - else: - print(("GLUPY TRACE LINK CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; "+ - "op_errno={3:d}").format(unique, gfid, - op_ret, op_errno)) - del self.gfids[key] - dl.unwind_link(frame, cookie, this, op_ret, op_errno, inode, - buf, preparent, postparent, xdata) - return 0 - - def unlink_fop(self, frame, this, loc, xflag, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE UNLINK FOP- {0:d}; gfid={1:s}; path={2:s}; "+ - "flag={3:d}").format(unique, gfid, loc.contents.path, - xflag)) - self.gfids[key] = gfid - dl.wind_unlink(frame, POINTER(xlator_t)(), loc, xflag, - xdata) - return 0 - - def unlink_cbk(self, frame, cookie, this, op_ret, op_errno, - preparent, postparent, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - preparentstr = trace_stat2str(preparent) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE UNLINK CBK- {0:d}: gfid ={1:s}; "+ - "op_ret={2:d}; *prebuf={3:s}; "+ - "*postbuf={4:s} ").format(unique, gfid, op_ret, - preparentstr, - postparentstr)) - else: - print(("GLUPY TRACE UNLINK CBK: {0:d}: gfid ={1:s}; "+ - "op_ret={2:d}; "+ - "op_errno={3:d}").format(unique, gfid, op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_unlink(frame, cookie, this, op_ret, op_errno, - preparent, postparent, xdata) - return 0 - - def readlink_fop(self, frame, this, loc, size, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE READLINK FOP- {0:d}: gfid={1:s}; path={2:s};"+ - " size={3:d}").format(unique, gfid, loc.contents.path, - size)) - self.gfids[key] = gfid - dl.wind_readlink(frame, POINTER(xlator_t)(), loc, size, - xdata) - return 0 - - def readlink_cbk(self, frame, cookie, this, op_ret, op_errno, - buf, stbuf, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - statstr = trace_stat2str(stbuf) - print(("GLUPY TRACE READLINK CBK- {0:d}: gfid={1:s} "+ - " op_ret={2:d}; op_errno={3:d}; *prebuf={4:s}; "+ - "*postbuf={5:s} ").format(unique, gfid, - op_ret, op_errno, - buf, statstr)) - else: - print(("GLUPY TRACE READLINK CBK- {0:d}: gfid={1:s} "+ - " op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_readlink(frame, cookie, this, op_ret, op_errno, buf, - stbuf, xdata) - return 0 - - def symlink_fop(self, frame, this, linkpath, loc, umask, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = uuid2str(loc.contents.inode.contents.gfid) - print(("GLUPY TRACE SYMLINK FOP- {0:d}: gfid={1:s}; "+ - "linkpath={2:s}; path={3:s};"+ - "umask=0{4:o}").format(unique, gfid, linkpath, - loc.contents.path, umask)) - self.gfids[key] = gfid - dl.wind_symlink(frame, POINTER(xlator_t)(), linkpath, loc, - umask, xdata) - return 0 - - def symlink_cbk(self, frame, cookie, this, op_ret, op_errno, - inode, buf, preparent, postparent, xdata): - unique = dl.get_rootunique(frame) - key = dl.get_id(frame) - gfid = self.gfids[key] - if op_ret == 0: - statstr = trace_stat2str(buf) - preparentstr = trace_stat2str(preparent) - postparentstr = trace_stat2str(postparent) - print(("GLUPY TRACE SYMLINK CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; *stbuf={3:s}; *preparent={4:s}; "+ - "*postparent={5:s}").format(unique, gfid, - op_ret, statstr, - preparentstr, - postparentstr)) - else: - print(("GLUPY TRACE SYMLINK CBK- {0:d}: gfid={1:s}; "+ - "op_ret={2:d}; op_errno={3:d}").format(unique, - gfid, - op_ret, - op_errno)) - del self.gfids[key] - dl.unwind_symlink(frame, cookie, this, op_ret, op_errno, - inode, buf, preparent, postparent, xdata) - return 0 diff --git a/xlators/features/glupy/examples/helloworld.py b/xlators/features/glupy/examples/helloworld.py deleted file mode 100644 index 282f9207949..00000000000 --- a/xlators/features/glupy/examples/helloworld.py +++ /dev/null @@ -1,21 +0,0 @@ - -from __future__ import print_function -import sys -from gluster.glupy import * - -class xlator (Translator): - - def __init__(self, c_this): - Translator.__init__(self, c_this) - - def lookup_fop(self, frame, this, loc, xdata): - print("Python xlator: Hello!") - dl.wind_lookup(frame, POINTER(xlator_t)(), loc, xdata) - return 0 - - def lookup_cbk(self, frame, cookie, this, op_ret, op_errno, inode, buf, - xdata, postparent): - print("Python xlator: Hello again!") - dl.unwind_lookup(frame, cookie, this, op_ret, op_errno, inode, buf, - xdata, postparent) - return 0 diff --git a/xlators/features/glupy/examples/negative.py b/xlators/features/glupy/examples/negative.py deleted file mode 100644 index e04b16aa553..00000000000 --- a/xlators/features/glupy/examples/negative.py +++ /dev/null @@ -1,93 +0,0 @@ - -from __future__ import print_function -import sys -from uuid import UUID -from gluster.glupy import * - -# Negative-lookup-caching example. If a file wasn't there the last time we -# looked, it's probably still not there. This translator keeps track of -# those failed lookups for us, and returns ENOENT without needing to pass the -# call any further for repeated requests. - -# If we were doing this for real, we'd need separate caches for each xlator -# instance. The easiest way to do this would be to have xlator.__init__ -# "register" each instance in a module-global dict, with the key as the C -# translator address and the value as the xlator object itself. For testing -# and teaching, it's sufficient just to have one cache. The keys are parent -# GFIDs, and the entries are lists of names within that parent that we know -# don't exist. -cache = {} - -# TBD: we need a better way of handling per-request data (frame->local in C). -dl.get_id.restype = c_long -dl.get_id.argtypes = [ POINTER(call_frame_t) ] - -def uuid2str (gfid): - return str(UUID(''.join(map("{0:02x}".format, gfid)))) - -class xlator (Translator): - - def __init__ (self, c_this): - self.requests = {} - Translator.__init__(self, c_this) - - def lookup_fop (self, frame, this, loc, xdata): - pargfid = uuid2str(loc.contents.pargfid) - print("lookup FOP: %s:%s" % (pargfid, loc.contents.name)) - # Check the cache. - if pargfid in cache: - if loc.contents.name in cache[pargfid]: - print("short-circuiting for %s:%s" % (pargfid, - loc.contents.name)) - dl.unwind_lookup(frame, 0, this, -1, 2, None, None, None, None) - return 0 - key = dl.get_id(frame) - self.requests[key] = (pargfid, loc.contents.name[:]) - # TBD: get real child xl from init, pass it here - dl.wind_lookup(frame, POINTER(xlator_t)(), loc, xdata) - return 0 - - def lookup_cbk (self, frame, cookie, this, op_ret, op_errno, inode, buf, - xdata, postparent): - print("lookup CBK: %d (%d)" % (op_ret, op_errno)) - key = dl.get_id(frame) - pargfid, name = self.requests[key] - # Update the cache. - if op_ret == 0: - print("found %s, removing from cache" % name) - if pargfid in cache: - cache[pargfid].discard(name) - elif op_errno == 2: # ENOENT - print("failed to find %s, adding to cache" % name) - if pargfid in cache: - cache[pargfid].add(name) - else: - cache[pargfid] = {name} - del self.requests[key] - dl.unwind_lookup(frame, cookie, this, op_ret, op_errno, - inode, buf, xdata, postparent) - return 0 - - def create_fop (self, frame, this, loc, flags, mode, umask, fd, xdata): - pargfid = uuid2str(loc.contents.pargfid) - print("create FOP: %s:%s" % (pargfid, loc.contents.name)) - key = dl.get_id(frame) - self.requests[key] = (pargfid, loc.contents.name[:]) - # TBD: get real child xl from init, pass it here - dl.wind_create(frame, POINTER(xlator_t)(), loc, flags, mode, umask, fd, xdata) - return 0 - - def create_cbk (self, frame, cookie, this, op_ret, op_errno, fd, inode, - buf, preparent, postparent, xdata): - print("create CBK: %d (%d)" % (op_ret, op_errno)) - key = dl.get_id(frame) - pargfid, name = self.requests[key] - # Update the cache. - if op_ret == 0: - print("created %s, removing from cache" % name) - if pargfid in cache: - cache[pargfid].discard(name) - del self.requests[key] - dl.unwind_create(frame, cookie, this, op_ret, op_errno, fd, inode, buf, - preparent, postparent, xdata) - return 0 diff --git a/xlators/features/glupy/src/Makefile.am b/xlators/features/glupy/src/Makefile.am deleted file mode 100644 index 817b0d00f61..00000000000 --- a/xlators/features/glupy/src/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -xlator_LTLIBRARIES = glupy.la - -# Ensure GLUSTER_PYTHON_PATH is passed to glupy.so -xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features -glupydir = $(xlatordir)/glupy - -AM_CPPFLAGS = $(GF_CPPFLAGS) \ - -I$(top_srcdir)/libglusterfs/src \ - -I$(top_srcdir)/rpc/xdr/src -I$(top_builddir)/rpc/xdr/src - -AM_CFLAGS = -Wall -fno-strict-aliasing \ - -DGLUSTER_PYTHON_PATH=\"$(glupydir)\" \ - -DPATH_GLUSTERFS_GLUPY_MODULE=\"${xlatordir}/glupy${shrext_cmds}\" \ - $(GF_CFLAGS) $(PYTHON_CFLAGS) - -# Flags to build glupy.so with -glupy_la_LDFLAGS = -module -nostartfiles \ - -export-symbols $(top_srcdir)/xlators/features/glupy/src/glupy.sym \ - $(GF_XLATOR_LDFLAGS) $(PYTHON_LIBS) - -glupy_la_SOURCES = glupy.c -glupy_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ - -lpthread $(LIB_DL) - -noinst_HEADERS = glupy.h - -# Install __init__.py into the Python site-packages area -pyglupydir = @BUILD_PYTHON_SITE_PACKAGES@/gluster -pyglupy_PYTHON = __init__.py - -# Install glupy/__init_-.py into the Python site-packages area -SUBDIRS = glupy - -CLEANFILES = - -EXTRA_DIST = glupy.sym diff --git a/xlators/features/glupy/src/__init__.py.in b/xlators/features/glupy/src/__init__.py.in deleted file mode 100644 index 3ad9513f40e..00000000000 --- a/xlators/features/glupy/src/__init__.py.in +++ /dev/null @@ -1,2 +0,0 @@ -from pkgutil import extend_path -__path__ = extend_path(__path__, __name__) diff --git a/xlators/features/glupy/src/glupy.c b/xlators/features/glupy/src/glupy.c deleted file mode 100644 index e2241b49ad3..00000000000 --- a/xlators/features/glupy/src/glupy.c +++ /dev/null @@ -1,2446 +0,0 @@ -/* - Copyright (c) 2006-2014 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#include <ctype.h> -#include <dlfcn.h> -#include <sys/uio.h> -#include <Python.h> - -#include <glusterfs/glusterfs.h> -#include <glusterfs/xlator.h> -#include <glusterfs/logging.h> -#include <glusterfs/defaults.h> - -#include "glupy.h" - -/* UTILITY FUNCTIONS FOR FOP-SPECIFIC CODE */ - -pthread_key_t gil_init_key; - -PyGILState_STATE -glupy_enter(void) -{ - if (!pthread_getspecific(gil_init_key)) { - PyEval_ReleaseLock(); - (void)pthread_setspecific(gil_init_key, (void *)1); - } - - return PyGILState_Ensure(); -} - -void -glupy_leave(PyGILState_STATE gstate) -{ - PyGILState_Release(gstate); -} - -/* FOP: LOOKUP */ - -int32_t -glupy_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, dict_t *xdata, struct iatt *postparent) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_LOOKUP]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_lookup_cbk_t)(priv->cbks[GLUPY_LOOKUP]))( - frame, cookie, this, op_ret, op_errno, inode, buf, xdata, postparent); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf, xdata, - postparent); - return 0; -} - -int32_t -glupy_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_LOOKUP]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_lookup_t)(priv->fops[GLUPY_LOOKUP]))(frame, this, loc, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_lookup_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->lookup, loc, xdata); - return 0; -} - -void -wind_lookup(call_frame_t *frame, xlator_t *xl, loc_t *loc, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_lookup_cbk, xl, xl->fops->lookup, loc, xdata); -} - -void -unwind_lookup(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, inode_t *inode, struct iatt *buf, dict_t *xdata, - struct iatt *postparent) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf, xdata, - postparent); -} - -void -set_lookup_fop(long py_this, fop_lookup_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_LOOKUP] = (long)fop; -} - -void -set_lookup_cbk(long py_this, fop_lookup_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_LOOKUP] = (long)cbk; -} - -/* FOP: CREATE */ - -int32_t -glupy_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, - struct iatt *buf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_CREATE]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_create_cbk_t)(priv->cbks[GLUPY_CREATE]))( - frame, cookie, this, op_ret, op_errno, fd, inode, buf, preparent, - postparent, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf, - preparent, postparent, xdata); - return 0; -} - -int32_t -glupy_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, - mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_CREATE]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_create_t)(priv->fops[GLUPY_CREATE]))(frame, this, loc, flags, - mode, umask, fd, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_create_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->create, loc, flags, mode, umask, fd, - xdata); - return 0; -} - -void -wind_create(call_frame_t *frame, xlator_t *xl, loc_t *loc, int32_t flags, - mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_create_cbk, xl, xl->fops->create, loc, flags, mode, - umask, fd, xdata); -} - -void -unwind_create(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, fd_t *fd, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf, - preparent, postparent, xdata); -} - -void -set_create_fop(long py_this, fop_create_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_CREATE] = (long)fop; -} - -void -set_create_cbk(long py_this, fop_create_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_CREATE] = (long)cbk; -} - -/* FOP: OPEN */ - -int32_t -glupy_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_OPEN]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_open_cbk_t)(priv->cbks[GLUPY_OPEN]))( - frame, cookie, this, op_ret, op_errno, fd, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd, xdata); - return 0; -} - -int32_t -glupy_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, - fd_t *fd, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_OPEN]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_open_t)(priv->fops[GLUPY_OPEN]))(frame, this, loc, flags, fd, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_open_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata); - return 0; -} - -void -wind_open(call_frame_t *frame, xlator_t *xl, loc_t *loc, int32_t flags, - fd_t *fd, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_open_cbk, xl, xl->fops->open, loc, flags, fd, - xdata); -} - -void -unwind_open(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, fd_t *fd, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd, xdata); -} - -void -set_open_fop(long py_this, fop_open_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - priv->fops[GLUPY_OPEN] = (long)fop; -} - -void -set_open_cbk(long py_this, fop_open_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - priv->cbks[GLUPY_OPEN] = (long)cbk; -} - -/* FOP: READV */ - -int32_t -glupy_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iovec *vector, - int32_t count, struct iatt *stbuf, struct iobref *iobref, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_READV]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_readv_cbk_t)(priv->cbks[GLUPY_READV]))( - frame, cookie, this, op_ret, op_errno, vector, count, stbuf, iobref, - xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count, stbuf, - iobref, xdata); - return 0; -} - -int32_t -glupy_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset, uint32_t flags, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_READV]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_readv_t)(priv->fops[GLUPY_READV]))(frame, this, fd, size, - offset, flags, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_readv_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata); - return 0; -} - -void -wind_readv(call_frame_t *frame, xlator_t *xl, fd_t *fd, size_t size, - off_t offset, uint32_t flags, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_readv_cbk, xl, xl->fops->readv, fd, size, offset, - flags, xdata); -} - -void -unwind_readv(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct iovec *vector, int32_t count, - struct iatt *stbuf, struct iobref *iobref, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count, stbuf, - iobref, xdata); -} - -void -set_readv_fop(long py_this, fop_readv_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - priv->fops[GLUPY_READV] = (long)fop; -} - -void -set_readv_cbk(long py_this, fop_readv_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - priv->cbks[GLUPY_READV] = (long)cbk; -} - -/* FOP: WRITEV */ - -int32_t -glupy_writev_cbk(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) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_WRITEV]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_writev_cbk_t)(priv->cbks[GLUPY_WRITEV]))( - frame, cookie, this, op_ret, op_errno, prebuf, postbuf, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf, - xdata); - return 0; -} - -int32_t -glupy_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iovec *vector, int32_t count, off_t offset, uint32_t flags, - struct iobref *iobref, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_WRITEV]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_writev_t)(priv->fops[GLUPY_WRITEV]))( - frame, this, fd, vector, count, offset, flags, iobref, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_writev_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->writev, fd, vector, count, offset, - flags, iobref, xdata); - return 0; -} - -void -wind_writev(call_frame_t *frame, xlator_t *xl, fd_t *fd, struct iovec *vector, - int32_t count, off_t offset, uint32_t flags, struct iobref *iobref, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_writev_cbk, xl, xl->fops->writev, fd, vector, count, - offset, flags, iobref, xdata); -} - -void -unwind_writev(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, - dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf, - xdata); -} - -void -set_writev_fop(long py_this, fop_writev_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - priv->fops[GLUPY_WRITEV] = (long)fop; -} - -void -set_writev_cbk(long py_this, fop_writev_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - priv->cbks[GLUPY_WRITEV] = (long)cbk; -} - -/* FOP: OPENDIR */ - -int32_t -glupy_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_OPENDIR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_opendir_cbk_t)(priv->cbks[GLUPY_OPENDIR]))( - frame, cookie, this, op_ret, op_errno, fd, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(opendir, frame, op_ret, op_errno, fd, xdata); - return 0; -} - -int32_t -glupy_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_OPENDIR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_opendir_t)(priv->fops[GLUPY_OPENDIR]))(frame, this, loc, fd, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_opendir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->opendir, loc, fd, xdata); - return 0; -} - -void -wind_opendir(call_frame_t *frame, xlator_t *xl, loc_t *loc, fd_t *fd, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_opendir_cbk, xl, xl->fops->opendir, loc, fd, xdata); -} - -void -unwind_opendir(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, fd_t *fd, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(opendir, frame, op_ret, op_errno, fd, xdata); -} - -void -set_opendir_fop(long py_this, fop_opendir_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_OPENDIR] = (long)fop; -} - -void -set_opendir_cbk(long py_this, fop_opendir_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_OPENDIR] = (long)cbk; -} - -/* FOP: READDIR */ - -int32_t -glupy_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_READDIR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_readdir_cbk_t)(priv->cbks[GLUPY_READDIR]))( - frame, cookie, this, op_ret, op_errno, entries, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(readdir, frame, op_ret, op_errno, entries, xdata); - return 0; -} - -int32_t -glupy_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_READDIR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_readdir_t)(priv->fops[GLUPY_READDIR]))(frame, this, fd, size, - offset, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_readdir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readdir, fd, size, offset, xdata); - return 0; -} - -void -wind_readdir(call_frame_t *frame, xlator_t *xl, fd_t *fd, size_t size, - off_t offset, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_readdir_cbk, xl, xl->fops->readdir, fd, size, - offset, xdata); -} - -void -unwind_readdir(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, gf_dirent_t *entries, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(readdir, frame, op_ret, op_errno, entries, xdata); -} - -void -set_readdir_fop(long py_this, fop_readdir_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_READDIR] = (long)fop; -} - -void -set_readdir_cbk(long py_this, fop_readdir_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_READDIR] = (long)cbk; -} - -/* FOP: READDIRP */ - -int32_t -glupy_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_READDIRP]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_readdirp_cbk_t)(priv->cbks[GLUPY_READDIRP]))( - frame, cookie, this, op_ret, op_errno, entries, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, entries, xdata); - return 0; -} - -int32_t -glupy_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_READDIRP]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_readdirp_t)(priv->fops[GLUPY_READDIRP]))(frame, this, fd, size, - offset, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_readdirp_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readdirp, fd, size, offset, xdata); - return 0; -} - -void -wind_readdirp(call_frame_t *frame, xlator_t *xl, fd_t *fd, size_t size, - off_t offset, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_readdirp_cbk, xl, xl->fops->readdirp, fd, size, - offset, xdata); -} - -void -unwind_readdirp(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, - dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, entries, xdata); -} - -void -set_readdirp_fop(long py_this, fop_readdirp_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_READDIRP] = (long)fop; -} - -void -set_readdirp_cbk(long py_this, fop_readdirp_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_READDIRP] = (long)cbk; -} - -/* FOP:STAT */ - -int32_t -glupy_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *buf, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_STAT]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_stat_cbk_t)(priv->cbks[GLUPY_STAT]))( - frame, cookie, this, op_ret, op_errno, buf, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(stat, frame, op_ret, op_errno, buf, xdata); - return 0; -} - -int32_t -glupy_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_STAT]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_stat_t)(priv->fops[GLUPY_STAT]))(frame, this, loc, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_stat_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->stat, loc, xdata); - return 0; -} - -void -wind_stat(call_frame_t *frame, xlator_t *xl, loc_t *loc, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_stat_cbk, xl, xl->fops->stat, loc, xdata); -} - -void -unwind_stat(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct iatt *buf, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(stat, frame, op_ret, op_errno, buf, xdata); -} - -void -set_stat_fop(long py_this, fop_stat_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_STAT] = (long)fop; -} - -void -set_stat_cbk(long py_this, fop_stat_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_STAT] = (long)cbk; -} - -/* FOP: FSTAT */ - -int32_t -glupy_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *buf, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_FSTAT]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_fstat_cbk_t)(priv->cbks[GLUPY_FSTAT]))( - frame, cookie, this, op_ret, op_errno, buf, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(fstat, frame, op_ret, op_errno, buf, xdata); - return 0; -} - -int32_t -glupy_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_FSTAT]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_fstat_t)(priv->fops[GLUPY_FSTAT]))(frame, this, fd, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_fstat_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fstat, fd, xdata); - return 0; -} - -void -wind_fstat(call_frame_t *frame, xlator_t *xl, fd_t *fd, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_fstat_cbk, xl, xl->fops->fstat, fd, xdata); -} - -void -unwind_fstat(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct iatt *buf, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(fstat, frame, op_ret, op_errno, buf, xdata); -} - -void -set_fstat_fop(long py_this, fop_fstat_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_FSTAT] = (long)fop; -} - -void -set_fstat_cbk(long py_this, fop_fstat_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_FSTAT] = (long)cbk; -} - -/* FOP:STATFS */ - -int32_t -glupy_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct statvfs *buf, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_STATFS]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_statfs_cbk_t)(priv->cbks[GLUPY_STATFS]))( - frame, cookie, this, op_ret, op_errno, buf, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(statfs, frame, op_ret, op_errno, buf, xdata); - return 0; -} - -int32_t -glupy_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_STATFS]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_statfs_t)(priv->fops[GLUPY_STATFS]))(frame, this, loc, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_statfs_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->statfs, loc, xdata); - return 0; -} - -void -wind_statfs(call_frame_t *frame, xlator_t *xl, loc_t *loc, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_statfs_cbk, xl, xl->fops->statfs, loc, xdata); -} - -void -unwind_statfs(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct statvfs *buf, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(statfs, frame, op_ret, op_errno, buf, xdata); -} - -void -set_statfs_fop(long py_this, fop_statfs_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_STATFS] = (long)fop; -} - -void -set_statfs_cbk(long py_this, fop_statfs_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_STATFS] = (long)cbk; -} - -/* FOP: SETXATTR */ - -int32_t -glupy_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_SETXATTR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_setxattr_cbk_t)(priv->cbks[GLUPY_SETXATTR]))( - frame, cookie, this, op_ret, op_errno, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno, xdata); - return 0; -} - -int32_t -glupy_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, - int32_t flags, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_SETXATTR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_setxattr_t)(priv->fops[GLUPY_SETXATTR]))(frame, this, loc, dict, - flags, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_setxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->setxattr, loc, dict, flags, xdata); - return 0; -} - -void -wind_setxattr(call_frame_t *frame, xlator_t *xl, loc_t *loc, dict_t *dict, - int32_t flags, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_setxattr_cbk, xl, xl->fops->setxattr, loc, dict, - flags, xdata); -} - -void -unwind_setxattr(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(setxattr, frame, op_ret, op_errno, xdata); -} - -void -set_setxattr_fop(long py_this, fop_setxattr_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_SETXATTR] = (long)fop; -} - -void -set_setxattr_cbk(long py_this, fop_setxattr_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_SETXATTR] = (long)cbk; -} - -/* FOP: GETXATTR */ - -int32_t -glupy_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_GETXATTR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_getxattr_cbk_t)(priv->cbks[GLUPY_GETXATTR]))( - frame, cookie, this, op_ret, op_errno, dict, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, dict, xdata); - return 0; -} - -int32_t -glupy_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_GETXATTR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_getxattr_t)(priv->fops[GLUPY_GETXATTR]))(frame, this, loc, name, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_getxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->getxattr, loc, name, xdata); - return 0; -} - -void -wind_getxattr(call_frame_t *frame, xlator_t *xl, loc_t *loc, const char *name, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_getxattr_cbk, xl, xl->fops->getxattr, loc, name, - xdata); -} - -void -unwind_getxattr(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, dict, xdata); -} - -void -set_getxattr_fop(long py_this, fop_getxattr_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_GETXATTR] = (long)fop; -} - -void -set_getxattr_cbk(long py_this, fop_getxattr_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_GETXATTR] = (long)cbk; -} - -/* FOP: FSETXATTR */ - -int32_t -glupy_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_FSETXATTR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_fsetxattr_cbk_t)(priv->cbks[GLUPY_FSETXATTR]))( - frame, cookie, this, op_ret, op_errno, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(fsetxattr, frame, op_ret, op_errno, xdata); - return 0; -} - -int32_t -glupy_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, - int32_t flags, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_FSETXATTR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_fsetxattr_t)(priv->fops[GLUPY_FSETXATTR]))(frame, this, fd, - dict, flags, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_fsetxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, xdata); - return 0; -} - -void -wind_fsetxattr(call_frame_t *frame, xlator_t *xl, fd_t *fd, dict_t *dict, - int32_t flags, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_fsetxattr_cbk, xl, xl->fops->fsetxattr, fd, dict, - flags, xdata); -} - -void -unwind_fsetxattr(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(fsetxattr, frame, op_ret, op_errno, xdata); -} - -void -set_fsetxattr_fop(long py_this, fop_fsetxattr_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_FSETXATTR] = (long)fop; -} - -void -set_fsetxattr_cbk(long py_this, fop_fsetxattr_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_FSETXATTR] = (long)cbk; -} - -/* FOP: FGETXATTR */ - -int32_t -glupy_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_FGETXATTR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_fgetxattr_cbk_t)(priv->cbks[GLUPY_FGETXATTR]))( - frame, cookie, this, op_ret, op_errno, dict, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(fgetxattr, frame, op_ret, op_errno, dict, xdata); - return 0; -} - -int32_t -glupy_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_FGETXATTR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_fgetxattr_t)(priv->fops[GLUPY_FGETXATTR]))(frame, this, fd, - name, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_fgetxattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata); - return 0; -} - -void -wind_fgetxattr(call_frame_t *frame, xlator_t *xl, fd_t *fd, const char *name, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_fgetxattr_cbk, xl, xl->fops->fgetxattr, fd, name, - xdata); -} - -void -unwind_fgetxattr(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(fgetxattr, frame, op_ret, op_errno, dict, xdata); -} - -void -set_fgetxattr_fop(long py_this, fop_fgetxattr_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_FGETXATTR] = (long)fop; -} - -void -set_fgetxattr_cbk(long py_this, fop_fgetxattr_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_FGETXATTR] = (long)cbk; -} - -/* FOP:REMOVEXATTR */ - -int32_t -glupy_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_REMOVEXATTR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_removexattr_cbk_t)(priv->cbks[GLUPY_REMOVEXATTR]))( - frame, cookie, this, op_ret, op_errno, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(removexattr, frame, op_ret, op_errno, xdata); - return 0; -} - -int32_t -glupy_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_REMOVEXATTR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_removexattr_t)(priv->fops[GLUPY_REMOVEXATTR]))(frame, this, loc, - name, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_removexattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->removexattr, loc, name, xdata); - return 0; -} - -void -wind_removexattr(call_frame_t *frame, xlator_t *xl, loc_t *loc, - const char *name, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_removexattr_cbk, xl, xl->fops->removexattr, loc, - name, xdata); -} - -void -unwind_removexattr(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(removexattr, frame, op_ret, op_errno, xdata); -} - -void -set_removexattr_fop(long py_this, fop_removexattr_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_REMOVEXATTR] = (long)fop; -} - -void -set_removexattr_cbk(long py_this, fop_removexattr_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_REMOVEXATTR] = (long)cbk; -} - -/* FOP:FREMOVEXATTR */ - -int32_t -glupy_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_FREMOVEXATTR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_fremovexattr_cbk_t)(priv->cbks[GLUPY_FREMOVEXATTR]))( - frame, cookie, this, op_ret, op_errno, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(fremovexattr, frame, op_ret, op_errno, xdata); - return 0; -} - -int32_t -glupy_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, - const char *name, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_FREMOVEXATTR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_fremovexattr_t)(priv->fops[GLUPY_FREMOVEXATTR]))( - frame, this, fd, name, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_fremovexattr_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->fremovexattr, fd, name, xdata); - return 0; -} - -void -wind_fremovexattr(call_frame_t *frame, xlator_t *xl, fd_t *fd, const char *name, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_fremovexattr_cbk, xl, xl->fops->fremovexattr, fd, - name, xdata); -} - -void -unwind_fremovexattr(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(fremovexattr, frame, op_ret, op_errno, xdata); -} - -void -set_fremovexattr_fop(long py_this, fop_fremovexattr_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_FREMOVEXATTR] = (long)fop; -} - -void -set_fremovexattr_cbk(long py_this, fop_fremovexattr_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_FREMOVEXATTR] = (long)cbk; -} - -/* FOP: LINK*/ -int32_t -glupy_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_LINK]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_link_cbk_t)(priv->cbks[GLUPY_LINK]))( - frame, cookie, this, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - return 0; -} - -int32_t -glupy_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_LINK]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_link_t)(priv->fops[GLUPY_LINK]))(frame, this, oldloc, newloc, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_link_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata); - return 0; -} - -void -wind_link(call_frame_t *frame, xlator_t *xl, loc_t *oldloc, loc_t *newloc, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_link_cbk, xl, xl->fops->link, oldloc, newloc, - xdata); -} - -void -unwind_link(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(link, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); -} - -void -set_link_fop(long py_this, fop_link_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_LINK] = (long)fop; -} - -void -set_link_cbk(long py_this, fop_link_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_LINK] = (long)cbk; -} - -/* FOP: SYMLINK*/ -int32_t -glupy_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_SYMLINK]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_symlink_cbk_t)(priv->cbks[GLUPY_SYMLINK]))( - frame, cookie, this, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(symlink, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - return 0; -} - -int32_t -glupy_symlink(call_frame_t *frame, xlator_t *this, const char *linkname, - loc_t *loc, mode_t umask, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_SYMLINK]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_symlink_t)(priv->fops[GLUPY_SYMLINK]))(frame, this, linkname, - loc, umask, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_symlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->symlink, linkname, loc, umask, xdata); - return 0; -} - -void -wind_symlink(call_frame_t *frame, xlator_t *xl, const char *linkname, - loc_t *loc, mode_t umask, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_symlink_cbk, xl, xl->fops->symlink, linkname, loc, - umask, xdata); -} - -void -unwind_symlink(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(symlink, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); -} - -void -set_symlink_fop(long py_this, fop_symlink_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_SYMLINK] = (long)fop; -} - -void -set_symlink_cbk(long py_this, fop_symlink_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_SYMLINK] = (long)cbk; -} - -/* FOP: READLINK */ -int32_t -glupy_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, const char *path, - struct iatt *buf, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_READLINK]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_readlink_cbk_t)(priv->cbks[GLUPY_READLINK]))( - frame, cookie, this, op_ret, op_errno, path, buf, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(readlink, frame, op_ret, op_errno, path, buf, xdata); - return 0; -} - -int32_t -glupy_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_READLINK]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_readlink_t)(priv->fops[GLUPY_READLINK]))(frame, this, loc, size, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_readlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->readlink, loc, size, xdata); - return 0; -} - -void -wind_readlink(call_frame_t *frame, xlator_t *xl, loc_t *loc, size_t size, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_readlink_cbk, xl, xl->fops->readlink, loc, size, - xdata); -} - -void -unwind_readlink(call_frame_t *frame, long cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, const char *path, - struct iatt *buf, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(readlink, frame, op_ret, op_errno, path, buf, xdata); -} - -void -set_readlink_fop(long py_this, fop_readlink_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_READLINK] = (long)fop; -} - -void -set_readlink_cbk(long py_this, fop_readlink_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_READLINK] = (long)cbk; -} - -/* FOP: UNLINK */ - -int32_t -glupy_unlink_cbk(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) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_UNLINK]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_unlink_cbk_t)(priv->cbks[GLUPY_UNLINK]))( - frame, cookie, this, op_ret, op_errno, preparent, postparent, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno, preparent, postparent, - xdata); - return 0; -} - -int32_t -glupy_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflags, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_UNLINK]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_unlink_t)(priv->fops[GLUPY_UNLINK]))(frame, this, loc, xflags, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_unlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->unlink, loc, xflags, xdata); - return 0; -} - -void -wind_unlink(call_frame_t *frame, xlator_t *xl, loc_t *loc, int xflags, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_unlink_cbk, xl, xl->fops->unlink, loc, xflags, - xdata); -} - -void -unwind_unlink(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct iatt *preparent, struct iatt *postparent, - dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(unlink, frame, op_ret, op_errno, preparent, postparent, - xdata); -} - -void -set_unlink_fop(long py_this, fop_unlink_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_UNLINK] = (long)fop; -} - -void -set_unlink_cbk(long py_this, fop_unlink_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_UNLINK] = (long)cbk; -} - -/* FOP: MKDIR */ - -int32_t -glupy_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, inode_t *inode, - struct iatt *buf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_MKDIR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_mkdir_cbk_t)(priv->cbks[GLUPY_MKDIR]))( - frame, cookie, this, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(mkdir, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); - return 0; -} - -int32_t -glupy_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, - mode_t umask, dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_MKDIR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_mkdir_t)(priv->fops[GLUPY_MKDIR]))(frame, this, loc, mode, - umask, xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_mkdir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->mkdir, loc, mode, umask, xdata); - return 0; -} - -void -wind_mkdir(call_frame_t *frame, xlator_t *xl, loc_t *loc, mode_t mode, - mode_t umask, dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_mkdir_cbk, xl, xl->fops->mkdir, loc, mode, umask, - xdata); -} - -void -unwind_mkdir(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent, dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(mkdir, frame, op_ret, op_errno, inode, buf, preparent, - postparent, xdata); -} - -void -set_mkdir_fop(long py_this, fop_mkdir_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_MKDIR] = (long)fop; -} - -void -set_mkdir_cbk(long py_this, fop_mkdir_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_MKDIR] = (long)cbk; -} - -/* FOP: RMDIR */ - -int32_t -glupy_rmdir_cbk(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) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - - if (!priv->cbks[GLUPY_RMDIR]) { - goto unwind; - } - - gstate = glupy_enter(); - ret = ((fop_rmdir_cbk_t)(priv->cbks[GLUPY_RMDIR]))( - frame, cookie, this, op_ret, op_errno, preparent, postparent, xdata); - glupy_leave(gstate); - - return ret; - -unwind: - frame->local = NULL; - STACK_UNWIND_STRICT(rmdir, frame, op_ret, op_errno, preparent, postparent, - xdata); - return 0; -} - -int32_t -glupy_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflags, - dict_t *xdata) -{ - glupy_private_t *priv = this->private; - PyGILState_STATE gstate; - int32_t ret; - static long next_id = 0; - - if (!priv->fops[GLUPY_RMDIR]) { - goto wind; - } - - gstate = glupy_enter(); - frame->local = (void *)++next_id; - ret = ((fop_rmdir_t)(priv->fops[GLUPY_RMDIR]))(frame, this, loc, xflags, - xdata); - glupy_leave(gstate); - - return ret; - -wind: - STACK_WIND(frame, glupy_rmdir_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->rmdir, loc, xflags, xdata); - return 0; -} - -void -wind_rmdir(call_frame_t *frame, xlator_t *xl, loc_t *loc, int xflags, - dict_t *xdata) -{ - xlator_t *this = THIS; - - if (!xl || (xl == this)) { - xl = FIRST_CHILD(this); - } - - STACK_WIND(frame, glupy_rmdir_cbk, xl, xl->fops->rmdir, loc, xflags, xdata); -} - -void -unwind_rmdir(call_frame_t *frame, long cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, struct iatt *preparent, struct iatt *postparent, - dict_t *xdata) -{ - frame->local = NULL; - STACK_UNWIND_STRICT(rmdir, frame, op_ret, op_errno, preparent, postparent, - xdata); -} - -void -set_rmdir_fop(long py_this, fop_rmdir_t fop) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->fops[GLUPY_RMDIR] = (long)fop; -} - -void -set_rmdir_cbk(long py_this, fop_rmdir_cbk_t cbk) -{ - glupy_private_t *priv = ((xlator_t *)py_this)->private; - - priv->cbks[GLUPY_RMDIR] = (long)cbk; -} - -/* NON-FOP-SPECIFIC CODE */ - -long -get_id(call_frame_t *frame) -{ - return (long)(frame->local); -} - -uint64_t -get_rootunique(call_frame_t *frame) -{ - return frame->root->unique; -} - -int32_t -mem_acct_init(xlator_t *this) -{ - int ret = -1; - - if (!this) - return ret; - - ret = xlator_mem_acct_init(this, gf_glupy_mt_end); - - if (ret != 0) { - gf_log(this->name, GF_LOG_ERROR, - "Memory accounting init" - " failed"); - return ret; - } - - return ret; -} - -static void -py_error_log(const char *name, PyObject *pystr) -{ -#if PY_MAJOR_VERSION > 2 - char scr[256]; - if (PyUnicode_Check(pystr)) { - PyObject *tmp = PyUnicode_AsEncodedString(pystr, "UTF-8", "strict"); - if (tmp != NULL) { - strncpy(scr, PyBytes_AS_STRING(pystr), sizeof(scr)); - Py_DECREF(tmp); - } else { - strncpy(scr, "string encoding error", sizeof(scr)); - } - } else if (PyBytes_Check(pystr)) { - strncpy(scr, PyBytes_AS_STRING(pystr), sizeof(scr)); - } else { - strncpy(scr, "string encoding error", sizeof(scr)); - } - gf_log(name, GF_LOG_ERROR, "Python error: %s", scr); -#else - gf_log(name, GF_LOG_ERROR, "Python error: %s", PyString_AsString(pystr)); -#endif -} - -static PyObject * -encode(const char *str) -{ -#if PY_MAJOR_VERSION > 2 - return PyUnicode_FromString(str); -#else - return PyString_FromString(str); -#endif -} - -int32_t -init(xlator_t *this) -{ - glupy_private_t *priv = NULL; - char *module_name = NULL; - PyObject *py_mod_name = NULL; - PyObject *py_init_func = NULL; - PyObject *py_args = NULL; - PyObject *syspath = NULL; - PyObject *path = NULL; - PyObject *error_type = NULL; - PyObject *error_msg = NULL; - PyObject *error_bt = NULL; - static gf_boolean_t py_inited = _gf_false; - void *err_cleanup = &&err_return; - char libpython[16]; - - if (dict_get_str(this->options, "module-name", &module_name) != 0) { - gf_log(this->name, GF_LOG_ERROR, "missing module-name"); - return -1; - } - - priv = GF_CALLOC(1, sizeof(glupy_private_t), gf_glupy_mt_priv); - if (!priv) { - goto *err_cleanup; - } - this->private = priv; - err_cleanup = &&err_free_priv; - - if (!py_inited) { - /* FIXME: - * This hack is necessary because glusterfs (rightly) loads - * glupy.so with RTLD_LOCAL but glupy needs libpython to be - * loaded with RTLD_GLOBAL even though glupy is correctly - * linked with libpython. - * This is needed because one of the internal modules of - * python 2.x (lib-dynload/_struct.so) does not explicitly - * link with libpython. - */ - snprintf(libpython, sizeof(libpython), "libpython%d.%d.so", - PY_MAJOR_VERSION, PY_MINOR_VERSION); - if (!dlopen(libpython, RTLD_NOW | RTLD_GLOBAL)) { - gf_msg(this->name, GF_LOG_WARNING, 0, LG_MSG_DLOPEN_FAILED, - "dlopen(%s) failed: %s", libpython, dlerror()); - } - - /* - * This must be done before Py_Initialize(), - * because it will duplicate the environment, - * and fail to see later environment updates. - */ - setenv("PATH_GLUSTERFS_GLUPY_MODULE", PATH_GLUSTERFS_GLUPY_MODULE, 1); - - Py_Initialize(); - PyEval_InitThreads(); - - (void)pthread_key_create(&gil_init_key, NULL); - (void)pthread_setspecific(gil_init_key, (void *)1); - - /* PyEval_InitThreads takes this "for" us. No thanks. */ - PyEval_ReleaseLock(); - py_inited = _gf_true; - } - - /* Adjust python's path */ - syspath = PySys_GetObject("path"); - path = encode(GLUSTER_PYTHON_PATH); - PyList_Append(syspath, path); - Py_DECREF(path); - - py_mod_name = encode(module_name); - if (!py_mod_name) { - gf_log(this->name, GF_LOG_ERROR, "could not create name"); - if (PyErr_Occurred()) { - PyErr_Fetch(&error_type, &error_msg, &error_bt); - py_error_log(this->name, error_msg); - } - goto *err_cleanup; - } - - gf_log(this->name, GF_LOG_DEBUG, "py_mod_name = %s", module_name); - priv->py_module = PyImport_Import(py_mod_name); - Py_DECREF(py_mod_name); - if (!priv->py_module) { - gf_log(this->name, GF_LOG_ERROR, "Python import of %s failed", - module_name); - if (PyErr_Occurred()) { - PyErr_Fetch(&error_type, &error_msg, &error_bt); - py_error_log(this->name, error_msg); - } - goto *err_cleanup; - } - gf_log(this->name, GF_LOG_INFO, "Import of %s succeeded", module_name); - err_cleanup = &&err_deref_module; - - py_init_func = PyObject_GetAttrString(priv->py_module, "xlator"); - if (!py_init_func || !PyCallable_Check(py_init_func)) { - gf_log(this->name, GF_LOG_ERROR, "missing init func"); - if (PyErr_Occurred()) { - PyErr_Fetch(&error_type, &error_msg, &error_bt); - py_error_log(this->name, error_msg); - } - goto *err_cleanup; - } - err_cleanup = &&err_deref_init; - - py_args = PyTuple_New(1); - if (!py_args) { - gf_log(this->name, GF_LOG_ERROR, "could not create args"); - if (PyErr_Occurred()) { - PyErr_Fetch(&error_type, &error_msg, &error_bt); - py_error_log(this->name, error_msg); - } - goto *err_cleanup; - } - PyTuple_SetItem(py_args, 0, PyLong_FromLong((long)this)); - - /* TBD: pass in list of children */ - priv->py_xlator = PyObject_CallObject(py_init_func, py_args); - Py_DECREF(py_args); - if (!priv->py_xlator) { - gf_log(this->name, GF_LOG_ERROR, "Python init failed"); - if (PyErr_Occurred()) { - PyErr_Fetch(&error_type, &error_msg, &error_bt); - py_error_log(this->name, error_msg); - } - goto *err_cleanup; - } - gf_log(this->name, GF_LOG_DEBUG, "init returned %p", priv->py_xlator); - - return 0; - -err_deref_init: - Py_DECREF(py_init_func); -err_deref_module: - Py_DECREF(priv->py_module); -err_free_priv: - GF_FREE(priv); -err_return: - return -1; -} - -void -fini(xlator_t *this) -{ - glupy_private_t *priv = this->private; - - if (!priv) - return; - Py_DECREF(priv->py_xlator); - Py_DECREF(priv->py_module); - this->private = NULL; - GF_FREE(priv); - - return; -} - -struct xlator_fops fops = {.lookup = glupy_lookup, - .create = glupy_create, - .open = glupy_open, - .readv = glupy_readv, - .writev = glupy_writev, - .opendir = glupy_opendir, - .readdir = glupy_readdir, - .stat = glupy_stat, - .fstat = glupy_fstat, - .setxattr = glupy_setxattr, - .getxattr = glupy_getxattr, - .fsetxattr = glupy_fsetxattr, - .fgetxattr = glupy_fgetxattr, - .removexattr = glupy_removexattr, - .fremovexattr = glupy_fremovexattr, - .link = glupy_link, - .unlink = glupy_unlink, - .readlink = glupy_readlink, - .symlink = glupy_symlink, - .mkdir = glupy_mkdir, - .rmdir = glupy_rmdir, - .statfs = glupy_statfs, - .readdirp = glupy_readdirp}; - -struct xlator_cbks cbks = {}; - -struct volume_options options[] = { - {.key = {NULL}}, -}; diff --git a/xlators/features/glupy/src/glupy.h b/xlators/features/glupy/src/glupy.h deleted file mode 100644 index ca3ac170451..00000000000 --- a/xlators/features/glupy/src/glupy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (c) 2006-2014 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef __GLUPY_H__ -#define __GLUPY_H__ - -#include <glusterfs/mem-types.h> - -enum { - GLUPY_LOOKUP = 0, - GLUPY_CREATE, - GLUPY_OPEN, - GLUPY_READV, - GLUPY_WRITEV, - GLUPY_OPENDIR, - GLUPY_READDIR, - GLUPY_READDIRP, - GLUPY_STAT, - GLUPY_FSTAT, - GLUPY_STATFS, - GLUPY_SETXATTR, - GLUPY_GETXATTR, - GLUPY_FSETXATTR, - GLUPY_FGETXATTR, - GLUPY_REMOVEXATTR, - GLUPY_FREMOVEXATTR, - GLUPY_LINK, - GLUPY_UNLINK, - GLUPY_READLINK, - GLUPY_SYMLINK, - GLUPY_MKNOD, - GLUPY_MKDIR, - GLUPY_RMDIR, - GLUPY_N_FUNCS -}; - -typedef struct { - PyObject *py_module; - PyObject *py_xlator; - long fops[GLUPY_N_FUNCS]; - long cbks[GLUPY_N_FUNCS]; -} glupy_private_t; - -enum gf_glupy_mem_types_ { - gf_glupy_mt_priv = gf_common_mt_end + 1, - gf_glupy_mt_end -}; - -#endif /* __GLUPY_H__ */ diff --git a/xlators/features/glupy/src/glupy.sym b/xlators/features/glupy/src/glupy.sym deleted file mode 100644 index 55d9a300108..00000000000 --- a/xlators/features/glupy/src/glupy.sym +++ /dev/null @@ -1,101 +0,0 @@ -init -fini -fops -cbks -options -notify -mem_acct_init -reconfigure -dumpops -set_lookup_fop -set_lookup_cbk -set_create_fop -set_create_cbk -set_open_fop -set_open_cbk -set_readv_fop -set_readv_cbk -set_writev_fop -set_writev_cbk -set_opendir_fop -set_opendir_cbk -set_readdir_fop -set_readdir_cbk -set_readdirp_fop -set_readdirp_cbk -set_stat_fop -set_stat_cbk -set_fstat_fop -set_fstat_cbk -set_statfs_fop -set_statfs_cbk -set_setxattr_fop -set_setxattr_cbk -set_getxattr_fop -set_getxattr_cbk -set_fsetxattr_fop -set_fsetxattr_cbk -set_fgetxattr_fop -set_fgetxattr_cbk -set_removexattr_fop -set_removexattr_cbk -set_fremovexattr_fop -set_fremovexattr_cbk -set_link_fop -set_link_cbk -set_symlink_fop -set_symlink_cbk -set_readlink_fop -set_readlink_cbk -set_unlink_fop -set_unlink_cbk -set_mkdir_fop -set_mkdir_cbk -set_rmdir_fop -set_rmdir_cbk -wind_lookup -wind_create -wind_open -wind_readv -wind_writev -wind_opendir -wind_readdir -wind_readdirp -wind_stat -wind_fstat -wind_statfs -wind_setxattr -wind_getxattr -wind_fsetxattr -wind_fgetxattr -wind_removexattr -wind_fremovexattr -wind_link -wind_symlink -wind_readlink -wind_unlink -wind_mkdir -wind_rmdir -unwind_lookup -unwind_create -unwind_open -unwind_readv -unwind_writev -unwind_opendir -unwind_readdir -unwind_readdirp -unwind_stat -unwind_fstat -unwind_statfs -unwind_setxattr -unwind_getxattr -unwind_fsetxattr -unwind_fgetxattr -unwind_removexattr -unwind_fremovexattr -unwind_link -unwind_symlink -unwind_readlink -unwind_unlink -unwind_mkdir -unwind_rmdir diff --git a/xlators/features/glupy/src/glupy/Makefile.am b/xlators/features/glupy/src/glupy/Makefile.am deleted file mode 100644 index 573d2da12e1..00000000000 --- a/xlators/features/glupy/src/glupy/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -# Install __init__.py into the Python site-packages area -pyglupydir = @BUILD_PYTHON_SITE_PACKAGES@/gluster/glupy -pyglupy_PYTHON = __init__.py - -CLEANFILES = diff --git a/xlators/features/glupy/src/glupy/__init__.py b/xlators/features/glupy/src/glupy/__init__.py deleted file mode 100644 index 576fbdb9945..00000000000 --- a/xlators/features/glupy/src/glupy/__init__.py +++ /dev/null @@ -1,852 +0,0 @@ -## -## Copyright (c) 2006-2014 Red Hat, Inc. <http://www.redhat.com> -## This file is part of GlusterFS. -## -## This file is licensed to you under your choice of the GNU Lesser -## General Public License, version 3 or any later version (LGPLv3 or -## later), or the GNU General Public License, version 2 (GPLv2), in all -## cases as published by the Free Software Foundation. -## - -import sys -import os -from ctypes import * - -dl = CDLL(os.getenv("PATH_GLUSTERFS_GLUPY_MODULE", ""), RTLD_GLOBAL) - - -class call_frame_t (Structure): - pass - -class dev_t (Structure): - pass - - -class dict_t (Structure): - pass - - -class gf_dirent_t (Structure): - pass - - -class iobref_t (Structure): - pass - - -class iovec_t (Structure): - pass - - -class list_head (Structure): - pass - -list_head._fields_ = [ - ("next", POINTER(list_head)), - ("prev", POINTER(list_head)) - ] - - -class rwxperm_t (Structure): - _fields_ = [ - ("read", c_uint8, 1), - ("write", c_uint8, 1), - ("execn", c_uint8, 1) - ] - - -class statvfs_t (Structure): - pass - - -class xlator_t (Structure): - pass - - -class ia_prot_t (Structure): - _fields_ = [ - ("suid", c_uint8, 1), - ("sgid", c_uint8, 1), - ("sticky", c_uint8, 1), - ("owner", rwxperm_t), - ("group", rwxperm_t), - ("other", rwxperm_t) - ] - -# For checking file type. -(IA_INVAL, IA_IFREG, IA_IFDIR, IA_IFLNK, IA_IFBLK, IA_IFCHR, IA_IFIFO, - IA_IFSOCK) = range(8) - - -class iatt_t (Structure): - _fields_ = [ - ("ia_no", c_uint64), - ("ia_gfid", c_ubyte * 16), - ("ia_dev", c_uint64), - ("ia_type", c_uint), - ("ia_prot", ia_prot_t), - ("ia_nlink", c_uint32), - ("ia_uid", c_uint32), - ("ia_gid", c_uint32), - ("ia_rdev", c_uint64), - ("ia_size", c_uint64), - ("ia_blksize", c_uint32), - ("ia_blocks", c_uint64), - ("ia_atime", c_uint32 ), - ("ia_atime_nsec", c_uint32), - ("ia_mtime", c_uint32), - ("ia_mtime_nsec", c_uint32), - ("ia_ctime", c_uint32), - ("ia_ctime_nsec", c_uint32) - ] - - -class mem_pool (Structure): - _fields_ = [ - ("list", list_head), - ("hot_count", c_int), - ("cold_count", c_int), - ("lock", c_void_p), - ("padded_sizeof_type", c_ulong), - ("pool", c_void_p), - ("pool_end", c_void_p), - ("real_sizeof_type", c_int), - ("alloc_count", c_uint64), - ("pool_misses", c_uint64), - ("max_alloc", c_int), - ("curr_stdalloc", c_int), - ("max_stdalloc", c_int), - ("name", c_char_p), - ("global_list", list_head) - ] - - -class U_ctx_key_inode (Union): - _fields_ = [ - ("key", c_uint64), - ("xl_key", POINTER(xlator_t)) - ] - - -class U_ctx_value1 (Union): - _fields_ = [ - ("value1", c_uint64), - ("ptr1", c_void_p) - ] - - -class U_ctx_value2 (Union): - _fields_ = [ - ("value2", c_uint64), - ("ptr2", c_void_p) - ] - -class inode_ctx (Structure): - _anonymous_ = ("u_key", "u_value1", "u_value2",) - _fields_ = [ - ("u_key", U_ctx_key_inode), - ("u_value1", U_ctx_value1), - ("u_value2", U_ctx_value2) - ] - -class inode_t (Structure): - pass - -class inode_table_t (Structure): - _fields_ = [ - ("lock", c_void_p), - ("hashsize", c_size_t), - ("name", c_char_p), - ("root", POINTER(inode_t)), - ("xl", POINTER(xlator_t)), - ("lru_limit", c_uint32), - ("inode_hash", POINTER(list_head)), - ("name_hash", POINTER(list_head)), - ("active", list_head), - ("active_size", c_uint32), - ("lru", list_head), - ("lru_size", c_uint32), - ("purge", list_head), - ("purge_size", c_uint32), - ("inode_pool", POINTER(mem_pool)), - ("dentry_pool", POINTER(mem_pool)), - ("fd_mem_pool", POINTER(mem_pool)) - ] - -inode_t._fields_ = [ - ("table", POINTER(inode_table_t)), - ("gfid", c_ubyte * 16), - ("lock", c_void_p), - ("nlookup", c_uint64), - ("fd_count", c_uint32), - ("ref", c_uint32), - ("ia_type", c_uint), - ("fd_list", list_head), - ("dentry_list", list_head), - ("hashv", list_head), - ("listv", list_head), - ("ctx", POINTER(inode_ctx)) - ] - - - -class U_ctx_key_fd (Union): - _fields_ = [ - ("key", c_uint64), - ("xl_key", c_void_p) - ] - -class fd_lk_ctx (Structure): - _fields_ = [ - ("lk_list", list_head), - ("ref", c_int), - ("lock", c_void_p) - ] - -class fd_ctx (Structure): - _anonymous_ = ("u_key", "u_value1") - _fields_ = [ - ("u_key", U_ctx_key_fd), - ("u_value1", U_ctx_value1) - ] - -class fd_t (Structure): - _fields_ = [ - ("pid", c_uint64), - ("flags", c_int32), - ("refcount", c_int32), - ("inode_list", list_head), - ("inode", POINTER(inode_t)), - ("lock", c_void_p), - ("ctx", POINTER(fd_ctx)), - ("xl_count", c_int), - ("lk_ctx", POINTER(fd_lk_ctx)), - ("anonymous", c_uint) - ] - -class loc_t (Structure): - _fields_ = [ - ("path", c_char_p), - ("name", c_char_p), - ("inode", POINTER(inode_t)), - ("parent", POINTER(inode_t)), - ("gfid", c_ubyte * 16), - ("pargfid", c_ubyte * 16), - ] - - - -def _init_op (a_class, fop, cbk, wind, unwind): - # Decorators, used by translators. We could pass the signatures as - # parameters, but it's actually kind of nice to keep them around for - # inspection. - a_class.fop_type = CFUNCTYPE(*a_class.fop_sig) - a_class.cbk_type = CFUNCTYPE(*a_class.cbk_sig) - # Dispatch-function registration. - fop.restype = None - fop.argtypes = [ c_long, a_class.fop_type ] - # Callback-function registration. - cbk.restype = None - cbk.argtypes = [ c_long, a_class.cbk_type ] - # STACK_WIND function. - wind.restype = None - wind.argtypes = list(a_class.fop_sig[1:]) - # STACK_UNWIND function. - unwind.restype = None - unwind.argtypes = list(a_class.cbk_sig[1:]) - -class OpLookup: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(inode_t), POINTER(iatt_t), - POINTER(dict_t), POINTER(iatt_t)) -_init_op (OpLookup, dl.set_lookup_fop, dl.set_lookup_cbk, - dl.wind_lookup, dl.unwind_lookup) - -class OpCreate: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_int, c_uint, c_uint, POINTER(fd_t), - POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(fd_t), POINTER(inode_t), - POINTER(iatt_t), POINTER(iatt_t), POINTER(iatt_t), - POINTER(dict_t)) -_init_op (OpCreate, dl.set_create_fop, dl.set_create_cbk, - dl.wind_create, dl.unwind_create) - -class OpOpen: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_int, POINTER(fd_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(fd_t), POINTER(dict_t)) -_init_op (OpOpen, dl.set_open_fop, dl.set_open_cbk, - dl.wind_open, dl.unwind_open) - -class OpReadv: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), c_size_t, c_long, c_uint32, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(iovec_t), c_int, POINTER(iatt_t), - POINTER(iobref_t), POINTER(dict_t)) -_init_op (OpReadv, dl.set_readv_fop, dl.set_readv_cbk, - dl.wind_readv, dl.unwind_readv) -class OpWritev: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), POINTER(iovec_t), c_int, c_long, c_uint32, - POINTER(iobref_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(iatt_t), POINTER(iatt_t), - POINTER(dict_t)) -_init_op (OpWritev, dl.set_writev_fop, dl.set_writev_cbk, - dl.wind_writev, dl.unwind_writev) - -class OpOpendir: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), POINTER(fd_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(fd_t), POINTER(dict_t)) -_init_op (OpOpendir, dl.set_opendir_fop, dl.set_opendir_cbk, - dl.wind_opendir, dl.unwind_opendir) - -class OpReaddir: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), c_size_t, c_long, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(gf_dirent_t), POINTER(dict_t)) -_init_op (OpReaddir, dl.set_readdir_fop, dl.set_readdir_cbk, - dl.wind_readdir, dl.unwind_readdir) - -class OpReaddirp: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), c_size_t, c_long, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(gf_dirent_t), POINTER(dict_t)) -_init_op (OpReaddirp, dl.set_readdirp_fop, dl.set_readdirp_cbk, - dl.wind_readdirp, dl.unwind_readdirp) - -class OpStat: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(iatt_t), POINTER(dict_t)) -_init_op (OpStat, dl.set_stat_fop, dl.set_stat_cbk, - dl.wind_stat, dl.unwind_stat) - -class OpFstat: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(iatt_t), POINTER(dict_t)) -_init_op (OpFstat, dl.set_fstat_fop, dl.set_fstat_cbk, - dl.wind_fstat, dl.unwind_fstat) - -class OpStatfs: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(statvfs_t), POINTER(dict_t)) -_init_op (OpStatfs, dl.set_statfs_fop, dl.set_statfs_cbk, - dl.wind_statfs, dl.unwind_statfs) - - -class OpSetxattr: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), POINTER(dict_t), c_int32, - POINTER (dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(dict_t)) -_init_op (OpSetxattr, dl.set_setxattr_fop, dl.set_setxattr_cbk, - dl.wind_setxattr, dl.unwind_setxattr) - -class OpGetxattr: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_char_p, POINTER (dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(dict_t), POINTER(dict_t)) -_init_op (OpGetxattr, dl.set_getxattr_fop, dl.set_getxattr_cbk, - dl.wind_getxattr, dl.unwind_getxattr) - -class OpFsetxattr: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), POINTER(dict_t), c_int32, - POINTER (dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(dict_t)) -_init_op (OpFsetxattr, dl.set_fsetxattr_fop, dl.set_fsetxattr_cbk, - dl.wind_fsetxattr, dl.unwind_fsetxattr) - -class OpFgetxattr: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), c_char_p, POINTER (dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(dict_t), POINTER(dict_t)) -_init_op (OpFgetxattr, dl.set_fgetxattr_fop, dl.set_fgetxattr_cbk, - dl.wind_fgetxattr, dl.unwind_fgetxattr) - -class OpRemovexattr: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_char_p, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(dict_t)) -_init_op (OpRemovexattr, dl.set_removexattr_fop, dl.set_removexattr_cbk, - dl.wind_removexattr, dl.unwind_removexattr) - - -class OpFremovexattr: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(fd_t), c_char_p, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(dict_t)) -_init_op (OpFremovexattr, dl.set_fremovexattr_fop, dl.set_fremovexattr_cbk, - dl.wind_fremovexattr, dl.unwind_fremovexattr) - -class OpLink: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), POINTER(loc_t), POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(inode_t), POINTER(iatt_t), - POINTER(iatt_t), POINTER(iatt_t), POINTER(dict_t)) -_init_op (OpLink, dl.set_link_fop, dl.set_link_cbk, - dl.wind_link, dl.unwind_link) - -class OpSymlink: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - c_char_p, POINTER(loc_t), c_uint, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(inode_t), POINTER(iatt_t), - POINTER(iatt_t), POINTER(iatt_t), POINTER(dict_t)) -_init_op (OpSymlink, dl.set_symlink_fop, dl.set_symlink_cbk, - dl.wind_symlink, dl.unwind_symlink) - -class OpUnlink: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_int, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(iatt_t), POINTER(iatt_t), - POINTER(dict_t)) -_init_op (OpUnlink, dl.set_unlink_fop, dl.set_unlink_cbk, - dl.wind_unlink, dl.unwind_unlink) - -class OpReadlink: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_size_t, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, c_char_p, POINTER(iatt_t), POINTER(dict_t)) -_init_op (OpReadlink, dl.set_readlink_fop, dl.set_readlink_cbk, - dl.wind_readlink, dl.unwind_readlink) - -class OpMkdir: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_uint, c_uint, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(inode_t), POINTER(iatt_t), - POINTER(iatt_t), POINTER(iatt_t), POINTER(dict_t)) -_init_op (OpMkdir, dl.set_mkdir_fop, dl.set_mkdir_cbk, - dl.wind_mkdir, dl.unwind_mkdir) - -class OpRmdir: - fop_sig = (c_int, POINTER(call_frame_t), POINTER(xlator_t), - POINTER(loc_t), c_int, POINTER(dict_t)) - cbk_sig = (c_int, POINTER(call_frame_t), c_long, POINTER(xlator_t), - c_int, c_int, POINTER(iatt_t), POINTER(iatt_t), - POINTER(dict_t)) -_init_op (OpRmdir, dl.set_rmdir_fop, dl.set_rmdir_cbk, - dl.wind_rmdir, dl.unwind_rmdir) - - -class Translator: - def __init__ (self, c_this): - # This is only here to keep references to the stubs we create, - # because ctypes doesn't and glupy.so can't because it doesn't - # get a pointer to the actual Python object. It's a dictionary - # instead of a list in case we ever allow changing fops/cbks - # after initialization and need to look them up. - self.stub_refs = {} - funcs = dir(self.__class__) - if "lookup_fop" in funcs: - @OpLookup.fop_type - def stub (frame, this, loc, xdata, s=self): - return s.lookup_fop (frame, this, loc, xdata) - self.stub_refs["lookup_fop"] = stub - dl.set_lookup_fop(c_this, stub) - if "lookup_cbk" in funcs: - @OpLookup.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, inode, - buf, xdata, postparent, s=self): - return s.lookup_cbk(frame, cookie, this, op_ret, - op_errno, inode, buf, xdata, - postparent) - self.stub_refs["lookup_cbk"] = stub - dl.set_lookup_cbk(c_this, stub) - if "create_fop" in funcs: - @OpCreate.fop_type - def stub (frame, this, loc, flags, mode, umask, fd, - xdata, s=self): - return s.create_fop (frame, this, loc, flags, - mode, umask, fd, xdata) - self.stub_refs["create_fop"] = stub - dl.set_create_fop(c_this, stub) - if "create_cbk" in funcs: - @OpCreate.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, fd, - inode, buf, preparent, postparent, xdata, - s=self): - return s.create_cbk (frame, cookie, this, - op_ret, op_errno, fd, - inode, buf, preparent, - postparent, xdata) - self.stub_refs["create_cbk"] = stub - dl.set_create_cbk(c_this, stub) - if "open_fop" in funcs: - @OpOpen.fop_type - def stub (frame, this, loc, flags, fd, - xdata, s=self): - return s.open_fop (frame, this, loc, flags, - fd, xdata) - self.stub_refs["open_fop"] = stub - dl.set_open_fop(c_this, stub) - if "open_cbk" in funcs: - @OpOpen.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, fd, - xdata, s=self): - return s.open_cbk (frame, cookie, this, - op_ret, op_errno, fd, - xdata) - self.stub_refs["open_cbk"] = stub - dl.set_open_cbk(c_this, stub) - if "readv_fop" in funcs: - @OpReadv.fop_type - def stub (frame, this, fd, size, offset, flags, - xdata, s=self): - return s.readv_fop (frame, this, fd, size, - offset, flags, xdata) - self.stub_refs["readv_fop"] = stub - dl.set_readv_fop(c_this, stub) - if "readv_cbk" in funcs: - @OpReadv.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - vector, count, stbuf, iobref, xdata, - s=self): - return s.readv_cbk (frame, cookie, this, - op_ret, op_errno, vector, - count, stbuf, iobref, - xdata) - self.stub_refs["readv_cbk"] = stub - dl.set_readv_cbk(c_this, stub) - if "writev_fop" in funcs: - @OpWritev.fop_type - def stub (frame, this, fd, vector, count, - offset, flags, iobref, xdata, s=self): - return s.writev_fop (frame, this, fd, vector, - count, offset, flags, - iobref, xdata) - self.stub_refs["writev_fop"] = stub - dl.set_writev_fop(c_this, stub) - if "writev_cbk" in funcs: - @OpWritev.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - prebuf, postbuf, xdata, s=self): - return s.writev_cbk (frame, cookie, this, - op_ret, op_errno, prebuf, - postbuf, xdata) - self.stub_refs["writev_cbk"] = stub - dl.set_writev_cbk(c_this, stub) - if "opendir_fop" in funcs: - @OpOpendir.fop_type - def stub (frame, this, loc, fd, xdata, s=self): - return s.opendir_fop (frame, this, loc, fd, - xdata) - self.stub_refs["opendir_fop"] = stub - dl.set_opendir_fop(c_this, stub) - if "opendir_cbk" in funcs: - @OpOpendir.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, fd, - xdata, s=self): - return s.opendir_cbk(frame, cookie, this, - op_ret, op_errno, fd, - xdata) - self.stub_refs["opendir_cbk"] = stub - dl.set_opendir_cbk(c_this, stub) - if "readdir_fop" in funcs: - @OpReaddir.fop_type - def stub (frame, this, fd, size, offset, xdata, s=self): - return s.readdir_fop (frame, this, fd, size, - offset, xdata) - self.stub_refs["readdir_fop"] = stub - dl.set_readdir_fop(c_this, stub) - if "readdir_cbk" in funcs: - @OpReaddir.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - entries, xdata, s=self): - return s.readdir_cbk(frame, cookie, this, - op_ret, op_errno, entries, - xdata) - self.stub_refs["readdir_cbk"] = stub - dl.set_readdir_cbk(c_this, stub) - if "readdirp_fop" in funcs: - @OpReaddirp.fop_type - def stub (frame, this, fd, size, offset, xdata, s=self): - return s.readdirp_fop (frame, this, fd, size, - offset, xdata) - self.stub_refs["readdirp_fop"] = stub - dl.set_readdirp_fop(c_this, stub) - if "readdirp_cbk" in funcs: - @OpReaddirp.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - entries, xdata, s=self): - return s.readdirp_cbk (frame, cookie, this, - op_ret, op_errno, - entries, xdata) - self.stub_refs["readdirp_cbk"] = stub - dl.set_readdirp_cbk(c_this, stub) - if "stat_fop" in funcs: - @OpStat.fop_type - def stub (frame, this, loc, xdata, s=self): - return s.stat_fop (frame, this, loc, xdata) - self.stub_refs["stat_fop"] = stub - dl.set_stat_fop(c_this, stub) - if "stat_cbk" in funcs: - @OpStat.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, buf, - xdata, s=self): - return s.stat_cbk(frame, cookie, this, op_ret, - op_errno, buf, xdata) - self.stub_refs["stat_cbk"] = stub - dl.set_stat_cbk(c_this, stub) - if "fstat_fop" in funcs: - @OpFstat.fop_type - def stub (frame, this, fd, xdata, s=self): - return s.fstat_fop (frame, this, fd, xdata) - self.stub_refs["fstat_fop"] = stub - dl.set_fstat_fop(c_this, stub) - if "fstat_cbk" in funcs: - @OpFstat.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, buf, - xdata, s=self): - return s.fstat_cbk(frame, cookie, this, op_ret, - op_errno, buf, xdata) - self.stub_refs["fstat_cbk"] = stub - dl.set_fstat_cbk(c_this, stub) - if "statfs_fop" in funcs: - @OpStatfs.fop_type - def stub (frame, this, loc, xdata, s=self): - return s.statfs_fop (frame, this, loc, xdata) - self.stub_refs["statfs_fop"] = stub - dl.set_statfs_fop(c_this, stub) - if "statfs_cbk" in funcs: - @OpStatfs.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, buf, - xdata, s=self): - return s.statfs_cbk (frame, cookie, this, - op_ret, op_errno, buf, - xdata) - self.stub_refs["statfs_cbk"] = stub - dl.set_statfs_cbk(c_this, stub) - if "setxattr_fop" in funcs: - @OpSetxattr.fop_type - def stub (frame, this, loc, dictionary, flags, xdata, - s=self): - return s.setxattr_fop (frame, this, loc, - dictionary, flags, - xdata) - self.stub_refs["setxattr_fop"] = stub - dl.set_setxattr_fop(c_this, stub) - if "setxattr_cbk" in funcs: - @OpSetxattr.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, xdata, - s=self): - return s.setxattr_cbk(frame, cookie, this, - op_ret, op_errno, xdata) - self.stub_refs["setxattr_cbk"] = stub - dl.set_setxattr_cbk(c_this, stub) - if "getxattr_fop" in funcs: - @OpGetxattr.fop_type - def stub (frame, this, loc, name, xdata, s=self): - return s.getxattr_fop (frame, this, loc, name, - xdata) - self.stub_refs["getxattr_fop"] = stub - dl.set_getxattr_fop(c_this, stub) - if "getxattr_cbk" in funcs: - @OpGetxattr.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - dictionary, xdata, s=self): - return s.getxattr_cbk(frame, cookie, this, - op_ret, op_errno, - dictionary, xdata) - self.stub_refs["getxattr_cbk"] = stub - dl.set_getxattr_cbk(c_this, stub) - if "fsetxattr_fop" in funcs: - @OpFsetxattr.fop_type - def stub (frame, this, fd, dictionary, flags, xdata, - s=self): - return s.fsetxattr_fop (frame, this, fd, - dictionary, flags, - xdata) - self.stub_refs["fsetxattr_fop"] = stub - dl.set_fsetxattr_fop(c_this, stub) - if "fsetxattr_cbk" in funcs: - @OpFsetxattr.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, xdata, - s=self): - return s.fsetxattr_cbk(frame, cookie, this, - op_ret, op_errno, xdata) - self.stub_refs["fsetxattr_cbk"] = stub - dl.set_fsetxattr_cbk(c_this, stub) - if "fgetxattr_fop" in funcs: - @OpFgetxattr.fop_type - def stub (frame, this, fd, name, xdata, s=self): - return s.fgetxattr_fop (frame, this, fd, name, - xdata) - self.stub_refs["fgetxattr_fop"] = stub - dl.set_fgetxattr_fop(c_this, stub) - if "fgetxattr_cbk" in funcs: - @OpFgetxattr.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - dictionary, xdata, s=self): - return s.fgetxattr_cbk(frame, cookie, this, - op_ret, op_errno, - dictionary, xdata) - self.stub_refs["fgetxattr_cbk"] = stub - dl.set_fgetxattr_cbk(c_this, stub) - if "removexattr_fop" in funcs: - @OpRemovexattr.fop_type - def stub (frame, this, loc, name, xdata, s=self): - return s.removexattr_fop (frame, this, loc, - name, xdata) - self.stub_refs["removexattr_fop"] = stub - dl.set_removexattr_fop(c_this, stub) - if "removexattr_cbk" in funcs: - @OpRemovexattr.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - xdata, s=self): - return s.removexattr_cbk(frame, cookie, this, - op_ret, op_errno, - xdata) - self.stub_refs["removexattr_cbk"] = stub - dl.set_removexattr_cbk(c_this, stub) - if "fremovexattr_fop" in funcs: - @OpFremovexattr.fop_type - def stub (frame, this, fd, name, xdata, s=self): - return s.fremovexattr_fop (frame, this, fd, - name, xdata) - self.stub_refs["fremovexattr_fop"] = stub - dl.set_fremovexattr_fop(c_this, stub) - if "fremovexattr_cbk" in funcs: - @OpFremovexattr.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - xdata, s=self): - return s.fremovexattr_cbk(frame, cookie, this, - op_ret, op_errno, - xdata) - self.stub_refs["fremovexattr_cbk"] = stub - dl.set_fremovexattr_cbk(c_this, stub) - if "link_fop" in funcs: - @OpLink.fop_type - def stub (frame, this, oldloc, newloc, - xdata, s=self): - return s.link_fop (frame, this, oldloc, - newloc, xdata) - self.stub_refs["link_fop"] = stub - dl.set_link_fop(c_this, stub) - if "link_cbk" in funcs: - @OpLink.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - inode, buf, preparent, postparent, xdata, - s=self): - return s.link_cbk (frame, cookie, this, - op_ret, op_errno, inode, - buf, preparent, - postparent, xdata) - self.stub_refs["link_cbk"] = stub - dl.set_link_cbk(c_this, stub) - if "symlink_fop" in funcs: - @OpSymlink.fop_type - def stub (frame, this, linkname, loc, - umask, xdata, s=self): - return s.symlink_fop (frame, this, linkname, - loc, umask, xdata) - self.stub_refs["symlink_fop"] = stub - dl.set_symlink_fop(c_this, stub) - if "symlink_cbk" in funcs: - @OpSymlink.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - inode, buf, preparent, postparent, xdata, - s=self): - return s.symlink_cbk (frame, cookie, this, - op_ret, op_errno, inode, - buf, preparent, - postparent, xdata) - self.stub_refs["symlink_cbk"] = stub - dl.set_symlink_cbk(c_this, stub) - if "unlink_fop" in funcs: - @OpUnlink.fop_type - def stub (frame, this, loc, xflags, - xdata, s=self): - return s.unlink_fop (frame, this, loc, - xflags, xdata) - self.stub_refs["unlink_fop"] = stub - dl.set_unlink_fop(c_this, stub) - if "unlink_cbk" in funcs: - @OpUnlink.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - preparent, postparent, xdata, s=self): - return s.unlink_cbk (frame, cookie, this, - op_ret, op_errno, - preparent, postparent, - xdata) - self.stub_refs["unlink_cbk"] = stub - dl.set_unlink_cbk(c_this, stub) - if "readlink_fop" in funcs: - @OpReadlink.fop_type - def stub (frame, this, loc, size, - xdata, s=self): - return s.readlink_fop (frame, this, loc, - size, xdata) - self.stub_refs["readlink_fop"] = stub - dl.set_readlink_fop(c_this, stub) - if "readlink_cbk" in funcs: - @OpReadlink.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - path, buf, xdata, s=self): - return s.readlink_cbk (frame, cookie, this, - op_ret, op_errno, - path, buf, xdata) - self.stub_refs["readlink_cbk"] = stub - dl.set_readlink_cbk(c_this, stub) - if "mkdir_fop" in funcs: - @OpMkdir.fop_type - def stub (frame, this, loc, mode, umask, xdata, - s=self): - return s.mkdir_fop (frame, this, loc, mode, - umask, xdata) - self.stub_refs["mkdir_fop"] = stub - dl.set_mkdir_fop(c_this, stub) - if "mkdir_cbk" in funcs: - @OpMkdir.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, inode, - buf, preparent, postparent, xdata, s=self): - return s.mkdir_cbk (frame, cookie, this, - op_ret, op_errno, inode, - buf, preparent, - postparent, xdata) - self.stub_refs["mkdir_cbk"] = stub - dl.set_mkdir_cbk(c_this, stub) - if "rmdir_fop" in funcs: - @OpRmdir.fop_type - def stub (frame, this, loc, xflags, - xdata, s=self): - return s.rmdir_fop (frame, this, loc, - xflags, xdata) - self.stub_refs["rmdir_fop"] = stub - dl.set_rmdir_fop(c_this, stub) - if "rmdir_cbk" in funcs: - @OpRmdir.cbk_type - def stub (frame, cookie, this, op_ret, op_errno, - preparent, postparent, xdata, s=self): - return s.rmdir_cbk (frame, cookie, this, - op_ret, op_errno, - preparent, postparent, - xdata) - self.stub_refs["rmdir_cbk"] = stub - dl.set_rmdir_cbk(c_this, stub) diff --git a/xlators/features/glupy/src/setup.py.in b/xlators/features/glupy/src/setup.py.in deleted file mode 100644 index 611e9695f76..00000000000 --- a/xlators/features/glupy/src/setup.py.in +++ /dev/null @@ -1,24 +0,0 @@ -from distutils.core import setup - -DESC = """GlusterFS is a distributed file-system capable of scaling to -several petabytes. It aggregates various storage bricks over Infiniband -RDMA or TCP/IP interconnect into one large parallel network file system. -GlusterFS is one of the most sophisticated file systems in terms of -features and extensibility. It borrows a powerful concept called -Translators from GNU Hurd kernel. Much of the code in GlusterFS is in -user space and easily manageable. - -This package contains Glupy, the Python translator interface for GlusterFS.""" - -setup( - name='glusterfs-glupy', - version='@PACKAGE_VERSION@', - description='Glupy is the Python translator interface for GlusterFS', - long_description=DESC, - author='Gluster Community', - author_email='gluster-devel@gluster.org', - license='LGPLv3', - url='http://gluster.org/', - package_dir={'gluster':''}, - packages=['gluster'] -) |