From patchwork Wed May 30 09:58: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: 10438173 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 15857601E9 for ; Wed, 30 May 2018 09:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 063342818E for ; Wed, 30 May 2018 09:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF1F5288E8; Wed, 30 May 2018 09:59:05 +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 949BC2818E for ; Wed, 30 May 2018 09:59:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 675FE6B0270; Wed, 30 May 2018 05:59:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 64CBB6B0271; Wed, 30 May 2018 05:59:02 -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 518C16B0273; Wed, 30 May 2018 05:59:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id E394F6B0270 for ; Wed, 30 May 2018 05:59:01 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id e1-v6so10994357pld.23 for ; Wed, 30 May 2018 02:59:01 -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=1WBeCBTSp+uKsqd9/QA7dUDU/Kt+aS18Zm4C7zAwUlU=; b=dIyUCxTnsyh2QDEw1fwiaqtU/Z6YtEXLVTE24o8j8oqmBDqK10Bd5CWQ3lWkzx6+PJ SU6P5MxUjVPQT9xacoE/MJeiRo2qizfFRYqYTFSvyR/Rnya+07MTIwR13ePnO7+FOZ5V 6WpBcI5kJt3VNS9i4sJASOU92JWz/D2ghSfDsvmJ7KRg6rTBqp35zphUxPnpYXIvTdqQ OagUMD4bAp2Er/UGOmz196wxv2XRaz5B2Ye7mKUaofMptZnOO9d63qXgCpsmZFlG7fiq Tgzi4vWaoC98zS8hx0rDc6iIEVjJinDlKHdEcrsMYmN5KQKV7IstYivbFBDxHIincAUz bwFQ== X-Gm-Message-State: ALKqPwf4jmxZt2RMELWVOC5vjxNZmvGYjFRE68nzF35y7TpsjZyCVOKm XFoIceS8lUqUS2ZiC5C5ffNFIf1RNmlocJJf6zxrEBHzaofAHvhW2ieyzTMWJX57M8jkPsbAEEK x3Qx7EJlae0TmPZa1qy6kDNm/7woPcT9v3yoiqdPkLQzzcPgHlN1a2CEzvvEkvRQ= X-Received: by 2002:a62:50d6:: with SMTP id g83-v6mr2110934pfj.31.1527674341617; Wed, 30 May 2018 02:59:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJwt8IYYClcCYem6aIhClxXBHrs357euyJvlBWrEMF+sjkIG1miVQ6EUMEYQ/Ee3QiHk0TF X-Received: by 2002:a62:50d6:: with SMTP id g83-v6mr2110898pfj.31.1527674340886; Wed, 30 May 2018 02:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527674340; cv=none; d=google.com; s=arc-20160816; b=J9ZBobNx70TO5UU2/FSAzgQ88HmBz3sMEBf3X9kiVPZGSo5j1S/kLrUqUy0IWmmBDi Vot+EOCwPS+Vf7DIH5ZR3QGUzrFBlV4lkA7DUBs4MtOqAomfZ1BSQ/kDmppcPJAkr3DR ujjP8UeZMGL1Hz+M9K+U/F3WNlT+OLSizU3znU8wmh/ufZW1bjfg1QWl7AXIHuFKazro Mi9zXDgqgQn6v1JQ+jQ8+3kC5eyjRrNa0X0k71sZ5DAD+bZvebuHLCwB3bNUtM0JL2bD 7IEs1aRLIS5I97Vg7HUxeeiSxPJYpBM0NQIJTih/LGnIqt9ALVeG/BIeVymd941Uf+FV wsEw== 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=1WBeCBTSp+uKsqd9/QA7dUDU/Kt+aS18Zm4C7zAwUlU=; b=sn5w+ZQ15e4o/ZJIlQsC4S9Cbh/NpThMhWZD31weuoFIUf/QIhDZvSMeILEgIdIq+/ h2GNcwyd5kuuPM56B/kxgsv6vlvtMsJlIT9nViOJYv4UvWTVaYuF1g96VdwUuwjcz1WG DJF1EPeZT3VkIQ8h4xwdUCPIh56IjowBseqCD4BSwL+/s9Wqmvun3N2lgSWQjrjY1VCH xX2oYxeSDkfR6j7TM29s/CuqGlc0sqldL7FxPy4BsdpgkM6ZvZkmxhltsVPjWU85m36M wPf4aYXxHiPx5MeH/q0C3F0KzE0cynat73xe3gukR3hUkK1yQc5SEAShEdJANHs2Dj/j 9HZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Ik/AeSeW; spf=pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1f4557cc97fec8e307c5+5393+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 z6-v6si16393072pln.250.2018.05.30.02.59.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 02:59:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+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=Ik/AeSeW; spf=pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1f4557cc97fec8e307c5+5393+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=1WBeCBTSp+uKsqd9/QA7dUDU/Kt+aS18Zm4C7zAwUlU=; b=Ik/AeSeW1+xmFkhi6JnKfMPml wyo7gFoE2tB8FSgsTcZt2jWuFFGg7brfRgvmzYd4I3oKWsx6fHnP6izfmXKSV1PApNsLOGEAwoUjR UYmP5KFtAlyi4sc4LgV/q7e8+QXW3wDCZsebtBsxQDnrN1r5TjeBqvR3zUYZle2bgFAEvwZe5f8HZ SnJa6oc5l6J+0wRnhM0+y9Dd/2XcuAASWD2CPQKpjLjSFLU7G4TZF0nEDOzdMMT8LU3HBblx3Qg0k 3kMsvpMknONbn3WKuPQeRZJWibzfoJU7I+kocw/O4/N2Q0p99pAvlSsa27MQ9eciZGfFA0DvTPmMK lEyEp1RwQ==; 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 1fNxsh-0006YT-DH; Wed, 30 May 2018 09:59:00 +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: Wed, 30 May 2018 11:58:10 +0200 Message-Id: <20180530095813.31245-11-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530095813.31245-1-hch@lst.de> References: <20180530095813.31245-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: Darrick J. Wong Reviewed-by: Dave Chinner --- 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: