From patchwork Thu May 31 18:06:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10441705 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 A18F2602BF for ; Thu, 31 May 2018 18:07:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F2A728E05 for ; Thu, 31 May 2018 18:07:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83EB228F91; Thu, 31 May 2018 18:07:03 +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 2E07528E05 for ; Thu, 31 May 2018 18:07:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABFDA6B0271; Thu, 31 May 2018 14:06:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A44616B0272; Thu, 31 May 2018 14:06:53 -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 8C1316B0273; Thu, 31 May 2018 14:06:53 -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 3B6246B0271 for ; Thu, 31 May 2018 14:06:53 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id x23-v6so13050243pfm.7 for ; Thu, 31 May 2018 11:06:53 -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=Z68pN6Y7MM71Y6qfPB6Rqc/aRa02l0lwZocIukU+9Us=; b=qa1zkKXYpUV9MExy4CtzxnNxH2ydO2N3jtde0ftQaLgGbyXU4P/8l99gEQHFYxlwpF u6fUv7GgbhOpu6ADS2QLoN7kScz5B6oZZlbM1ObxQt9JtXTOu5UG0AYisI/XIEL/QxkG FBY5HzbXVqBIv1BzIDdnibrEM+dXb/8JApEMdT4NwAn4hcWBXpuuriWgdEI+J6JRySFe DimW62P2muaV1EfvBfCT7iTPDygukEPsRRRhJObRr0+5Dz2k7805Gpg85kn66dFX4ko1 qFkd+0NmaThDag98K69j+uPLaZf300ayyxVZKZgqN/OmDPPpd/+V/X3Wxc4SxhRLuN2i yzZg== X-Gm-Message-State: ALKqPwc7iiOci0vpOU2f2prMuX8UejExHczYU60ZQ7hPCakXzCapEAso Yl5GqJNjsExrW7nfpar/OiDj56oQdO/Ve8YgqSP8ksVFvSNrmOReAu6aAfsL3pMAf18bIqoPHHL Sm+IP4hyHoTyC3xsA5qdkR8XFv8km9z0rfw6VYpAZKbpd7w/2Jsp2UhUPgNejqog= X-Received: by 2002:a17:902:343:: with SMTP id 61-v6mr8141559pld.39.1527790012927; Thu, 31 May 2018 11:06:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJouB11C8O7Lm2Iy/UMeOz4tkaWcJEZhK8x4HOByIRcKrfA3LOV7QImIHS5BFnlVl9YmzJc X-Received: by 2002:a17:902:343:: with SMTP id 61-v6mr8141526pld.39.1527790012108; Thu, 31 May 2018 11:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527790012; cv=none; d=google.com; s=arc-20160816; b=ZkgRQDEYt5BNrinuXfJnwFrusGPEcQDC2Nl/x6ptqmCo/AC5OEc7RVGOemv8pCg0EJ Oe+Ud8lo8/UIQHG8180w4av4+XQhRcKm8sEf3b2mISMzwLTlvAZx5EkPolh/aRaqFCw4 NwBv9mdBkZZuYmtyVd4P0d4vAkzWY+6Q0ZsyY0wUk8XoNuFkYt+Ke4I8MtUuh1diRmyp Nfz/qxHyWIJhSuHveOCRaSOl9jVJHQVeR1KsRy5s35lPjPo+q5yzBd9PJSHvbSQ0DBNk 8VGEsnVPiaM7X+Weyc9y1TqUBycv6YaohpEeqAImruZIPMQcMzyZwP7tmAVH40Da+qbb XsRg== 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=Z68pN6Y7MM71Y6qfPB6Rqc/aRa02l0lwZocIukU+9Us=; b=WckvOVxH10DVAqbfOdoqMa+C1B+p/9XuBDyI2QKj/oYCBXo9GqLUascLZf14VB8sWe n9jiQ4UNP95fTP8QK+ng44y7viToFv0bHcsG8gP97U8ynH66QMNW6rbXp9V1neQsFq1i e/92TdjAzbQ3Ph1wFPCme9vkHbIjCh7dZIskFyKmL8YP3qsNQDra7uiZodTdi+2xYqO4 3pxHPa6cfC47hufRQAdPVzX7p15BkBHxv9WTDU4OEv5yG8mvROlYpwQCYRU0g/iLMVqj 6iIw/3alL3pVX8D2Pwh/ckhI5dy1aDOw31zakutjPXOvmpHNdrOtOhgDYGlYvo5aYGb0 dyFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=AzomIvag; 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 bj1-v6si36807222plb.395.2018.05.31.11.06.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 11:06:52 -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=AzomIvag; 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=Z68pN6Y7MM71Y6qfPB6Rqc/aRa02l0lwZocIukU+9Us=; b=AzomIvagyA0dLa2whUTke8OnE cmEY8nBoRN5H1warslhk6waomPG9/mK76E5UQVt2du3b63CtmE7GIzcV+hvMmbFqqqI8XORpzl/h7 ++CEHWht04IsQKBsCJvb8qJBN2MfLxvV+NVCWAqEITtRccne+UuFB5fFXAqQTum8+08anSQFxpEhq fgVFHE2b8i3CavtIm/AC8LP+spW7PYbHDbAbvq0RDJNlAgWAMtLkEcN3A26n3ZTurxNumhMDWDPm+ kMtfRmyNc/fEY1q38akg70BBhxZjOTvysah4KSiZ1ZBNhEe4avyJDYJj1MdRr61yAwwuQipxiNiCf oLt2C3Eig==; 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 1fORyN-0003S4-44; Thu, 31 May 2018 18:06:51 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/13] iomap: add an iomap-based bmap implementation Date: Thu, 31 May 2018 20:06:11 +0200 Message-Id: <20180531180614.21506-11-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 This adds a simple iomap-based implementation of the legacy ->bmap interface. Note that we can't easily add checks for rt or reflink files, so these will have to remain in the callers. This interface just needs to die.. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/iomap.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/iomap.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/fs/iomap.c b/fs/iomap.c index 74cdf8b5bbb0..b0bc928672af 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1307,3 +1307,37 @@ int iomap_swapfile_activate(struct swap_info_struct *sis, } EXPORT_SYMBOL_GPL(iomap_swapfile_activate); #endif /* CONFIG_SWAP */ + +static loff_t +iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length, + void *data, struct iomap *iomap) +{ + sector_t *bno = data, addr; + + if (iomap->type == IOMAP_MAPPED) { + addr = (pos - iomap->offset + iomap->addr) >> inode->i_blkbits; + if (addr > INT_MAX) + WARN(1, "would truncate bmap result\n"); + else + *bno = addr; + } + return 0; +} + +/* legacy ->bmap interface. 0 is the error return (!) */ +sector_t +iomap_bmap(struct address_space *mapping, sector_t bno, + const struct iomap_ops *ops) +{ + struct inode *inode = mapping->host; + loff_t pos = bno >> inode->i_blkbits; + unsigned blocksize = i_blocksize(inode); + + if (filemap_write_and_wait(mapping)) + return 0; + + bno = 0; + iomap_apply(inode, pos, blocksize, 0, ops, &bno, iomap_bmap_actor); + return bno; +} +EXPORT_SYMBOL_GPL(iomap_bmap); diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 819e0cd2a950..a044a824da85 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -4,6 +4,7 @@ #include +struct address_space; struct fiemap_extent_info; struct inode; struct iov_iter; @@ -100,6 +101,8 @@ loff_t iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops); loff_t iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops); +sector_t iomap_bmap(struct address_space *mapping, sector_t bno, + const struct iomap_ops *ops); /* * Flags for direct I/O ->end_io: