From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com ([134.134.136.20]:51645 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752693AbcELTg2 (ORCPT ); Thu, 12 May 2016 15:36:28 -0400 Date: Thu, 12 May 2016 13:36:24 -0600 From: Ross Zwisler To: Jan Kara Cc: linux-nvdimm@lists.01.org, Ted Tso , linux-ext4@vger.kernel.org, Vishal Verma , Ross Zwisler , Dan Williams , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 5/7] dax: New fault locking Message-ID: <20160512193624.GA20719@linux.intel.com> References: <1463070560-1979-1-git-send-email-jack@suse.cz> <1463070560-1979-6-git-send-email-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1463070560-1979-6-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, May 12, 2016 at 06:29:18PM +0200, Jan Kara wrote: > Currently DAX page fault locking is racy. > > CPU0 (write fault) CPU1 (read fault) > > __dax_fault() __dax_fault() > get_block(inode, block, &bh, 0) -> not mapped > get_block(inode, block, &bh, 0) > -> not mapped > if (!buffer_mapped(&bh)) > if (vmf->flags & FAULT_FLAG_WRITE) > get_block(inode, block, &bh, 1) -> allocates blocks > if (page) -> no > if (!buffer_mapped(&bh)) > if (vmf->flags & FAULT_FLAG_WRITE) { > } else { > dax_load_hole(); > } > dax_insert_mapping() > > And we are in a situation where we fail in dax_radix_entry() with -EIO. > > Another problem with the current DAX page fault locking is that there is > no race-free way to clear dirty tag in the radix tree. We can always > end up with clean radix tree and dirty data in CPU cache. > > We fix the first problem by introducing locking of exceptional radix > tree entries in DAX mappings acting very similarly to page lock and thus > synchronizing properly faults against the same mapping index. The same > lock can later be used to avoid races when clearing radix tree dirty > tag. > > Reviewed-by: NeilBrown > Reviewed-by: Ross Zwisler > Signed-off-by: Jan Kara > --- <> > @@ -897,13 +1166,10 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, > * the write to insert a dirty entry. > */ > if (write) { > - error = dax_radix_entry(mapping, pgoff, dax.sector, > - true, true); > - if (error) { > - dax_pmd_dbg(&bh, address, > - "PMD radix insertion failed"); > - goto fallback; > - } > + /* > + * We should insert radix-tree entry and dirty it here. > + * For now this is broken... > + */ With this change the 'error' variable in __dax_pmd_fault() is now unused, resulting in a compiler warning. fs/dax.c: In function ‘__dax_pmd_fault’: fs/dax.c:1019:6: warning: unused variable ‘error’ [-Wunused-variable] int error, result = 0; ^