diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-dir-write.c')
| -rw-r--r-- | xlators/cluster/afr/src/afr-dir-write.c | 193 |
1 files changed, 31 insertions, 162 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c index 5725b1c5cb3..b7cceb79158 100644 --- a/xlators/cluster/afr/src/afr-dir-write.c +++ b/xlators/cluster/afr/src/afr-dir-write.c @@ -10,24 +10,20 @@ #include <libgen.h> #include <unistd.h> -#include <fnmatch.h> #include <sys/time.h> #include <stdlib.h> #include <signal.h> -#include "glusterfs.h" +#include <glusterfs/glusterfs.h> #include "afr.h" -#include "dict.h" -#include "xlator.h" -#include "hashfn.h" -#include "logging.h" -#include "list.h" -#include "call-stub.h" -#include "defaults.h" -#include "common-utils.h" -#include "compat-errno.h" -#include "compat.h" -#include "byte-order.h" +#include <glusterfs/dict.h> +#include <glusterfs/logging.h> +#include <glusterfs/list.h> +#include <glusterfs/defaults.h> +#include <glusterfs/common-utils.h> +#include <glusterfs/compat-errno.h> +#include <glusterfs/compat.h> +#include <glusterfs/byte-order.h> #include "afr.h" #include "afr-transaction.h" @@ -98,7 +94,9 @@ __afr_dir_write_finalize(call_frame_t *frame, xlator_t *this) } if (local->inode) { - afr_replies_interpret(frame, this, local->inode, NULL); + if (local->op != GF_FOP_RENAME && local->op != GF_FOP_LINK) + afr_replies_interpret(frame, this, local->inode, NULL); + inode_read_subvol = afr_data_subvol_get(local->inode, this, NULL, NULL, NULL, &args); } @@ -121,11 +119,11 @@ __afr_dir_write_finalize(call_frame_t *frame, xlator_t *this) continue; if (local->replies[i].op_ret < 0) { if (local->inode) - afr_inode_event_gen_reset(local->inode, this); + afr_inode_need_refresh_set(local->inode, this); if (local->parent) - afr_inode_event_gen_reset(local->parent, this); + afr_inode_need_refresh_set(local->parent, this); if (local->parent2) - afr_inode_event_gen_reset(local->parent2, this); + afr_inode_need_refresh_set(local->parent2, this); continue; } @@ -231,9 +229,9 @@ __afr_dir_write_cbk(call_frame_t *frame, void *cookie, xlator_t *this, __afr_dir_write_fill(frame, this, child_index, op_ret, op_errno, buf, preparent, postparent, preparent2, postparent2, xdata); + call_count = --local->call_count; } UNLOCK(&frame->lock); - call_count = afr_frame_return(frame); if (call_count == 0) { __afr_dir_write_finalize(frame, this); @@ -347,6 +345,7 @@ afr_mark_entry_pending_changelog(call_frame_t *frame, xlator_t *this) afr_private_t *priv = NULL; int pre_op_count = 0; int failed_count = 0; + unsigned char *success_replies = NULL; local = frame->local; priv = this->private; @@ -362,9 +361,22 @@ afr_mark_entry_pending_changelog(call_frame_t *frame, xlator_t *this) failed_count = AFR_COUNT(local->transaction.failed_subvols, priv->child_count); + /* FOP succeeded on all bricks. */ if (pre_op_count == priv->child_count && !failed_count) return; + /* FOP did not suceed on quorum no. of bricks. */ + success_replies = alloca0(priv->child_count); + afr_fill_success_replies(local, priv, success_replies); + if (!afr_has_quorum(success_replies, this, NULL)) + return; + + if (priv->thin_arbiter_count) { + /*Mark new entry using ta file*/ + local->is_new_entry = _gf_true; + return; + } + afr_mark_new_entry_changelog(frame, this); return; @@ -423,15 +435,11 @@ int afr_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) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - priv = this->private; - transaction_frame = copy_frame(frame); if (!transaction_frame) goto out; @@ -473,16 +481,6 @@ afr_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(loc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[0], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - int_lock->lockee_count++; ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; @@ -553,15 +551,11 @@ int afr_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dev_t dev, mode_t umask, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - priv = this->private; - transaction_frame = copy_frame(frame); if (!transaction_frame) goto out; @@ -596,16 +590,6 @@ afr_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(loc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[0], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - int_lock->lockee_count++; ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; @@ -674,15 +658,11 @@ int afr_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - priv = this->private; - transaction_frame = copy_frame(frame); if (!transaction_frame) goto out; @@ -698,7 +678,7 @@ afr_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, local->cont.mkdir.mode = mode; local->umask = umask; - if (!xdata || !dict_get(xdata, "gfid-req")) { + if (!xdata || !dict_get_sizen(xdata, "gfid-req")) { op_errno = EPERM; gf_msg_callingfn(this->name, GF_LOG_WARNING, op_errno, AFR_MSG_GFID_NULL, @@ -724,16 +704,6 @@ afr_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(loc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[0], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - int_lock->lockee_count++; ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; @@ -802,15 +772,11 @@ int afr_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - priv = this->private; - transaction_frame = copy_frame(frame); if (!transaction_frame) goto out; @@ -845,16 +811,6 @@ afr_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(newloc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[0], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - int_lock->lockee_count++; ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; @@ -924,15 +880,11 @@ int afr_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, loc_t *loc, mode_t umask, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - priv = this->private; - transaction_frame = copy_frame(frame); if (!transaction_frame) goto out; @@ -966,16 +918,6 @@ afr_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(loc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[0], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - int_lock->lockee_count++; ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; @@ -1048,15 +990,10 @@ int afr_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - int nlockee = 0; - - priv = this->private; transaction_frame = copy_frame(frame); if (!transaction_frame) { @@ -1099,35 +1036,6 @@ afr_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(oldloc->path); local->transaction.new_basename = AFR_BASENAME(newloc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = nlockee = 0; - ret = afr_init_entry_lockee( - &int_lock->lockee[nlockee], local, &local->transaction.new_parent_loc, - local->transaction.new_basename, priv->child_count); - if (ret) - goto out; - - nlockee++; - ret = afr_init_entry_lockee(&int_lock->lockee[nlockee], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - nlockee++; - if (local->newloc.inode && IA_ISDIR(local->newloc.inode->ia_type)) { - ret = afr_init_entry_lockee(&int_lock->lockee[nlockee], local, - &local->newloc, NULL, priv->child_count); - if (ret) - goto out; - - nlockee++; - } - qsort(int_lock->lockee, nlockee, sizeof(*int_lock->lockee), - afr_entry_lockee_cmp); - int_lock->lockee_count = nlockee; - ret = afr_transaction(transaction_frame, this, AFR_ENTRY_RENAME_TRANSACTION); if (ret < 0) { @@ -1196,15 +1104,11 @@ int afr_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - priv = this->private; - transaction_frame = copy_frame(frame); if (!transaction_frame) goto out; @@ -1237,16 +1141,6 @@ afr_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(loc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[0], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - int_lock->lockee_count++; ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; @@ -1313,15 +1207,10 @@ int afr_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata) { - afr_private_t *priv = NULL; afr_local_t *local = NULL; - afr_internal_lock_t *int_lock = NULL; call_frame_t *transaction_frame = NULL; int ret = -1; int op_errno = ENOMEM; - int nlockee = 0; - - priv = this->private; transaction_frame = copy_frame(frame); if (!transaction_frame) @@ -1355,26 +1244,6 @@ afr_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, local->transaction.main_frame = frame; local->transaction.basename = AFR_BASENAME(loc->path); - int_lock = &local->internal_lock; - - int_lock->lockee_count = nlockee = 0; - ret = afr_init_entry_lockee(&int_lock->lockee[nlockee], local, - &local->transaction.parent_loc, - local->transaction.basename, priv->child_count); - if (ret) - goto out; - - nlockee++; - ret = afr_init_entry_lockee(&int_lock->lockee[nlockee], local, &local->loc, - NULL, priv->child_count); - if (ret) - goto out; - - nlockee++; - qsort(int_lock->lockee, nlockee, sizeof(*int_lock->lockee), - afr_entry_lockee_cmp); - int_lock->lockee_count = nlockee; - ret = afr_transaction(transaction_frame, this, AFR_ENTRY_TRANSACTION); if (ret < 0) { op_errno = -ret; |
