Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread Anand Avati
On Tue, Oct 14, 2014 at 7:22 PM, Emmanuel Dreyfus m...@netbsd.org wrote:

 J. Bruce Fields bfie...@fieldses.org wrote:

  Is the result on non-Linux really to fail any readdir using an offset
  not returned from the current open?

 Yes, but thatnon-Linux behabvior is POSIX compliant. Linux just happens
 to do more than the standard here.

  I can't see how NFS READDIR will work on non-Linux platforms in that
  case.

 Differrent case: seekdir/telldir operate at libc level on data cached in
 userland. NFS READDIR operates on data in the kernel.


Is there a way to get hold of the directory entry cookies used by NFS
readdir from user-space? some sort of a NetBSD specific syscall (like
getdents of Linux)?

Thanks
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread Emmanuel Dreyfus
Anand Avati av...@gluster.org wrote:

 Is there a way to get hold of the directory entry cookies used by NFS
 readdir from user-space? some sort of a NetBSD specific syscall (like
 getdents of Linux)?

NetBSD has getdents(2) too, but it returns buffer of struct dirent that
have no NFS cookies. On Linux, getdents(2) returns buffers of struct
dirent or dirent64, but I see no NFS cookie there either.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread J. Bruce Fields
On Wed, Oct 15, 2014 at 01:26:19PM +0200, Emmanuel Dreyfus wrote:
 Anand Avati av...@gluster.org wrote:
 
  Is there a way to get hold of the directory entry cookies used by NFS
  readdir from user-space? some sort of a NetBSD specific syscall (like
  getdents of Linux)?
 
 NetBSD has getdents(2) too, but it returns buffer of struct dirent that
 have no NFS cookies. On Linux, getdents(2) returns buffers of struct
 dirent or dirent64, but I see no NFS cookie there either.

On Linux, it's returned in the d_off field.

Googling around  the NetBSD manpage doesn't mention any d_off field,
but it does have this:

http://nixdoc.net/man-pages/netbsd/man2/getdents.2.html

The current position pointer may be set and retrieved by
lseek(2).  The current position pointer should only be set to a
value returned by lseek(2), or zero.

So maybe that's what you want.

--b.
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread J. Bruce Fields
On Mon, Oct 13, 2014 at 08:57:11AM +, Emmanuel Dreyfus wrote:
 On Mon, Oct 13, 2014 at 01:42:38PM +0530, Pranith Kumar Karampuri wrote:
  No bug here, just suboptimal behavior, both in glusterfs and NetBSD FUSE.
  oh!, but shouldn't it get op_ret = 0 instead of op_ret -1, op_errno EINVAL?
 
 It happens because of thei change I introduced:
 seekdir (dir, (long)off);
 #ifndef GF_LINUX_HOST_OS
 if (telldir(dir) != off) {
 gf_log (THIS-name, GF_LOG_ERROR,
 seekdir(%ld) failed on dir=%p: 
 Invalid argument (offset reused from 
 another DIR * structure?), (long)off, dir);
 errno = EINVAL;
 count = -1;
 goto out;
 }   
 #endif /* GF_LINUX_HOST_OS */
 
 The idea is to catch wrong opendir/closedir usage, and the errno = EINVAL
 is critical in such a situation to avoid an infinite loop. On the other
 hand it also fires for last entry. I did not notice it before because
 this EINVAL will not reach calling process, but it may cause trouble
 for internal glusterfs usage.
 
 I see an easy way yo fix it (patch below)
 - when posix xlator detects EOF, return an offset of -1 in last entry.
 - When called with an offset of -1, immediatly return op_ret = 0 with no entry

You're assuming no filesystem uses -1 as a cookie?

Might be true, but it's taking a small chance.

