diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2015-09-08 08:22:23 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-09-08 19:14:10 -0700 |
commit | ccb52e0cba557a792b9227c86155a2dc8e29f44f (patch) | |
tree | 7c28096554dcd72f20b363b2a157b830797b3b81 /xlators/features/shard | |
parent | 0bd9beabd2facbd2c7fb52e74dc56ecb89abde8e (diff) |
features/shard: Filter internal shard xattrs in {get,remove,set}xattr
Change-Id: I40e4a5dbd13d6c3d777e7e01f93dabc83e52b137
BUG: 1260637
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/12121
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/features/shard')
-rw-r--r-- | xlators/features/shard/src/shard.c | 149 | ||||
-rw-r--r-- | xlators/features/shard/src/shard.h | 1 |
2 files changed, 150 insertions, 0 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 74d75758f59..d76dea7db64 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -3570,6 +3570,149 @@ shard_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, return 0; } +int32_t +shard_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata) +{ + int op_errno = EINVAL; + + GF_IF_NATIVE_XATTR_GOTO (SHARD_XATTR_PREFIX"*", name, op_errno, out); + dict_del (xdata, GF_XATTR_SHARD_BLOCK_SIZE); + dict_del (xdata, GF_XATTR_SHARD_FILE_SIZE); + + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->removexattr, loc, name, + xdata); + return 0; + +out: + SHARD_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL); + return 0; +} + +int32_t +shard_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name, dict_t *xdata) +{ + int op_errno = EINVAL; + + GF_IF_NATIVE_XATTR_GOTO (SHARD_XATTR_PREFIX"*", name, op_errno, out); + dict_del (xdata, GF_XATTR_SHARD_BLOCK_SIZE); + dict_del (xdata, GF_XATTR_SHARD_FILE_SIZE); + + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fremovexattr, fd, name, + xdata); + return 0; + +out: + SHARD_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL); + return 0; +} + +int32_t +shard_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) +{ + dict_del (xdata, GF_XATTR_SHARD_BLOCK_SIZE); + dict_del (xdata, GF_XATTR_SHARD_FILE_SIZE); + + SHARD_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict, xdata); + return 0; +} + + +int32_t +shard_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, + dict_t *xdata) +{ + dict_del (xdata, GF_XATTR_SHARD_BLOCK_SIZE); + dict_del (xdata, GF_XATTR_SHARD_FILE_SIZE); + + SHARD_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata); + return 0; +} + +int32_t +shard_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata) +{ + int op_errno = EINVAL; + + if ((name) && (!strncmp (name, SHARD_XATTR_PREFIX, + strlen (SHARD_XATTR_PREFIX)))) { + op_errno = ENODATA; + goto out; + } + + STACK_WIND (frame, shard_getxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->getxattr, loc, name, xdata); + return 0; + +out: + SHARD_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL, NULL); + return 0; +} + +int32_t +shard_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name, dict_t *xdata) +{ + int op_errno = EINVAL; + + if ((name) && (!strncmp (name, SHARD_XATTR_PREFIX, + strlen (SHARD_XATTR_PREFIX)))) { + op_errno = ENODATA; + goto out; + } + + STACK_WIND (frame, shard_fgetxattr_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata); + return 0; + +out: + SHARD_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL, NULL); + return 0; +} + +int32_t +shard_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata) +{ + int op_errno = EINVAL; + + GF_IF_INTERNAL_XATTR_GOTO (SHARD_XATTR_PREFIX"*", dict, op_errno, out); + + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fsetxattr, fd, dict, flags, + xdata); + return 0; + +out: + SHARD_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL); + return 0; +} + +int32_t +shard_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata) +{ + int op_errno = EINVAL; + + GF_IF_INTERNAL_XATTR_GOTO (SHARD_XATTR_PREFIX"*", dict, op_errno, out); + + STACK_WIND_TAIL (frame, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->setxattr, loc, dict, flags, + xdata); + return 0; + +out: + SHARD_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); + return 0; +} + int shard_post_setattr_handler (call_frame_t *frame, xlator_t *this) { @@ -3915,12 +4058,18 @@ struct xlator_fops fops = { .fsync = shard_fsync, .stat = shard_stat, .fstat = shard_fstat, + .getxattr = shard_getxattr, + .fgetxattr = shard_fgetxattr, .readv = shard_readv, .writev = shard_writev, .truncate = shard_truncate, .ftruncate = shard_ftruncate, + .setxattr = shard_setxattr, + .fsetxattr = shard_fsetxattr, .setattr = shard_setattr, .fsetattr = shard_fsetattr, + .removexattr = shard_removexattr, + .fremovexattr = shard_fremovexattr, .fallocate = shard_fallocate, .discard = shard_discard, .zerofill = shard_zerofill, diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h index 16e58d9991f..8daf2272dd3 100644 --- a/xlators/features/shard/src/shard.h +++ b/xlators/features/shard/src/shard.h @@ -18,6 +18,7 @@ #define GF_SHARD_DIR ".shard" #define SHARD_MIN_BLOCK_SIZE (4 * GF_UNIT_MB) #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" |