From patchwork Thu May 31 18:06:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10441695 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 AF23F602BC for ; Thu, 31 May 2018 18:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E00B28F25 for ; Thu, 31 May 2018 18:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9305128FA8; Thu, 31 May 2018 18:06:59 +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 3634728F25 for ; Thu, 31 May 2018 18:06:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 678AE6B026E; Thu, 31 May 2018 14:06:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5FCB36B0270; Thu, 31 May 2018 14:06:50 -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 401AB6B0271; Thu, 31 May 2018 14:06:50 -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 F268F6B026E for ; Thu, 31 May 2018 14:06:49 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id f35-v6so13696656plb.10 for ; Thu, 31 May 2018 11:06:49 -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=zbdiSDyRyVcLzDGEJT3lhSaCWdO4FdDc5kqwmrhw2Pk=; b=m+3GX6kIoMnRXE8l6SAQb4nNPind9ylhilxtTwL0KQbIzEtLNewdBWZFf24tGnfH34 1zxWNrUxcHowwNul11g7uUpzTnOgYbbaoBgtBYdyZxOUyl2UAaafkPde9bYI+XXdLWcu A1F76l1saY0P4rqqvamdqtv59DO43N8Vzac8dGhmRKjLBYD1wwVvKrdt3dhuH3s8AuUq Rwa8WWT5U0zWz2y2DBOMqdFn17FX4vFk+xMnHRmmotNzyP5nYfrkylFH0sdpJgubBa/o XVlNtZtOl+9SPpAXjbXxgDKPK28t8KmlQseE5hpgCl28A2UfPUH/0/DwhzlhVzsucGpw WTDQ== X-Gm-Message-State: ALKqPwfac3IHjYhLNMP3w+Xy0RRRJKSwk+Cf9qRHKMshns+M8w1Zt6iD yizdtLGaL2YVk+n85n5/ZcJfxhhbrtXkRmnCTmpVAMg1BEQN+oe5NbvG5MZhxahTA3c7Xkuls0/ FGUlH6kAorT9/l76JglFAgZhfZV8YRxwxQKzaHIYgryRvrsMgj3pcrIHC6BUNbS8= X-Received: by 2002:a17:902:850a:: with SMTP id bj10-v6mr7780435plb.239.1527790009704; Thu, 31 May 2018 11:06:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISyBkXWZDq7CKYVbDQRlg+/9qsoFhnJA31AP8ggLMGNdBjYk5GMJ61nh8BE2WosRKsYzKJ X-Received: by 2002:a17:902:850a:: with SMTP id bj10-v6mr7780400plb.239.1527790008899; Thu, 31 May 2018 11:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527790008; cv=none; d=google.com; s=arc-20160816; b=YNgMuGPGx/Do/OvS4BHhQrR3SW20DHNggEL21az4u8rngql8W5AnMN4AtN7Yf2aXal sVSvKIgRjughvXLKtmPxI61/+wyOn+0m8FjhYiqF8N7C0/kkb1L1MKd/iwv2rq9XDO1U J0ZX76GUqfb4Or9vGwoaCPrAyRpYPiaOWmu9Z7fq9Lirc92IO9fT3cxXhmvoHWJqJFme Jy/8WTXz/iffyPMOUq/UBrJXvtE1npx+4g0t1RdzNY4cn2QTdt0ilTVyzZdBFyUbXGgj w6Y9ivXVvphcJlfTv/ZeKnNcDhUWSpB1TZXukkJcqKEjyQeV6lM19dczwcAMEpti3LrN AzbA== 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=zbdiSDyRyVcLzDGEJT3lhSaCWdO4FdDc5kqwmrhw2Pk=; b=Gmkw5uAvDmL3DGnSmWUITQ9v4GUrZpUqyYS7E+PgJfCsncCYF6sdDXeWPEqL/FD6nI lvZMH4XgSKP2FVYf+FJJBfC06YelPgwB/tWKk1glPehnRI1hN0XhZpXgahDOt3VmSmbE waqQgASnDBkqxknfKWFr9ZZOzqXBVUAG7V+aTD+SoMDQRu/oXuTTMQhmVjQmDOWoqM6v JGh9or2MjPedhXAVH0A0e3FdNg4L61qEJw8HJueT3d/Vrl5Lrm1Lyn48JF4gExurrkBf T+OeGl1Ui9UNAzfk1N5b+uGYBG/510pJ/zHOLB6wpSbxwK7F18Bkxr/cksf+6UHptoFK 56Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=B5vF+xCg; spf=pass (google.com: best guess record for domain of batv+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+67dfbb8f664e29ec4bbc+5394+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 n59-v6si37273389plb.198.2018.05.31.11.06.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 11:06:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+67dfbb8f664e29ec4bbc+5394+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=B5vF+xCg; spf=pass (google.com: best guess record for domain of batv+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+67dfbb8f664e29ec4bbc+5394+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=zbdiSDyRyVcLzDGEJT3lhSaCWdO4FdDc5kqwmrhw2Pk=; b=B5vF+xCgn94nqx8a5XNxj146M S0jJp70en1c8rBWBUH5WzYoUnU1eVYViriRgAMiX+0ufv4jDI+gVOG5Rd/fP9ibNLz4AjgyTqznZL 6duuwr62GlDfnAKdtVX8Jahd+k2+XreUf3klRZ8ddzWLxGFwJzLu3V4/6dkgM6eMwS0Z2b3HYHk5M OfzRJ94zOMzV26vZfim2f3HRFPg/6in+KLVVoZjwQRU0BljioAXCRYZ+UfRUNoXmVAU0zIyNodxKx EaVz79ZsJPYxwtYtNssT6tDyz2ax1mlqePK+nQ1V9y3vHVVRgzQdUaacZ6owxFcqfKF2RpTDQ1IMf ELvsI5Qdg==; 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 1fORyJ-0003QH-TV; Thu, 31 May 2018 18:06:48 +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: Thu, 31 May 2018 20:06:10 +0200 Message-Id: <20180531180614.21506-10-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531180614.21506-1-hch@lst.de> References: <20180531180614.21506-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: Dave Chinner Reviewed-by: Darrick J. Wong --- 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;