Hello Martin,
Thank you for your bug report (including /proc/mounts) and the
reproducible script.

Martin Walter:
> cat <<EOF > a.c
> main() {
>     int x = open("x", 0);
>     rename("y","x");
>     fdatasync(x);
> }
> EOF

In this case, a.c didn't open(2) the file "x" for writing. So
fdatasync(2) may return EBADF, since 'man fdatasync' on my system
describes as,
        :::
ERRORS
       EBADF  fd is not a valid file descriptor open for writing.
        :::

So aufs should return an error, instead of BUG aufs/file.c:342! msg.

I tried your program on ext2 and ext3, and found they never return an
error. They return 0 which means success.
Finally, I decided to change aufs to success in this case too.

Will you try this patch?
If it succeeds, I will include it in next Monday release.

Junjiro Okajima


Index: fs/aufs/f_op.c
===================================================================
RCS file: /cvsroot/aufs/aufs/fs/aufs/f_op.c,v
retrieving revision 1.14
diff -u -p -I.*Copyright.*200[56].* -r1.14 f_op.c
--- fs/aufs/f_op.c      22 Jan 2007 04:00:21 -0000      1.14
+++ fs/aufs/f_op.c      27 Jan 2007 04:24:32 -0000
@@ -476,6 +476,9 @@ static int aufs_fsync_nondir(struct file
 
        sb = dentry->d_sb;
        si_read_lock(sb);
+       err = 0; //-EBADF;
+       if (unlikely(!(file->f_mode & FMODE_WRITE)))
+               goto out;
        err = reval_and_lock_finfo(file, reopen_nondir, /*wlock*/1,
                                   /*locked*/1);
        //err = -1;
Index: fs/aufs/file.c
===================================================================
RCS file: /cvsroot/aufs/aufs/fs/aufs/file.c,v
retrieving revision 1.29
diff -u -p -I.*Copyright.*200[56].* -r1.29 file.c
--- fs/aufs/file.c      22 Jan 2007 04:00:21 -0000      1.29
+++ fs/aufs/file.c      27 Jan 2007 04:24:32 -0000
@@ -339,7 +339,6 @@ int ready_to_write(struct file *file, lo
 
        dentry = file->f_dentry;
        LKTRTrace("%.*s, len %Ld\n", DLNPair(dentry), len);
-       DEBUG_ON(!(file->f_mode & FMODE_WRITE));
        FiMustWriteLock(file);
 
        sb = dentry->d_sb;

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Reply via email to