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

Re: [RFC/PATCH 0/4] Re: Bug#605009: serious performance regression with ext4

On Mon, Nov 29, 2010 at 02:46:11PM +0100, Raphael Hertzog wrote:
> On Mon, 29 Nov 2010, Theodore Tso wrote:
> > BTW, if you had opened the file handle in subsequent passes using
> > O_RDONLY|O_NOATIME, the use of fdatasync() instead of fsync() might not
> > have been necessary.   And as far as the comments in patch #4 was
> Hum, fsync()/fdatasync() require a fd opened for writing, so this is not
> really possible? (Or at least the man page says so and indicates EBADF as
> return value in that case)

Hmm....   that's not the language used in SuSv3:

     The fildes argument is not a valid descriptor.
- http://www.opengroup.org/onlinepubs/009695399/functions/fsync.html

But yes, I see where the Linux system call man pages have stated this.

     EBADF  fd is not a valid file descriptor open for writing.

My test program which I sent out works, and it does:

   fd = open(file, O_RDONLY|O_NOATIME);

with all of the appropriate error checking, so I can tell you it's not
required for recent 2.6 kernels (I tested this using 2.6.37-rc2).  But
whether this was required on older kernels, I'm not 100% sure.  I've
cc'ed Michael Kerrisk to see if he might be able to shed any light on
where the EBADF wording from the fsync() man page might have come from.

I've since done more looking at the source code, and from what I can
tell, O_WRONLY should be OK; merely opening a file using O_WRONLY
shouldn't affect the mod time.  Any opening of a file using O_RDONLY
touches the atime of the file (and all directories and symlinks needed
to open it), though so the use of O_NOATIME and fdatasync() to
minimize unneeded I/O does seem to be a good idea.

							- Ted

Reply to: