From 8f207feb260bc6112d5085859b43efc8378a4c5f Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Mon, 24 Sep 2018 13:21:58 -0700 Subject: features/marker: Avoid passing structures as parameters to functions Fixes CIDs: 1388779,1390242,1390057 The patch does the following: 1. Changes the prototype of mq_inspect_file_xattr() and mq_xattr_state() to have a parameter of struct iatt * instead of struct iatt. 2. Remove unneeded struct iatt parameter from mq_inspect_directory_xattr() Change-Id: I1f6eabda042f0fe56d8c9bca010302f5e518dbe4 updates: bz#789278 Signed-off-by: Vijay Bellur --- xlators/features/marker/src/marker-quota.c | 21 ++++++++++++--------- xlators/features/marker/src/marker-quota.h | 2 +- xlators/features/marker/src/marker.c | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index c680bc9a475..28da33849a0 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -2054,7 +2054,7 @@ out: int32_t mq_inspect_directory_xattr(xlator_t *this, quota_inode_ctx_t *ctx, inode_contribution_t *contribution, loc_t *loc, - dict_t *dict, struct iatt buf) + dict_t *dict) { int32_t ret = -1; int8_t dirty = -1; @@ -2151,7 +2151,7 @@ out: int32_t mq_inspect_file_xattr(xlator_t *this, quota_inode_ctx_t *ctx, inode_contribution_t *contribution, loc_t *loc, - dict_t *dict, struct iatt buf) + dict_t *dict, struct iatt *buf) { int32_t ret = -1; quota_meta_t size = { @@ -2168,9 +2168,12 @@ mq_inspect_file_xattr(xlator_t *this, quota_inode_ctx_t *ctx, }; gf_boolean_t status = _gf_false; + if (!buf || !contribution || !ctx) + goto out; + LOCK(&ctx->lock); { - ctx->size = 512 * buf.ia_blocks; + ctx->size = 512 * buf->ia_blocks; ctx->file_count = 1; ctx->dir_count = 0; @@ -2215,7 +2218,8 @@ out: } int32_t -mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, struct iatt buf) +mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, + struct iatt *buf) { int32_t ret = -1; quota_inode_ctx_t *ctx = NULL; @@ -2224,7 +2228,7 @@ mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, struct iatt buf) }; inode_contribution_t *contribution = NULL; - ret = mq_prevalidate_txn(this, origin_loc, &loc, &ctx, &buf); + ret = mq_prevalidate_txn(this, origin_loc, &loc, &ctx, buf); if (ret < 0 || loc.parent == NULL) goto out; @@ -2239,13 +2243,12 @@ mq_xattr_state(xlator_t *this, loc_t *origin_loc, dict_t *dict, struct iatt buf) ret = -1; goto out; } - if (buf.ia_type == IA_IFDIR) - mq_inspect_directory_xattr(this, ctx, contribution, &loc, dict, - buf); + if (buf->ia_type == IA_IFDIR) + mq_inspect_directory_xattr(this, ctx, contribution, &loc, dict); else mq_inspect_file_xattr(this, ctx, contribution, &loc, dict, buf); } else { - mq_inspect_directory_xattr(this, ctx, 0, &loc, dict, buf); + mq_inspect_directory_xattr(this, ctx, 0, &loc, dict); } out: diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h index 7f63e268203..7e24f1bc4f7 100644 --- a/xlators/features/marker/src/marker-quota.h +++ b/xlators/features/marker/src/marker-quota.h @@ -129,7 +129,7 @@ int32_t mq_req_xattr(xlator_t *, loc_t *, dict_t *, char *, char *); int32_t -mq_xattr_state(xlator_t *, loc_t *, dict_t *, struct iatt); +mq_xattr_state(xlator_t *, loc_t *, dict_t *, struct iatt *); int mq_initiate_quota_txn(xlator_t *, loc_t *, struct iatt *); diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index d3abd4b0b5b..29294e73fd4 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -2966,7 +2966,7 @@ unwind: gf_uuid_copy(local->loc.gfid, buf->ia_gfid); if (priv->feature_enabled & GF_QUOTA) { - mq_xattr_state(this, &local->loc, dict, *buf); + mq_xattr_state(this, &local->loc, dict, buf); } out: @@ -3118,7 +3118,7 @@ marker_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, "failed for %s", uuid_utoa(loc.inode->gfid)); - mq_xattr_state(this, &loc, entry->dict, entry->d_stat); + mq_xattr_state(this, &loc, entry->dict, &entry->d_stat); loc_wipe(&loc); ret = marker_key_set_ver(this, entry->dict); -- cgit