|
|
21ab4e |
From 08ba386864e244a08cc5f257ea5530aeb70e782f Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Krutika Dhananjay <kdhananj@redhat.com>
|
|
|
21ab4e |
Date: Tue, 28 Feb 2017 15:52:49 +0530
|
|
|
21ab4e |
Subject: [PATCH 471/473] storage/posix: Use granular mutex locks for pgfid
|
|
|
21ab4e |
update syscalls
|
|
|
21ab4e |
|
|
|
21ab4e |
Backport of: https://review.gluster.org/16869
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: Ibfe94aeb99037c98d939ad3e0261078baa465d29
|
|
|
21ab4e |
BUG: 1415178
|
|
|
21ab4e |
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/107026
|
|
|
21ab4e |
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
xlators/storage/posix/src/posix-helpers.c | 2 +
|
|
|
21ab4e |
xlators/storage/posix/src/posix.c | 62 +++++++++++++++++++++++++------
|
|
|
21ab4e |
xlators/storage/posix/src/posix.h | 1 +
|
|
|
21ab4e |
3 files changed, 54 insertions(+), 11 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
21ab4e |
index 46ac867..0c50967 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
21ab4e |
@@ -2288,11 +2288,13 @@ __posix_inode_ctx_get (inode_t *inode, xlator_t *this)
|
|
|
21ab4e |
|
|
|
21ab4e |
pthread_mutex_init (&ctx_p->xattrop_lock, NULL);
|
|
|
21ab4e |
pthread_mutex_init (&ctx_p->write_atomic_lock, NULL);
|
|
|
21ab4e |
+ pthread_mutex_init (&ctx_p->pgfid_lock, NULL);
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = __inode_ctx_set (inode, this, (uint64_t *)&ctx_p);
|
|
|
21ab4e |
if (ret < 0) {
|
|
|
21ab4e |
pthread_mutex_destroy (&ctx_p->xattrop_lock);
|
|
|
21ab4e |
pthread_mutex_destroy (&ctx_p->write_atomic_lock);
|
|
|
21ab4e |
+ pthread_mutex_destroy (&ctx_p->pgfid_lock);
|
|
|
21ab4e |
GF_FREE (ctx_p);
|
|
|
21ab4e |
return NULL;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
index 7f5ece4..95eaf0c 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
@@ -138,6 +138,7 @@ posix_forget (xlator_t *this, inode_t *inode)
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
pthread_mutex_destroy (&ctx->xattrop_lock);
|
|
|
21ab4e |
pthread_mutex_destroy (&ctx->write_atomic_lock);
|
|
|
21ab4e |
+ pthread_mutex_destroy (&ctx->pgfid_lock);
|
|
|
21ab4e |
GF_FREE (ctx);
|
|
|
21ab4e |
return ret;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
@@ -160,6 +161,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
char *pgfid_xattr_key = NULL;
|
|
|
21ab4e |
int32_t nlink_samepgfid = 0;
|
|
|
21ab4e |
struct posix_private *priv = NULL;
|
|
|
21ab4e |
+ posix_inode_ctx_t *ctx = NULL;
|
|
|
21ab4e |
|
|
|
21ab4e |
VALIDATE_OR_GOTO (frame, out);
|
|
|
21ab4e |
VALIDATE_OR_GOTO (this, out);
|
|
|
21ab4e |
@@ -219,7 +221,14 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
PGFID_XATTR_KEY_PREFIX,
|
|
|
21ab4e |
loc->pargfid);
|
|
|
21ab4e |
|
|
|
21ab4e |
- LOCK (&loc->inode->lock);
|
|
|
21ab4e |
+ op_ret = posix_inode_ctx_get_all (loc->inode, this,
|
|
|
21ab4e |
+ &ctx;;
|
|
|
21ab4e |
+ if (op_ret < 0) {
|
|
|
21ab4e |
+ op_errno = ENOMEM;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ pthread_mutex_lock (&ctx->pgfid_lock);
|
|
|
21ab4e |
{
|
|
|
21ab4e |
SET_PGFID_XATTR_IF_ABSENT (real_path,
|
|
|
21ab4e |
pgfid_xattr_key,
|
|
|
21ab4e |
@@ -228,7 +237,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
this, unlock);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
unlock:
|
|
|
21ab4e |
- UNLOCK (&loc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_unlock (&ctx->pgfid_lock);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -1924,6 +1933,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
char uuid_str[GF_UUID_BUF_SIZE] = {0};
|
|
|
21ab4e |
char gfid_str[GF_UUID_BUF_SIZE] = {0};
|
|
|
21ab4e |
gf_boolean_t get_link_count = _gf_false;
|
|
|
21ab4e |
+ posix_inode_ctx_t *ctx = NULL;
|
|
|
21ab4e |
|
|
|
21ab4e |
DECLARE_OLD_FS_ID_VAR;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -2027,14 +2037,19 @@ posix_unlink (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
if (priv->update_pgfid_nlinks && (stbuf.ia_nlink > 1)) {
|
|
|
21ab4e |
MAKE_PGFID_XATTR_KEY (pgfid_xattr_key, PGFID_XATTR_KEY_PREFIX,
|
|
|
21ab4e |
loc->pargfid);
|
|
|
21ab4e |
- LOCK (&loc->inode->lock);
|
|
|
21ab4e |
+ op_ret = posix_inode_ctx_get_all (loc->inode, this, &ctx;;
|
|
|
21ab4e |
+ if (op_ret < 0) {
|
|
|
21ab4e |
+ op_errno = ENOMEM;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ pthread_mutex_lock (&ctx->pgfid_lock);
|
|
|
21ab4e |
{
|
|
|
21ab4e |
UNLINK_MODIFY_PGFID_XATTR (real_path, pgfid_xattr_key,
|
|
|
21ab4e |
nlink_samepgfid, 0, op_ret,
|
|
|
21ab4e |
this, unlock);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
unlock:
|
|
|
21ab4e |
- UNLOCK (&loc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_unlock (&ctx->pgfid_lock);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (op_ret < 0) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
21ab4e |
@@ -2389,6 +2404,8 @@ posix_rename (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
dict_t *unwind_dict = NULL;
|
|
|
21ab4e |
gf_boolean_t locked = _gf_false;
|
|
|
21ab4e |
gf_boolean_t get_link_count = _gf_false;
|
|
|
21ab4e |
+ posix_inode_ctx_t *ctx_old = NULL;
|
|
|
21ab4e |
+ posix_inode_ctx_t *ctx_new = NULL;
|
|
|
21ab4e |
|
|
|
21ab4e |
DECLARE_OLD_FS_ID_VAR;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -2471,10 +2488,26 @@ posix_rename (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
+ op_ret = posix_inode_ctx_get_all (oldloc->inode, this, &ctx_old);
|
|
|
21ab4e |
+ if (op_ret < 0) {
|
|
|
21ab4e |
+ op_ret = -1;
|
|
|
21ab4e |
+ op_errno = ENOMEM;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (newloc->inode) {
|
|
|
21ab4e |
+ op_ret = posix_inode_ctx_get_all (newloc->inode, this, &ctx_new);
|
|
|
21ab4e |
+ if (op_ret < 0) {
|
|
|
21ab4e |
+ op_ret = -1;
|
|
|
21ab4e |
+ op_errno = ENOMEM;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
if (IA_ISDIR (oldloc->inode->ia_type))
|
|
|
21ab4e |
posix_handle_unset (this, oldloc->inode->gfid, NULL);
|
|
|
21ab4e |
|
|
|
21ab4e |
- LOCK (&oldloc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_lock (&ctx_old->pgfid_lock);
|
|
|
21ab4e |
{
|
|
|
21ab4e |
if (!IA_ISDIR (oldloc->inode->ia_type)
|
|
|
21ab4e |
&& priv->update_pgfid_nlinks) {
|
|
|
21ab4e |
@@ -2490,7 +2523,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
|
|
|
21ab4e |
if ((xdata) && (dict_get (xdata, GET_LINK_COUNT))
|
|
|
21ab4e |
&& (real_newpath) && (was_present)) {
|
|
|
21ab4e |
- LOCK (&newloc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_lock (&ctx_new->pgfid_lock);
|
|
|
21ab4e |
locked = _gf_true;
|
|
|
21ab4e |
get_link_count = _gf_true;
|
|
|
21ab4e |
op_ret = posix_pstat (this, newloc->gfid, real_newpath,
|
|
|
21ab4e |
@@ -2532,7 +2565,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
if (locked) {
|
|
|
21ab4e |
- UNLOCK (&newloc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_unlock (&ctx_new->pgfid_lock);
|
|
|
21ab4e |
locked = _gf_false;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -2557,10 +2590,10 @@ posix_rename (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
unlock:
|
|
|
21ab4e |
if (locked) {
|
|
|
21ab4e |
- UNLOCK (&newloc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_unlock (&ctx_new->pgfid_lock);
|
|
|
21ab4e |
locked = _gf_false;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
- UNLOCK (&oldloc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_unlock (&ctx_old->pgfid_lock);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (op_ret < 0) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_FAILED,
|
|
|
21ab4e |
@@ -2641,6 +2674,7 @@ posix_link (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
int32_t nlink_samepgfid = 0;
|
|
|
21ab4e |
char *pgfid_xattr_key = NULL;
|
|
|
21ab4e |
gf_boolean_t entry_created = _gf_false;
|
|
|
21ab4e |
+ posix_inode_ctx_t *ctx = NULL;
|
|
|
21ab4e |
|
|
|
21ab4e |
DECLARE_OLD_FS_ID_VAR;
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -2707,14 +2741,20 @@ posix_link (call_frame_t *frame, xlator_t *this,
|
|
|
21ab4e |
MAKE_PGFID_XATTR_KEY (pgfid_xattr_key, PGFID_XATTR_KEY_PREFIX,
|
|
|
21ab4e |
newloc->pargfid);
|
|
|
21ab4e |
|
|
|
21ab4e |
- LOCK (&newloc->inode->lock);
|
|
|
21ab4e |
+ op_ret = posix_inode_ctx_get_all (newloc->inode, this, &ctx;;
|
|
|
21ab4e |
+ if (op_ret < 0) {
|
|
|
21ab4e |
+ op_errno = ENOMEM;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ pthread_mutex_lock (&ctx->pgfid_lock);
|
|
|
21ab4e |
{
|
|
|
21ab4e |
LINK_MODIFY_PGFID_XATTR (real_newpath, pgfid_xattr_key,
|
|
|
21ab4e |
nlink_samepgfid, 0, op_ret,
|
|
|
21ab4e |
this, unlock);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
unlock:
|
|
|
21ab4e |
- UNLOCK (&newloc->inode->lock);
|
|
|
21ab4e |
+ pthread_mutex_unlock (&ctx->pgfid_lock);
|
|
|
21ab4e |
|
|
|
21ab4e |
if (op_ret < 0) {
|
|
|
21ab4e |
gf_msg (this->name, GF_LOG_WARNING, 0,
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
21ab4e |
index aac8d39..febd432 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix.h
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
21ab4e |
@@ -194,6 +194,7 @@ typedef struct {
|
|
|
21ab4e |
uint64_t unlink_flag;
|
|
|
21ab4e |
pthread_mutex_t xattrop_lock;
|
|
|
21ab4e |
pthread_mutex_t write_atomic_lock;
|
|
|
21ab4e |
+ pthread_mutex_t pgfid_lock;
|
|
|
21ab4e |
} posix_inode_ctx_t;
|
|
|
21ab4e |
|
|
|
21ab4e |
#define POSIX_BASE_PATH(this) (((struct posix_private *)this->private)->base_path)
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|