Re: [PATCH 08/11] ext4: Convert DAX faults to iomap infrastructure

2016-11-03 Thread Jan Kara
On Wed 02-11-16 07:30:06, Christoph Hellwig wrote: > On Tue, Nov 01, 2016 at 10:06:18PM +0100, Jan Kara wrote: > > Convert DAX faults to use iomap infrastructure. We would not have to start > > transaction in ext4_dax_fault() anymore since ext4_iomap_begin takes > > care of that but so far we do th

Re: [PATCH 02/11] ext4: Allow unaligned unlocked DAX IO

2016-11-03 Thread Jan Kara
On Wed 02-11-16 07:27:46, Christoph Hellwig wrote: > On Tue, Nov 01, 2016 at 10:06:12PM +0100, Jan Kara wrote: > > Currently we don't allow unaligned writes without inode_lock. This is > > because zeroing of partial blocks could cause data corruption for racing > > unaligned writes to the same bloc

Re: [PATCH 0/11] ext4: Convert ext4 DAX IO to iomap framework

2016-11-03 Thread Jan Kara
On Wed 02-11-16 09:03:53, Ted Tso wrote: > On Wed, Nov 02, 2016 at 12:09:03AM +0100, Jan Kara wrote: > > > > I plan to grab Ross's PMD series in the next couple of days and I'll > > > > push it out as a stable topic branch once I've sanity tested it. I > > > > don't really want to take a big chunk

Re: [PATCH 0/21 v4] dax: Clear dirty bits after flushing caches

2016-11-03 Thread Jan Kara
On Tue 01-11-16 23:17:33, Ross Zwisler wrote: > On Tue, Nov 01, 2016 at 11:36:06PM +0100, Jan Kara wrote: > > Hello, > > > > this is the fourth revision of my patches to clear dirty bits from radix > > tree > > of DAX inodes when caches for corresponding pfns have been flushed. This > > patch >

Re: [PATCH 11/11] dax: Rip out get_block based IO support

2016-11-03 Thread Jan Kara
On Wed 02-11-16 07:31:00, Christoph Hellwig wrote: > On Tue, Nov 01, 2016 at 10:06:21PM +0100, Jan Kara wrote: > > No one uses functions using the get_block callback anymore. Rip them > > out. > > Documentation/filesystems/dax.txt will also need some updates for this. Right, will do.

Re: [PATCH 01/21] mm: Join struct fault_env and vm_fault

2016-11-03 Thread Jan Kara
On Wed 02-11-16 12:58:48, Kirill A. Shutemov wrote: > On Tue, Nov 01, 2016 at 11:36:08PM +0100, Jan Kara wrote: > > Currently we have two different structures for passing fault information > > around - struct vm_fault and struct fault_env. DAX will need more > > information in struct vm_fault to ha

[PATCH 07/21] mm: Add orig_pte field into vm_fault

2016-11-03 Thread Jan Kara
Add orig_pte field to vm_fault structure to allow ->page_mkwrite handlers to fully handle the fault. This also allows us to save some passing of extra arguments around. Signed-off-by: Jan Kara --- include/linux/mm.h | 4 +-- mm/internal.h | 2 +- mm/khugepaged.c| 7 ++--- mm/memory.c

[PATCH 17/21] mm: Change return values of finish_mkwrite_fault()

2016-11-03 Thread Jan Kara
Currently finish_mkwrite_fault() returns 0 when PTE got changed before we acquired PTE lock and VM_FAULT_WRITE when we succeeded in modifying the PTE. This is somewhat confusing since 0 generally means success, it is also inconsistent with finish_fault() which returns 0 on success. Change finish_mk

[PATCH 10/21] mm: Move handling of COW faults into DAX code

2016-11-03 Thread Jan Kara
Move final handling of COW faults from generic code into DAX fault handler. That way generic code doesn't have to be aware of peculiarities of DAX locking so remove that knowledge and make locking functions private to fs/dax.c. Signed-off-by: Jan Kara --- fs/dax.c| 58 +++

[PATCH 05/21] mm: Trim __do_fault() arguments

2016-11-03 Thread Jan Kara
Use vm_fault structure to pass cow_page, page, and entry in and out of the function. That reduces number of __do_fault() arguments from 4 to 1. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/memory.c | 53 +++-- 1 file changed, 23 insert

[PATCH 16/21] mm: Provide helper for finishing mkwrite faults

