From patchwork Fri May 18 16:48: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: 10411275 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 CBD7A601F9 for ; Fri, 18 May 2018 16:49:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCD8D28619 for ; Fri, 18 May 2018 16:49:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1F50288BD; Fri, 18 May 2018 16:49:22 +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=unavailable 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 5410428619 for ; Fri, 18 May 2018 16:49:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29E956B0610; Fri, 18 May 2018 12:49:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 24F3C6B0611; Fri, 18 May 2018 12:49:14 -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 0A2FA6B0612; Fri, 18 May 2018 12:49:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id B21BB6B0610 for ; Fri, 18 May 2018 12:49:13 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id d4-v6so5333223plr.17 for ; Fri, 18 May 2018 09:49:13 -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=DS1dd6L5xr52k+80Wdf/qV974m9yfNNSq1+im5KfuKc=; b=UKCHf5yPP61OwpuZEhYAMkuIxVQmE1Gy/n5N7I2ru5RwWjB/gpTtR/xd1Aad0rYQhI q0DpvLk6l+DmVy4eSjWh3rBNfMDZg71Zs/w17F5jRRC8OmkubUlb4qvpx9mlKhBvUDea cb8aDn9m0nmk7VZPPy0p5FRAHga7G702WUJBMcXC69MWZwFwTCO5zXMOtzB5pHXEkzcn BNHunjr6HyZ5dCJuJpv7y5LL7N8zYt5B7Fq6bLI/SkhscjGGq8X7g/9ZecF0Gq6OoUHA nUfF/lQouqqLJYImgUvApCxXxcFrUfM0HXCCN1aAcBO/4LdZB+NrYCPRV7pqPuk1pbV8 yoAA== X-Gm-Message-State: ALKqPwcK4j8uIZadd/DeQDkQ2z95xfhH66etvn2Kg5RwFt6w5ctH7iTi LGIEakxtKzIdupgkBoFSLd6z0rDPy3eGgsmjrYC/CwLewstctSQKmBXesD5fZPxtrmrVB4+aEyH JEnuZCUuOa0F9FNAgWCGRzpFdpKNJkiA7m3JSVPWMZIgtblkHKRHzw25zaGv0k/U= X-Received: by 2002:a62:f24a:: with SMTP id y10-v6mr10200070pfl.75.1526662153099; Fri, 18 May 2018 09:49:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpBMRFQNk/Cs7KdeYapu0ndM7XxOp98m/19Xr4erSK2LvJzVTZj5x5ucCpYzBEdR2MiH5jh X-Received: by 2002:a62:f24a:: with SMTP id y10-v6mr10200035pfl.75.1526662152301; Fri, 18 May 2018 09:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526662152; cv=none; d=google.com; s=arc-20160816; b=wbu7oj6J6LKE3iiWR0CaT6lAG4ift0sqYdpSfuGI2wPcmk7dpiIxlMUv4K4N5BjGnl R7wjDNU2H9co70qiIixGfz1nkdVv/Xu1q/GuT5XnlNoOudZyYblWuyn+4keZ3XgtUE7m eniAxzC+O8FyG6D+9mvAY39tPSMuZwofxP6nqDF4An2Z7sviJbJ5hsWQGCv4nuv5lEqs w+4Y178GN6by3iUs5Lc3zahb8vPHOFlxIxrxvLR34qrNF/C6fMCMphS74m4BYDwliOGc q9Uvw51KKqngaMqC+wmwK2ftj7yCxN5S1NFIZfQCxWjQRQhSrVyN1imytODPkGGcC7mX iYmg== 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=DS1dd6L5xr52k+80Wdf/qV974m9yfNNSq1+im5KfuKc=; b=ZekRTuoxCpvEIly9yHgKviYpSRES7AFrg6DVlpwHbZTFxSXo9P4b5KGq5AaXlcCpnX GyLotBeJ6c2y/bYZGqH7lu2st53WvshITiDyZYvv00050YbzH8QoG5mN636OStt3bLch R//lbm6ec2OAGv2JDWoS3E2yQvc8H0HoyU40h/ekqwje17906DtK9cW9wNEq5O+YGCcE AbhhBTPxWUO4No7AjxeaprcorCWBThfYKk9XwD/nVcaip5Xry6FrvBpGRJxq43dCEAqp yBLuCFbHl0FMr3VK0PwEmPOlyG16HDGiG4ZFcAKtDRT0qzp2Q+uCsnyDu1VUskwx+PZ5 mV0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=sufs7m09; spf=pass (google.com: best guess record for domain of batv+77ddf8e9b1b344f28472+5381+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+77ddf8e9b1b344f28472+5381+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 u74-v6si5872524pgc.186.2018.05.18.09.49.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 09:49:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+77ddf8e9b1b344f28472+5381+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=sufs7m09; spf=pass (google.com: best guess record for domain of batv+77ddf8e9b1b344f28472+5381+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+77ddf8e9b1b344f28472+5381+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=DS1dd6L5xr52k+80Wdf/qV974m9yfNNSq1+im5KfuKc=; b=sufs7m09qT2xZGvH76JpQfIIS RitRWyPE6NzQuPh1oR4fDeCG6YuGlWr3ZDWtZ+aM8zeuR5vL8YNL8hLmpod+cdlgAZZPdtog2IlMC 9QBoTuL37xzgAGWKxwPa0UVMAIlTgr0cUEcZ7BwrrsMWUC4FO42XfP5ppuiK9WksF9edmi90gSC3j 6WRzJ6Z3/4UvkqY+1eAKS/16CgdZANZQXDIkgz/SBcg7u55MxafTeRk6YdqLwqvop2voTg8kpw8x7 KI/2+C5CalURvrzEhqvRTLOsHqXgQfnNssUNOeDp476oFuFCCfiQQslyLh+c8zAkpENJLHHHA5sbD cOhxOo6RQ==; Received: from 80-109-164-210.cable.dynamic.surfer.at ([80.109.164.210] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJiZ5-0006Y6-Bq; Fri, 18 May 2018 16:49:11 +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 13/34] iomap: add a iomap_sector helper Date: Fri, 18 May 2018 18:48:09 +0200 Message-Id: <20180518164830.1552-14-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518164830.1552-1-hch@lst.de> References: <20180518164830.1552-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 6427627a247f..44259eadb69d 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -97,6 +97,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) { @@ -354,11 +360,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 @@ -951,8 +954,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; @@ -1046,8 +1048,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;