summaryrefslogtreecommitdiffstats
path: root/xlators/system
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2016-03-27 11:01:34 +0530
committerRaghavendra G <rgowdapp@redhat.com>2016-04-04 05:33:32 -0700
commit028afb21a7793d3efbb9db431bde37ec332d9839 (patch)
treede0000532bffb46ecb09e93bc876720208a21090 /xlators/system
parent8b7a96fa6f8e3909d7adf42d7e388f11795bfed2 (diff)
storage/posix: send proper iatt attributes for the root inode
This is a backport of http://review.gluster.org/13730 * changes in posix to send proper iatt attributes for the root directory when ancestry is built. Before posix was filling only the gfid and the inode type in the iatt structure keeping rest of the fields zeros. This was cached by posix-acl and used to send EACCES when some fops came on that object if the uid of the caller is same as the uid of the object on the disk. * getting and setting inode_ctx in function 'posix_acl_ctx_get' is not atomic and can lead to memory leak when there are multiple lookups for an inode at same time. This patch fixes this problem * Linking an inode in posix_build_ancestry, can cause a race in posix_acl. When parent inode is linked in posix_build_ancestry, and before it reaches posix_acl_readdirp_cbk, create/lookup can come on a leaf-inode, as parent-inode-ctx not yet updated in posix_acl_readdirp_cbk, create/lookup can fail with EACCESS. So do the inode linking in the quota xlator > Change-Id: I3101eefb65551cc4162c4ff2963be1b73deacd6d > BUG: 1320818 > Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> > Reviewed-on: http://review.gluster.org/13730 > Tested-by: Vijaikumar Mallikarjuna <vmallika@redhat.com> > Smoke: Gluster Build System <jenkins@build.gluster.com> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Change-Id: I65b0bbf83e563b519db07f2bcddcc6465743b6ea BUG: 1320892 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/13825 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/system')
-rw-r--r--xlators/system/posix-acl/src/posix-acl.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c
index 6f6deec7d34..1ec3144500c 100644
--- a/xlators/system/posix-acl/src/posix-acl.c
+++ b/xlators/system/posix-acl/src/posix-acl.c
@@ -193,8 +193,12 @@ acl_permits (call_frame_t *frame, inode_t *inode, int want)
conf = frame->this->private;
ctx = posix_acl_ctx_get (inode, frame->this);
- if (!ctx)
+ if (!ctx) {
+ gf_log_callingfn (frame->this->name, GF_LOG_ERROR,
+ "inode ctx is NULL for %s",
+ uuid_utoa (inode->gfid));
goto red;
+ }
if (frame_is_super_user (frame))
goto green;
@@ -287,21 +291,52 @@ out:
struct posix_acl_ctx *
-posix_acl_ctx_get (inode_t *inode, xlator_t *this)
+__posix_acl_ctx_get (inode_t *inode, xlator_t *this, gf_boolean_t create)
{
struct posix_acl_ctx *ctx = NULL;
uint64_t int_ctx = 0;
int ret = 0;
- ret = inode_ctx_get (inode, this, &int_ctx);
+ ret = __inode_ctx_get (inode, this, &int_ctx);
if ((ret == 0) && (int_ctx))
return PTR(int_ctx);
+ if (create == _gf_false)
+ return NULL;
+
ctx = GF_CALLOC (1, sizeof (*ctx), gf_posix_acl_mt_ctx_t);
if (!ctx)
return NULL;
- ret = inode_ctx_put (inode, this, UINT64 (ctx));
+ ret = __inode_ctx_put (inode, this, UINT64 (ctx));
+
+ return ctx;
+}
+
+struct posix_acl_ctx *
+posix_acl_ctx_new (inode_t *inode, xlator_t *this)
+{
+ struct posix_acl_ctx *ctx = NULL;
+
+ LOCK (&inode->lock);
+ {
+ ctx = __posix_acl_ctx_get (inode, this, _gf_true);
+ }
+ UNLOCK (&inode->lock);
+
+ return ctx;
+}
+
+struct posix_acl_ctx *
+posix_acl_ctx_get (inode_t *inode, xlator_t *this)
+{
+ struct posix_acl_ctx *ctx = NULL;
+
+ LOCK (&inode->lock);
+ {
+ ctx = __posix_acl_ctx_get (inode, this, _gf_false);
+ }
+ UNLOCK (&inode->lock);
return ctx;
}
@@ -636,7 +671,7 @@ posix_acl_inherit (xlator_t *this, loc_t *loc, dict_t *params, mode_t mode,
if (!par_default)
goto out;
- ctx = posix_acl_ctx_get (loc->inode, this);
+ ctx = posix_acl_ctx_new (loc->inode, this);
acl_access = posix_acl_dup (this, par_default);
if (!acl_access)
@@ -740,14 +775,14 @@ posix_acl_ctx_update (inode_t *inode, xlator_t *this, struct iatt *buf)
int ret = 0;
int i = 0;
- ctx = posix_acl_ctx_get (inode, this);
- if (!ctx) {
- ret = -1;
- goto out;
- }
-
LOCK(&inode->lock);
{
+ ctx = __posix_acl_ctx_get (inode, this, _gf_true);
+ if (!ctx) {
+ ret = -1;
+ goto unlock;
+ }
+
ctx->uid = buf->ia_uid;
ctx->gid = buf->ia_gid;
ctx->perm = st_mode_from_ia (buf->ia_prot, buf->ia_type);
@@ -792,7 +827,6 @@ posix_acl_ctx_update (inode_t *inode, xlator_t *this, struct iatt *buf)
}
unlock:
UNLOCK(&inode->lock);
-out:
return ret;
}