--b.

 
 What do you think?
 diff --git a/xlators/storage/posix/src/posix.c 
 b/xlators/storage/posix/src/posix
 index 6b12d39..3e539bb 100644
 --- a/xlators/storage/posix/src/posix.c
 +++ b/xlators/storage/posix/src/posix.c
 @@ -79,6 +79,10 @@ extern char *marker_xattrs[];
  #define SET_TO_OLD_FS_ID()
  
  #endif
 +
 +/* offset  sizeof(struct dirent) cannot be valid */
 +#define INVALID_DIRENT_OFFSET sizeof (void *)
 +
  int
  posix_forget (xlator_t *this, inode_t *inode)
  {
 @@ -4851,6 +4855,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, 
 size_t
  int   len = 0;
  int   ret = 0;
  
 +/* EOF was previously detected */
 +if (off == INVALID_DIRENT_OFFSET) 
 +   goto out;
 +
  if (skip_dirs) {
  len = posix_handle_path (this, fd-inode-gfid, NULL, NULL, 
 0);
  hpath = alloca (len + 256); /* NAME_MAX */
 @@ -4969,9 +4977,12 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, 
 size_t
  count ++;
  }
  
 -if ((!readdir (dir)  (errno == 0)))
 +if ((!readdir (dir)  (errno == 0))) {
  /* Indicate EOF */
  errno = ENOENT;
 +/* Set invalid offset for later detection */
 +this_entry-d_off = INVALID_DIRENT_OFFSET;
 +}
  out:
  return count;
  }
 
 
 -- 
 Emmanuel Dreyfus
 m...@netbsd.org
 ___
 Gluster-devel mailing list
 Gluster-devel@gluster.org
 http://supercolony.gluster.org/mailman/listinfo/gluster-devel
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread Emmanuel Dreyfus
J. Bruce Fields bfie...@fieldses.org wrote:

 You're assuming no filesystem uses -1 as a cookie?
 Might be true, but it's taking a small chance.

Latest version does not work like this anymore: when EOF is reached,
current offset is recorded in pfd-dir_eof, and we fire EINVAL if
seekdir() failed to set the offset and the offset is not  pfd-dir_eof:

if (telldir(dir) != (long)off  off != pfd-dir_eof)

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread Emmanuel Dreyfus
J. Bruce Fields bfie...@fieldses.org wrote:

 (It'd still be better to figure out how to get stable directory cookies,
 possibly using some other interface, but that's a preexisting problem
 not introduced by c65d4ea8a10a).

getdents(2) seems the way to go.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-15 Thread J. Bruce Fields
On Wed, Oct 15, 2014 at 07:42:25PM +0200, Emmanuel Dreyfus wrote:
 J. Bruce Fields bfie...@fieldses.org wrote:
 
  You're assuming no filesystem uses -1 as a cookie?
  Might be true, but it's taking a small chance.
 
 Latest version does not work like this anymore: when EOF is reached,
 current offset is recorded in pfd-dir_eof, and we fire EINVAL if
 seekdir() failed to set the offset and the offset is not  pfd-dir_eof:
 
 if (telldir(dir) != (long)off  off != pfd-dir_eof)

But actually, I was wrong: telldir returns -1 for error or offset on
success, so -1 is reserved.

--b.
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-14 Thread Emmanuel Dreyfus
On Mon, Oct 13, 2014 at 10:04:33AM +, Emmanuel Dreyfus wrote:
 Here it is:
 http://review.gluster.org/8926

It passed regression, please review.
Linux behavior is unaltered.

-- 
Emmanuel Dreyfus
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-14 Thread J. Bruce Fields
On Sun, Oct 12, 2014 at 10:09:01AM +0200, Emmanuel Dreyfus wrote:
 When quota xlator is enabled, bricks get this:
 
 [2014-10-12 07:56:03.090516] E [posix.c:4874:posix_fill_readdir]
 0-patchy-posix: seekdir(-1154801456) failed on dir=0xb99cb250: Invalid
 argument (offset reused from another DIR * structure?)
 
 This means something either seekdir on a DIR * that was not obtained by
 opendir(), or that was closedir() and then opendir() again. Can someone
 explain me what directory walks are introduced by quota, and where
 opendir/readdir/closedir happen for that?

Apologies, I'm just catching up, but I'm confused by

c65d4ea8a10a Fix invalid seekdir() usage

Is the result on non-Linux really to fail any readdir using an offset
not returned from the current open?

I can't see how NFS READDIR will work on non-Linux platforms in that
case.

--b.
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-14 Thread Emmanuel Dreyfus
J. Bruce Fields bfie...@fieldses.org wrote:

 Is the result on non-Linux really to fail any readdir using an offset
 not returned from the current open?

