From patchwork Wed May 9 07:48:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10388355 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 552FC60540 for ; Wed, 9 May 2018 07:49:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4914128E56 for ; Wed, 9 May 2018 07:49:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E0CE28E2B; Wed, 9 May 2018 07:49:17 +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 DD25928E08 for ; Wed, 9 May 2018 07:49:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 396BE6B034C; Wed, 9 May 2018 03:49:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3211B6B034E; Wed, 9 May 2018 03:49:13 -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 0FE6F6B034F; Wed, 9 May 2018 03:49:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id B7F1B6B034C for ; Wed, 9 May 2018 03:49:12 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id s3so25858562pfh.0 for ; Wed, 09 May 2018 00:49:12 -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=tmdogpdSxcXlHOyivijk1esS6KVy+7cyB0CLFBOcRF4=; b=nMt4wtzHTkdAXOyhcbb8odfvwrDb17jqcX22yFm1tep3x/PiNWoAEF/xNhYth62n66 Gc9qQuLIb8guC2JxTaFgw5N8rq2e9Et25HQvUopyq2FvpavfQXxehxI3DceH3azD3S31 Nyf36OW/RtJ9PrxUz5YniqaAPNxC1iZ2NoYsifxTWfBntAXQHNMM0ver1+j8ULptpSmk DiCNQCggHsA85loh7C0yPqXJfQQFZwKE82sgqOmhsWMbd51Iwg6xeqU64MbhReNR/vKM qFTPyTvwqUmAjkO/TzJVTKZfbqZJS0mADul7aWHR4jb47jyHZgCMOmRYcCDxxQ3AItfj 9T0w== X-Gm-Message-State: ALKqPwdLoWg5gMU5Y7Y/axlsOk+x201SLDKx7J3H1jN3rwheCPnlhPdL Y5JpIie8UjH8UrQqMgsUriaQit4wM64A/CYz43WmogX6kcdrgoKfywMUPOCBj65F35HqnJSCTyd SlmN41gfoYAln6yGonS6xrUiSqqN24v6SZVEZYp90v08bIaxntVfqt7s155GXGGU= X-Received: by 2002:a17:902:59ce:: with SMTP id d14-v6mr3444011plj.253.1525852152452; Wed, 09 May 2018 00:49:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrZ5o3ThnCoJbZIeIDwQbPx2Ec/LHrgE6O882+HyMnfUfvaxMWdalQ+tDNADKfMnEFQ4r/T X-Received: by 2002:a17:902:59ce:: with SMTP id d14-v6mr3443984plj.253.1525852151727; Wed, 09 May 2018 00:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525852151; cv=none; d=google.com; s=arc-20160816; b=jqdrakwjm2+FtyCYp/haB2fXddKIMB6gkG91sgPQJQoOdORExK/1SK3hVboZbh9IJt 5eKJQufkNmgl3ITAPFskUEH42G+vX7lKltBCDwyvRI+XVdGwNdCWbLS5l6TPdiZCAsw+ jpgJTJu8DtOrHclTYmBYCKnLLoT7rOuhx5kKKKupkMxWj0tMWFkBpliFfLaHHPPEX14A yxyStr6JN7u832hp5LiVI0LVgTC3fZGlaAjWJFZiE6KmEYdcjVrfBibdWb000arnAbGk 2OkqBJXw4iUHE+0FDvt+lyDofN12IgrpaNtAm3ufRFcy2rxnLFhxVhbCuDySNF+Z0zbj qX+g== 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=tmdogpdSxcXlHOyivijk1esS6KVy+7cyB0CLFBOcRF4=; b=lrVfcXpGYsens1iOSKOBxAxcRQJxG7e8t/k9LtEk77Y0OXEcu2N7BcxjeSh/loDM9g i0YQcgpgrX6i7ugFmZ9jkcZvFv6XzVxzkjOidCrqZ/c7DNjxyyf6pAzqieXa9HmOoTR1 iMK2toYWQ9NMriMxPw+RK7w7DBrEaGdvu8/lJvkpyfPd55aspt2/RtDrpzlAzy+p1GQg M522VC2Fon1p2zZ29eHA2wDVT3Cm2kwsie2g/I+WnFgB8O62M0d33zneqLcA7SLVybrA CW/keP9l1ri2rfQXtJIeCdnZQiYhtxUuScqRh7v1Ccn/BAInQ7SFJA4lhcvfoOThL4D/ SPeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gFgNdS2S; 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 p26-v6si26202097pli.35.2018.05.09.00.49.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 00:49:11 -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=gFgNdS2S; 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=tmdogpdSxcXlHOyivijk1esS6KVy+7cyB0CLFBOcRF4=; b=gFgNdS2STz0b5FHk4r97QW7tE Lfz2O9Ny0KTvw7g2936i/H7s/Ii9wsJ1MrJC52sOHzPtSg+lBOosdyGXOqUyp1PvOfnn1UIFPjChE ZcitlIU5yZgx0YKFtUYG5uJPFqr/c1WEKBcDTDOhT7MpsMKwGgz1uiTLr6Luf4nqJ0MQwoNSEDYXm qMZRdhwTWEFlQkSahruxlpKqK1EBZANpMdhu7lBUBJWUSSK7Nw/IYIc971vzMjUZNkXcr3zEXPqLI Frimd6QgJFkCcCqtppJCDOI05KvigIrypwE0Q9/SpeTQZMR/MZOEFcFM0aOpk/AriN4HN3MxaUSFh 9o5lKxVhQ==; 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 1fGJqX-0001UQ-Q8; Wed, 09 May 2018 07:49:10 +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 10/33] iomap: add an iomap-based bmap implementation Date: Wed, 9 May 2018 09:48:07 +0200 Message-Id: <20180509074830.16196-11-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 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 --- fs/iomap.c | 29 +++++++++++++++++++++++++++++ include/linux/iomap.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/fs/iomap.c b/fs/iomap.c index af525cb47339..049e0c4aacac 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1201,3 +1201,32 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, return ret; } EXPORT_SYMBOL_GPL(iomap_dio_rw); + +static loff_t +iomap_bmap_actor(struct inode *inode, loff_t pos, loff_t length, + void *data, struct iomap *iomap) +{ + sector_t *bno = data; + + if (iomap->type == IOMAP_MAPPED) + *bno = (iomap->addr + pos - iomap->offset) >> inode->i_blkbits; + 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 19a07de28212..07f73224c38b 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; @@ -95,6 +96,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: