diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-12-17 10:41:05 +0100 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2014-12-17 03:48:22 -0800 |
commit | e398f99d9ac7ca5c83004b814a4e8561916187f0 (patch) | |
tree | d74d7fe7dc7e45aa37b12fb88557c5ecab4a68b4 /heal/src | |
parent | 466a6f37ebaaad746e2eae045ebd249e28673717 (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 'heal/src')
-rw-r--r-- | heal/src/glfs-heal.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c index 1056ea467c4..9416316458d 100644 --- a/heal/src/glfs-heal.c +++ b/heal/src/glfs-heal.c @@ -284,7 +284,7 @@ _get_afr_ancestor (xlator_t *xl) static int glfsh_process_entries (xlator_t *xl, fd_t *fd, gf_dirent_t *entries, - off_t *offset, uint64_t *num_entries) + uint64_t *offset, uint64_t *num_entries) { gf_dirent_t *entry = NULL; gf_dirent_t *tmp = NULL; @@ -359,7 +359,7 @@ out: static int glfsh_crawl_directory (xlator_t *readdir_xl, fd_t *fd, loc_t *loc) { - off_t offset = 0; + uint64_t offset = 0; gf_dirent_t entries; int ret = 0; gf_boolean_t free_entries = _gf_false; @@ -472,7 +472,27 @@ glfsh_print_pending_heals (xlator_t *xl, loc_t *rootloc) goto out; } - fd = fd_anonymous (dirloc.inode); + fd = fd_create (dirloc.inode, GF_CLIENT_PID_GLFS_HEAL); + if (!fd) { + printf ("fd_create failed: %s", strerror(errno)); + goto out; + } + ret = syncop_opendir (xl, &dirloc, fd); + if (ret) { + fd_unref(fd); +#ifdef GF_LINUX_HOST_OS /* See comment in afr_shd_index_opendir() */ + fd = fd_anonymous (dirloc.inode); + if (!fd) { + printf ("fd_anonymous failed: %s", + strerror(errno)); + goto out; + } +#else + printf ("opendir failed: %s", strerror(errno)); + goto out; +#endif + } + ret = glfsh_crawl_directory (xl, fd, &dirloc); if (fd) fd_unref (fd); |