From: Jeff Moyer <jmoyer@redhat.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Zach Brown <zach.brown@oracle.com>, linux-kernel@vger.kernel.org
Subject: Re: [patch] call truncate_inode_pages in the DIO fallback to buffered I/O path
Date: Thu, 12 Oct 2006 18:01:43 -0400 [thread overview]
Message-ID: <x491wpdb3co.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20061011113720.463e331c.akpm@osdl.org> (Andrew Morton's message of "Wed, 11 Oct 2006 11:37:20 -0700")
==> Regarding Re: [patch] call truncate_inode_pages in the DIO fallback to buffered I/O path; Andrew Morton <akpm@osdl.org> adds:
akpm> So I'd propose:
> diff -puN mm/filemap.c~direct-io-sync-and-invalidate-file-region-when-falling-back-to-buffered-write-fix mm/filemap.c
> --- a/mm/filemap.c~direct-io-sync-and-invalidate-file-region-when-falling-back-to-buffered-write-fix
> +++ a/mm/filemap.c
> @@ -2291,19 +2291,30 @@ __generic_file_aio_write_nolock(struct k
> written_buffered = generic_file_buffered_write(iocb, iov,
> nr_segs, pos, ppos, count,
> written);
> + /*
> + * If generic_file_buffered_write() retuned a synchronous error
> + * then we want to return the number of bytes which were
> + * direct-written, or the error code if that was zero. Note
> + * that this differs from normal direct-io semantics, which
> + * will return -EFOO even if some bytes were written.
> + */
> + if (written_buffered < 0) {
> + err = written_buffered;
> + goto out;
> + }
> /*
> * We need to ensure that the page cache pages are written to
> * disk and invalidated to preserve the expected O_DIRECT
> * semantics.
> */
> - endbyte = pos + written_buffered - 1;
> + endbyte = pos + written_buffered - written - 1;
> err = do_sync_file_range(file, pos, endbyte,
> SYNC_FILE_RANGE_WAIT_BEFORE|
> SYNC_FILE_RANGE_WRITE|
> SYNC_FILE_RANGE_WAIT_AFTER);
> if (err == 0) {
> - written += written_buffered;
> + written = written_buffered;
> invalidate_mapping_pages(mapping,
> pos >> PAGE_CACHE_SHIFT,
> endbyte >> PAGE_CACHE_SHIFT);
> _
This passes my tests and the Oracle tests that triggered the problem in the
first place. Thanks!
Acked-by: Jeff Moyer <jmoyer@redhat.com>
next prev parent reply other threads:[~2006-10-12 22:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-04 17:04 [patch] call truncate_inode_pages in the DIO fallback to buffered I/O path Jeff Moyer
2006-10-04 17:25 ` Andrew Morton
2006-10-04 17:51 ` Zach Brown
2006-10-04 17:53 ` Jeff Moyer
2006-10-04 18:16 ` Andrew Morton
2006-10-04 18:40 ` Zach Brown
2006-10-04 19:16 ` Andrew Morton
2006-10-04 20:53 ` Jeff Moyer
2006-10-04 21:22 ` Jeff Moyer
2006-10-04 23:55 ` Andrew Morton
2006-10-05 19:31 ` Jeff Moyer
2006-10-06 20:11 ` Andrew Morton
2006-10-11 16:48 ` jmoyer
2006-10-11 18:37 ` Andrew Morton
2006-10-12 22:01 ` Jeff Moyer [this message]
2006-10-12 22:37 ` Andrew Morton
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=x491wpdb3co.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zach.brown@oracle.com \
/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