From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>,
nfs@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 2.4.19-rc1/2.5.25 provide dummy fsync() routine for directories on NFS mounts
Date: Tue, 9 Jul 2002 15:13:14 -0400 (EDT) [thread overview]
Message-ID: <agfcp3$2a1$2@main.gmane.org> (raw)
In-Reply-To: <E17S0OD-0005UY-00@the-village.bc.nu>
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
next prev parent reply other threads:[~2002-07-09 19:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 message]
[not found] <E17SjDh-00067R-00@usw-sf-list2.sourceforge.net>
2002-07-11 19:14 ` Rex Dieter
2002-07-11 20:05 ` Tom McNeal
[not found] <200207091549.15913.trond.myklebust@fys.uio.no>
2002-07-09 14:06 ` Richard B. Johnson
[not found] ` <Pine.LNX.3.95.1020709095544.27285A-100000@chaos.analogic.com>
2002-07-09 14:08 ` Trond Myklebust
2002-07-11 10:52 ` Matthias Andree
2002-07-11 11:26 ` Trond Myklebust
[not found] <Pine.LNX.3.95.1020709150615.14559A-100000@chaos.analogic.com>
2002-07-09 19:59 ` Alan Cox
2002-07-09 19:50 ` Richard B. Johnson
[not found] ` <Pine.LNX.3.95.1020709154108.14801B-100000@chaos.analogic.com>
2002-07-15 7:52 ` Sean Hunter
2002-07-15 12:45 ` Richard B. Johnson
[not found] <15658.61035.450205.832652@charged.uio.no>
2002-07-09 15:06 ` Richard B. Johnson
2002-07-09 13:49 Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='agfcp3$2a1$2@main.gmane.org' \
--to=root@chaos.analogic.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=nfs@lists.sourceforge.net \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox