Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1636261rwn; Thu, 15 Sep 2022 20:38:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ALgimaXpY5PR1q663L23UZsWadHeYUxPJiTQJ33EQ4xPkErqbv30OmdWL2ZS5q1vCCghw X-Received: by 2002:aa7:888f:0:b0:544:7429:b07c with SMTP id z15-20020aa7888f000000b005447429b07cmr3229166pfe.15.1663299507130; Thu, 15 Sep 2022 20:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663299507; cv=none; d=google.com; s=arc-20160816; b=EKk8fWE57P2DlePR8Le6o0KSe3wmXOX3IdtPJ1I2zTNG2O4DGPcWoNXzwuLbeaNvkg XCkuVgIdl1xPVEX8qj9yRw9Na0qK0zTVRLBvT5IoCfpX9OrRgRI8hDJOnEyS305AItp/ lXO/vQll246S+7YHt9MMex3r4ulVKymv2Fep6hXMPFamCXhaXrEn4aqS6y2OcvaIDPon DeX0uNHElcsutAPMxnk9D0/o0oVgDbkN6K6VK5UgobVfFtbJtdYfO5fyn4Jx3A3osh2M An8JIQPAKRpnZeqGwkpobFyxTPa2oNUjQs13+Y25b/Q2i2SrU/793ZqeeA+vVxnfkHIv rWoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=NuHs7P0LUMGO2X4fh8xdHJG7aEV2M7sHwUIri9TENYs=; b=bISEi5JFi1o5J36xWskKGz6soXAWca+gHMNa9HXi3nsnYo0x21Q++XQhnDVhd/0AQw VUrawAA9S1C0pD5/spvsIVflHtgSY0bx/cdtLpmfD3NISIO/OMCFrzgpAQVrmkzvB157 F7kW53XiOqMq0a91ydmJBOVTbuBt2wLeaP23j68NZ5arWokS6XY/v2Xuy/swC+vjjFWr /g/uuI2DhDnglpRn7eS6juD7BTHMoqOGuo5KCZ8QfZB5IVg07PDMjuZiLrwGTtn9X1rG wI2x7NISAK53+PDQUntXKdroLg5sxFFf4A7QfFu7+CDLZz3Dv/5p5AYYOSqRClVDjI4C 6/IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iDypxwJU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi3-20020a17090b4b4300b00202c5cc15c9si1068861pjb.9.2022.09.15.20.38.14; Thu, 15 Sep 2022 20:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iDypxwJU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbiIPDgX (ORCPT + 99 others); Thu, 15 Sep 2022 23:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbiIPDf5 (ORCPT ); Thu, 15 Sep 2022 23:35:57 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F391D371A2; Thu, 15 Sep 2022 20:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663299352; x=1694835352; h=subject:from:to:cc:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gvNMBXmzRliL/61+0l3Vp0DMaKfxeHPNaGSpEyGRros=; b=iDypxwJUKMQkCx0bXijvtpfGHOlepKeIsgyxigK9wYgjZbQ/60jSz9AK NlAaJvP7kGGJbAZ9iwvw6p5/7zYEvjq1qHi/YvpiX3NW8QTYgIhS63Vym JG7YxiqCL8dv2jYDN1QCciw7Y4IDM/mIK4reF+nTc6yhUHg4un+s7wgoG xC2WxpxuDBCQJr9UV/InKYj9Ssbcmyiwtq6Vu6ql2uGzs9WC4aaGxWoAj nxakp5OMI+AG7FEgYscpApusjWAs9AAkdUtsaRqIT4mZZ70Qwr9yu1G/t VhZle4xhZ8VNHO71JUbiznkadbEeANkAeSloFIBC8cGy64wqPXJC3Y3q2 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10471"; a="279283844" X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="279283844" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:35:51 -0700 X-IronPort-AV: E=Sophos;i="5.93,319,1654585200"; d="scan'208";a="792961964" Received: from colinlix-mobl.amr.corp.intel.com (HELO dwillia2-xfh.jf.intel.com) ([10.209.29.52]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 20:35:50 -0700 Subject: [PATCH v2 07/18] fsdax: Update dax_insert_entry() calling convention to return an error From: Dan Williams To: akpm@linux-foundation.org Cc: Matthew Wilcox , Jan Kara , "Darrick J. Wong" , Jason Gunthorpe , Christoph Hellwig , John Hubbard , linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-ext4@vger.kernel.org Date: Thu, 15 Sep 2022 20:35:50 -0700 Message-ID: <166329935018.2786261.15861171979773593749.stgit@dwillia2-xfh.jf.intel.com> In-Reply-To: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> References: <166329930818.2786261.6086109734008025807.stgit@dwillia2-xfh.jf.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In preparation for teaching dax_insert_entry() to take live @pgmap references, enable it to return errors. Given the observation that all callers overwrite the passed in entry with the return value, just update @entry in place and convert the return code to a vm_fault_t status. Cc: Matthew Wilcox Cc: Jan Kara Cc: "Darrick J. Wong" Cc: Jason Gunthorpe Cc: Christoph Hellwig Cc: John Hubbard Signed-off-by: Dan Williams --- fs/dax.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 616bac4b7df3..8382aab0d2f7 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -887,14 +887,15 @@ static bool dax_fault_is_cow(const struct iomap_iter *iter) * already in the tree, we will skip the insertion and just dirty the PMD as * appropriate. */ -static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, - const struct iomap_iter *iter, void *entry, pfn_t pfn, - unsigned long flags) +static vm_fault_t dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, + const struct iomap_iter *iter, void **pentry, + pfn_t pfn, unsigned long flags) { struct address_space *mapping = vmf->vma->vm_file->f_mapping; void *new_entry = dax_make_entry(pfn, flags); bool dirty = !dax_fault_is_synchronous(iter, vmf->vma); bool cow = dax_fault_is_cow(iter); + void *entry = *pentry; if (dirty) __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); @@ -940,7 +941,8 @@ static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, xas_set_mark(xas, PAGECACHE_TAG_TOWRITE); xas_unlock_irq(xas); - return entry; + *pentry = entry; + return 0; } static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev, @@ -1188,9 +1190,12 @@ static vm_fault_t dax_load_hole(struct xa_state *xas, struct vm_fault *vmf, pfn_t pfn = pfn_to_pfn_t(my_zero_pfn(vaddr)); vm_fault_t ret; - *entry = dax_insert_entry(xas, vmf, iter, *entry, pfn, DAX_ZERO_PAGE); + ret = dax_insert_entry(xas, vmf, iter, entry, pfn, DAX_ZERO_PAGE); + if (ret) + goto out; ret = vmf_insert_mixed(vmf->vma, vaddr, pfn); +out: trace_dax_load_hole(inode, vmf, ret); return ret; } @@ -1207,6 +1212,7 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, struct page *zero_page; spinlock_t *ptl; pmd_t pmd_entry; + vm_fault_t ret; pfn_t pfn; zero_page = mm_get_huge_zero_page(vmf->vma->vm_mm); @@ -1215,8 +1221,10 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, goto fallback; pfn = page_to_pfn_t(zero_page); - *entry = dax_insert_entry(xas, vmf, iter, *entry, pfn, - DAX_PMD | DAX_ZERO_PAGE); + ret = dax_insert_entry(xas, vmf, iter, entry, pfn, + DAX_PMD | DAX_ZERO_PAGE); + if (ret) + return ret; if (arch_needs_pgtable_deposit()) { pgtable = pte_alloc_one(vma->vm_mm); @@ -1568,6 +1576,7 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf, loff_t pos = (loff_t)xas->xa_index << PAGE_SHIFT; bool write = iter->flags & IOMAP_WRITE; unsigned long entry_flags = pmd ? DAX_PMD : 0; + vm_fault_t ret; int err = 0; pfn_t pfn; void *kaddr; @@ -1592,7 +1601,9 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf, if (err) return pmd ? VM_FAULT_FALLBACK : dax_fault_return(err); - *entry = dax_insert_entry(xas, vmf, iter, *entry, pfn, entry_flags); + ret = dax_insert_entry(xas, vmf, iter, entry, pfn, entry_flags); + if (ret) + return ret; if (write && srcmap->type != IOMAP_HOLE && srcmap->addr != iomap->addr) {