Re: rename(2) on open file loose unsync data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Can you try with disabling 'write-behind' and 'quick-read' ? We have these type of tests in our QA which works fine on master branch as of now. Will reconfirm the behavior with master on GNU/Linux.

-Amar

On Sat, Mar 31, 2012 at 10:32 AM, Emmanuel Dreyfus <manu@xxxxxxxxxx> wrote:
I have hit a bug in glusterfs on NetBSD, but I wonder if NetBSD FUSE is
the culprit, or if the problem is in glusterfs itself. If I rename and
open file, the unsync data get lost (it is replaced by a chunk of
zeroes).

The test case below exhibit the bug. Does it happens on Linux too, or is
it a problem in NetBSD FUSE?

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <err.h>
#include <sysexits.h>

int
main(void)
{
       int fd1, fd2;
       char buf[] = "abcdefgh";
       char buf2[] = "xxxxxxxx";

       (void)unlink("tmp");
       (void)unlink("tmp2");

       if ((fd1 = open("tmp", O_CREAT|O_RDWR, 0644)) == -1)
               err(EX_OSERR, "cannot open tmp");

       if (write(fd1, buf, sizeof(buf)) != sizeof(buf))
               err(EX_OSERR, "write failed");

       if (rename("tmp", "tmp2") == -1)
               err(EX_OSERR, "rename failed");

       /* No bug if fd1 is closed or fsync'ed before rename */
       (void)close(fd1);

       if ((fd2 = open("tmp2", O_RDONLY, 0)) == -1)
               err(EX_OSERR, "cannot open tmp2");

       if (read(fd2, buf2, sizeof(buf2)) != sizeof(buf2))
               err(EX_OSERR, "read failed");

       (void)close(fd2);

       printf("buf  = \"%s\"\nbuf2 = \"%s\"\n", buf, buf2);

       return 0;
}

--
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu@xxxxxxxxxx

_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxx
https://lists.nongnu.org/mailman/listinfo/gluster-devel


[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux