From b6e3e9c480be4226925b51c5e9ee0c368aa94a6d Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Sun, 21 Aug 2011 18:53:04 +0530 Subject: features/marker: changes in marker to avoid race conditions and corruptions Change-Id: I38ddfab200d59dd4c8e9f9dd964a98f3d7aa7ab7 BUG: 3389 Reviewed-on: http://review.gluster.com/289 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/features/marker/src/marker-quota-helper.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'xlators/features/marker/src/marker-quota-helper.c') diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c index 2d5b234d1..d701cb5a3 100644 --- a/xlators/features/marker/src/marker-quota-helper.c +++ b/xlators/features/marker/src/marker-quota-helper.c @@ -32,8 +32,12 @@ quota_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path) { int ret = -1; - if (!loc) - return ret; + GF_VALIDATE_OR_GOTO ("marker", loc, out); + GF_VALIDATE_OR_GOTO ("marker", inode, out); + GF_VALIDATE_OR_GOTO ("marker", path, out); + /* Not checking for parent because while filling + * loc of root, parent will be NULL + */ if (inode) { loc->inode = inode_ref (inode); @@ -59,7 +63,7 @@ quota_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path) loc_wipe: if (ret < 0) loc_wipe (loc); - +out: return ret; } @@ -180,6 +184,7 @@ __add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc) uuid_copy (contribution->gfid, loc->parent->gfid); LOCK_INIT (&contribution->lock); + INIT_LIST_HEAD (&contribution->contri_list); list_add_tail (&contribution->contri_list, &ctx->contribution_head); @@ -363,7 +368,7 @@ quota_local_unref (xlator_t *this, quota_local_t *local) QUOTA_SAFE_DECREMENT (&local->lock, local->ref, ref); - if (ref > 0) + if (ref != 0) goto out; if (local->fd != NULL) @@ -374,6 +379,8 @@ quota_local_unref (xlator_t *this, quota_local_t *local) loc_wipe (&local->parent_loc); LOCK_DESTROY (&local->lock); + + GF_FREE (local); out: return 0; } -- cgit