From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 876A6C07E9B for ; Tue, 20 Jul 2021 13:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 736B7610C7 for ; Tue, 20 Jul 2021 13:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238679AbhGTM6N (ORCPT ); Tue, 20 Jul 2021 08:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237236AbhGTM4N (ORCPT ); Tue, 20 Jul 2021 08:56:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05E8BC061797; Tue, 20 Jul 2021 06:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9tQ/vkftl90fUakEYwmUtyqNIiTjMWNhtPNyLLbAXC4=; b=CG28sDnc9ZabaWRAeS8SY53hiF C37QAZA+391g+vVM/mvA9UM0te38hfwPCzHBT9I4vJ6c0MyNjPpOGCP0Fdw7DNQ0Pb/J6VSWhy88A er0getgYzwBesjbTTwKBg0fZREfa+Tb3tbZ7UQoyP3JQ9k5C/P5FVJpVjh0ZkbMV0zoohIfx+AbOa Quylr0B9EH9N+5nyODcyoAkGXiU9cE966q1xNl6B+Mxjq6tkuAISHO05XTD3ftYkpXkKRYi/q7mM4 S7lgyhguHpPWEpaDUl+5Hn1VY6cx9Wq0ddtwzu1NeT6hJI/BFkphT7XnX0cciWboWpkZBmCjMEXIR lvlOhMyg==; Received: from [2001:4bb8:193:7660:5612:5e3c:ba3d:2b3c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5pto-0089Ke-4X; Tue, 20 Jul 2021 13:35:17 +0000 From: Christoph Hellwig To: Jan Kara , Mikulas Patocka Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 2/4] ext2: use iomap_fiemap to implement ->fiemap Date: Tue, 20 Jul 2021 15:33:39 +0200 Message-Id: <20210720133341.405438-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210720133341.405438-1-hch@lst.de> References: <20210720133341.405438-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Switch from generic_block_fiemap to use the iomap version. The only interesting part is that ext2_get_blocks gets confused when being asked for overly long ranges, so copy over the limit to the inode size from generic_block_fiemap into ext2_fiemap. Signed-off-by: Christoph Hellwig --- fs/ext2/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 3e9a04770f49..04f0def0f5eb 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -855,8 +855,14 @@ const struct iomap_ops ext2_iomap_ops = { int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len) { - return generic_block_fiemap(inode, fieinfo, start, len, - ext2_get_block); + int ret; + + inode_lock(inode); + len = min_t(u64, len, i_size_read(inode)); + ret = iomap_fiemap(inode, fieinfo, start, len, &ext2_iomap_ops); + inode_unlock(inode); + + return ret; } static int ext2_writepage(struct page *page, struct writeback_control *wbc) -- 2.30.2