summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-dir-write.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-12-18 14:38:22 +0530
committerAmar Tumballi <amarts@redhat.com>2018-12-28 10:46:00 +0000
commita12cadc1377ef51ad52defd1da91bf8f599e5786 (patch)
tree3380715fe1dd17255d75af1f9486e54a04a23bfb /xlators/cluster/afr/src/afr-dir-write.c
parent8d38c5b7337e44ad9f282966c0aa2e99bd7da506 (diff)
cluster/afr: Refactor internal locking code to allow multiple inodelks
For implementing copy_file_range fop, AFR needs to perform two inodelks in the same transaction. This patch brings in the necessary structure to make it easier to do so. Entry-locks in AFR were already taking multiple entry-locks on different inodes with the respective basenames. This patch extends the logic in inodelks to use the same lockee_t structure. This lead to removal of quite a lot of duplicate code present in afr-lk-common.c as both the locks are doing same things except 'winding' part. updates: #536 Change-Id: Ibfce7e3f260bb27b18645152ec680c33866fe0ae Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-dir-write.c')
-rw-r--r--xlators/cluster/afr/src/afr-dir-write.c143
1 files changed, 0 insertions, 143 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c
index 486b06b..f2c8ef4 100644
--- a/xlators/cluster/afr/src/afr-dir-write.c
+++ b/xlators/cluster/afr/src/afr-dir-write.c
@@ -425,15 +425,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;
@@ -475,16 +471,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;
@@ -555,15 +541,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;
@@ -598,16 +580,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;
@@ -676,15 +648,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;
@@ -726,16 +694,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;
@@ -804,15 +762,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;
@@ -847,16 +801,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;
@@ -926,15 +870,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;
@@ -968,16 +908,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;
@@ -1050,15 +980,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) {
@@ -1101,35 +1026,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) {
@@ -1198,15 +1094,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;
@@ -1239,16 +1131,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;
@@ -1315,15 +1197,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)
@@ -1357,26 +1234,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;