2016-11-03 Thread Jan Kara
Provide a helper function for finishing write faults due to PTE being read-only. The helper will be used by DAX to avoid the need of complicating generic MM code with DAX locking specifics. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- include/linux/mm.h | 1 + mm/memory.c| 67

[PATCH 0/21 v4 RESEND] dax: Clear dirty bits after flushing caches

2016-11-03 Thread Jan Kara
Hello, I'm resending v4 of my DAX write-protection patches since I've messed up previous posting, mixing old and new version of the patch series... This is the fourth revision of my patches to clear dirty bits from radix tree of DAX inodes when caches for corresponding pfns have been flushed. Thi

[PATCH 02/21] mm: Use vmf->address instead of of vmf->virtual_address

2016-11-03 Thread Jan Kara
Every single user of vmf->virtual_address typed that entry to unsigned long before doing anything with it so the type of virtual_address does not really provide us any additional safety. Just use masked vmf->address which already has the appropriate type. Signed-off-by: Jan Kara --- arch/powerpc

[PATCH 13/21] mm: Pass vm_fault structure into do_page_mkwrite()

2016-11-03 Thread Jan Kara
We will need more information in the ->page_mkwrite() helper for DAX to be able to fully finish faults there. Pass vm_fault structure to do_page_mkwrite() and use it there so that information propagates properly from upper layers. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/memory.

[PATCH 03/21] mm: Use pgoff in struct vm_fault instead of passing it separately

2016-11-03 Thread Jan Kara
struct vm_fault has already pgoff entry. Use it instead of passing pgoff as a separate argument and then assigning it later. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/khugepaged.c | 1 + mm/memory.c | 35 ++- 2 files changed, 19 insertions(+),

[PATCH 04/21] mm: Use passed vm_fault structure in __do_fault()

2016-11-03 Thread Jan Kara
Instead of creating another vm_fault structure, use the one passed to __do_fault() for passing arguments into fault handler. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/memory.c | 25 ++--- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mm/memor

[PATCH 12/21] mm: Factor out common parts of write fault handling

2016-11-03 Thread Jan Kara
Currently we duplicate handling of shared write faults in wp_page_reuse() and do_shared_fault(). Factor them out into a common function. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/memory.c | 78 + 1 file changed, 37 inser

[PATCH 01/21] mm: Join struct fault_env and vm_fault

2016-11-03 Thread Jan Kara
Currently we have two different structures for passing fault information around - struct vm_fault and struct fault_env. DAX will need more information in struct vm_fault to handle its faults so the content of that structure would become event closer to fault_env. Furthermore it would need to genera

[PATCH 19/21] dax: Make cache flushing protected by entry lock

2016-11-03 Thread Jan Kara
Currently, flushing of caches for DAX mappings was ignoring entry lock. So far this was ok (modulo a bug that a difference in entry lock could cause cache flushing to be mistakenly skipped) but in the following patches we will write-protect PTEs on cache flushing and clear dirty tags. For that we w

[PATCH 20/21] dax: Protect PTE modification on WP fault by radix tree entry lock

