lkml.org 
[lkml]   [2006]   [Oct]   [12]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch] call truncate_inode_pages in the DIO fallback to buffered I/O path
FromJeff Moyer <>
DateThu, 12 Oct 2006 18:01:43 -0400
==> 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>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-10-13 00:05    [from the cache]
©2003-2008