All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Boaz Harrosh <openosd@gmail.com>
Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Ross Zwisler <ross.zwisler@linux.intel.com>,
	willy@linux.intel.com
Subject: Re: [PATCH v10 20/21] ext4: Add DAX functionality
Date: Thu, 11 Sep 2014 14:38:15 +1000	[thread overview]
Message-ID: <20140911043815.GP20518@dastard> (raw)
In-Reply-To: <54108124.9030707@gmail.com>

On Wed, Sep 10, 2014 at 07:49:40PM +0300, Boaz Harrosh wrote:
> On 09/03/2014 02:13 PM, Dave Chinner wrote:
> <>
> > 
> > When direct IO fails ext4 falls back to buffered IO, right? And
> > dax_do_io() can return partial writes, yes?
> > 
> 
> There is no buffered writes with DAX. .I.E buffered writes are always
> direct as well. (No page cache)

Yes, I know. But you didn't actually read the code I pointed out,
did you?

> > So that means if you get, say, ENOSPC part way through a DAX write,
> > ext4 can start dirtying the page cache from
> > __generic_file_write_iter() because the DAX write didn't wholly
> > complete? And say this ENOSPC races with space being freed from
> > another inode, then the buffered write will succeed and we'll end up
> > with coherency issues, right?
> > 
> > This is not an idle question - XFS if firing asserts all over the
> > place when doing ENOSPC testing because DAX is returning partial
> > writes and the XFS direct IO code is expecting them to either wholly
> > complete or wholly fail. I can make the DAX variant do allow partial
> > writes, but I'm not going to add a useless fallback to buffered IO
> > for XFS when the (fully featured) direct allocation fails.
> > 
> 
> Right, no fall back.

And so ext4 is buggy, because what ext4 does ....

> Because a fallback is just a retry, because in any
> way DAX assumes there is never a page_cache_page for a written data

... is not a retry - it falls back to a fundamentally different
code path. i.e:

sys_write()
....
	new_sync_write
	  ext4_file_write_iter
	    __generic_file_write_iter(O_DIRECT)
	      written = generic_file_direct_write()
	      if (error || complete write)
	        return
	      /* short write! do buffered IO to finish! */
	      generic_perform_write()
	        loop {
			ext4_write_begin
			ext4_write_end
		}

and so we allocate pages in the page cache and do buffered IO into
them because DAX doesn't hook ->writebegin/write_end as we are
supposed to intercept all buffered IO at a higher level.

This causes data corruption when tested at ENOSPC on DAX enabled
ext4 filesystems. I think that it's an oversight and hence a bug
that needs to be fixed but I'm first asking Willy to see if it was
intentional or not because maybe I missed sometihng in the past 4
months since I've paid really close attention to the DAX code.

And in saying that, Boaz, I'd suggest you spend some time looking at
the history of the DAX patchset. Pay careful note to who came up
with the original idea and architecture that led to the IO path you
are so stridently defending.....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

WARNING: multiple messages have this Message-ID (diff)
From: Dave Chinner <david@fromorbit.com>
To: Boaz Harrosh <openosd@gmail.com>
Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Ross Zwisler <ross.zwisler@linux.intel.com>,
	willy@linux.intel.com
Subject: Re: [PATCH v10 20/21] ext4: Add DAX functionality
Date: Thu, 11 Sep 2014 14:38:15 +1000	[thread overview]
Message-ID: <20140911043815.GP20518@dastard> (raw)
In-Reply-To: <54108124.9030707@gmail.com>

On Wed, Sep 10, 2014 at 07:49:40PM +0300, Boaz Harrosh wrote:
> On 09/03/2014 02:13 PM, Dave Chinner wrote:
> <>
> > 
> > When direct IO fails ext4 falls back to buffered IO, right? And
> > dax_do_io() can return partial writes, yes?
> > 
> 
> There is no buffered writes with DAX. .I.E buffered writes are always
> direct as well. (No page cache)

Yes, I know. But you didn't actually read the code I pointed out,
did you?

> > So that means if you get, say, ENOSPC part way through a DAX write,
> > ext4 can start dirtying the page cache from
> > __generic_file_write_iter() because the DAX write didn't wholly
> > complete? And say this ENOSPC races with space being freed from
> > another inode, then the buffered write will succeed and we'll end up
> > with coherency issues, right?
> > 
> > This is not an idle question - XFS if firing asserts all over the
> > place when doing ENOSPC testing because DAX is returning partial
> > writes and the XFS direct IO code is expecting them to either wholly
> > complete or wholly fail. I can make the DAX variant do allow partial
> > writes, but I'm not going to add a useless fallback to buffered IO
> > for XFS when the (fully featured) direct allocation fails.
> > 
> 
> Right, no fall back.

And so ext4 is buggy, because what ext4 does ....

> Because a fallback is just a retry, because in any
> way DAX assumes there is never a page_cache_page for a written data

... is not a retry - it falls back to a fundamentally different
code path. i.e:

sys_write()
....
	new_sync_write
	  ext4_file_write_iter
	    __generic_file_write_iter(O_DIRECT)
	      written = generic_file_direct_write()
	      if (error || complete write)
	        return
	      /* short write! do buffered IO to finish! */
	      generic_perform_write()
	        loop {
			ext4_write_begin
			ext4_write_end
		}

and so we allocate pages in the page cache and do buffered IO into
them because DAX doesn't hook ->writebegin/write_end as we are
supposed to intercept all buffered IO at a higher level.

This causes data corruption when tested at ENOSPC on DAX enabled
ext4 filesystems. I think that it's an oversight and hence a bug
that needs to be fixed but I'm first asking Willy to see if it was
intentional or not because maybe I missed sometihng in the past 4
months since I've paid really close attention to the DAX code.