2016-11-03 Thread Jan Kara
Currently PTE gets updated in wp_pfn_shared() after dax_pfn_mkwrite() has released corresponding radix tree entry lock. When we want to writeprotect PTE on cache flush, we need PTE modification to happen under radix tree entry lock to ensure consistent updates of PTE and radix tree (standard faults

[PATCH 18/21] mm: Export follow_pte()

2016-11-03 Thread Jan Kara
DAX will need to implement its own version of page_check_address(). To avoid duplicating page table walking code, export follow_pte() which does what we need. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- include/linux/mm.h | 2 ++ mm/memory.c| 4 ++-- 2 files changed, 4 inserti

[PATCH 14/21] mm: Use vmf->page during WP faults

2016-11-03 Thread Jan Kara
So far we set vmf->page during WP faults only when we needed to pass it to the ->page_mkwrite handler. Set it in all the cases now and use that instead of passing page pointer explicitly around. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/memory.c | 58 +

[PATCH 08/21] mm: Allow full handling of COW faults in ->fault handlers

2016-11-03 Thread Jan Kara
To allow full handling of COW faults add memcg field to struct vm_fault and a return value of ->fault() handler meaning that COW fault is fully handled and memcg charge must not be canceled. This will allow us to remove knowledge about special DAX locking from the generic fault code. Reviewed-by:

[PATCH 09/21] mm: Factor out functionality to finish page faults

2016-11-03 Thread Jan Kara
Introduce function finish_fault() as a helper function for finishing page faults. It is rather thin wrapper around alloc_set_pte() but since we'd want to call this from DAX code or filesystems, it is still useful to avoid some boilerplate code. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara -

[PATCH 06/21] mm: Use passed vm_fault structure for in wp_pfn_shared()

2016-11-03 Thread Jan Kara
Instead of creating another vm_fault structure, use the one passed to wp_pfn_shared() for passing arguments into pfn_mkwrite handler. Reviewed-by: Ross Zwisler Signed-off-by: Jan Kara --- mm/memory.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/m

[PATCH 11/21] mm: Remove unnecessary vma->vm_ops check

2016-11-03 Thread Jan Kara
We don't check whether vma->vm_ops is NULL in do_shared_fault() so there's hardly any point in checking it in wp_page_shared() or wp_pfn_shared() which get called only for shared file mappings as well. Signed-off-by: Jan Kara --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions

[PATCH 21/21] dax: Clear dirty entry tags on cache flush

2016-11-03 Thread Jan Kara
Currently we never clear dirty tags in DAX mappings and thus address ranges to flush accumulate. Now that we have locking of radix tree entries, we have all the locking necessary to reliably clear the radix tree dirty tag when flushing caches for corresponding address range. Similarly to page_mkcle

[PATCH 15/21] mm: Move part of wp_page_reuse() into the single call site

2016-11-03 Thread Jan Kara
wp_page_reuse() handles write shared faults which is needed only in wp_page_shared(). Move the handling only into that location to make wp_page_reuse() simpler and avoid a strange situation when we sometimes pass in locked page, sometimes unlocked etc. Reviewed-by: Ross Zwisler Signed-off-by: Jan

Re: [PATCH 01/11] ext4: Factor out checks from ext4_file_write_iter()

2016-11-03 Thread Jan Kara
On Thu 03-11-16 15:04:40, Ross Zwisler wrote: > On Tue, Nov 01, 2016 at 10:06:11PM +0100, Jan Kara wrote: > > + /* > > +* 'err==len' means that all of blocks has been preallocated no matter > > +* they are initialized or not. For excluding unwritten extents, we > > +* need to check m

Re: [PATCH 02/21] mm: Use vmf->address instead of of vmf->virtual_address

2016-11-03 Thread Jan Kara
On Wed 02-11-16 12:18:10, Hillf Danton wrote: > On Wednesday, November 02, 2016 6:36 AM Jan Kara wrote: > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 8e8b76d11bb4..2a4ebe3c67c6 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -297,8 +297,6 @@ struct vm_fa

Re: [PATCH v9 00/16] re-enable DAX PMD support

2016-11-03 Thread Dave Chinner
On Thu, Nov 03, 2016 at 11:51:02AM -0600, Ross Zwisler wrote: > On Thu, Nov 03, 2016 at 12:58:26PM +1100, Dave Chinner wrote: > > On Tue, Nov 01, 2016 at 01:54:02PM -0600, Ross Zwisler wrote: > > > DAX PMDs have been disabled since Jan Kara introduced DAX radix tree based > > > locking. This serie

Re: [PATCH 01/11] ext4: Factor out checks from ext4_file_write_iter()

2016-11-03 Thread Ross Zwisler
On Tue, Nov 01, 2016 at 10:06:11PM +0100, Jan Kara wrote: > Factor out checks of 'from' and whether we are overwriting out of > ext4_file_write_iter() so that the function is easier to follow. > > Signed-off-by: Jan Kara > --- > fs/ext4/file.c | 97 > ++--

Re: [PATCH 0/21 v4] dax: Clear dirty bits after flushing caches

2016-11-03 Thread Jan Kara
On Wed 02-11-16 13:02:17, Kirill A. Shutemov wrote: > On Wed, Nov 02, 2016 at 12:13:18AM +0100, Jan Kara wrote: > > Hi, > > > > forgot to add Kirill to CC since this modifies the fault path he changed > > recently. I don't want to resend the whole series just because of this so > > at least I'm pi

Re: [PATCH v9 00/16] re-enable DAX PMD support

2016-11-03 Thread Ross Zwisler
On Thu, Nov 03, 2016 at 12:58:26PM +1100, Dave Chinner wrote: > On Tue, Nov 01, 2016 at 01:54:02PM -0600, Ross Zwisler wrote: > > DAX PMDs have been disabled since Jan Kara introduced DAX radix tree based > > locking. This series allows DAX PMDs to participate in the DAX radix tree > > based locki