diff options
author | Kotresh HR <khiremat@redhat.com> | 2015-09-22 16:18:29 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-11-22 22:49:15 -0800 |
commit | 8805a4c65bf9c725cb26bb6979f3ebd62748138f (patch) | |
tree | 8be59d9b6090788733951337c3889a33cd8ac3b8 /xlators | |
parent | 26abf56130c37bb47676658c0a0211164f05ed24 (diff) |
features/changelog: Capture FXATTROP and XATTROP in changelog
GEO-REP INTEROP WITH SHARD FEATURE
shard xlator updates size of the file using FXATTROP
or XATTROP. Hence record the same in changelog.
Change-Id: Ie0c21e9326da05ea78dc1ef3fd32a90ef38b4bb9
BUG: 1265148
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/12225
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/changelog/src/changelog.c | 129 | ||||
-rw-r--r-- | xlators/features/shard/src/shard.h | 2 |
2 files changed, 129 insertions, 2 deletions
diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index c954e5e0616..cbfc307eb3c 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -1249,12 +1249,19 @@ changelog_setattr (call_frame_t *frame, changelog_priv_t *priv = NULL; changelog_opt_t *co = NULL; size_t xtra_len = 0; + uuid_t shard_root_gfid = {0,}; priv = this->private; CHANGELOG_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); CHANGELOG_IF_INTERNAL_FOP_THEN_GOTO (frame, xdata, wind); + /* Do not record META on .shard */ + gf_uuid_parse (SHARD_ROOT_GFID, shard_root_gfid); + if (gf_uuid_compare (loc->gfid, shard_root_gfid) == 0) { + goto wind; + } + CHANGELOG_OP_BOUNDARY_CHECK (frame, wind); CHANGELOG_INIT (this, frame->local, @@ -1567,6 +1574,126 @@ changelog_fsetxattr (call_frame_t *frame, return 0; } +int32_t +changelog_xattrop_cbk (call_frame_t *frame, + void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xattr, dict_t *xdata) +{ + changelog_priv_t *priv = NULL; + changelog_local_t *local = NULL; + + priv = this->private; + local = frame->local; + + CHANGELOG_COND_GOTO (priv, ((op_ret < 0) || !local), unwind); + + changelog_update (this, priv, local, CHANGELOG_TYPE_METADATA); + + unwind: + changelog_dec_fop_cnt (this, priv, local); + CHANGELOG_STACK_UNWIND (xattrop, frame, op_ret, op_errno, xattr, xdata); + + return 0; +} + +int32_t +changelog_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata) +{ + changelog_priv_t *priv = NULL; + changelog_opt_t *co = NULL; + size_t xtra_len = 0; + int ret = 0; + void *size_attr = NULL; + + priv = this->private; + CHANGELOG_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); + ret = dict_get_ptr (xattr, GF_XATTR_SHARD_FILE_SIZE, &size_attr); + if (ret) + goto wind; + + CHANGELOG_OP_BOUNDARY_CHECK (frame, wind); + + CHANGELOG_INIT (this, frame->local, + loc->inode, loc->inode->gfid, 1); + + co = changelog_get_usable_buffer (frame->local); + if (!co) + goto wind; + + CHANGLOG_FILL_FOP_NUMBER (co, frame->root->op, fop_fn, xtra_len); + + changelog_set_usable_record_and_length (frame->local, xtra_len, 1); + + wind: + changelog_color_fop_and_inc_cnt (this, priv, frame->local); + STACK_WIND (frame, changelog_xattrop_cbk, + FIRST_CHILD (this), FIRST_CHILD (this)->fops->xattrop, + loc, optype, xattr, xdata); + return 0; +} + +int32_t +changelog_fxattrop_cbk (call_frame_t *frame, + void *cookie, xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xattr, dict_t *xdata) +{ + changelog_priv_t *priv = NULL; + changelog_local_t *local = NULL; + + priv = this->private; + local = frame->local; + + CHANGELOG_COND_GOTO (priv, ((op_ret < 0) || !local), unwind); + + changelog_update (this, priv, local, CHANGELOG_TYPE_METADATA); + + unwind: + changelog_dec_fop_cnt (this, priv, local); + CHANGELOG_STACK_UNWIND (fxattrop, frame, + op_ret, op_errno, xattr, xdata); + + return 0; +} + +int32_t +changelog_fxattrop (call_frame_t *frame, + xlator_t *this, fd_t *fd, gf_xattrop_flags_t optype, + dict_t *xattr, dict_t *xdata) +{ + changelog_priv_t *priv = NULL; + changelog_opt_t *co = NULL; + size_t xtra_len = 0; + void *size_attr = NULL; + int ret = 0; + + priv = this->private; + CHANGELOG_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); + ret = dict_get_ptr (xattr, GF_XATTR_SHARD_FILE_SIZE, &size_attr); + if (ret) + goto wind; + + + CHANGELOG_OP_BOUNDARY_CHECK (frame, wind); + + CHANGELOG_INIT (this, frame->local, + fd->inode, fd->inode->gfid, 1); + + co = changelog_get_usable_buffer (frame->local); + if (!co) + goto wind; + + CHANGLOG_FILL_FOP_NUMBER (co, frame->root->op, fop_fn, xtra_len); + + changelog_set_usable_record_and_length (frame->local, xtra_len, 1); + + wind: + changelog_color_fop_and_inc_cnt (this, priv, frame->local); + STACK_WIND (frame, changelog_fxattrop_cbk, + FIRST_CHILD (this), FIRST_CHILD (this)->fops->fxattrop, + fd, optype, xattr, xdata); + return 0; +} /* }}} */ @@ -2797,6 +2924,8 @@ struct xlator_fops fops = { .removexattr = changelog_removexattr, .fremovexattr = changelog_fremovexattr, .ipc = changelog_ipc, + .xattrop = changelog_xattrop, + .fxattrop = changelog_fxattrop, }; struct xlator_cbks cbks = { diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h index ecb63dd157b..8303a2ca030 100644 --- a/xlators/features/shard/src/shard.h +++ b/xlators/features/shard/src/shard.h @@ -21,8 +21,6 @@ #define SHARD_MAX_BLOCK_SIZE (4 * GF_UNIT_TB) #define SHARD_XATTR_PREFIX "trusted.glusterfs.shard." #define GF_XATTR_SHARD_BLOCK_SIZE "trusted.glusterfs.shard.block-size" -#define GF_XATTR_SHARD_FILE_SIZE "trusted.glusterfs.shard.file-size" -#define SHARD_ROOT_GFID "be318638-e8a0-4c6d-977d-7a937aa84806" #define SHARD_INODE_LRU_LIMIT 4096 #define SHARD_MAX_INODES 16384 /** |