Yes, but thatnon-Linux behabvior is POSIX compliant. Linux just happens
to do more than the standard here.

 I can't see how NFS READDIR will work on non-Linux platforms in that
 case.

Differrent case: seekdir/telldir operate at libc level on data cached in
userland. NFS READDIR operates on data in the kernel.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Emmanuel Dreyfus
On Mon, Oct 13, 2014 at 12:39:33PM +0530, Pranith Kumar Karampuri wrote:
 Op_errno is valid only if 'op_ret  0'. so that doesn't say much. After the
 last readdir call with op_ret  0, there will be one more readdir call for
 which op_ret will come as '0'. That means reading of the directory is
 complete.

Right, I have 3 calls for end of directory:
op_ret  0, op_errno = ENOENT,  but glusterfs does an extra call and gets:
op_ret = -1, op_errno = EINVAL, but NetBSD FUSE does an extra call ang gets:
op_ret = -1, op_errno = EINVAL

No bug here, just suboptimal behavior, both in glusterfs and NetBSD FUSE.

-- 
Emmanuel Dreyfus
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Pranith Kumar Karampuri


On 10/13/2014 01:14 PM, Emmanuel Dreyfus wrote:

On Mon, Oct 13, 2014 at 12:39:33PM +0530, Pranith Kumar Karampuri wrote:

Op_errno is valid only if 'op_ret  0'. so that doesn't say much. After the
last readdir call with op_ret  0, there will be one more readdir call for
which op_ret will come as '0'. That means reading of the directory is
complete.

Right, I have 3 calls for end of directory:
op_ret  0, op_errno = ENOENT,  but glusterfs does an extra call and gets:
op_ret = -1, op_errno = EINVAL, but NetBSD FUSE does an extra call ang gets:
op_ret = -1, op_errno = EINVAL

No bug here, just suboptimal behavior, both in glusterfs and NetBSD FUSE.

oh!, but shouldn't it get op_ret = 0 instead of op_ret -1, op_errno EINVAL?

Pranith




___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Emmanuel Dreyfus
On Mon, Oct 13, 2014 at 01:42:38PM +0530, Pranith Kumar Karampuri wrote:
 No bug here, just suboptimal behavior, both in glusterfs and NetBSD FUSE.
 oh!, but shouldn't it get op_ret = 0 instead of op_ret -1, op_errno EINVAL?

It happens because of thei change I introduced:
seekdir (dir, (long)off);
#ifndef GF_LINUX_HOST_OS
if (telldir(dir) != off) {
gf_log (THIS-name, GF_LOG_ERROR,
seekdir(%ld) failed on dir=%p: 
Invalid argument (offset reused from 
another DIR * structure?), (long)off, dir);
errno = EINVAL;
count = -1;
goto out;
}   
#endif /* GF_LINUX_HOST_OS */

The idea is to catch wrong opendir/closedir usage, and the errno = EINVAL
is critical in such a situation to avoid an infinite loop. On the other
hand it also fires for last entry. I did not notice it before because
this EINVAL will not reach calling process, but it may cause trouble
for internal glusterfs usage.

I see an easy way yo fix it (patch below)
- when posix xlator detects EOF, return an offset of -1 in last entry.
- When called with an offset of -1, immediatly return op_ret = 0 with no entry

What do you think?
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix
index 6b12d39..3e539bb 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -79,6 +79,10 @@ extern char *marker_xattrs[];
 #define SET_TO_OLD_FS_ID()
 
 #endif
+
+/* offset  sizeof(struct dirent) cannot be valid */
+#define INVALID_DIRENT_OFFSET sizeof (void *)
+
 int
 posix_forget (xlator_t *this, inode_t *inode)
 {
@@ -4851,6 +4855,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t
 int   len = 0;
 int   ret = 0;
 
+/* EOF was previously detected */
+if (off == INVALID_DIRENT_OFFSET) 
+   goto out;
+
 if (skip_dirs) {
 len = posix_handle_path (this, fd-inode-gfid, NULL, NULL, 0);
 hpath = alloca (len + 256); /* NAME_MAX */
@@ -4969,9 +4977,12 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t
 count ++;
 }
 
-if ((!readdir (dir)  (errno == 0)))
+if ((!readdir (dir)  (errno == 0))) {
 /* Indicate EOF */
 errno = ENOENT;
+/* Set invalid offset for later detection */
+this_entry-d_off = INVALID_DIRENT_OFFSET;
+}
 out:
 return count;
 }