And in saying that, Boaz, I'd suggest you spend some time looking at
the history of the DAX patchset. Pay careful note to who came up
with the original idea and architecture that led to the IO path you
are so stridently defending.....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2014-09-11  4:38 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  3:45 [PATCH v10 00/21] Support ext4 on NV-DIMMs Matthew Wilcox
2014-08-27  3:45 ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 01/21] axonram: Fix bug in direct_access Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 02/21] Change direct_access calling convention Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 03/21] Fix XIP fault vs truncate race Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 04/21] Allow page fault handlers to perform the COW Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 05/21] Introduce IS_DAX(inode) Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 06/21] Add copy_to_iter(), copy_from_iter() and iov_iter_zero() Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 07/21] Replace XIP read and write with DAX I/O Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-09-14 14:11   ` Boaz Harrosh
2014-09-14 14:11     ` Boaz Harrosh
2014-08-27  3:45 ` [PATCH v10 08/21] Replace ext2_clear_xip_target with dax_clear_blocks Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 09/21] Replace the XIP page fault handler with the DAX page fault handler Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-09-03  7:47   ` Dave Chinner
2014-09-03  7:47     ` Dave Chinner
2014-09-10 15:23     ` Matthew Wilcox
2014-09-10 15:23       ` Matthew Wilcox
2014-09-11  3:09       ` Dave Chinner
2014-09-11  3:09         ` Dave Chinner
2014-09-24 15:43         ` Matthew Wilcox
2014-09-24 15:43           ` Matthew Wilcox
2014-09-25  1:01           ` Dave Chinner
2014-09-25  1:01             ` Dave Chinner
2014-08-27  3:45 ` [PATCH v10 10/21] Replace xip_truncate_page with dax_truncate_page Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 11/21] Replace XIP documentation with DAX documentation Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 12/21] Remove get_xip_mem Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 13/21] ext2: Remove ext2_xip_verify_sb() Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 14/21] ext2: Remove ext2_use_xip Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 15/21] ext2: Remove xip.c and xip.h Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 16/21] Remove CONFIG_EXT2_FS_XIP and rename CONFIG_FS_XIP to CONFIG_FS_DAX Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 17/21] ext2: Remove ext2_aops_xip Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 18/21] Get rid of most mentions of XIP in ext2 Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 19/21] xip: Add xip_zero_page_range Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-09-03  9:21   ` Dave Chinner
2014-09-03  9:21     ` Dave Chinner
2014-09-04 21:08     ` Matthew Wilcox
2014-09-04 21:08       ` Matthew Wilcox
2014-09-04 21:36       ` Theodore Ts'o
2014-09-04 21:36         ` Theodore Ts'o
2014-09-08 18:59         ` Matthew Wilcox
2014-09-08 18:59           ` Matthew Wilcox
2014-08-27  3:45 ` [PATCH v10 20/21] ext4: Add DAX functionality Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-09-03 11:13   ` Dave Chinner
2014-09-03 11:13     ` Dave Chinner
2014-09-10 16:49     ` Boaz Harrosh
2014-09-10 16:49       ` Boaz Harrosh
2014-09-11  4:38       ` Dave Chinner [this message]
2014-09-11  4:38         ` Dave Chinner
2014-09-14 12:25         ` Boaz Harrosh
2014-09-14 12:25           ` Boaz Harrosh
2014-09-15  6:15           ` Dave Chinner
2014-09-15  6:15             ` Dave Chinner
2014-09-15  9:41             ` Boaz Harrosh
2014-09-15  9:41               ` Boaz Harrosh
2014-08-27  3:45 ` [PATCH v10 21/21] brd: Rename XIP to DAX Matthew Wilcox
2014-08-27  3:45   ` Matthew Wilcox
2014-08-27 20:06 ` [PATCH v10 00/21] Support ext4 on NV-DIMMs Andrew Morton
2014-08-27 20:06   ` Andrew Morton
2014-08-27 21:12   ` Matthew Wilcox
2014-08-27 21:12     ` Matthew Wilcox
2014-08-27 21:46     ` Andrew Morton
2014-08-27 21:46       ` Andrew Morton
2014-08-28  1:30       ` Andy Lutomirski
2014-08-28  1:30         ` Andy Lutomirski
2014-08-28 16:50         ` Matthew Wilcox
2014-08-28 16:50           ` Matthew Wilcox
2014-08-28 15:45       ` Matthew Wilcox
2014-08-28 15:45         ` Matthew Wilcox
2014-08-27 21:22   ` Christoph Lameter
2014-08-27 21:22     ` Christoph Lameter
2014-08-27 21:30     ` Andrew Morton
2014-08-27 21:30       ` Andrew Morton
2014-08-27 23:04       ` One Thousand Gnomes
2014-08-27 23:04         ` One Thousand Gnomes
2014-08-28  7:17       ` Dave Chinner
2014-08-28  7:17         ` Dave Chinner
2014-08-30 23:11         ` Christian Stroetmann
2014-08-30 23:11           ` Christian Stroetmann
2014-08-28  8:08 ` Boaz Harrosh
2014-08-28  8:08   ` Boaz Harrosh
2014-08-28 22:09   ` Zwisler, Ross
2014-08-28 22:09     ` Zwisler, Ross
2014-09-03 12:05 ` [PATCH 1/1] xfs: add DAX support Dave Chinner
2014-09-03 12:05   ` Dave Chinner

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=20140911043815.GP20518@dastard \
    --to=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.r.wilcox@intel.com \
    --cc=openosd@gmail.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=willy@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.