summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c23
-rw-r--r--xlators/storage/posix/src/posix-metadata.c7
2 files changed, 23 insertions, 7 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 8906584684d..651569bf041 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -5423,19 +5423,21 @@ posix_forget(xlator_t *this, inode_t *inode)
{
int ret = 0;
char *unlink_path = NULL;
- uint64_t ctx_uint = 0;
+ uint64_t ctx_uint1 = 0;
+ uint64_t ctx_uint2 = 0;
posix_inode_ctx_t *ctx = NULL;
+ posix_mdata_t *mdata = NULL;
struct posix_private *priv_posix = NULL;
priv_posix = (struct posix_private *)this->private;
if (!priv_posix)
return 0;
- ret = inode_ctx_del(inode, this, &ctx_uint);
- if (!ctx_uint)
- return 0;
+ ret = inode_ctx_del2(inode, this, &ctx_uint1, &ctx_uint2);
+ if (!ctx_uint1)
+ goto check_ctx2;
- ctx = (posix_inode_ctx_t *)(uintptr_t)ctx_uint;
+ ctx = (posix_inode_ctx_t *)(uintptr_t)ctx_uint1;
if (ctx->unlink_flag == GF_UNLINK_TRUE) {
POSIX_GET_FILE_UNLINK_PATH(priv_posix->base_path, inode->gfid,
@@ -5444,14 +5446,21 @@ posix_forget(xlator_t *this, inode_t *inode)
gf_msg(this->name, GF_LOG_ERROR, ENOMEM, P_MSG_UNLINK_FAILED,
"Failed to remove gfid :%s", uuid_utoa(inode->gfid));
ret = -1;
- goto out;
+ goto ctx_free;
}
ret = sys_unlink(unlink_path);
}
-out:
+ctx_free:
pthread_mutex_destroy(&ctx->xattrop_lock);
pthread_mutex_destroy(&ctx->write_atomic_lock);
pthread_mutex_destroy(&ctx->pgfid_lock);
GF_FREE(ctx);
+
+check_ctx2:
+ if (ctx_uint2) {
+ mdata = (posix_mdata_t *)(uintptr_t)ctx_uint2;
+ }
+
+ GF_FREE(mdata);
return ret;
}
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c
index 62fc328dd3b..99b49ff4458 100644
--- a/xlators/storage/posix/src/posix-metadata.c
+++ b/xlators/storage/posix/src/posix-metadata.c
@@ -269,6 +269,7 @@ __posix_get_mdata_xattr(xlator_t *this, const char *real_path, int _fd,
*/
if (stbuf && op_errno != ENOENT) {
ret = 0;
+ GF_FREE(mdata);
goto out;
} else {
/* This case should not be hit. If it hits,
@@ -342,6 +343,7 @@ posix_set_mdata_xattr(xlator_t *this, const char *real_path, int fd,
posix_mdata_t *mdata = NULL;
int ret = -1;
int op_errno = 0;
+ bool free_mdata = false;
GF_VALIDATE_OR_GOTO("posix", this, out);
GF_VALIDATE_OR_GOTO(this->name, inode, out);
@@ -412,6 +414,8 @@ posix_set_mdata_xattr(xlator_t *this, const char *real_path, int fd,
mdata->mtime.tv_nsec = time->tv_nsec;
__inode_ctx_set1(inode, this, (uint64_t *)&mdata);
+ } else {
+ free_mdata = true;
}
}
@@ -485,6 +489,9 @@ out:
stbuf->ia_atime_nsec = mdata->atime.tv_nsec;
}
+ if (free_mdata)
+ GF_FREE(mdata);
+
return ret;
}