* Re: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts [not found] <Pine.LNX.3.95.1020709104427.27442B-100000@chaos.analogic.com> @ 2002-07-09 16:56 ` Alan Cox 2002-07-09 17:22 ` Richard B. Johnson 0 siblings, 1 reply; 5+ messages in thread From: Alan Cox @ 2002-07-09 16:56 UTC (permalink / raw) To: root; +Cc: Trond Myklebust, nfs, linux-kernel > > not adhere to this convention. > > Well, no. It's not supported. You can't get a valid file-descriptor... Wrong (as usual) > If an application insists, it is up to the application to determine, > probably once upon startup, just what kind of file synchronization > is supported. Linux defines fsync for directories ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Stuff, things, and much much more. http://thinkgeek.com/sf _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts 2002-07-09 16:56 ` [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts Alan Cox @ 2002-07-09 17:22 ` Richard B. Johnson 2002-07-09 18:58 ` Bill Rugolsky Jr. 2002-07-09 19:11 ` Alan Cox 0 siblings, 2 replies; 5+ messages in thread From: Richard B. Johnson @ 2002-07-09 17:22 UTC (permalink / raw) To: Alan Cox; +Cc: Trond Myklebust, nfs, linux-kernel On Tue, 9 Jul 2002, Alan Cox wrote: > > > not adhere to this convention. > > > > Well, no. It's not supported. You can't get a valid file-descriptor... > > Wrong (as usual) Really? Then what is the meaning of fsync() on a read-only file- descriptor? You can't update the information you can't change. This is (as usual) just an example of your helpful responses. Cheers, Dick Johnson Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips). Windows-2000/Professional isn't. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Stuff, things, and much much more. http://thinkgeek.com/sf _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts 2002-07-09 17:22 ` Richard B. Johnson @ 2002-07-09 18:58 ` Bill Rugolsky Jr. 2002-07-09 19:11 ` Alan Cox 1 sibling, 0 replies; 5+ messages in thread From: Bill Rugolsky Jr. @ 2002-07-09 18:58 UTC (permalink / raw) To: Richard B. Johnson; +Cc: Alan Cox, Trond Myklebust, nfs, linux-kernel On Tue, Jul 09, 2002 at 01:22:29PM -0400, Richard B. Johnson 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. Eh? I do an fchmod() on a readonly descriptor, then I call fsync() on that descriptor. The inode gets sync'd to disk (with updated mode and c_time). So no, I don't need a writable descriptor to call fsync(). The only question is *what* gets sync'd when I call fsync() on an O_RDONLY file-descriptor. SUSv3 (http://www.opengroup.org/onlinepubs/007908799/xsh/fsync.html) says "The fsync() function forces all currently queued I/O operations associated with the file indicated by file descriptor fildes to the synchronised I/O completion state." It appears from this wording that the file-descriptor is *merely* a handle referring to the inode, and that *all* outstanding I/O on the inode [within the "system"] is performed. In other words, if I had several different file handles referring to the same inode (but different kernel "struct file" objects), all inode data and meta-data updates prior to the fsync() call would be synchronized. It doesn't say that explicitly, but given the usual visibility rules regarding writes, etc., that is the "natural" interpretation. [Caveat: mmap()] To state it succinctly: if other (data or meta-data) writes are visible to the process doing the fsync(), they need to be sync'd too. In the case of directories, there is no file handle "doing the writing" -- the kernel does that, so absent the ability to call fsync() on a readonly handle to a directory, i.e. fsync(dirfd(dir)), there is no convenient way to sync the directory contents. Calling fsync() on every file in a directory does not necessitate syncing the directory! Regards, Bill Rugolsky ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Stuff, things, and much much more. http://thinkgeek.com/sf _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts 2002-07-09 17:22 ` Richard B. Johnson 2002-07-09 18:58 ` Bill Rugolsky Jr. @ 2002-07-09 19:11 ` Alan Cox 2002-07-09 19:13 ` Richard B. Johnson 1 sibling, 1 reply; 5+ messages in thread From: Alan Cox @ 2002-07-09 19:11 UTC (permalink / raw) To: root; +Cc: Alan Cox, Trond Myklebust, nfs, linux-kernel > 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. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Stuff, things, and much much more. http://thinkgeek.com/sf _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts 2002-07-09 19:11 ` Alan Cox @ 2002-07-09 19:13 ` Richard B. Johnson 0 siblings, 0 replies; 5+ messages in thread From: Richard B. Johnson @ 2002-07-09 19:13 UTC (permalink / raw) To: Alan Cox; +Cc: Trond Myklebust, nfs, linux-kernel 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. > That is what it's supposed to do with files. The attached code clearly shows that it doesn't work with directories. The fsync() instantly returns, even though there is buffered data still to be written. #include <stdio.h> #include <unistd.h> #include <fcntl.h> #define NR_WRITES 0x1000 int main() { char foo[0x10000]; int dirfd, outfd; int flags, i; outfd = open("/foo", O_WRONLY|O_TRUNC|O_CREAT, 0644); dirfd = open("/", O_RDONLY, 0); flags = fcntl(dirfd, F_GETFL); flags &= ~O_RDONLY; flags |= O_RDWR; fcntl(dirfd, F_SETFL, flags); 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. The dummy return of 0, that Linux provides is a database bug waiting to happen. Cheers, Dick Johnson Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips). Windows-2000/Professional isn't. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Stuff, things, and much much more. http://thinkgeek.com/sf _______________________________________________ NFS maillist - NFS@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-07-09 19:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.3.95.1020709104427.27442B-100000@chaos.analogic.com>
2002-07-09 16:56 ` [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts Alan Cox
2002-07-09 17:22 ` Richard B. Johnson
2002-07-09 18:58 ` Bill Rugolsky Jr.
2002-07-09 19:11 ` Alan Cox
2002-07-09 19:13 ` Richard B. Johnson
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox