Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp101167pxh; Tue, 9 Nov 2021 07:55:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJtZ7V/htTWJ3bRTIZhv0jM/zjoAPanYNW55btUXAuGqGDG645yAmFcmR8jtYKsdUA2eWj X-Received: by 2002:a17:907:6d28:: with SMTP id sa40mr10665768ejc.201.1636473335382; Tue, 09 Nov 2021 07:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636473335; cv=none; d=google.com; s=arc-20160816; b=D15kxad3SzW387eUe2DJk6tHLMrdnK4SaUoXxGGJ3qDGFeqI+oJNRu+mdWT8Gf09OA u/JUxIjTED3wOrKIa/Wa5ABwjcPXALZqHHOKOageDgF59vLAaQ9uRmcCgkEU+sgJeZfv GJgHsxVs8NpyWsjZqyG06p1+3XFFbQLg/EPYGjEhBoOkccROL1cxWZTrdPvwCu34BuzB BcjLTfBmXrlW3tEiAtRvjtRHpMsOI3Ye+W91RN5ZM6JU5tGW+hgsAop4Q9aEocwO5jtI RL58OrY+fW93efyejDvgprY9m9uJ6n0lGRcL84yb40GqI9kp88zTAwEeyDID2Kc5iGRi o5Sg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GFhvoqOvL9OJvQf8+jTjW82TnTUOvEd+75/q2F+O9PE=; b=rqDAK861VbQd90dB3wK1lOL+EdQr+vtYcLQ4fgNV5khdci+9RrDrfqagVDoDHwihP1 MSwbkJT88jAkIsoNu3vpic18pBplZC5oFiaw9za0vx+hb4HTeujdD/Qv6YWT2iWZ3Hwi rqPuMWTFWjwYsWsGFbvbZS9/lQZq+Ogay/4udP+liJ7tmeup3kuNj3eJZ5oAVJN7KDAm /YLrDKqkjQdabTBzSEbixlDo3ls0cn9r9JTmTvxaTWkF9X8ALuYwqYv4rz+gWFcvK1la r3qwmV49W1Vpl2RPZUw5ZK6OVzlAnKND6S1qe/s6pMF/AUe/owSj5x92FuLgsJ9XcwSZ 40JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=skBgYHYj; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si28504528edz.312.2021.11.09.07.54.58; Tue, 09 Nov 2021 07:55:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=skBgYHYj; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244165AbhKIIgb (ORCPT + 99 others); Tue, 9 Nov 2021 03:36:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244174AbhKIIg2 (ORCPT ); Tue, 9 Nov 2021 03:36:28 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800E4C061767; Tue, 9 Nov 2021 00:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=GFhvoqOvL9OJvQf8+jTjW82TnTUOvEd+75/q2F+O9PE=; b=skBgYHYjavMuoPq2CV+3MX/Hg3 N0ec6jUVnP3dTGwezupk6zCDVbBZpXVnnkz2V1hkxkmqrKJSgR0xhtkALlVZvJtYBEiEhfIWlBAKK BC7m73sgtzTm5SOhafl9DgiuxDS6wK6jJq6TtnTNhuFgXa7mVCaRWvYtE9Z0pFIDQGcniQntwbtzp VL1vMQMckVa3zEij5h0NcvaLDA6J8imgtaEBv4iiTmwIiEYegUYnbbtmVEn9zhY8R99+J1WWGh5J+ qMY3LBjBWS5k/isgkkDvO1c/87syeC7Cwd7SmnLK1Fif4MEuSuYTPq+uejut0GwzwpVuXr5aRz6g9 Ga0NH+ww==; Received: from [2001:4bb8:19a:7ee7:fb46:2fe1:8652:d9d4] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkMZU-000s3V-Sg; Tue, 09 Nov 2021 08:33:37 +0000 From: Christoph Hellwig To: Dan Williams Cc: Mike Snitzer , Ira Weiny , dm-devel@redhat.com, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 13/29] fsdax: use a saner calling convention for copy_cow_page_dax Date: Tue, 9 Nov 2021 09:32:53 +0100 Message-Id: <20211109083309.584081-14-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211109083309.584081-1-hch@lst.de> References: <20211109083309.584081-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Just pass the vm_fault and iomap_iter structures, and figure out the rest locally. Note that this requires moving dax_iomap_sector up in the file. Signed-off-by: Christoph Hellwig --- fs/dax.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 73bd1439d8089..e51b4129d1b65 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -709,26 +709,31 @@ int dax_invalidate_mapping_entry_sync(struct address_space *mapping, return __dax_invalidate_entry(mapping, index, false); } -static int copy_cow_page_dax(struct block_device *bdev, struct dax_device *dax_dev, - sector_t sector, struct page *to, unsigned long vaddr) +static sector_t dax_iomap_sector(const struct iomap *iomap, loff_t pos) { + return (iomap->addr + (pos & PAGE_MASK) - iomap->offset) >> 9; +} + +static int copy_cow_page_dax(struct vm_fault *vmf, const struct iomap_iter *iter) +{ + sector_t sector = dax_iomap_sector(&iter->iomap, iter->pos); void *vto, *kaddr; pgoff_t pgoff; long rc; int id; - rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); + rc = bdev_dax_pgoff(iter->iomap.bdev, sector, PAGE_SIZE, &pgoff); if (rc) return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL); + rc = dax_direct_access(iter->iomap.dax_dev, pgoff, 1, &kaddr, NULL); if (rc < 0) { dax_read_unlock(id); return rc; } - vto = kmap_atomic(to); - copy_user_page(vto, kaddr, vaddr, to); + vto = kmap_atomic(vmf->cow_page); + copy_user_page(vto, kaddr, vmf->address, vmf->cow_page); kunmap_atomic(vto); dax_read_unlock(id); return 0; @@ -1005,11 +1010,6 @@ int dax_writeback_mapping_range(struct address_space *mapping, } EXPORT_SYMBOL_GPL(dax_writeback_mapping_range); -static sector_t dax_iomap_sector(const struct iomap *iomap, loff_t pos) -{ - return (iomap->addr + (pos & PAGE_MASK) - iomap->offset) >> 9; -} - static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, pfn_t *pfnp) { @@ -1332,19 +1332,16 @@ static vm_fault_t dax_fault_synchronous_pfnp(pfn_t *pfnp, pfn_t pfn) static vm_fault_t dax_fault_cow_page(struct vm_fault *vmf, const struct iomap_iter *iter) { - sector_t sector = dax_iomap_sector(&iter->iomap, iter->pos); - unsigned long vaddr = vmf->address; vm_fault_t ret; int error = 0; switch (iter->iomap.type) { case IOMAP_HOLE: case IOMAP_UNWRITTEN: - clear_user_highpage(vmf->cow_page, vaddr); + clear_user_highpage(vmf->cow_page, vmf->address); break; case IOMAP_MAPPED: - error = copy_cow_page_dax(iter->iomap.bdev, iter->iomap.dax_dev, - sector, vmf->cow_page, vaddr); + error = copy_cow_page_dax(vmf, iter); break; default: WARN_ON_ONCE(1); -- 2.30.2