-- 
Emmanuel Dreyfus
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Pranith Kumar Karampuri


On 10/13/2014 02:27 PM, Emmanuel Dreyfus wrote:

On Mon, Oct 13, 2014 at 01:42:38PM +0530, Pranith Kumar Karampuri wrote:

No bug here, just suboptimal behavior, both in glusterfs and NetBSD FUSE.

oh!, but shouldn't it get op_ret = 0 instead of op_ret -1, op_errno EINVAL?

It happens because of thei change I introduced:
 seekdir (dir, (long)off);
#ifndef GF_LINUX_HOST_OS
 if (telldir(dir) != off) {
 gf_log (THIS-name, GF_LOG_ERROR,
 seekdir(%ld) failed on dir=%p: 
 Invalid argument (offset reused from 
 another DIR * structure?), (long)off, dir);
 errno = EINVAL;
 count = -1;
 goto out;
 }
#endif /* GF_LINUX_HOST_OS */

The idea is to catch wrong opendir/closedir usage, and the errno = EINVAL
is critical in such a situation to avoid an infinite loop. On the other
hand it also fires for last entry. I did not notice it before because
this EINVAL will not reach calling process, but it may cause trouble
for internal glusterfs usage.

I see an easy way yo fix it (patch below)
- when posix xlator detects EOF, return an offset of -1 in last entry.
- When called with an offset of -1, immediatly return op_ret = 0 with no entry

What do you think?
I am not aware of backend filesystems that much, may be someone with 
that knowledge can comment here, what happens when new entries are 
created in the directory after this readdir is responded with '-1'?



diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix
index 6b12d39..3e539bb 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -79,6 +79,10 @@ extern char *marker_xattrs[];
  #define SET_TO_OLD_FS_ID()
  
  #endif

+
+/* offset  sizeof(struct dirent) cannot be valid */
+#define INVALID_DIRENT_OFFSET sizeof (void *)
+
  int
  posix_forget (xlator_t *this, inode_t *inode)
  {
@@ -4851,6 +4855,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t
  int   len = 0;
  int   ret = 0;
  
+/* EOF was previously detected */

+if (off == INVALID_DIRENT_OFFSET)
+   goto out;
+
  if (skip_dirs) {
  len = posix_handle_path (this, fd-inode-gfid, NULL, NULL, 
0);
  hpath = alloca (len + 256); /* NAME_MAX */
@@ -4969,9 +4977,12 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t off, size_t
  count ++;
  }
  
-if ((!readdir (dir)  (errno == 0)))

+if ((!readdir (dir)  (errno == 0))) {
  /* Indicate EOF */
  errno = ENOENT;
Now I understand why you kept saying ENOENT ;-). This may not be a good 
idea IMO. Code all through gluster doesn't care what errno it unwinds 
upwards.

+/* Set invalid offset for later detection */
+this_entry-d_off = INVALID_DIRENT_OFFSET;
+}
  out:
  return count;
  }




___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Pranith Kumar Karampuri


On 10/13/2014 02:37 PM, Pranith Kumar Karampuri wrote:


On 10/13/2014 02:27 PM, Emmanuel Dreyfus wrote:

On Mon, Oct 13, 2014 at 01:42:38PM +0530, Pranith Kumar Karampuri wrote:
No bug here, just suboptimal behavior, both in glusterfs and NetBSD 
FUSE.
oh!, but shouldn't it get op_ret = 0 instead of op_ret -1, op_errno 
EINVAL?

It happens because of thei change I introduced:
 seekdir (dir, (long)off);
#ifndef GF_LINUX_HOST_OS
 if (telldir(dir) != off) {
 gf_log (THIS-name, GF_LOG_ERROR,
 seekdir(%ld) failed on dir=%p: 
 Invalid argument (offset reused from 
 another DIR * structure?), 
(long)off, dir);

 errno = EINVAL;
 count = -1;
 goto out;
 }
