[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <x491wpdb3co.fsf@segfault.boston.devel.redhat.com>
Date: Thu, 12 Oct 2006 18:01:43 -0400
From: Jeff Moyer <jmoyer@...hat.com>
To: Andrew Morton <akpm@...l.org>
Cc: Zach Brown <zach.brown@...cle.com>, linux-kernel@...r.kernel.org
Subject: Re: [patch] call truncate_inode_pages in the DIO fallback to buffered I/O path
==> Regarding Re: [patch] call truncate_inode_pages in the DIO fallback to buffered I/O path; Andrew Morton <akpm@...l.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@...hat.com>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists