From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F16652C83 for ; Thu, 28 Oct 2021 01:41:25 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id oa4so3483088pjb.2 for ; Wed, 27 Oct 2021 18:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=GwABTqD6Tkvmyhn2eav2yJwtbW1tJceyJOpR55oElF8Cpl62Tl7fpwDRJSoK85tktg WcSZzYI1J3gqZuBvcpDIMaP3fjxWgAXp2/71GNnfMTHJUKsW82nQtl3PxcHMw5XB0BGj ol0Z6vrOct/ohRKJEQ4971tC4ghv27sixDbbqgpjArwG9QA0di/1K6lcnuWx54KE2Iv0 PlLdrGzgfAPZa89z4zZVquTUHRBE3n1XFA2eZslunyTMpQ/h+DaZ/H5bzksM/u3SBYyF eGC2TY3oTZ8dh7yBcSfW5yNsChH5J+OrCKaL/dFJg1o9GeZbeU8dYWzE/mMch4zQe8Vr Evvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=JeliaaTYvaAkVcA9kMxK0BPZe+fCobCm/zIdYvcRDDVi3Uh46qlEG3rGOYbERfRv7s T5Oi1JsGwaY81X2ErXLSxCH4KNkW60hgc4WKjiT9fuXAvnApdKj2mE8MhuhTSI9rbZGS wwCnwjmESvJv8EfaysC0WZtyJb9T2gCSsOhc3+8PSXtp/turoNufwAKITBQHcthOHzqq EAWOw2xp7vn1cdQ2OXhZ2/HG5R5YJqS9rQFXiMHh8x5SElVP+m2VflYRRx+2owfz8hrI L+Lf4W9ap+U8VeTdd0jlbp6cdRBH+VcX3MQXW7uyPDmI/aHz6YvgBlzzh1badtVmnDC8 TWrw== X-Gm-Message-State: AOAM531e8QkJT/GC/SywofouadSxiHD3sE7craJU4kf+aQ1oZlwKoBC4 pUr4iCtCtUzKuHZwBfP1sKAFtUBGa6svi1p2cCsaUA== X-Google-Smtp-Source: ABdhPJy+l4+hDjjFqjiYrNzY24jHwGCV82yPyLMD7+lqHF6GqMdOIsbo6sHeOhaMgqSlqL4IZjgKI/J2hsCPQtYDPIA= X-Received: by 2002:a17:902:ab50:b0:13f:4c70:9322 with SMTP id ij16-20020a170902ab5000b0013f4c709322mr995386plb.89.1635385285322; Wed, 27 Oct 2021 18:41:25 -0700 (PDT) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20211018044054.1779424-1-hch@lst.de> <20211018044054.1779424-11-hch@lst.de> In-Reply-To: <20211018044054.1779424-11-hch@lst.de> From: Dan Williams Date: Wed, 27 Oct 2021 18:41:13 -0700 Message-ID: Subject: Re: [PATCH 10/11] dm-stripe: add a stripe_dax_pgoff helper To: Christoph Hellwig , Mike Snitzer Cc: Ira Weiny , device-mapper development , linux-xfs , Linux NVDIMM , linux-s390 , linux-fsdevel , linux-erofs@lists.ozlabs.org, linux-ext4 , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" On Sun, Oct 17, 2021 at 9:41 PM Christoph Hellwig wrote: > > 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. Again, looks good. Kind of embarrassing when the open-coded version is less LOC than using the helper. Mike, ack? > > Signed-off-by: Christoph Hellwig > --- > 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59A74C433EF for ; Thu, 28 Oct 2021 01:41:30 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 015F461106 for ; Thu, 28 Oct 2021 01:41:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 015F461106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B91586067B; Thu, 28 Oct 2021 01:41:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7_kqd9Jh70ty; Thu, 28 Oct 2021 01:41:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4828D6066A; Thu, 28 Oct 2021 01:41:28 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2B986C0012; Thu, 28 Oct 2021 01:41:28 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 640B2C000E for ; Thu, 28 Oct 2021 01:41:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3E5D44010E for ; Thu, 28 Oct 2021 01:41:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=intel-com.20210112.gappssmtp.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P_K5TnXueRK4 for ; Thu, 28 Oct 2021 01:41:26 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by smtp2.osuosl.org (Postfix) with ESMTPS id 34EC940112 for ; Thu, 28 Oct 2021 01:41:25 +0000 (UTC) Received: by mail-pj1-x1035.google.com with SMTP id x1-20020a17090a530100b001a1efa4ebe6so4387046pjh.0 for ; Wed, 27 Oct 2021 18:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=GwABTqD6Tkvmyhn2eav2yJwtbW1tJceyJOpR55oElF8Cpl62Tl7fpwDRJSoK85tktg WcSZzYI1J3gqZuBvcpDIMaP3fjxWgAXp2/71GNnfMTHJUKsW82nQtl3PxcHMw5XB0BGj ol0Z6vrOct/ohRKJEQ4971tC4ghv27sixDbbqgpjArwG9QA0di/1K6lcnuWx54KE2Iv0 PlLdrGzgfAPZa89z4zZVquTUHRBE3n1XFA2eZslunyTMpQ/h+DaZ/H5bzksM/u3SBYyF eGC2TY3oTZ8dh7yBcSfW5yNsChH5J+OrCKaL/dFJg1o9GeZbeU8dYWzE/mMch4zQe8Vr Evvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=3C+sQfgjsCOTUgR+DIpo1gkqDsj/k31vRfxm6e230sI/1mikW0S5Gy8GfpRcBcH0yU nhFcEbK+ELPJk2TgDa98cjKzQ5Il5MP1TBEUYNe7Ue8vl0Kb7FcpfET5hrqQ6RF+u9fq wcKmradri+tI15vO9MOtVqxuRez5gWG2qUxIs79ZU2fd6afsEoKCQ1rg+pDPtJXEOM/r vQ8esQ/BHSeJQXyGUDnvrP5bJUKoJJ+Z4WjnInxQ2qXNMNVBvA9kXFzY0r68pSntmzrH VPwUYdqo6wbrUYA/APvMumRCuDhgePK4hofI4Rt9OI6cVFCRJO2hWu7OkwkW6FeyY6B4 +OTQ== X-Gm-Message-State: AOAM533WnO9ft/5ApapCM1INa4sr0TRtsCFueHaCos6K6g3GAYid11b1 jqkiKyT/KzZMW/z6YwesNKY5WGFOY07fkCh03ha2Pg== X-Google-Smtp-Source: ABdhPJy+l4+hDjjFqjiYrNzY24jHwGCV82yPyLMD7+lqHF6GqMdOIsbo6sHeOhaMgqSlqL4IZjgKI/J2hsCPQtYDPIA= X-Received: by 2002:a17:902:ab50:b0:13f:4c70:9322 with SMTP id ij16-20020a170902ab5000b0013f4c709322mr995386plb.89.1635385285322; Wed, 27 Oct 2021 18:41:25 -0700 (PDT) MIME-Version: 1.0 References: <20211018044054.1779424-1-hch@lst.de> <20211018044054.1779424-11-hch@lst.de> In-Reply-To: <20211018044054.1779424-11-hch@lst.de> From: Dan Williams Date: Wed, 27 Oct 2021 18:41:13 -0700 Message-ID: Subject: Re: [PATCH 10/11] dm-stripe: add a stripe_dax_pgoff helper To: Christoph Hellwig , Mike Snitzer Cc: Linux NVDIMM , linux-s390 , linux-erofs@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-xfs , device-mapper development , linux-fsdevel , linux-ext4 , Ira Weiny X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Sun, Oct 17, 2021 at 9:41 PM Christoph Hellwig wrote: > > 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. Again, looks good. Kind of embarrassing when the open-coded version is less LOC than using the helper. Mike, ack? > > Signed-off-by: Christoph Hellwig > --- > 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 > _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 543AEC433EF for ; Thu, 28 Oct 2021 01:41:35 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C65961106 for ; Thu, 28 Oct 2021 01:41:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9C65961106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HfpF923H6z2yMN for ; Thu, 28 Oct 2021 12:41:33 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel-com.20210112.gappssmtp.com header.i=@intel-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=GwABTqD6; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=2607:f8b0:4864:20::102a; helo=mail-pj1-x102a.google.com; envelope-from=dan.j.williams@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel-com.20210112.gappssmtp.com header.i=@intel-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=GwABTqD6; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HfpF53f6Cz2xg3 for ; Thu, 28 Oct 2021 12:41:28 +1100 (AEDT) Received: by mail-pj1-x102a.google.com with SMTP id gn3so3509464pjb.0 for ; Wed, 27 Oct 2021 18:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=GwABTqD6Tkvmyhn2eav2yJwtbW1tJceyJOpR55oElF8Cpl62Tl7fpwDRJSoK85tktg WcSZzYI1J3gqZuBvcpDIMaP3fjxWgAXp2/71GNnfMTHJUKsW82nQtl3PxcHMw5XB0BGj ol0Z6vrOct/ohRKJEQ4971tC4ghv27sixDbbqgpjArwG9QA0di/1K6lcnuWx54KE2Iv0 PlLdrGzgfAPZa89z4zZVquTUHRBE3n1XFA2eZslunyTMpQ/h+DaZ/H5bzksM/u3SBYyF eGC2TY3oTZ8dh7yBcSfW5yNsChH5J+OrCKaL/dFJg1o9GeZbeU8dYWzE/mMch4zQe8Vr Evvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=T7Wx2i/9g4mBknDN/FCaOBgGd6OkzmiQnePFLEI6PV2+dJ/ED0569kTMlVhIVpe82h 9XjjWL+QBCGeP1EEjiLVvIuT9FSIUotpwxuzDIxn05r+LKeYVP8Mr3q+Jdz5vW5GnpYA WDXWFgU7VilVUGhu0f76lpvftcOObWBKCixB72m4H+Vnjb4alJa5qUNtz+PG02ldqYqK fMxfssH/6LE2cUsoOqwrd7bWW1It3mbWhpTIdLoRKZAW38VjHj6oQ7JizRhCB1akw1pH 1SG8nOn0l1peNRyEMSFj4rg6kOvq3zUpnHpmivbIpZ6LRmjuXJaAHTfLoDJYY9pXRRQC vjEA== X-Gm-Message-State: AOAM530xQdXTknROpMF+WCJawV10qdFSnkzvOi7VQn2rpWHsaPlbQSje sT/3GwIy9n19pZ5ZJ+gHupk3CNU/ltif7INu4pqAaw== X-Google-Smtp-Source: ABdhPJy+l4+hDjjFqjiYrNzY24jHwGCV82yPyLMD7+lqHF6GqMdOIsbo6sHeOhaMgqSlqL4IZjgKI/J2hsCPQtYDPIA= X-Received: by 2002:a17:902:ab50:b0:13f:4c70:9322 with SMTP id ij16-20020a170902ab5000b0013f4c709322mr995386plb.89.1635385285322; Wed, 27 Oct 2021 18:41:25 -0700 (PDT) MIME-Version: 1.0 References: <20211018044054.1779424-1-hch@lst.de> <20211018044054.1779424-11-hch@lst.de> In-Reply-To: <20211018044054.1779424-11-hch@lst.de> From: Dan Williams Date: Wed, 27 Oct 2021 18:41:13 -0700 Message-ID: Subject: Re: [PATCH 10/11] dm-stripe: add a stripe_dax_pgoff helper To: Christoph Hellwig , Mike Snitzer Content-Type: text/plain; charset="UTF-8" X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux NVDIMM , linux-s390 , linux-erofs@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-xfs , device-mapper development , linux-fsdevel , linux-ext4 , Ira Weiny Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" On Sun, Oct 17, 2021 at 9:41 PM Christoph Hellwig wrote: > > 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. Again, looks good. Kind of embarrassing when the open-coded version is less LOC than using the helper. Mike, ack? > > Signed-off-by: Christoph Hellwig > --- > 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A10DFC433F5 for ; Thu, 28 Oct 2021 01:41:46 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E1C361107 for ; Thu, 28 Oct 2021 01:41:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3E1C361107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-k2Sn4s5uPo2Q9DjE7SlwdQ-1; Wed, 27 Oct 2021 21:41:41 -0400 X-MC-Unique: k2Sn4s5uPo2Q9DjE7SlwdQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16CAC1808324; Thu, 28 Oct 2021 01:41:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA0081ACBB; Thu, 28 Oct 2021 01:41:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7338A4A703; Thu, 28 Oct 2021 01:41:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19S1fXwm028883 for ; Wed, 27 Oct 2021 21:41:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D7A82144B22; Thu, 28 Oct 2021 01:41:33 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2840B2144B20 for ; Thu, 28 Oct 2021 01:41:30 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 429698022F4 for ; Thu, 28 Oct 2021 01:41:30 +0000 (UTC) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-497-ERgbEc9ZP9eXFXdMCm9Lvg-1; Wed, 27 Oct 2021 21:41:26 -0400 X-MC-Unique: ERgbEc9ZP9eXFXdMCm9Lvg-1 Received: by mail-pj1-f44.google.com with SMTP id x1-20020a17090a530100b001a1efa4ebe6so4387044pjh.0 for ; Wed, 27 Oct 2021 18:41:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+57OykW2c30gUJR4jUskDQk4x1gwxn9Qbm17JsREFMA=; b=WpvcEC//DZG2pu9pzZD8hmPLZuZNIcJxZSkGfBy2PnhnI2+te4MgdauBg4P0BAyx/T Edv/UUYCJOYWVVhJ6GFQTmdwyMH00RVulG2K8Ka6rjHixxX+BHRHCsY1HVrDiPMq0XS5 gCT7KfL6vFFk/NfCe7MjOvX3X4uIlOC/CzvlmTXYkzewXyGLtdgTf9McUuvsGpOyWjLu Qnlwt/8hQmczAM/XG8mf6xl8LpKXrtwXE4YUzesZBlyItVCuB9DspXI2FHepFcyH+Q9M zNDiHxhLA26S+QtLL/IztY7iPdf39k/sn/yKPEY8tsYcQjyRGhBRjgJjPhZxsqvvQfy/ C8sA== X-Gm-Message-State: AOAM531zZ83XCgu2bTh5AiBFVO9I/JSdn9V4nhLgqnq8waf3I5Ppuds0 fyGLBcGpmq8p9v4XezkdRcZIHQv0ZiEeq+2vmj9vMQ== X-Google-Smtp-Source: ABdhPJy+l4+hDjjFqjiYrNzY24jHwGCV82yPyLMD7+lqHF6GqMdOIsbo6sHeOhaMgqSlqL4IZjgKI/J2hsCPQtYDPIA= X-Received: by 2002:a17:902:ab50:b0:13f:4c70:9322 with SMTP id ij16-20020a170902ab5000b0013f4c709322mr995386plb.89.1635385285322; Wed, 27 Oct 2021 18:41:25 -0700 (PDT) MIME-Version: 1.0 References: <20211018044054.1779424-1-hch@lst.de> <20211018044054.1779424-11-hch@lst.de> In-Reply-To: <20211018044054.1779424-11-hch@lst.de> From: Dan Williams Date: Wed, 27 Oct 2021 18:41:13 -0700 Message-ID: To: Christoph Hellwig , Mike Snitzer X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com Cc: Linux NVDIMM , linux-s390 , linux-erofs@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-xfs , device-mapper development , linux-fsdevel , linux-ext4 , Ira Weiny Subject: Re: [dm-devel] [PATCH 10/11] dm-stripe: add a stripe_dax_pgoff helper X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Sun, Oct 17, 2021 at 9:41 PM Christoph Hellwig wrote: > > 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. Again, looks good. Kind of embarrassing when the open-coded version is less LOC than using the helper. Mike, ack? > > Signed-off-by: Christoph Hellwig > --- > 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 > -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel