From patchwork Wed May 30 09:58:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10438165 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 1E1D8601E9 for ; Wed, 30 May 2018 09:59:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EB03288E8 for ; Wed, 30 May 2018 09:59:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02FAC288F1; Wed, 30 May 2018 09:59:00 +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 911D6288E8 for ; Wed, 30 May 2018 09:59:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8CC26B026E; Wed, 30 May 2018 05:58:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E3C1D6B026F; Wed, 30 May 2018 05:58:57 -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 CDB226B0270; Wed, 30 May 2018 05:58:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 8DB366B026E for ; Wed, 30 May 2018 05:58:57 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id v133-v6so4960228pgb.10 for ; Wed, 30 May 2018 02:58:57 -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=i3Kc2Sdq0Kto10RY8JbA9d6JFoKNBfdFYcJsApkqm+w=; b=I9fHOFu8h1ZW2T0fkgnbUvoHpaIkAnCT0AVE2vb/e5y1o9rvKgLPc00qTMEN/b1dqb 0XMdUvXmNIo7PksMHi+2yy2JYJOKmVTMH6v0VGLqhsb7x/6fbIj6WZCPliqjt2RUGUok T8VXNVy6QIOmZ2JbZdGyrCv7AH+IJmOicP/6nUYTAB30g412tJgl30B0a1Ta7m4XbcEl zWCAlpCR8Z3wRMO7YNCJHily57GUw65XBwqxvIbGrB8ehQgPiVSd136rkuNg1bT9xBnD ePrvRvRXFsiuULA1tE8Kmyg7O1/93E4WpvwC2sMUsBsmFPehHCk49dX0dd+J2dikCELH S9XA== X-Gm-Message-State: ALKqPwd1QCMQCFVtTzt/4iAHiUlyJHa9gyw50A4r1lalDN950kn0QKf9 TfMR4cAHOmYsK+CN6XJoo/lg2NgWbCpW4oszNPCG2Q7RmHUn0oMFGAb7x3b5AcCfojzDA9FuF5R xut+5FxbBGQC2lQ7+9z2Tq+gqi3pY52wK/i99PoCogpQHhSyHzLgvEoX2O4ZxiJ0= X-Received: by 2002:a63:2b46:: with SMTP id r67-v6mr1658101pgr.89.1527674337279; Wed, 30 May 2018 02:58:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKS1MiIJ8TC8njo6LC54KaCTYfW58vpj1IpFvf20hbdL6UovJ9QYeKAXSOKOKsRCCU+pusm X-Received: by 2002:a63:2b46:: with SMTP id r67-v6mr1658075pgr.89.1527674336501; Wed, 30 May 2018 02:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527674336; cv=none; d=google.com; s=arc-20160816; b=ncq/JDt0JilWoGuugyTqU2rTunD0lHRkjo6uYmS4pQRBLBX1ViG6HnHfidxD4ex4V9 1GVDTz+DzwHZKoVOJBgoPD6pifPYtxAZ7LMeBhcPqP0/kGkA6s9GXcBG+OpLLnjftbr8 P+dEXNiCarbd38HKHNIye+ctdSRi/w9plOV6lcP4xteCXMPY+LX6NvfwQDkfyJ+vzFGg MvfC+sUUiNuNpub8cZAZLvS4/SOfGbvLcg6i+EiKNPR/4omsVBDgb2gwagTQiwRpdUA1 R6HHrwxpQpS5m5qo4l5meINe9I7NUr7c6f/ixqNv6Vbs1wiqI1kmTnPktuddSDyp2T6B v46Q== 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=i3Kc2Sdq0Kto10RY8JbA9d6JFoKNBfdFYcJsApkqm+w=; b=iytWVaKoS952ArEd73Miz6Lzf51OYZ3CAJPft89lUah4sEvjI2wUhpgXz6RSydGyim 9wg7N2/lu86DefiGBf63mP8bnPJMSJa4C3A1/y5SEAWwyod0jRhhqUxSJjcAGgYtv6gw 2wkfrKQ/OzYPfzXMRDue3rg1rHWYXSGy4GIb+QmHm6f0IpqE2/Si3Tb6mxj+iLakUW4F ps/Ql7OSf11RY3Z0alo4up/WztKcJmpJF7Ir8Jc1ahLAfHAd27/0F2BFL6jla36a+8Cc niFP/GWFtaurZqYG6dfQlo64Jwl87TF6nvPl/6swRf5NXybb856HxIQDm41XKceSS/Yb MrvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Gb6wSY1q; spf=pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1f4557cc97fec8e307c5+5393+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 w1-v6si27219602pgp.10.2018.05.30.02.58.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 02:58:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+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=Gb6wSY1q; spf=pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1f4557cc97fec8e307c5+5393+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=i3Kc2Sdq0Kto10RY8JbA9d6JFoKNBfdFYcJsApkqm+w=; b=Gb6wSY1qn2rhog15AvXXObLnh NIRAfM0KYOwfhMx93/gDHzKM2oREuuBpTp6rJlvRi7HMmc3MPhiUeL0L0FGtw/01/9F0KV2CUhJff bB6vvO9NjqEkY6TKyf28rtT0fBVOds+3H2vAOl1S2ytKw3qEg1TuMR3oEYE+DvjNUEUB8OrMUvfhm MJLvNEwKC5NQSdxzIXUzLhdQZfrjFOQZ8+8JfVEO3fSAMkLv4hcxQ/UVfEAtJxwLvemZqvBWtQDkv pz7RMljGsndnhLPO14BlkKkAslBb1rtJ5/vOkPWs99K4WA6lPINvz0IppOx4MlK7GNFtOeaXxjEwU 1DTCBMRzw==; Received: from 213-225-38-123.nat.highway.a1.net ([213.225.38.123] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNxsc-0006XM-T5; Wed, 30 May 2018 09:58:55 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/13] iomap: add a iomap_sector helper Date: Wed, 30 May 2018 11:58:09 +0200 Message-Id: <20180530095813.31245-10-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530095813.31245-1-hch@lst.de> References: <20180530095813.31245-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 Reviewed-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/iomap.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 85901b449146..74cdf8b5bbb0 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 @@ -839,8 +842,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; @@ -934,8 +936,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;