lkml.org 
[lkml]   [2002]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine fordirectories on NFS mounts
"Richard B. Johnson" wrote:
>
> On Tue, 9 Jul 2002, Alan Cox wrote:
>
> > > Really? Then what is the meaning of fsync() on a read-only file-
> > > descriptor? You can't update the information you can't change.
> >
> > fsync ensures the data for that inode/file content is on stable storage - note
> > _the_ _data_ not only random things written by this specific file handle.
> >

> flags = fcntl(dirfd, F_GETFL);
> flags &= ~O_RDONLY;
> flags |= O_RDWR;
> fcntl(dirfd, F_SETFL, flags);

Ehh? Not sure what you're doing here...

> fprintf(stderr, "Write %d bytes\n", sizeof(foo) * NR_WRITES);
> for(i=0; i< NR_WRITES; i++)
> write(outfd, foo, sizeof(foo));
> fprintf(stderr, "Write complete\n");
> fprintf(stderr, "Sync the directory\n");
> fsync(dirfd);
> fprintf(stderr, "Done, returns immediately!\n");
> close(outfd);
> fprintf(stderr, "Now execute sync and see if your disk is active!\n");
> // unlink("/foo");
> }
>
> Again, to assure that file-data is written to storage, one must
> execute fsync on files, not directories.

You are correct, but re-read what Alan said -- "fsync ensures the data
for that inode/file content is on stable storage". So your fsync(dirfd)
only makes sure data written to the directory is on disk, i.e. the name
of the new file "foo". sync still causes mucho activity because you did
not fsync the outfd.

> The dummy return of 0,
> that Linux provides is a database bug waiting to happen.

No, the dummy return of 0 from NFS is not a problem, because directory
updates, and indeed all writes, are supposed to be syncronous by
default. There really is no need to fsync on an NFS directory, as the
name should already be on stable storage by the time open() returns.

At least this is my understanding,
D
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:27    [W:0.050 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site