summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2015-09-08 18:08:20 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-09-22 22:51:48 -0700
commit6838a5b342b40099d09ccdce6af8c6f769cccf39 (patch)
tree43d83f35384af4f510dd1264c55c74f323591523
parent5ad1add883ee54f83a42f0f6d6ae2c6e3f9a543a (diff)
downloadglusterfs-6838a5b342b40099d09ccdce6af8c6f769cccf39.tar.gz
glusterfs-6838a5b342b40099d09ccdce6af8c6f769cccf39.tar.xz
glusterfs-6838a5b342b40099d09ccdce6af8c6f769cccf39.zip
features/shard: Performance improvements in IO path - Part 2
This is change 2/2 of the performance improvements for sharding. The changes are with respect to maintaining up-to-date values of file attributes in [f]stat, [f]setattr, link, and [f]truncate codepaths. Change-Id: Ia3ce4664fb33be869e4dc76494adbe9c314cc098 BUG: 1258905 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/12138 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
-rw-r--r--xlators/features/shard/src/shard.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
index 4ccd4b01a0..4deabd209a 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -823,6 +823,10 @@ shard_post_fstat_handler (call_frame_t *frame, xlator_t *this)
local = frame->local;
+ if (local->op_ret >= 0)
+ shard_inode_ctx_set (local->fd->inode, this, &local->prebuf, 0,
+ SHARD_LOOKUP_MASK);
+
SHARD_STACK_UNWIND (fstat, frame, local->op_ret, local->op_errno,
&local->prebuf, local->xattr_rsp);
return 0;
@@ -835,6 +839,10 @@ shard_post_stat_handler (call_frame_t *frame, xlator_t *this)
local = frame->local;
+ if (local->op_ret >= 0)
+ shard_inode_ctx_set (local->loc.inode, this, &local->prebuf, 0,
+ SHARD_LOOKUP_MASK);
+
SHARD_STACK_UNWIND (stat, frame, local->op_ret, local->op_errno,
&local->prebuf, local->xattr_rsp);
return 0;
@@ -902,6 +910,7 @@ shard_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
frame->local = local;
local->handler = shard_post_stat_handler;
+ loc_copy (&local->loc, loc);
local->xattr_req = (xdata) ? dict_ref (xdata) : dict_new ();
if (!local->xattr_req)
goto err;
@@ -956,6 +965,7 @@ shard_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
frame->local = local;
local->handler = shard_post_fstat_handler;
+ local->fd = fd_ref (fd);
local->xattr_req = (xdata) ? dict_ref (xdata) : dict_new ();
if (!local->xattr_req)
goto err;
@@ -996,6 +1006,7 @@ shard_truncate_last_shard_cbk (call_frame_t *frame, void *cookie,
struct iatt *prebuf, struct iatt *postbuf,
dict_t *xdata)
{
+ inode_t *inode = NULL;
shard_local_t *local = NULL;
local = frame->local;
@@ -1014,6 +1025,10 @@ shard_truncate_last_shard_cbk (call_frame_t *frame, void *cookie,
local->delta_blocks = postbuf->ia_blocks - prebuf->ia_blocks;
local->hole_size = 0;
+ inode = (local->fop == GF_FOP_TRUNCATE) ? local->loc.inode
+ : local->fd->inode;
+ shard_inode_ctx_set (inode, this, postbuf, 0, SHARD_MASK_TIMES);
+
shard_update_file_size (frame, this, NULL, &local->loc,
shard_post_update_size_truncate_handler);
return 0;
@@ -1744,6 +1759,60 @@ err:
}
+int32_t
+shard_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, struct iatt *preparent,
+ struct iatt *postparent,
+ dict_t *xdata)
+{
+ if (op_ret < 0)
+ goto err;
+
+ shard_inode_ctx_set (inode, this, buf, 0,
+ SHARD_MASK_NLINK | SHARD_MASK_TIMES);
+
+ SHARD_STACK_UNWIND (link, frame, op_ret, op_errno, inode, buf,
+ preparent, postparent, xdata);
+ return 0;
+err:
+ SHARD_STACK_UNWIND (link, frame, op_ret, op_errno, inode, NULL, NULL,
+ NULL, NULL);
+ return 0;
+}
+
+int32_t
+shard_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
+{
+ int ret = -1;
+ uint64_t block_size = 0;
+
+ ret = shard_inode_ctx_get_block_size (oldloc->inode, this, &block_size);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to get block size "
+ "from inode ctx of %s",
+ uuid_utoa (oldloc->inode->gfid));
+ goto err;
+ }
+
+ if (!block_size) {
+ STACK_WIND_TAIL (frame, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->link, oldloc, newloc,
+ xdata);
+ return 0;
+ }
+
+ STACK_WIND (frame, shard_link_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata);
+ return 0;
+
+err:
+ SHARD_STACK_UNWIND (link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
+ NULL);
+ return 0;
+}
+
int
shard_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *preparent,
@@ -3865,10 +3934,18 @@ shard_post_setattr_handler (call_frame_t *frame, xlator_t *this)
local = frame->local;
if (local->fop == GF_FOP_SETATTR) {
+ if (local->op_ret >= 0)
+ shard_inode_ctx_set (local->loc.inode, this,
+ &local->postbuf, 0,
+ SHARD_LOOKUP_MASK);
SHARD_STACK_UNWIND (setattr, frame, local->op_ret,
local->op_errno, &local->prebuf,
&local->postbuf, local->xattr_rsp);
} else if (local->fop == GF_FOP_FSETATTR) {
+ if (local->op_ret >= 0)
+ shard_inode_ctx_set (local->fd->inode, this,
+ &local->postbuf, 0,
+ SHARD_LOOKUP_MASK);
SHARD_STACK_UNWIND (fsetattr, frame, local->op_ret,
local->op_errno, &local->prebuf,
&local->postbuf, local->xattr_rsp);
@@ -3950,6 +4027,7 @@ shard_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
if (!local->xattr_req)
goto err;
local->fop = GF_FOP_SETATTR;
+ loc_copy (&local->loc, loc);
SHARD_MD_READ_FOP_INIT_REQ_DICT (this, local->xattr_req,
local->loc.gfid, local, err);
@@ -4009,6 +4087,7 @@ shard_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (!local->xattr_req)
goto err;
local->fop = GF_FOP_FSETATTR;
+ local->fd = fd_ref (fd);
SHARD_MD_READ_FOP_INIT_REQ_DICT (this, local->xattr_req,
fd->inode->gfid, local, err);
@@ -4221,6 +4300,7 @@ struct xlator_fops fops = {
.readdirp = shard_readdirp,
.create = shard_create,
.mknod = shard_mknod,
+ .link = shard_link,
.unlink = shard_unlink,
.rename = shard_rename,
};