From patchwork Wed May 9 07:48:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10388443 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 04CC660170 for ; Wed, 9 May 2018 07:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA00F28E05 for ; Wed, 9 May 2018 07:50:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DED8828E65; Wed, 9 May 2018 07:50: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 68DDD28E05 for ; Wed, 9 May 2018 07:50:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E45CD6B0363; Wed, 9 May 2018 03:49:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DCA7F6B0364; Wed, 9 May 2018 03:49:58 -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 C46866B0367; Wed, 9 May 2018 03:49:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 81DB86B0363 for ; Wed, 9 May 2018 03:49:58 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id x23so18346509pfm.7 for ; Wed, 09 May 2018 00:49:58 -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=je9ENHe5Vn3J3C3wVwvsXtqUfPbYRc+8MCZDBN7O8m0=; b=b8rVQcaEkoopK22997bx9P0iwIMR3YW2eMTMcVOLIbrcRjxkCn22mAZ1kcj20lpcrv r6f/m3IkxVghdpORvy8whEg3w609HwlV061KyjLJxIWuM5orMPTWO6GNTV76ONWmLP34 CVUTEccYRt8Eb/hwUhzKvmSc8PG4k+/MlchrKwA8pZIOmq2xiuOhkk7IPJB+Ts3BFgu2 H2QIFTeO0yKqAt1DP2QKu/7YE0VKvWiue+dB0WH9wNzL+VwKoMn3QxHCPEz8lnrkUNEC 1wVicomujPFqsBHTQ2qu9/TUdSCYsyidyDDEGCLqwDCwzDsSz3NEC0deCFhWuGEjrUH4 3ZBQ== X-Gm-Message-State: ALKqPwcD3tiCldddC6cZQxZ5Hsu9qYuYNFI09CCNKhgir1d3qtuiPw82 axcvhgFH4Dp9zDYXCHL1pRTObJvtKxsPBRag5PHsS1n3s/lsBRlxaNuBRNOG0j1KAF0/P0s0XSd AvhMcKiWSzjsscz52Jbu8n/lrIqVlNTAhd0maKtR1o6o39vn8heVTe8PIupgY8TE= X-Received: by 2002:a63:7e18:: with SMTP id z24-v6mr333134pgc.276.1525852198210; Wed, 09 May 2018 00:49:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpYoV8RR3bsa4CHP4ilProobGgd+NDYkcFUzUH3CmfAtSyTO43hJ22P57MrdkcqdFuvhMwl X-Received: by 2002:a63:7e18:: with SMTP id z24-v6mr333110pgc.276.1525852197468; Wed, 09 May 2018 00:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525852197; cv=none; d=google.com; s=arc-20160816; b=NEtmvH/XdEw2kqPLjAF9sDcO+YZ9V8oThrdJn55VXiom/FUgevd3eU4v9980mvBDDa FrZCKrWMmMCIogQBcDZ8JnGpKAR5if4oseqsF9uY69zuuM/O5ZvJzDrc4xPqAkYJlvP0 MqH3JxcKlLlALpE40cJy3OCNo7kEpRnhtvOmCpj3ASzNj5VzeanivaP8qGs1D1tRZKWV ebGRjLy7CtQuXJBmRysrwCIdo/28B98+Al1cBeCkR/YQkXcqOT/84HwYi1Fgedwthryl c8hFGL5b820Foh8NdxiNx6jWeRtHV9GwZz48FocZA4gcS6+/9ZRvV3iCWR/YTxDkdYcX G6VQ== 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=je9ENHe5Vn3J3C3wVwvsXtqUfPbYRc+8MCZDBN7O8m0=; b=iPq4oagGgnJdSZeIe8Pc1vvivWGvIkCaNfMmRurjP3tO5usbD8M0va0/XhJTGCSDXe E+CRUYehwVijgzFEYpnKJD1pv33+D3NR8kjWOgxpnAXYJW4kgqmhO7mkLqLW3ZZEGTKU 6ua64PduLbPaFwlXe8AxKGnfrMMrCKut/aHfyFmAYPQqcTVbz4gdPhAs5KFG0mM0jVdb 2mbMNt2DAlnahr9urLfGQ/Tob4OJv+FkTt0AzPpie/tns7cfFw+iQG8Q36nZMA+PxyYS 9gIbQ/O76I+ILouEnrz7D7a+1NELrFZi/UA8wzLzadGGWGTkRmuDmg195mHN/uBSWDq2 hCPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=LQKBqRtz; 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 a23-v6si18078981pls.571.2018.05.09.00.49.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 00:49:57 -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=LQKBqRtz; 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=je9ENHe5Vn3J3C3wVwvsXtqUfPbYRc+8MCZDBN7O8m0=; b=LQKBqRtzDggDEja4jbxJc0EGg pmfd1KLXKO539Lsw5XUAs5mzbW5ldTt1AgAlbCt5TJqyHdOWYg9N0srlNKhialIRKC8P+gJ26w5I5 VFwoXimY3e/Ruc/VjC1tk89bJ54/mcYgLvqiSZxk5uzb3ALnF0mmJC/hhNxDAUU+8fjzRYPh5B+8m HNXREF4vSTn6eoXjoXlo4xgb4dAEjM7l5yUNdbuMPisM7bGG9oIjY9oU2rUg26DtauPTV+vSM41IX qhBEvEi+AZ6HAif+I2kEQVJvOKaHkgEg5a6C2xZY7bRAujTC94OhdWv1N1QwkyP/fcx+OuwOuMsLN /VOhbYPgw==; 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 1fGJrC-0001kM-FR; Wed, 09 May 2018 07:49:51 +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 21/33] xfs: simplify xfs_map_blocks by using xfs_iext_lookup_extent directly Date: Wed, 9 May 2018 09:48:18 +0200 Message-Id: <20180509074830.16196-22-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 xfs_bmapi_read adds zero value in xfs_map_blocks. Replace it with a direct call to the low-level extent lookup function. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_aops.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 09fb10be1256..07d5255a0f9f 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -387,7 +387,6 @@ xfs_map_blocks( int whichfork = XFS_DATA_FORK; struct xfs_iext_cursor icur; int error = 0; - int nimaps = 1; bool cow_valid = false; if (XFS_FORCED_SHUTDOWN(mp)) @@ -432,24 +431,16 @@ xfs_map_blocks( goto done; } - error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, - imap, &nimaps, XFS_BMAPI_ENTIRE); + if (!xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, imap)) + imap->br_startoff = end_fsb; /* fake a hole past EOF */ xfs_iunlock(ip, XFS_ILOCK_SHARED); - if (error) - return error; - if (!nimaps) { - /* - * Lookup returns no match? Beyond eof? regardless, - * return it as a hole so we don't write it - */ + if (imap->br_startoff > offset_fsb) { + /* landed in a hole or beyond EOF */ + imap->br_blockcount = imap->br_startoff - offset_fsb; imap->br_startoff = offset_fsb; - imap->br_blockcount = end_fsb - offset_fsb; imap->br_startblock = HOLESTARTBLOCK; *type = XFS_IO_HOLE; - } else if (imap->br_startblock == HOLESTARTBLOCK) { - /* landed in a hole */ - *type = XFS_IO_HOLE; } else if (isnullstartblock(imap->br_startblock)) { /* got a delalloc extent */ *type = XFS_IO_DELALLOC;