From 460ce40d3e2069bf6262dccea6f5ae2fac60d90f Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 16 Sep 2013 21:35:08 +0530 Subject: features/marker: quota friendly changes * handles renames on dht linkfiles correctly * nameless lookup friendly changes. uses gfid-to-path conversion functionality from storage/posix to build ancestry till root. * log message cleanup. * build inode contexts in readdirp * Accounting still not correct with hardlinks. Credits: ======== Vijay Bellur Raghavendra Bhat Change-Id: I415b6fbbc9691f5a38d9fd3c5d083a61e578bb81 BUG: 969461 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/5953 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/features/marker/src/marker.c | 141 +++++++++++++++++++++++++++++------ 1 file changed, 120 insertions(+), 21 deletions(-) (limited to 'xlators/features/marker/src/marker.c') diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 6df1f5688e2..e448bc08f67 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -303,13 +303,11 @@ marker_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, priv = this->private; - if (priv == NULL || (priv->feature_enabled & GF_XTIME) == 0) - goto wind; - gf_log (this->name, GF_LOG_DEBUG, "USER:PID = %d", frame->root->pid); - ret = call_from_special_client (frame, this, name); -wind: + if (priv && priv->feature_enabled & GF_XTIME) + ret = call_from_special_client (frame, this, name); + if (ret == _gf_false) { if (name == NULL) { /* Signifies that marker translator @@ -807,8 +805,10 @@ marker_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, priv = this->private; - if ((priv->feature_enabled & GF_QUOTA) && (local->ia_nlink == 1)) - mq_reduce_parent_size (this, &local->loc, -1); + if (priv->feature_enabled & GF_QUOTA) { + if (!local->skip_txn) + mq_reduce_parent_size (this, &local->loc, -1); + } if (priv->feature_enabled & GF_XTIME) marker_xtime_update_marks (this, local); @@ -874,6 +874,11 @@ marker_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, if (ret == -1) goto err; + if (xdata && dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { + local->skip_txn = 1; + goto unlink_wind; + } + if (uuid_is_null (loc->gfid) && loc->inode) uuid_copy (loc->gfid, loc->inode->gfid); @@ -919,8 +924,11 @@ marker_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, priv = this->private; - if (priv->feature_enabled & GF_QUOTA) - mq_initiate_quota_txn (this, &local->loc); + if (priv->feature_enabled & GF_QUOTA) { + if (!local->skip_txn) + mq_set_inode_xattr (this, &local->loc); + } + if (priv->feature_enabled & GF_XTIME) marker_xtime_update_marks (this, local); @@ -951,6 +959,9 @@ marker_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, if (ret == -1) goto err; + + if (xdata && dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) + local->skip_txn = 1; wind: STACK_WIND (frame, marker_link_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata); @@ -1011,7 +1022,7 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this, newloc.name++; newloc.parent = inode_ref (local->loc.parent); - mq_rename_update_newpath (this, &newloc); + mq_set_inode_xattr (this, &newloc); loc_wipe (&newloc); @@ -2490,22 +2501,94 @@ err: return 0; } + +int +marker_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, gf_dirent_t *entries, + dict_t *xdata) +{ + gf_dirent_t *entry = NULL; + loc_t loc = {0, }; + inode_t *parent = NULL; + + if ((op_ret <= 0) || (entries == NULL)) { + goto out; + } + + + list_for_each_entry (entry, &entries->list, list) { + if (entry->inode == entry->inode->table->root) { + loc.path = gf_strdup ("/"); + inode_unref (parent); + parent = NULL; + } + + loc.inode = inode_ref (entry->inode); + + if (parent != NULL) { + loc.parent = inode_ref (parent); + uuid_copy (loc.pargfid, parent->gfid); + } + + uuid_copy (loc.gfid, entry->d_stat.ia_gfid); + + mq_xattr_state (this, &loc, entry->dict, entry->d_stat); + + inode_unref (parent); + parent = inode_ref (entry->inode); + loc_wipe (&loc); + } + + if (parent) + inode_unref (parent); + +out: + STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata); + return 0; +} + int marker_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata) { - gf_dirent_t *entry = NULL; + gf_dirent_t *entry = NULL; + marker_conf_t *priv = NULL; + marker_local_t *local = NULL; + loc_t loc = {0, }; if (op_ret <= 0) goto unwind; + priv = this->private; + local = frame->local; + + if (!(priv->feature_enabled & GF_QUOTA) || (local == NULL)) { + goto unwind; + } + list_for_each_entry (entry, &entries->list, list) { - /* TODO: fill things */ + if ((strcmp (entry->d_name, ".") == 0) || + (strcmp (entry->d_name, "..") == 0)) + continue; + + loc.inode = inode_ref (entry->inode); + loc.parent = inode_ref (local->loc.inode); + + uuid_copy (loc.gfid, entry->d_stat.ia_gfid); + uuid_copy (loc.pargfid, loc.parent->gfid); + + mq_xattr_state (this, &loc, entry->dict, entry->d_stat); + + loc_wipe (&loc); } unwind: + local = frame->local; + frame->local = NULL; + STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata); + marker_local_unref (local); return 0; } @@ -2514,20 +2597,36 @@ int marker_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset, dict_t *dict) { - marker_conf_t *priv = NULL; + marker_conf_t *priv = NULL; + loc_t loc = {0, }; + marker_local_t *local = NULL; priv = this->private; - if (priv->feature_enabled == 0) - goto wind; + if ((dict != NULL) && dict_get (dict, GET_ANCESTRY_DENTRY_KEY)) { + STACK_WIND (frame, marker_build_ancestry_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readdirp, + fd, size, offset, dict); + } else { + if (priv->feature_enabled & GF_QUOTA) { + local = mem_get0 (this->local_pool); - if ((priv->feature_enabled & GF_QUOTA) && dict) - mq_req_xattr (this, NULL, dict); + MARKER_INIT_LOCAL (frame, local); -wind: - STACK_WIND (frame, marker_readdirp_cbk, - FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, - fd, size, offset, dict); + loc.parent = local->loc.inode = inode_ref (fd->inode); + + if (dict == NULL) + dict = dict_new (); + + mq_req_xattr (this, &loc, dict); + } + + STACK_WIND (frame, marker_readdirp_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->readdirp, + fd, size, offset, dict); + } return 0; } -- cgit