This list has been deprecated. Please subscribe to the new devel list at 
lists.nfs-ganesha.org.
Hello,

I'm seeing an issue with a specific application flow and with ganesha
server (2.6.5). Here is what the application does:

- fd1 = open (file1, O_WRONLY|O_CREAT|O_TRUNC)
  Ganesha creates a state and stores the flags in fd->openflags (see
vfs_open2())
- write (fd1, ....)
- fd2 = open(file1, O_RDONLY)
  Ganesha finds the state for the first open, finds the flags and calls
fsal_reopen2() with old and new flags OR'd together. This causes the file
to be truncated because the original open was done with O_TRUNC.

I don't see this behavior with kernel NFS or a local filesystem. Any
suggestions on fixing this? Here is a quick and dirty program to reproduce
it - you can see that the second stat prints zero as size with a mount from
Ganesha server.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>

int main(int argc, char **argv)
{
  char *fn = argv[1];
  int fd;
  char buf[1024];
  struct stat stbuf;
  int rc;


  fd = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0666);
  printf("open(%s) = %d\n", fn, fd);

  ssize_t ret;
  ret = write(fd, buf, sizeof(buf));
  printf("write returned %ld\n", ret);

  rc = stat(fn, &stbuf);
  printf("size: %ld\n", stbuf.st_size);

  int fd1;
  fd1 = open(fn, O_RDONLY);
  printf("open(%s) = %d\n", fn, fd1);

  rc = stat(fn, &stbuf);
  printf("size: %ld\n", stbuf.st_size);
}

Thanks,
Pradeep
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to