Re: [PATCH] Fix failure in opening files with O_NOATIME

From: Aaron Carroll <aaronc_at_gelato.unsw.edu.au>
Date: Mon, 26 Nov 2007 11:56:31 +1100

Jens,

I didn't see any reply to this, but the bug is somewhat of a blocker for some
of the work I'm doing. If you don't like the patch, perhaps we come up with a
better way to solve the problem?

Thanks,
 -- Aaron

Aaron Carroll wrote:
> - If we try to open a file with O_NOATIME and it fails, turn off
> O_NOATIME and try again. This occurs if the user does not own
> the file and is unprivileged.
>
> ---
> filesetup.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/filesetup.c b/filesetup.c
> index 5134fdb..6c24151 100644
> --- a/filesetup.c
> +++ b/filesetup.c
> @@ -234,6 +234,7 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
> if (f->filetype != FIO_TYPE_FILE)
> flags |= O_NOATIME;
>
> +open_again:
> if (td_write(td)) {
> assert(!read_only);
>
> @@ -262,6 +263,11 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
> char buf[FIO_VERROR_SIZE];
> int __e = errno;
>
> + if (errno == EPERM && (flags & O_NOATIME)) {
> + flags &= ~O_NOATIME;
> + goto open_again;
> + }
> +
> snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name);
>
> td_verror(td, __e, buf);
Received on Mon Nov 26 2007 - 01:56:31 CET

This archive was generated by hypermail 2.2.0 : Mon Nov 26 2007 - 02:00:01 CET