Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp101166pxh; Tue, 9 Nov 2021 07:55:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzb5mE3XYzy5ySAGqIxm+wTiKpRkIoApUDvQdj4c49Za1Gt2YDzRZu59br7ktN3FSOy7y4b X-Received: by 2002:a05:6402:50ca:: with SMTP id h10mr11377047edb.277.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=i6KsGYJ+YH6mVrUm9N9dsunBWhIk/GkkZOsF31CpC+TyAfO1ls7g5IRZpeC2oMEgY5 DXauA87iTlVDBVcmNkR+GETwEna+7ZCvJZpGVHLSXuhJn8TsyDUnNyPd9TOgBDUQt6WE pcP6f9rOKWsZFZgWoEw4fpGOhCwi5TTwg+pxxo5DRRm6/KFboSvfv8rRhzCRnDnoKkcC 9jqzXz9r2WD3egcNhLAllwuMFFUVQAopHRGSmL58y/hlCwN2cVazysdTjezUVv7f3+pG guuqlwgdAyEr8dWeRIcwFmONyJSvdyEy2Vpf0zgrXbNVYSv8dlCQQRmB/cby6d3DGq2C ZNoQ== 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=NNTeFWC3odhppXufM7f0QQ7BHDvq14swtd/2bq0X3Oc=; b=ZugKJ9M7xAXi1zkQKLGcad5MkEY7mKzvR/f6xDYCzwj1aK9aExCxhovivY8i9P1931 MK5NQrJZ7Znap85yrBeGRXdLmc+RhAgshBdOZQHFA3CAseaySLp7utVVJGTlI+BJ8Pjn BdCmU9/5xg9OYXHt5gnJAPriooVrcFNFWJi7l84tzEtZ5BdCh2v/ak3wnTwMII+fpcxR ygw5y7eRdGhdpFG8gwzOOaTU+/Tm6drMsbgJV94hpt0DKIAIA6veEf5l52Bp+4OU/qyB 01UoL57DKVOetdHfdfUF+zfrC3IBRghXqd3hqpVqiDTh4TsEfV/CmiFdN2OYbLbXuWzP 4z1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pkpKIm7D; 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 o4si30401969edv.451.2021.11.09.07.54.59; 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=pkpKIm7D; 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 S244177AbhKIIgc (ORCPT + 99 others); Tue, 9 Nov 2021 03:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244175AbhKIIg2 (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 B8916C061205; 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=NNTeFWC3odhppXufM7f0QQ7BHDvq14swtd/2bq0X3Oc=; b=pkpKIm7D259VFNumCLiZQjw0GP 8SEzTbzxgkhrnPH7cmrSRQV1fb+fgE+/nsHgRq9+ZwmeatR1T51DbO0CiKD3m+YYt3bsy/wTUwWYi l2N9S7GlV1s6/4JMMdgC8l/aHzoVti95bP+uctparV7vxN1oLizGWjp+s+tA5TI0qnKk70akpeFUM WOvtvv1jNaar0mb+3pHgxV5RP2sZn3qVtPJNJgPGAiLe5LAYjfdkkg8q9uH0tVhO2OXeyVxUcC5Np YR6ztHMoJ1pmcJKhZVD1S7Vy3XVGi72y2QndZZRxKYzGqVEjVTVNrveRGmZzMHp5hWgIbPVgbLZnA VcI6cT2g==; 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 1mkMZR-000s1l-4A; Tue, 09 Nov 2021 08:33:34 +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 11/29] dm-stripe: add a stripe_dax_pgoff helper Date: Tue, 9 Nov 2021 09:32:51 +0100 Message-Id: <20211109083309.584081-12-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 Add a helper to perform the entire remapping for DAX accesses. This helper open codes bdev_dax_pgoff given that the alignment checks have already been done by the submitting file system and don't need to be repeated. Signed-off-by: Christoph Hellwig Acked-by: Mike Snitzer --- drivers/md/dm-stripe.c | 63 ++++++++++-------------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index f084607220293..50dba3f39274c 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -301,83 +301,50 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) } #if IS_ENABLED(CONFIG_FS_DAX) -static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) +static struct dax_device *stripe_dax_pgoff(struct dm_target *ti, pgoff_t *pgoff) { - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; struct block_device *bdev; + sector_t dev_sector; uint32_t stripe; - long ret; - stripe_map_sector(sc, sector, &stripe, &dev_sector); + stripe_map_sector(sc, *pgoff * PAGE_SECTORS, &stripe, &dev_sector); dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; bdev = sc->stripe[stripe].dev->bdev; - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); - if (ret) - return ret; + *pgoff = (get_start_sect(bdev) + dev_sector) >> PAGE_SECTORS_SHIFT; + return sc->stripe[stripe].dev->dax_dev; +} + +static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, + long nr_pages, void **kaddr, pfn_t *pfn) +{ + struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); } static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) { - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; + struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); } static size_t stripe_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) { - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; - - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; + struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) - return 0; return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); } static int stripe_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, size_t nr_pages) { - int ret; - sector_t dev_sector, sector = pgoff * PAGE_SECTORS; - struct stripe_c *sc = ti->private; - struct dax_device *dax_dev; - struct block_device *bdev; - uint32_t stripe; + struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); - stripe_map_sector(sc, sector, &stripe, &dev_sector); - dev_sector += sc->stripe[stripe].physical_start; - dax_dev = sc->stripe[stripe].dev->dax_dev; - bdev = sc->stripe[stripe].dev->bdev; - - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages << PAGE_SHIFT, &pgoff); - if (ret) - return ret; return dax_zero_page_range(dax_dev, pgoff, nr_pages); } -- 2.30.2