|
|
887953 |
From 64b238d3a5caf7bdb32bca25946f84e0afe9bc7a Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: Krutika Dhananjay <kdhananj@redhat.com>
|
|
|
887953 |
Date: Tue, 17 Apr 2018 22:14:20 +0530
|
|
|
887953 |
Subject: [PATCH 427/444] features/shard: Add option to barrier parallel lookup
|
|
|
887953 |
and unlink of shards
|
|
|
887953 |
|
|
|
887953 |
> Upstream: https://review.gluster.org/19915
|
|
|
887953 |
> BUG: 1568521
|
|
|
887953 |
> Change-Id: Ib0f90a5f62abdfa89cda7bef9f3ff99f349ec332
|
|
|
887953 |
|
|
|
887953 |
Also move the common parallel unlink callback for GF_FOP_TRUNCATE and
|
|
|
887953 |
GF_FOP_FTRUNCATE into a separate function.
|
|
|
887953 |
|
|
|
887953 |
Change-Id: Ib0f90a5f62abdfa89cda7bef9f3ff99f349ec332
|
|
|
887953 |
BUG: 1520882
|
|
|
887953 |
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/154861
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
887953 |
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
xlators/features/shard/src/shard.c | 113 ++++++++++++++++++++++++++++---------
|
|
|
887953 |
xlators/features/shard/src/shard.h | 4 ++
|
|
|
887953 |
2 files changed, 89 insertions(+), 28 deletions(-)
|
|
|
887953 |
|
|
|
887953 |
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
|
|
|
887953 |
index 5ff04df..268ba20 100644
|
|
|
887953 |
--- a/xlators/features/shard/src/shard.c
|
|
|
887953 |
+++ b/xlators/features/shard/src/shard.c
|
|
|
887953 |
@@ -475,6 +475,7 @@ shard_local_wipe (shard_local_t *local)
|
|
|
887953 |
|
|
|
887953 |
count = local->num_blocks;
|
|
|
887953 |
|
|
|
887953 |
+ syncbarrier_destroy (&local->barrier);
|
|
|
887953 |
loc_wipe (&local->loc);
|
|
|
887953 |
loc_wipe (&local->dot_shard_loc);
|
|
|
887953 |
loc_wipe (&local->loc2);
|
|
|
887953 |
@@ -861,6 +862,7 @@ shard_common_resolve_shards (call_frame_t *frame, xlator_t *this,
|
|
|
887953 |
|
|
|
887953 |
priv = this->private;
|
|
|
887953 |
local = frame->local;
|
|
|
887953 |
+ local->call_count = 0;
|
|
|
887953 |
shard_idx_iter = local->first_block;
|
|
|
887953 |
res_inode = local->resolver_base_inode;
|
|
|
887953 |
|
|
|
887953 |
@@ -1780,6 +1782,37 @@ shard_unlink_shards_do_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
887953 |
struct iatt *preparent, struct iatt *postparent,
|
|
|
887953 |
dict_t *xdata);
|
|
|
887953 |
|
|
|
887953 |
+void
|
|
|
887953 |
+shard_unlink_block_inode (shard_local_t *local, int shard_block_num);
|
|
|
887953 |
+
|
|
|
887953 |
+int
|
|
|
887953 |
+shard_truncate_htol_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
887953 |
+ int32_t op_ret, int32_t op_errno,
|
|
|
887953 |
+ struct iatt *preparent, struct iatt *postparent,
|
|
|
887953 |
+ dict_t *xdata)
|
|
|
887953 |
+{
|
|
|
887953 |
+ int call_count = 0;
|
|
|
887953 |
+ int shard_block_num = (long) cookie;
|
|
|
887953 |
+ shard_local_t *local = NULL;
|
|
|
887953 |
+
|
|
|
887953 |
+ local = frame->local;
|
|
|
887953 |
+
|
|
|
887953 |
+ if (op_ret < 0) {
|
|
|
887953 |
+ local->op_ret = op_ret;
|
|
|
887953 |
+ local->op_errno = op_errno;
|
|
|
887953 |
+ goto done;
|
|
|
887953 |
+ }
|
|
|
887953 |
+
|
|
|
887953 |
+ shard_unlink_block_inode (local, shard_block_num);
|
|
|
887953 |
+done:
|
|
|
887953 |
+ call_count = shard_call_count_return (frame);
|
|
|
887953 |
+ if (call_count == 0) {
|
|
|
887953 |
+ SHARD_UNSET_ROOT_FS_ID (frame, local);
|
|
|
887953 |
+ shard_truncate_last_shard (frame, this, local->inode_list[0]);
|
|
|
887953 |
+ }
|
|
|
887953 |
+ return 0;
|
|
|
887953 |
+}
|
|
|
887953 |
+
|
|
|
887953 |
int
|
|
|
887953 |
shard_truncate_htol (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
887953 |
{
|
|
|
887953 |
@@ -1839,10 +1872,9 @@ shard_truncate_htol (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
887953 |
continue;
|
|
|
887953 |
}
|
|
|
887953 |
if (wind_failed) {
|
|
|
887953 |
- shard_unlink_shards_do_cbk (frame,
|
|
|
887953 |
- (void *)(long) cur_block,
|
|
|
887953 |
- this, -1, ENOMEM, NULL,
|
|
|
887953 |
- NULL, NULL);
|
|
|
887953 |
+ shard_truncate_htol_cbk (frame, (void *)(long) cur_block,
|
|
|
887953 |
+ this, -1, ENOMEM, NULL, NULL,
|
|
|
887953 |
+ NULL);
|
|
|
887953 |
goto next;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
@@ -1860,10 +1892,9 @@ shard_truncate_htol (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
887953 |
local->op_errno = ENOMEM;
|
|
|
887953 |
loc_wipe (&loc;;
|
|
|
887953 |
wind_failed = _gf_true;
|
|
|
887953 |
- shard_unlink_shards_do_cbk (frame,
|
|
|
887953 |
- (void *)(long) cur_block,
|
|
|
887953 |
- this, -1, ENOMEM, NULL,
|
|
|
887953 |
- NULL, NULL);
|
|
|
887953 |
+ shard_truncate_htol_cbk (frame, (void *)(long) cur_block,
|
|
|
887953 |
+ this, -1, ENOMEM, NULL, NULL,
|
|
|
887953 |
+ NULL);
|
|
|
887953 |
goto next;
|
|
|
887953 |
}
|
|
|
887953 |
loc.name = strrchr (loc.path, '/');
|
|
|
887953 |
@@ -1871,7 +1902,7 @@ shard_truncate_htol (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
887953 |
loc.name++;
|
|
|
887953 |
loc.inode = inode_ref (local->inode_list[i]);
|
|
|
887953 |
|
|
|
887953 |
- STACK_WIND_COOKIE (frame, shard_unlink_shards_do_cbk,
|
|
|
887953 |
+ STACK_WIND_COOKIE (frame, shard_truncate_htol_cbk,
|
|
|
887953 |
(void *) (long) cur_block, FIRST_CHILD(this),
|
|
|
887953 |
FIRST_CHILD (this)->fops->unlink, &loc,
|
|
|
887953 |
0, NULL);
|
|
|
887953 |
@@ -2022,13 +2053,18 @@ shard_common_lookup_shards_cbk (call_frame_t *frame, void *cookie,
|
|
|
887953 |
|
|
|
887953 |
done:
|
|
|
887953 |
call_count = shard_call_count_return (frame);
|
|
|
887953 |
- if (call_count == 0) {
|
|
|
887953 |
- if (!local->first_lookup_done)
|
|
|
887953 |
- local->first_lookup_done = _gf_true;
|
|
|
887953 |
- if (local->op_ret < 0)
|
|
|
887953 |
- goto unwind;
|
|
|
887953 |
- else
|
|
|
887953 |
- local->pls_fop_handler (frame, this);
|
|
|
887953 |
+ if (local->lookup_shards_barriered) {
|
|
|
887953 |
+ syncbarrier_wake (&local->barrier);
|
|
|
887953 |
+ return 0;
|
|
|
887953 |
+ } else {
|
|
|
887953 |
+ if (call_count == 0) {
|
|
|
887953 |
+ if (!local->first_lookup_done)
|
|
|
887953 |
+ local->first_lookup_done = _gf_true;
|
|
|
887953 |
+ if (local->op_ret < 0)
|
|
|
887953 |
+ goto unwind;
|
|
|
887953 |
+ else
|
|
|
887953 |
+ local->pls_fop_handler (frame, this);
|
|
|
887953 |
+ }
|
|
|
887953 |
}
|
|
|
887953 |
return 0;
|
|
|
887953 |
|
|
|
887953 |
@@ -2074,6 +2110,7 @@ shard_common_lookup_shards (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
887953 |
{
|
|
|
887953 |
int i = 0;
|
|
|
887953 |
int ret = 0;
|
|
|
887953 |
+ int count = 0;
|
|
|
887953 |
int call_count = 0;
|
|
|
887953 |
int32_t shard_idx_iter = 0;
|
|
|
887953 |
int last_block = 0;
|
|
|
887953 |
@@ -2087,10 +2124,12 @@ shard_common_lookup_shards (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
887953 |
|
|
|
887953 |
priv = this->private;
|
|
|
887953 |
local = frame->local;
|
|
|
887953 |
- call_count = local->call_count;
|
|
|
887953 |
+ count = call_count = local->call_count;
|
|
|
887953 |
shard_idx_iter = local->first_block;
|
|
|
887953 |
last_block = local->last_block;
|
|
|
887953 |
local->pls_fop_handler = handler;
|
|
|
887953 |
+ if (local->lookup_shards_barriered)
|
|
|
887953 |
+ local->barrier.waitfor = local->call_count;
|
|
|
887953 |
|
|
|
887953 |
while (shard_idx_iter <= last_block) {
|
|
|
887953 |
if (local->inode_list[i]) {
|
|
|
887953 |
@@ -2162,7 +2201,8 @@ next:
|
|
|
887953 |
if (!--call_count)
|
|
|
887953 |
break;
|
|
|
887953 |
}
|
|
|
887953 |
-
|
|
|
887953 |
+ if (local->lookup_shards_barriered)
|
|
|
887953 |
+ syncbarrier_wait (&local->barrier, count);
|
|
|
887953 |
return 0;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
@@ -2400,6 +2440,9 @@ shard_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
|
|
|
887953 |
|
|
|
887953 |
frame->local = local;
|
|
|
887953 |
|
|
|
887953 |
+ ret = syncbarrier_init (&local->barrier);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto err;
|
|
|
887953 |
loc_copy (&local->loc, loc);
|
|
|
887953 |
local->offset = offset;
|
|
|
887953 |
local->block_size = block_size;
|
|
|
887953 |
@@ -2450,6 +2493,9 @@ shard_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
|
|
|
887953 |
goto err;
|
|
|
887953 |
|
|
|
887953 |
frame->local = local;
|
|
|
887953 |
+ ret = syncbarrier_init (&local->barrier);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto err;
|
|
|
887953 |
local->fd = fd_ref (fd);
|
|
|
887953 |
local->offset = offset;
|
|
|
887953 |
local->block_size = block_size;
|
|
|
887953 |
@@ -2881,18 +2927,19 @@ shard_unlink_shards_do_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
887953 |
|
|
|
887953 |
done:
|
|
|
887953 |
call_count = shard_call_count_return (frame);
|
|
|
887953 |
- if (call_count == 0) {
|
|
|
887953 |
- SHARD_UNSET_ROOT_FS_ID (frame, local);
|
|
|
887953 |
+ if (local->unlink_shards_barriered) {
|
|
|
887953 |
+ syncbarrier_wake (&local->barrier);
|
|
|
887953 |
+ } else {
|
|
|
887953 |
|
|
|
887953 |
- if (local->fop == GF_FOP_UNLINK)
|
|
|
887953 |
- shard_unlink_cbk (frame, this);
|
|
|
887953 |
- else if (local->fop == GF_FOP_RENAME)
|
|
|
887953 |
- shard_rename_cbk (frame, this);
|
|
|
887953 |
- else
|
|
|
887953 |
- shard_truncate_last_shard (frame, this,
|
|
|
887953 |
- local->inode_list[0]);
|
|
|
887953 |
- }
|
|
|
887953 |
+ if (call_count == 0) {
|
|
|
887953 |
+ SHARD_UNSET_ROOT_FS_ID (frame, local);
|
|
|
887953 |
|
|
|
887953 |
+ if (local->fop == GF_FOP_UNLINK)
|
|
|
887953 |
+ shard_unlink_cbk (frame, this);
|
|
|
887953 |
+ else if (local->fop == GF_FOP_RENAME)
|
|
|
887953 |
+ shard_rename_cbk (frame, this);
|
|
|
887953 |
+ }
|
|
|
887953 |
+ }
|
|
|
887953 |
return 0;
|
|
|
887953 |
}
|
|
|
887953 |
|
|
|
887953 |
@@ -2952,6 +2999,8 @@ shard_unlink_shards_do (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
887953 |
local->call_count = call_count = count;
|
|
|
887953 |
cur_block = 1;
|
|
|
887953 |
SHARD_SET_ROOT_FS_ID (frame, local);
|
|
|
887953 |
+ if (local->unlink_shards_barriered)
|
|
|
887953 |
+ local->barrier.waitfor = count;
|
|
|
887953 |
|
|
|
887953 |
/* Ignore the base file and start iterating from the first block shard.
|
|
|
887953 |
*/
|
|
|
887953 |
@@ -3006,6 +3055,8 @@ next:
|
|
|
887953 |
if (!--call_count)
|
|
|
887953 |
break;
|
|
|
887953 |
}
|
|
|
887953 |
+ if (local->unlink_shards_barriered)
|
|
|
887953 |
+ syncbarrier_wait (&local->barrier, count);
|
|
|
887953 |
|
|
|
887953 |
return 0;
|
|
|
887953 |
}
|
|
|
887953 |
@@ -3947,6 +3998,9 @@ shard_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
887953 |
|
|
|
887953 |
frame->local = local;
|
|
|
887953 |
|
|
|
887953 |
+ ret = syncbarrier_init (&local->barrier);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto err;
|
|
|
887953 |
local->fd = fd_ref (fd);
|
|
|
887953 |
local->block_size = block_size;
|
|
|
887953 |
local->offset = offset;
|
|
|
887953 |
@@ -5414,6 +5468,9 @@ shard_common_inode_write_begin (call_frame_t *frame, xlator_t *this,
|
|
|
887953 |
|
|
|
887953 |
frame->local = local;
|
|
|
887953 |
|
|
|
887953 |
+ ret = syncbarrier_init (&local->barrier);
|
|
|
887953 |
+ if (ret)
|
|
|
887953 |
+ goto out;
|
|
|
887953 |
local->xattr_req = (xdata) ? dict_ref (xdata) : dict_new ();
|
|
|
887953 |
if (!local->xattr_req)
|
|
|
887953 |
goto out;
|
|
|
887953 |
diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h
|
|
|
887953 |
index a1adb6a..225caa0 100644
|
|
|
887953 |
--- a/xlators/features/shard/src/shard.h
|
|
|
887953 |
+++ b/xlators/features/shard/src/shard.h
|
|
|
887953 |
@@ -15,6 +15,7 @@
|
|
|
887953 |
#include "xlator.h"
|
|
|
887953 |
#include "compat-errno.h"
|
|
|
887953 |
#include "shard-messages.h"
|
|
|
887953 |
+#include "syncop.h"
|
|
|
887953 |
|
|
|
887953 |
#define GF_SHARD_DIR ".shard"
|
|
|
887953 |
#define SHARD_MIN_BLOCK_SIZE (4 * GF_UNIT_MB)
|
|
|
887953 |
@@ -257,6 +258,9 @@ typedef struct shard_local {
|
|
|
887953 |
} lock;
|
|
|
887953 |
inode_t *resolver_base_inode;
|
|
|
887953 |
gf_boolean_t first_lookup_done;
|
|
|
887953 |
+ syncbarrier_t barrier;
|
|
|
887953 |
+ gf_boolean_t lookup_shards_barriered;
|
|
|
887953 |
+ gf_boolean_t unlink_shards_barriered;
|
|
|
887953 |
} shard_local_t;
|
|
|
887953 |
|
|
|
887953 |
typedef struct shard_inode_ctx {
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|