summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2014-12-17 10:41:05 +0100
committerRaghavendra Bhat <raghavendra@redhat.com>2014-12-17 03:48:22 -0800
commite398f99d9ac7ca5c83004b814a4e8561916187f0 (patch)
treed74d7fe7dc7e45aa37b12fb88557c5ecab4a68b4 /xlators/cluster
parent466a6f37ebaaad746e2eae045ebd249e28673717 (diff)
telldir()/seekdir() portability fixes
POSIX says that an offset obtained from telldir() can only be used on the same DIR *. Linux is abls to reuse the offset accross closedir()/opendir() for a given directory, but this is not portable and such a behavior should be fixed. An incomplete fix for the posix xlator was merged in http://review.gluster.com/8926 This change set completes it. - Perform the same fix index xlator. - Use appropriate casts and variable types so that 32 bit signed offsets obtained by telldir() do not get clobbered when copied into 64 bit signed types. - modify glfs-heal.c and afr-self-heald.c so that they do not use anonymous fd, since this will cause closedir()/opendir() between each syncop_readdir(). On failure we fallback to anonymous fs only for Linux so that we can cope with updated client vs not updated brick. - Avoid sending an EINVAL when the client request for the EOF offset. Here we fix an error in previous fix for posix xlator: since we fill each directory entry with the offset of the next entry, we must consider as EOF the offset of the last entry, and not the value of telldir() after we read it. - Add checks in regression tests that we do not hit cases where offsets fed to seekdir() are wrong. Introduce log_newer() shell function to check for messages produced by the current script. This fix gather changes from http://review.gluster.org/9047 and http://review.gluster.org/8936 making them obsolete. BUG: 1129939 Change-Id: I59fb7f06a872c4f98987105792d648141c258c6a Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-on: http://review.gluster.org/9071 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com> Tested-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index a341015303c..29f34107481 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -274,6 +274,8 @@ afr_shd_index_opendir (xlator_t *this, int child)
#ifdef GF_LINUX_HOST_OS
fd_unref (fd);
fd = fd_anonymous (inode);
+ if (!fd)
+ goto out;
#else /* GF_LINUX_HOST_OS */
gf_log(this->name, GF_LOG_ERROR,
"opendir of %s for %s failed: %s",
@@ -427,7 +429,7 @@ afr_shd_index_sweep (struct subvol_healer *healer)
fd_t *fd = NULL;
xlator_t *subvol = NULL;
afr_private_t *priv = NULL;
- off_t offset = 0;
+ uint64_t offset = 0;
gf_dirent_t entries;
gf_dirent_t *entry = NULL;
uuid_t gfid;
@@ -501,11 +503,12 @@ afr_shd_index_sweep (struct subvol_healer *healer)
int
afr_shd_full_sweep (struct subvol_healer *healer, inode_t *inode)
{
+ loc_t loc = {0, };
fd_t *fd = NULL;
xlator_t *this = NULL;
xlator_t *subvol = NULL;
afr_private_t *priv = NULL;
- off_t offset = 0;
+ uint64_t offset = 0;
gf_dirent_t entries;
gf_dirent_t *entry = NULL;
int ret = 0;
@@ -514,9 +517,38 @@ afr_shd_full_sweep (struct subvol_healer *healer, inode_t *inode)
priv = this->private;
subvol = priv->children[healer->subvol];
- fd = fd_anonymous (inode);
- if (!fd)
- return -errno;
+ uuid_copy (loc.gfid, inode->gfid);
+ loc.inode = inode_ref(inode);
+
+ fd = fd_create (inode, GF_CLIENT_PID_AFR_SELF_HEALD);
+ if (!fd) {
+ gf_log(this->name, GF_LOG_ERROR,
+ "fd_create of %s failed: %s",
+ uuid_utoa (loc.gfid), strerror(errno));
+ ret = -errno;
+ goto out;
+ }
+
+ ret = syncop_opendir (subvol, &loc, fd);
+ if (ret) {
+#ifdef GF_LINUX_HOST_OS /* See comment in afr_shd_index_opendir() */
+ fd_unref(fd);
+ fd = fd_anonymous (inode);
+ if (!fd) {
+ gf_log(this->name, GF_LOG_ERROR,
+ "fd_anonymous of %s failed: %s",
+ uuid_utoa (loc.gfid), strerror(errno));
+ ret = -errno;
+ goto out;
+ }
+#else /* GF_LINUX_HOST_OS */
+ gf_log(this->name, GF_LOG_ERROR,
+ "opendir of %s failed: %s",
+ uuid_utoa (loc.gfid), strerror(errno));
+ ret = -errno;
+ goto out;
+#endif /* GF_LINUX_HOST_OS */
+ }
INIT_LIST_HEAD (&entries.list);
@@ -558,6 +590,8 @@ afr_shd_full_sweep (struct subvol_healer *healer, inode_t *inode)
break;
}
+out:
+ loc_wipe (&loc);
if (fd)
fd_unref (fd);
return ret;
@@ -947,7 +981,7 @@ afr_shd_gather_index_entries (xlator_t *this, int child, dict_t *output)
fd_t *fd = NULL;
xlator_t *subvol = NULL;
afr_private_t *priv = NULL;
- off_t offset = 0;
+ uint64_t offset = 0;
gf_dirent_t entries;
gf_dirent_t *entry = NULL;
uuid_t gfid;