From 6064c220844e8c4963e22ec48c8f7da9da57fc2f Mon Sep 17 00:00:00 2001 From: Anuradha Date: Wed, 3 Sep 2014 19:04:02 +0530 Subject: cluster/afr : Mark pending changelog xattrs for new creations Based on type of file, set appropriate pending changelogs for new entries. Change-Id: Ifd124bf9bc54b996ce83ab9f39d03b3ccca7eb3c BUG: 1130892 Signed-off-by: Anuradha Reviewed-on: http://review.gluster.org/8555 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri --- xlators/cluster/afr/src/afr-dir-write.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'xlators/cluster/afr/src/afr-dir-write.c') diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c index a9f272126ae..f5c385c34a4 100644 --- a/xlators/cluster/afr/src/afr-dir-write.c +++ b/xlators/cluster/afr/src/afr-dir-write.c @@ -278,8 +278,6 @@ afr_mark_new_entry_changelog (call_frame_t *frame, xlator_t *this) dict_t *xattr = NULL; int32_t **changelog = NULL; int i = 0; - int idx = -1; - int m_idx = 0; int op_errno = ENOMEM; unsigned char *pending = NULL; int call_count = 0; @@ -295,22 +293,10 @@ afr_mark_new_entry_changelog (call_frame_t *frame, xlator_t *this) if (!new_local) goto out; - changelog = afr_matrix_create (priv->child_count, AFR_NUM_CHANGE_LOGS); - if (!changelog) - goto out; - - new_local->pending = changelog; xattr = dict_new (); if (!xattr) goto out; - if (IA_ISREG (local->cont.dir_fop.buf.ia_type)) { - idx = afr_index_for_transaction_type (AFR_DATA_TRANSACTION); - } else if (IA_ISDIR (local->cont.dir_fop.buf.ia_type)) { - idx = afr_index_for_transaction_type (AFR_ENTRY_TRANSACTION); - } - m_idx = afr_index_for_transaction_type (AFR_METADATA_TRANSACTION); - pending = alloca0 (priv->child_count); for (i = 0; i < priv->child_count; i++) { @@ -319,19 +305,19 @@ afr_mark_new_entry_changelog (call_frame_t *frame, xlator_t *this) call_count ++; continue; } - - changelog[i][m_idx] = hton32(1); - if (idx != -1) - changelog[i][idx] = hton32(1); pending[i] = 1; } + changelog = afr_mark_pending_changelog (priv, pending, xattr, + local->cont.dir_fop.buf.ia_type); + if (!changelog) + goto out; + + new_local->pending = changelog; + changelog = NULL; uuid_copy (new_local->loc.gfid, local->cont.dir_fop.buf.ia_gfid); new_local->loc.inode = inode_ref (local->inode); - - afr_set_pending_dict (priv, xattr, changelog); - new_local->call_count = call_count; for (i = 0; i < priv->child_count; i++) { @@ -349,6 +335,8 @@ afr_mark_new_entry_changelog (call_frame_t *frame, xlator_t *this) new_frame = NULL; out: + if (changelog) + afr_matrix_cleanup (changelog, priv->child_count); if (new_frame) AFR_STACK_DESTROY (new_frame); if (xattr) -- cgit