Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1887032imm; Thu, 27 Sep 2018 04:14:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV60e3EFXmKMVDU+FidyW3hVETbL77MMKdm0B07sE9wTQykQPizmbjfmW9QNbmDgGitVu0c/l X-Received: by 2002:a63:160d:: with SMTP id w13-v6mr9883151pgl.43.1538046858524; Thu, 27 Sep 2018 04:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538046858; cv=none; d=google.com; s=arc-20160816; b=Jl3Bl97vIFAixS9d7M6ZWCb0IFz426ozCcyHDSfhs7KQS6sERA+jCbJ9gLLpApwz9V oKlRS4HwT0W/T6ZfwAPRX0K3VWMjQfOBGaLekuSme9HQKAzs7GK5RPjb2kSR0UPpNcK7 N4xSSnh8y/GN0UtTvXIJWFxaQ5b4WFU//TbMzDQ5SSO/KTXlCdG9/oiAIZi4S2YYLotu AOo26iqQ26iWOAihlPr5N6hg0zFTfqms3bUU+fIscEKM/fIB3PCd99ALLezHtOFJebWV LIMSQvz2QeG2YcAEVUaQiIl7Nw/h51xE6U6nAo+CzOfnzpGNJkvsmCN2IaXtisu+ohtC Gigg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JChydw7xoi+x9dGM95yMPgN9kHFy47w8002Xom+J7h4=; b=qdNs39q98FIOuI4r+zQLSiongeTTesO3YOhcs/rRrKHLu69en1oO7v0v6sRO/fr25s r16q7+Ab6iaTapepouxIXKojZ0KA/DX5oLhLop5B4sTnlJDjc9N9UMxQtqJzp7Xz2cHz ln2CbQc6aMrFCi4HE9weXKdr06v8MJSeWc6zaWnsTlIav1xOOvPyyT/IOtc1zHqF4PMI n1xyzOcdv0UGauXwTyMdDs10fhb8zjDtTNkFJ0K/ni3c5mfPwJcwHNY2TtH2S6nVhUBR Jrn3OgsHm9yZYt6tALfSUgijOF7rJv/TcgYHSXuFtV5ZxeyXnuB8kN0EWF1NUZ9s8G5a xnMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10-v6si1426886pgs.362.2018.09.27.04.14.01; Thu, 27 Sep 2018 04:14:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbeI0Rbm (ORCPT + 99 others); Thu, 27 Sep 2018 13:31:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:60768 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727112AbeI0Rbl (ORCPT ); Thu, 27 Sep 2018 13:31:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CF211AE67; Thu, 27 Sep 2018 11:13:54 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7182A1E360F; Thu, 27 Sep 2018 13:13:54 +0200 (CEST) Date: Thu, 27 Sep 2018 13:13:54 +0200 From: Jan Kara To: Barret Rhoden Cc: Dan Williams , linux-nvdimm@lists.01.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jack@suse.cz, ross.zwisler@linux.intel.com Subject: Re: [PATCH v5 07/11] filesystem-dax: Introduce dax_lock_mapping_entry() Message-ID: <20180927111354.GA16469@quack2.suse.cz> References: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> <153074046078.27838.5465590228767136915.stgit@dwillia2-desk3.amr.corp.intel.com> <20180924115721.75893931@gnomeregan.cam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180924115721.75893931@gnomeregan.cam.corp.google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 24-09-18 11:57:21, Barret Rhoden wrote: > Hi Dan - > > On 2018-07-04 at 14:41 Dan Williams wrote: > [snip] > > diff --git a/fs/dax.c b/fs/dax.c > > index 4de11ed463ce..57ec272038da 100644 > > --- a/fs/dax.c > > +++ b/fs/dax.c > [snip] > > +bool dax_lock_mapping_entry(struct page *page) > > +{ > > + pgoff_t index; > > + struct inode *inode; > > + bool did_lock = false; > > + void *entry = NULL, **slot; > > + struct address_space *mapping; > > + > > + rcu_read_lock(); > > + for (;;) { > > + mapping = READ_ONCE(page->mapping); > > + > > + if (!dax_mapping(mapping)) > > + break; > > + > > + /* > > + * In the device-dax case there's no need to lock, a > > + * struct dev_pagemap pin is sufficient to keep the > > + * inode alive, and we assume we have dev_pagemap pin > > + * otherwise we would not have a valid pfn_to_page() > > + * translation. > > + */ > > + inode = mapping->host; > > + if (S_ISCHR(inode->i_mode)) { > > + did_lock = true; > > + break; > > + } > > + > > + xa_lock_irq(&mapping->i_pages); > > + if (mapping != page->mapping) { > > + xa_unlock_irq(&mapping->i_pages); > > + continue; > > + } > > + index = page->index; > > + > > + entry = __get_unlocked_mapping_entry(mapping, index, &slot, > > + entry_wait_revalidate); > > + if (!entry) { > > + xa_unlock_irq(&mapping->i_pages); > > + break; > > + } else if (IS_ERR(entry)) { > > + WARN_ON_ONCE(PTR_ERR(entry) != -EAGAIN); > > + continue; > > In the IS_ERR case, do you need to xa_unlock the mapping? It looks > like you'll deadlock the next time around the loop. Yep, that looks certainly wrong. I'll send a fix. Honza -- Jan Kara SUSE Labs, CR