#endif /* GF_LINUX_HOST_OS */

The idea is to catch wrong opendir/closedir usage, and the errno = 
EINVAL

is critical in such a situation to avoid an infinite loop. On the other
hand it also fires for last entry. I did not notice it before because
this EINVAL will not reach calling process, but it may cause trouble
for internal glusterfs usage.

I see an easy way yo fix it (patch below)
- when posix xlator detects EOF, return an offset of -1 in last entry.
- When called with an offset of -1, immediatly return op_ret = 0 with 
no entry


What do you think?
I am not aware of backend filesystems that much, may be someone with 
that knowledge can comment here, what happens when new entries are 
created in the directory after this readdir is responded with '-1'?


diff --git a/xlators/storage/posix/src/posix.c 
b/xlators/storage/posix/src/posix

index 6b12d39..3e539bb 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -79,6 +79,10 @@ extern char *marker_xattrs[];
  #define SET_TO_OLD_FS_ID()
#endif
+
+/* offset  sizeof(struct dirent) cannot be valid */
+#define INVALID_DIRENT_OFFSET sizeof (void *)
+
  int
  posix_forget (xlator_t *this, inode_t *inode)
  {
@@ -4851,6 +4855,10 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t 
off, size_t

  int   len = 0;
  int   ret = 0;
  +/* EOF was previously detected */
+if (off == INVALID_DIRENT_OFFSET)
+   goto out;
+
  if (skip_dirs) {
  len = posix_handle_path (this, fd-inode-gfid, 
NULL, NULL, 0);

  hpath = alloca (len + 256); /* NAME_MAX */
@@ -4969,9 +4977,12 @@ posix_fill_readdir (fd_t *fd, DIR *dir, off_t 
off, size_t

  count ++;
  }
  -if ((!readdir (dir)  (errno == 0)))
+if ((!readdir (dir)  (errno == 0))) {
  /* Indicate EOF */
  errno = ENOENT;
Now I understand why you kept saying ENOENT ;-). This may not be a 
good idea IMO. Code all through gluster doesn't care what errno it 
unwinds upwards.

In case op_ret is zero I mean :-)

Pranith

+/* Set invalid offset for later detection */
+this_entry-d_off = INVALID_DIRENT_OFFSET;
+}
  out:
  return count;
  }




___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Emmanuel Dreyfus
On Mon, Oct 13, 2014 at 02:37:12PM +0530, Pranith Kumar Karampuri wrote:
 I am not aware of backend filesystems that much, may be someone with that
 knowledge can comment here, what happens when new entries are created in the
 directory after this readdir is responded with '-1'?

In the meantime, I changed -1 to sizeof (void *) to address alignment
issues.

I am not sure we have cases where we loop awaiting for new entries
to be added at the end of the directory.  That is doomed to fail
anyway because getdents(2) cn return deleted entries, and a new
entry may be added before the end of the buffer.

-- 
Emmanuel Dreyfus
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Pranith Kumar Karampuri


On 10/13/2014 02:45 PM, Emmanuel Dreyfus wrote:

On Mon, Oct 13, 2014 at 02:37:12PM +0530, Pranith Kumar Karampuri wrote:

I am not aware of backend filesystems that much, may be someone with that
knowledge can comment here, what happens when new entries are created in the
directory after this readdir is responded with '-1'?

In the meantime, I changed -1 to sizeof (void *) to address alignment
issues.

