From patchwork Wed May 9 07:48:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10388347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04FF5602C2 for ; Wed, 9 May 2018 07:49:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB39428E05 for ; Wed, 9 May 2018 07:49:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E008728E08; Wed, 9 May 2018 07:49:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79FD028E2B for ; Wed, 9 May 2018 07:49:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4BFC6B034A; Wed, 9 May 2018 03:49:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DCDAC6B034C; Wed, 9 May 2018 03:49:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C27B96B034D; Wed, 9 May 2018 03:49:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 704086B034A for ; Wed, 9 May 2018 03:49:08 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id s3so25858472pfh.0 for ; Wed, 09 May 2018 00:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ovR+ykKzYRVOWEQ+bwxlpgxkireSXIZJp8TKQmqHFxs=; b=fty90gseb5gudHayl175wF9/T6wi/OLd/NdOXdvwF7vyaVoNZk96Rb8J5kUaVy+GvR tOe1d87VLvplvCisd14ikjLtEdaAxBrUdQKIHmwQQs4sz8q6jCNqBcOTWRNgRiwpHwmW 8qSzk4CNQ4GMVVTusttEuhjcKDMg29Bor/fAhHr5YNx5VsmsMgQZ5ZRW67K/UueshtAK owjzr+c9VNa6b01YREsbbG5EHAVUB7URvd8AngesuqP/5YmeqiMoi2709pYE7xmglJ38 HnKt+HFJH3wrP25IbXU3m7qTP+czn+SFvmaItQ9ik4eA+krQGYZMwcmpByyTGuNTz/8E v6xg== X-Gm-Message-State: ALQs6tB/Q3ihTDZisIheMX+rp5Vn4FYv2qfUEakOAT7koGDT4AgXr4TN fttOma4bEF6Vfjn2PhP7vFk8t39vBCcqi94sK+anm7nqK2TvAmI42/Q0inKWCkLFNG0+lHYczZC ZjXUU89K2rQGOKa0BK+6t0iY4FqGzTUWiNrNL4HX/tRZy0L1/6eHXjgIhakLPie4= X-Received: by 10.98.155.141 with SMTP id e13mr43361840pfk.157.1525852148157; Wed, 09 May 2018 00:49:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpuNbK7Kv3fJPvk199kJzKoHsLyFjN30N8RdAIVWVXYaM6o5c5x30pMmmdXkvVWnCilQI8T X-Received: by 10.98.155.141 with SMTP id e13mr43361804pfk.157.1525852147311; Wed, 09 May 2018 00:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525852147; cv=none; d=google.com; s=arc-20160816; b=Isi6Xpj4Cc2Wrgwdx32E5ilSQ2jqnhLvQh+jBKH/gAUxUD8QwswDFte8kY+a/+Ti2R 5aZHiRlw4JcuqezS5uLdDha7rTcXBGvw8p5SfwCIQJQGt5rCwJuuWKQIkhR7b7UquSEo 0vEL4JtKyoRvvEYKT71QxJqGSrXl0U5vHDRO8H7iVNhjoBxT7LvvW6z2f1GqGDVrvuid DE72CWhA0ZVrse69e4uMhVMeL+UP1byqUrn8b82QIibrpHFeSEZ/QZclXHxERswNGuwj H9DuRmJTtlp8sOSuq1oD4VUwKG6FWrgn3jB5UHHL/3oPPza01uFpBoebdvyGJjpWZQJa 70wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ovR+ykKzYRVOWEQ+bwxlpgxkireSXIZJp8TKQmqHFxs=; b=cQcP3moCR5GAHaNR9mg52p+/Qrp/vbxNozLZ7IWstRzag8aLH7nCybp5l+okkTMW/v 6OrX6f390YzNUCTHtiP4JKg7ezmD+vd1jhvIVXEN9CZI0+zX6YsJkftNpm7M0Gm/Tlms 4t4Dkuv69yb8IPl2WBbrkmPS8RZ9P6jfI1B1WakGRzNNr9sTGbsWdi0SmRqQZUeaOD7r kGf1J7GTnzj8W7du0J+k2YzN0Adgv9VYloDGgSwmsmjDiqIu/xCGqsaC0PQaOuRXi4TY MzZIQmlJ/2RIwruopa27tR3woji7ZnKLeCZ1No1eSrxskJMfpocsen2XBAqbc1jJBRcm xakA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Z5DHXVPn; spf=pass (google.com: best guess record for domain of batv+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id j19-v6si1525130pll.518.2018.05.09.00.49.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 00:49:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Z5DHXVPn; spf=pass (google.com: best guess record for domain of batv+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+e0efdd19ce80d487e3da+5372+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ovR+ykKzYRVOWEQ+bwxlpgxkireSXIZJp8TKQmqHFxs=; b=Z5DHXVPn3gOfMZWGVdpx9LtMN Rh3PMl+P6SrFaI1hNBw93iYVVG0IM18+22Noh4o7+OpETrdEOVYvaS1bq82OStu1IYehHpvlKi/3M nKplJO/GQqIBpjvLnTGDNiv8mjOEsPI2v5NU+lNp1l8UdpsVSK2Z39RHDy1KHUeNL/9+SjyCZQa3+ vw7OjepGyEszTDHbA7ckelWEFJDXOJwHlVBA47isBREohycFepR9DoRNt77El/Ki0ardvJU/w2J2/ 4GXlEzKo13m/dUC/GOsbzy747sDlTo0f++cZn3qJzuZ99HEu5e1+CMe5aFns6+XPDhIMtL6YpKAi9 uuszvapgw==; Received: from 213-225-15-246.nat.highway.a1.net ([213.225.15.246] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fGJqU-0001TF-6r; Wed, 09 May 2018 07:49:06 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/33] iomap: add a iomap_sector helper Date: Wed, 9 May 2018 09:48:06 +0200 Message-Id: <20180509074830.16196-10-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509074830.16196-1-hch@lst.de> References: <20180509074830.16196-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Factor the repeated calculation of the on-disk sector for a given logical block into a littler helper. Signed-off-by: Christoph Hellwig --- fs/iomap.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 58bb39bac72b..af525cb47339 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -96,6 +96,12 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags, return written ? written : ret; } +static sector_t +iomap_sector(struct iomap *iomap, loff_t pos) +{ + return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT; +} + static void iomap_write_failed(struct inode *inode, loff_t pos, unsigned len) { @@ -353,11 +359,8 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset, static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes, struct iomap *iomap) { - sector_t sector = (iomap->addr + - (pos & PAGE_MASK) - iomap->offset) >> 9; - - return __dax_zero_page_range(iomap->bdev, iomap->dax_dev, sector, - offset, bytes); + return __dax_zero_page_range(iomap->bdev, iomap->dax_dev, + iomap_sector(iomap, pos & PAGE_MASK), offset, bytes); } static loff_t @@ -945,8 +948,7 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos, bio = bio_alloc(GFP_KERNEL, 1); bio_set_dev(bio, iomap->bdev); - bio->bi_iter.bi_sector = - (iomap->addr + pos - iomap->offset) >> 9; + bio->bi_iter.bi_sector = iomap_sector(iomap, pos); bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; @@ -1027,8 +1029,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length, bio = bio_alloc(GFP_KERNEL, nr_pages); bio_set_dev(bio, iomap->bdev); - bio->bi_iter.bi_sector = - (iomap->addr + pos - iomap->offset) >> 9; + bio->bi_iter.bi_sector = iomap_sector(iomap, pos); bio->bi_write_hint = dio->iocb->ki_hint; bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io;