summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2015-09-08 08:22:23 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-09-13 22:02:43 -0700
commite89b7dc4f88644cb4538bd1dd3cd493028808bd6 (patch)
treed61ed73f21c2d4508ddbb600703dae8ec7d24e8d /xlators
parent1d02d4bd9b5f7d730ab08961c17ef58204c8e8fd (diff)
features/shard: Filter internal shard xattrs in {get,remove,set}xattr
Backport of: http://review.gluster.org/#/c/12121/ and http://review.gluster.org/#/c/12136/ Change-Id: Ifadebe1cda80fa4a525605e10513e6e64ee72709 BUG: 1261008 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/12127 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>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/shard/src/shard.c167
-rw-r--r--xlators/features/shard/src/shard.h1
2 files changed, 168 insertions, 0 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
index b93c5ec14a8..35a4f551e96 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -3570,6 +3570,167 @@ 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);
+
+ if (xdata) {
+ 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);
+
+ if (xdata) {
+ 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)
+{
+ if (op_ret < 0)
+ goto unwind;
+
+ if (dict) {
+ dict_del (dict, GF_XATTR_SHARD_BLOCK_SIZE);
+ dict_del (dict, GF_XATTR_SHARD_FILE_SIZE);
+ }
+
+unwind:
+ SHARD_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict, xdata);
+ 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_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)
+{
+ if (op_ret < 0)
+ goto unwind;
+
+ if (dict) {
+ dict_del (dict, GF_XATTR_SHARD_BLOCK_SIZE);
+ dict_del (dict, GF_XATTR_SHARD_FILE_SIZE);
+ }
+
+unwind:
+ 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_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 +4076,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 e859b96c4db..b57e2c4d7c9 100644
--- a/xlators/features/shard/src/shard.h
+++ b/xlators/features/shard/src/shard.h
@@ -23,6 +23,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"