summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2015-09-09 08:34:08 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-09-13 22:06:14 -0700
commit605e47fe69a7e11f09f95699348dfab4bbab03ff (patch)
tree879579231432f5e2b192e7833cd8303e3b9df574 /xlators
parentc90c03e9a22d4e21ac7570482255ab42d7ff188e (diff)
features/shard: Add appropriate NULL checks to prevent excessive logging
Also, 1) the getxattr() callback must check for the fop return status before attempting to delete the internal keys. 2) the correct dict was not being used in shard_getxattr_cbk(). This patch also fixes that issue. Change-Id: I516a1d98e112b572bcec7d1f1e03e23152567be3 BUG: 1260637 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/12136 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/shard/src/shard.c76
1 files changed, 47 insertions, 29 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
index 8fc2e88c314..35a4f551e96 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -3577,8 +3577,11 @@ shard_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
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);
+
+ 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,
@@ -3597,8 +3600,11 @@ shard_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
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);
+
+ 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,
@@ -3615,29 +3621,22 @@ 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;
-}
-
+ if (op_ret < 0)
+ goto unwind;
-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);
+ if (dict) {
+ dict_del (dict, GF_XATTR_SHARD_BLOCK_SIZE);
+ dict_del (dict, GF_XATTR_SHARD_FILE_SIZE);
+ }
- SHARD_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata);
+unwind:
+ SHARD_STACK_UNWIND (fgetxattr, 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)
+shard_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ const char *name, dict_t *xdata)
{
int op_errno = EINVAL;
@@ -3647,18 +3646,37 @@ shard_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto out;
}
- STACK_WIND (frame, shard_getxattr_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->getxattr, loc, name, xdata);
+ STACK_WIND (frame, shard_fgetxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata);
return 0;
out:
- SHARD_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL, NULL);
+ SHARD_STACK_UNWIND (fgetxattr, 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)
+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;
@@ -3668,12 +3686,12 @@ shard_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto out;
}
- STACK_WIND (frame, shard_fgetxattr_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fgetxattr, fd, name, xdata);
+ STACK_WIND (frame, shard_getxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr, loc, name, xdata);
return 0;
out:
- SHARD_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL, NULL);
+ SHARD_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL, NULL);
return 0;
}