Thread: ["Stephen C. Tweedie" ] Re: O_DSYNC flag for open
Just a quick delurk to pass along this tidbit from linux-kernel on Linux *sync() behavior, since we've been talking about it a lot... -Doug Hi, On Wed, Mar 14, 2001 at 10:26:42PM -0500, Tom Vier wrote: > fdatasync() is the same as fsync(), in linux. No, in 2.4 fdatasync does the right thing and skips the inode flush if only the timestamps have changed. > until fdatasync() is > implimented (ie, syncs the data only) fdatasync is required to sync more than just the data: it has to sync the inode too if any fields other than the timestamps have changed. So, for appending to files or writing new files from scratch, fsync == fdatasync (because each write also changes the inode size). Only for updating existing files in place does fdatasync behave differently. > #ifndef O_DSYNC > # define O_DSYNC O_SYNC > #endif 2.4's O_SYNC actually does a fdatasync internally. This is also the default behaviour of HPUX, which requires you to set a sysctl variable if you want O_SYNC to flush timestamp changes to disk. Cheers, Stephen
Doug McNaught <doug@wireboard.com> forwards: >> 2.4's O_SYNC actually does a fdatasync internally. This is also the >> default behaviour of HPUX, which requires you to set a sysctl variable >> if you want O_SYNC to flush timestamp changes to disk. Well, that guy might know all about Linux, but he doesn't know anything about HPUX (at least not any version I've ever run). O_SYNC is distinctly different from O_DSYNC around here. regards, tom lane
Tom Lane <tgl@sss.pgh.pa.us> writes: > Doug McNaught <doug@wireboard.com> forwards: > >> 2.4's O_SYNC actually does a fdatasync internally. This is also the > >> default behaviour of HPUX, which requires you to set a sysctl variable > >> if you want O_SYNC to flush timestamp changes to disk. > > Well, that guy might know all about Linux, but he doesn't know anything > about HPUX (at least not any version I've ever run). O_SYNC is > distinctly different from O_DSYNC around here. Y'know, I figured that might be the case. ;) He's a well-respected Linux filesystem hacker, so I trust him on the Linux stuff. So are we still thinking about preallocating log files as a performance hack? It does seem that using preallocated files along with O_DATASYNC will eliminate pretty much all metadata writes under Linux in future... [NOT suggesting we try to add anything to 7.1, I'm eagerly awaiting RC1] -Doug
Doug McNaught <doug@wireboard.com> writes: > So are we still thinking about preallocating log files as a > performance hack? We're not just thinking about it, we're doing it in current sources ... regards, tom lane
> So are we still thinking about preallocating log files as a > performance hack? It does seem that using preallocated files along > with O_DATASYNC will eliminate pretty much all metadata writes under > Linux in future... > > [NOT suggesting we try to add anything to 7.1, I'm eagerly awaiting RC1] I am pretty sure that is done. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
[ Drifting off topic ... ] > Well, that guy might know all about Linux, but he doesn't know anything > about HPUX (at least not any version I've ever run). O_SYNC is > distinctly different from O_DSYNC around here. There is a HP_UX kernel flag 'o_sync_is_o_dsync' which will cause O_DSYNC to be treated as O_SYNC. It defaults to being off -- it is/was a backward compatibility "feature" since HP-UX 9.X (which is history now) had implemented O_SYNC as O_DSYNC. http://docs.hp.com/cgi-bin/otsearch/getfile?id=/hpux/onlinedocs/os/KCparam.OsyncIsOdsync.html Regards, Giles
> There is a HP_UX kernel flag 'o_sync_is_o_dsync' which will cause > O_DSYNC to be treated as O_SYNC. It defaults to being off -- it ... other way around there, of course. Trying to clarify and adding confusion instead. :-( > is/was a backward compatibility "feature" since HP-UX 9.X (which is > history now) had implemented O_SYNC as O_DSYNC. Muttering, Giles