summaryrefslogtreecommitdiffstats
path: root/xlators/storage
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/storage
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/storage')
-rw-r--r--xlators/storage/posix/src/posix-handle.c53
-rw-r--r--xlators/storage/posix/src/posix-messages.h26
-rw-r--r--xlators/storage/posix/src/posix.c9
3 files changed, 73 insertions, 15 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index aad7db61430..d9086530322 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -35,24 +35,42 @@ inode_t *
posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent,
char *bname, struct iatt *iabuf)
{
- inode_t *inode = NULL, *linked_inode = NULL;
+ inode_t *inode = NULL;
int ret = -1;
ret = posix_istat (this, parent->gfid, bname, iabuf);
- if (ret < 0)
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING, "gfid: %s, bname: %s "
+ "failed", uuid_utoa (parent->gfid), bname);
goto out;
+ }
- inode = inode_find (itable, iabuf->ia_gfid);
- if (inode == NULL) {
- inode = inode_new (itable);
+ if (__is_root_gfid (iabuf->ia_gfid) && !strcmp (bname, "/")) {
+ inode = itable->root;
+ } else {
+ inode = inode_find (itable, iabuf->ia_gfid);
+ if (inode == NULL) {
+ inode = inode_new (itable);
+ gf_uuid_copy (inode->gfid, iabuf->ia_gfid);
+ }
}
- linked_inode = inode_link (inode, parent, bname, iabuf);
+ /* Linking an inode here, can cause a race in posix_acl.
+ Parent inode gets linked here, but 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 and lookup can fail
+ with EACCESS. So do the inode linking in the quota xlator
+
+ if (__is_root_gfid (iabuf->ia_gfid) && !strcmp (bname, "/"))
+ linked_inode = itable->root;
+ else
+ linked_inode = inode_link (inode, parent, bname, iabuf);
- inode_unref (inode);
+ inode_unref (inode);*/
out:
- return linked_inode;
+ return inode;
}
int
@@ -72,6 +90,8 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize,
}
strcat (path, dir_name);
+ if (*dir_name != '/')
+ strcat (path, "/");
if (type & POSIX_ANCESTRY_DENTRY) {
entry = gf_dirent_for_name (dir_name);
@@ -132,11 +152,16 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
*parent = inode_ref (itable->root);
}
- inode = itable->root;
- memset (&iabuf, 0, sizeof (iabuf));
- gf_uuid_copy (iabuf.ia_gfid, inode->gfid);
- iabuf.ia_type = inode->ia_type;
+ inode = posix_resolve (this, itable, *parent, "/", &iabuf);
+ if (!inode) {
+ gf_msg (this->name, GF_LOG_ERROR,
+ P_MSG_INODE_RESOLVE_FAILED, 0,
+ "posix resolve on the root inode %s failed",
+ uuid_utoa (gfid));
+ *op_errno = ESTALE;
+ goto out;
+ }
ret = posix_make_ancestral_node (priv_base_path, path, pathsize,
head, "/", &iabuf, inode, type,
@@ -182,12 +207,14 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
inode = posix_resolve (this, itable, *parent, dir_name, &iabuf);
if (inode == NULL) {
+ gf_msg (this->name, GF_LOG_ERROR, P_MSG_INODE_RESOLVE_FAILED,
+ 0, "posix resolve on the root inode %s failed",
+ uuid_utoa (gfid));
*op_errno = ESTALE;
ret = -1;
goto out;
}
- strcat (dir_name, "/");
ret = posix_make_ancestral_node (priv_base_path, path, pathsize, head,
dir_name, &iabuf, inode, type, xdata);
if (*parent != NULL) {
diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h
index 961a706cc36..4efdef0a6b9 100644
--- a/xlators/storage/posix/src/posix-messages.h
+++ b/xlators/storage/posix/src/posix-messages.h
@@ -45,7 +45,7 @@
*/
#define POSIX_COMP_BASE GLFS_MSGID_COMP_POSIX
-#define GLFS_NUM_MESSAGES 105
+#define GLFS_NUM_MESSAGES 108
#define GLFS_MSGID_END (POSIX_COMP_BASE + GLFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_x POSIX_COMP_BASE, "Invalid: Start of messages"
@@ -901,6 +901,30 @@
*
*/
+#define P_MSG_SEEK_UNKOWN (POSIX_COMP_BASE + 106)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_SEEK_FAILED (POSIX_COMP_BASE + 107)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
+#define P_MSG_INODE_RESOLVE_FAILED (POSIX_COMP_BASE + 108)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+
/*------------*/
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 761bc4e5946..c43029edd72 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3753,11 +3753,18 @@ posix_links_in_same_directory (char *dirpath, int count, inode_t *leaf_inode,
if (entry->d_ino != stbuf->st_ino)
continue;
+ /* Linking an inode here, can cause a race in posix_acl.
+ Parent inode gets linked here, but 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 and lookup can fail
+ with EACCESS. So do the inode linking in the quota xlator
+
linked_inode = inode_link (leaf_inode, parent,
entry->d_name, NULL);
GF_ASSERT (linked_inode == leaf_inode);
- inode_unref (linked_inode);
+ inode_unref (linked_inode);*/
if (type & POSIX_ANCESTRY_DENTRY) {
loc_t loc = {0, };