From patchwork Wed May 23 14:43:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10421549 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 3E21960327 for ; Wed, 23 May 2018 14:45:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C885287B4 for ; Wed, 23 May 2018 14:45:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F719287E9; Wed, 23 May 2018 14:45:04 +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 BEE8B287B4 for ; Wed, 23 May 2018 14:45:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B0F16B0270; Wed, 23 May 2018 10:44:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B7106B0271; Wed, 23 May 2018 10:44:43 -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 233CF6B0272; Wed, 23 May 2018 10:44:43 -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 CB6376B0270 for ; Wed, 23 May 2018 10:44:42 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id b31-v6so14397019plb.5 for ; Wed, 23 May 2018 07:44:42 -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=FS2ioLBtaeugrOmTPxKhtn4/Vpe5tVUh0JiquVNvxo0=; b=kzToot+QmIFjNQfI0LCvxYc9L1RAvWLkZuydwyDtx8KwF4k/5EkTAtVevHIxd753k/ pPyYKP/zSVslZs9zCwAZFyinnQgRJCKzJ9wCw74ATYz9M1njZlpxqS5njuErEoFN9Swy YhXdUOAI0crmZjMWlVVHvnp6i/n1zRfSypcdEUFsbdUX+Q9U1KM9i0f31oqIsQX11185 R0mOULsTgefVFGfxcCk19OHfF/gV4MovFh/s8cTd5IIqvHm0qxtGnnMnsRfjK3TgB73U l7NRR0N1YBgGnaWSi4IJ2hHcIdSo3e7+euC10/UoZ9McqI3gNYYk1t+rq93tH71eOGQY 8vZw== X-Gm-Message-State: ALKqPwdnUTxY6lAa/9yIlPNX8tRJAvqTKjT8IEvbnL1ZMbav3QHc6tMr +Olz/Dy0Y+RaRJuQ65LGEoIjc338hNC/kzXQydRTm6YmSp627ZSObfKfUkio5nNwv5IdpHtHI3o WiqCfxhqHGGLNBs+XgvA3KE6HiSAWjgPoVE9CkcH/cueM8QdKHH/nIlsK2Tv7hv8= X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr3199586plg.229.1527086682543; Wed, 23 May 2018 07:44:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpd1D3YtMq/UBp2t6ILvQuJTxnGbHr0QJZAz6oLRQIbSyh+7YjcIEoF7oPFkGoU0edcou7A X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr3199551plg.229.1527086681878; Wed, 23 May 2018 07:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527086681; cv=none; d=google.com; s=arc-20160816; b=Lvu+vUUEqaoogjYy7oJnxUmPSbYfvQikP6jHktHTUMMZMHTL4USx9FIVbKVd14Bakc OSvPTaN6UYw3AyorvyIzQMahS0c8TsntahiIPrvfgKQOMiv0NXURtb9mT/8lJ8N5ayQl 3+dHozLeqblSujvNfhU4YKaRYeh7y/nDg96GHRmdQSLJ2/n/RtzUJN2hjPJUKG0WEPTS 3o7XSIDlFxLstuBSl4drmlZvV81wuS2lKe96mWVJ7oCzsBqn2lx352Xi0shOkqNnqIUW SCUhuy/Nd4UJsy3nqMSzX90OvNhEXXLqE/PYNPa2wl3s7gy4rOMY6TkZ4h5D8N1jMx14 iaKg== 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=FS2ioLBtaeugrOmTPxKhtn4/Vpe5tVUh0JiquVNvxo0=; b=ftaOo0QMJ3PfRu7aEXm2VXnGc6030jLT5kYBWRouB2N8DtOsohDTEy33Bmf8pkWEuS t8n3vPPy+1L69c7wOgNMyScp8khEiwowjmS0X8j9xzvc3pcEZbgjEvkMaa/y0g0OTZtI 8eBF24PHHkiDecaFsQ067w/W6ufkCCw84boO7VxDq+9ImI4g3ZlGu5P1qdW98iFqrfxc LXNJ7STk2ZVY/cGUAgw21ihMaf39kXyXkAnxvhsVGarcAIlRxUSHMdAa8KZEVhJFPeN5 TW4dPMbpNY1q/gBwviY1hI1CAlBZJuytlFCneIjTiypGfPcpfZdBKSJi/faRMw4UVHao NAYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=spcivJbF; spf=pass (google.com: best guess record for domain of batv+df5a2477ff0fa86e9985+5386+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+df5a2477ff0fa86e9985+5386+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 34-v6si18648755plc.346.2018.05.23.07.44.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 07:44:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+df5a2477ff0fa86e9985+5386+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=spcivJbF; spf=pass (google.com: best guess record for domain of batv+df5a2477ff0fa86e9985+5386+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+df5a2477ff0fa86e9985+5386+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=FS2ioLBtaeugrOmTPxKhtn4/Vpe5tVUh0JiquVNvxo0=; b=spcivJbFYNqhNQIpykKWWlTLF EcYrHb6N/yb2Uj83uPQxczEEliCJPKpY8s1h0P1RcGZp6TPL2Ti/MExsc5M32GT1PtjXwRFVFTsGb fw/B/vLfyQhzrojpSwKym6bqxrt/cM60UL0WMyef8ddzN0Zew/62Rxg9ah2q4uuP81pgFs0Z0x4mF lsZYlLrf35ZEiNS+pq1SLg0OrQS/2NTOgu8jU5QTAH9VksHwSCHM9Xmi9UGHfg1b5xfsnXeEBQnFN YEGuecDD8nh6+Afbu0+ars69Vzd7QHQJhBUY04Y6AFppteVZ79x6Mn7t4luqBCWlrWJ67rAPd7hix eh8vVtfGg==; Received: from 089144199016.atnat0008.highway.a1.net ([89.144.199.16] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLV0K-0000NM-De; Wed, 23 May 2018 14:44:40 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/34] iomap: add a iomap_sector helper Date: Wed, 23 May 2018 16:43:36 +0200 Message-Id: <20180523144357.18985-14-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523144357.18985-1-hch@lst.de> References: <20180523144357.18985-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 --- fs/iomap.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 8e28f25f086f..f928df4ab9a9 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 @@ -943,8 +946,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; @@ -1038,8 +1040,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;