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

Re: [Ext2-devel] Re: Linux performance bug: fsync() for files with zero links

On Fri, Feb 24, 2006 at 06:25:20PM -0700, Andreas Dilger wrote:
> On Feb 25, 2006  05:32 +0500, Victor Porton wrote:
> > Linux kernel (as of has the following performance bug:
> > 
> > Syncing (fsync() or fdatasync()) files with zero links (deleted files) in not
> > no-op, as it should be.
> > 
> > See details, a test C program, and the rationale in the URL below:
> > 
> > http://b2e.ex-code.com/index.php/soft/2006/02/24/linux_performance_bug_zero_links_fsync
> > 
> > In the article with the URL above it is also explained how to make much more
> > efficient /tmp directory when this bug will be fixed.
> > 
> > Somebody please make a patch.
> Of course, for a cluster filesystem it does make sense that fsync flushes
> the data to disk even if the file has no links, because there may be other
> clients that are accessing the same file...

It even makes sense on a single machine with multiple programs still
accessing the same file. You want fsync() and fdatasync() to work
regardless of the amount of links. Not doing so could subtly break
programs. For example:

time	tty0		tty1		syslogd
0	tail -f /var/log/messages
1					write(messages, "blah");
2					fsync(messages);
3	blah
4			rm /var/log/messages
5					write(messages, "foobar");
6					fsync(messages);
7	(nothing)

At step 7 you should immediately see the "foobar" from syslogd, but
cause of the OP's proposed optimisation, you will only see it some time
in the future.


+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands

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