[Gluster-devel] How does GD_SYNCOP work?

Emmanuel Dreyfus manu at netbsd.org
Sat Sep 13 04:50:01 UTC 2014

Emmanuel Dreyfus <manu at netbsd.org> wrote:

> I tracked down most of the problem. The request to glustershd times out
> before the reply comes, because glustershd gets stuck in an infinite loop.
> In afr_shd_gather_index_entries(), the obtained offset is corrupted
> (huge negative value), and the loop never ens.

Here is the problem: once readdir() has reached the end of the
directory, on Linux, telldir() will report the last entry's offset,
while on NetBSD, it will report an invalid offset (it is in fact the
offset of the next entry beyond the last one, which does not exist).

The patch below breaks the infinite loop and lets NetBSD pass
tests/basic/self-heald.t, but I am not sure it is correct in the general
case. I suspect it breaks if  index_fill_readdir() is called multiple
time, which may happen for a large directory. I think the exit condition
should be handled better but I have to find how. Input appreciated.

diff --git a/xlators/features/index/src/index.c
index 2b80e71..1150380 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -284,6 +284,13 @@ index_fill_readdir (fd_t *fd, DIR *dir, off_t off,
         if (!off) {
                 rewinddir (dir);
         } else {
+#ifdef __NetBSD__
+               if (off > telldir(dir)) {
+                       errno = ENOENT;
+                       count = 0;
+                       goto out;
+               }
                 seekdir (dir, off);

Emmanuel Dreyfus
manu at netbsd.org

More information about the Gluster-devel mailing list