From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([198.137.202.9]:57560 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbcI3Izp (ORCPT ); Fri, 30 Sep 2016 04:55:45 -0400 Date: Fri, 30 Sep 2016 01:55:44 -0700 From: Christoph Hellwig To: Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-nvdimm@ml01.01.org, Dan Williams , Ross Zwisler Subject: Re: [PATCH 6/6] dax: Avoid page invalidation races and unnecessary radix tree traversals Message-ID: <20160930085544.GD22381@infradead.org> References: <1474994615-29553-1-git-send-email-jack@suse.cz> <1474994615-29553-7-git-send-email-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1474994615-29553-7-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Sep 27, 2016 at 06:43:35PM +0200, Jan Kara wrote: > Currently each filesystem (possibly through generic_file_direct_write() > or iomap_dax_rw()) takes care of invalidating page tables and evicting > hole pages from the radix tree when write(2) to the file happens. This > invalidation is only necessary when there is some block allocation > resulting from write(2). Furthermore in current place the invalidation > is racy wrt page fault instantiating a hole page just after we have > invalidated it. > > So perform the page invalidation inside dax_do_io() where we can do it > only when really necessary and after blocks have been allocated so > nobody will be instantiating new hole pages anymore. > > Signed-off-by: Jan Kara This looks fine with the comment from Dave addressed: Reviewed-by: Christoph Hellwig > + if (buffer_new(bh) && > + inode->i_mapping->nrpages) { Btw, it would be nice if the nrpages check could move into invalidate_inode_pages2_range instead of having to bother with it in the callers.