I am not sure we have cases where we loop awaiting for new entries
to be added at the end of the directory.  That is doomed to fail
anyway because getdents(2) cn return deleted entries, and a new
entry may be added before the end of the buffer.
I do not know :-(. Send the patch out for review, may be someone with 
this knowledge can do the review...


Pranith




___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-13 Thread Emmanuel Dreyfus
On Mon, Oct 13, 2014 at 02:58:12PM +0530, Pranith Kumar Karampuri wrote:
 I do not know :-(. Send the patch out for review, may be someone with this
 knowledge can do the review...

Here it is:
http://review.gluster.org/8926


-- 
Emmanuel Dreyfus
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-12 Thread Emmanuel Dreyfus
Emmanuel Dreyfus m...@netbsd.org wrote:

 This means something either seekdir on a DIR * that was not obtained by
 opendir(), or that was closedir() and then opendir() again. Can someone
 explain me what directory walks are introduced by quota, and where
 opendir/readdir/closedir happen for that?

Erratum: it happens because it attempts to seekdir to the offset
obtained for last record. But I still have to find what code is sending
the request.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-12 Thread Emmanuel Dreyfus
Emmanuel Dreyfus m...@netbsd.org wrote:

 Erratum: it happens because it attempts to seekdir to the offset
 obtained for last record. But I still have to find what code is sending
 the request.

Here is the king of debug trace I have:


[quota.c:3959:quota_readdirp] 0-XXXmanu: fd = 0xbb242818, offset = 0
[posix.c:4882:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801520
[posix.c:4966:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801504
[posix.c:4882:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801504
[posix.c:4966:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801488
[posix.c:4882:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801488
[posix.c:4882:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801472
[posix.c:4966:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801456
[posix.c:4882:posix_fill_readdir] 0-XXXmanu: telldir(0xb99c7250) = -1154801456
[quota.c:3892:quota_readdirp_cbk] 0-XXXmanu: op_ret = 3, op_errno = ENOENT
[quota.c:3959:quota_readdirp] 0-XXXmanu: fd = 0xbb242818, offset = -1154801456
[posix.c:4865:posix_fill_readdir] 0-XXXmanu: seekdir(0xb99c7250, -1154801456)
[posix.c:4872:posix_fill_readdir] 0-patchy-posix: seekdir(-1154801456) failed 
on dir=0xb99c7250: Invalid argument (offset reused from another DIR * 
structure?) 
[quota.c:3892:quota_readdirp_cbk] 0-XXXmanu: op_ret = -1, op_errno = EINVAL 
[2014-10-12 14:51:35.176375] I [server-rpc-fops.c:1917:server_readdirp_cbk] 
0-patchy-server: 19: READDIRP 0 (----0001) == 
(Invalid argument)
[quota.c:3959:quota_readdirp] 0-XXXmanu: fd = 0xbb242818, offset = -1154801456
[posix.c:4865:posix_fill_readdir] 0-XXXmanu: seekdir(0xb99c7250, -1154801456)
[posix.c:4872:posix_fill_readdir] 0-patchy-posix: seekdir(-1154801456) failed 
on dir=0xb99c7250: Invalid argument (offset reused from another DIR * 
structure?) 


-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-12 Thread Emmanuel Dreyfus
Emmanuel Dreyfus m...@netbsd.org wrote:

 Erratum: it happens because it attempts to seekdir to the offset
 obtained for last record. But I still have to find what code is sending
 the request.

This is a find(1) probably forked by quota-crawld glusterd. In fact
running a find . in the fs is enough to trigger the phenomenon: once end
of directory is reached (op_ret  0, op_errno = ENOENT), readdir is
called 2 more times (op_ret = -1, op_errno = EINVAL), which suggests end
of directory information does not reach the caller process correctly.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
m...@netbsd.org
___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel


Re: [Gluster-devel] Invalid DIR * usage in quota xlator

2014-10-12 Thread Pranith Kumar Karampuri


On 10/13/2014 09:45 AM, Emmanuel Dreyfus wrote:

Emmanuel Dreyfus m...@netbsd.org wrote:


Erratum: it happens because it attempts to seekdir to the offset
obtained for last record. But I still have to find what code is sending
the request.

This is a find(1) probably forked by quota-crawld glusterd. In fact
running a find . in the fs is enough to trigger the phenomenon: once end
of directory is reached (op_ret  0, op_errno = ENOENT), readdir is
called 2 more times (op_ret = -1, op_errno = EINVAL), which suggests end
of directory information does not reach the caller process correctly.

Emmanuel,
 End of directory is determined by 'op_ret == 0'. On my system with 
xfs as backend, things are working fine. Which backend filesystem are 
you using?


Pranith




___
Gluster-devel mailing list
Gluster-devel@gluster.org
http://supercolony.gluster.org/mailman/listinfo/gluster-devel