From 44cf0aa02bf081d0b94d0174493cbf162dd957b8 Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Tue, 10 May 2016 13:03:42 +0530 Subject: libglusterfs/gfapi: set appropriate errno for inode_link failures We do not seem to be setting errno appropriately in case of inode_link failures. This errno may be used by any application (for eg., nfs-ganesha) to determine the error encountered. This patch addresses the same. This is backport of below mainline fix - http://review.gluster.org/14278 Change-Id: I674f747c73369d0597a9c463e6ea4c85b9091355 BUG: 1335016 Signed-off-by: Soumya Koduri Reviewed-on: http://review.gluster.org/14278 Reviewed-by: Niels de Vos Reviewed-by: jiffin tony Thottan Reviewed-by: Kaleb KEITHLEY Reviewed-on: http://review.gluster.org/14287 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- api/src/glfs-resolve.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'api/src/glfs-resolve.c') diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index f8933326433..c2c6e64fb9d 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -134,6 +134,11 @@ glfs_refresh_inode_safe (xlator_t *subvol, inode_t *oldinode, if (newinode == loc.inode) inode_ctx_set (newinode, THIS, &ctx_value); inode_lookup (newinode); + } else { + gf_msg (subvol->name, GF_LOG_WARNING, errno, + API_MSG_INODE_LINK_FAILED, + "inode linking of %s failed", + uuid_utoa ((unsigned char *)&iatt.ia_gfid)); } loc_wipe (&loc); @@ -346,7 +351,14 @@ glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent, goto out; inode = inode_link (loc.inode, loc.parent, component, &ciatt); - if (inode == loc.inode) + + if (!inode) { + gf_msg (subvol->name, GF_LOG_WARNING, errno, + API_MSG_INODE_LINK_FAILED, + "inode linking of %s failed", + uuid_utoa ((unsigned char *)&ciatt.ia_gfid)); + goto out; + } else if (inode == loc.inode) inode_ctx_set (inode, THIS, &ctx_value); found: if (inode) -- cgit