Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4562011pxv; Tue, 20 Jul 2021 06:42:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywRRmYUbl7h8jA6LYNZj4PqlHsZiUkTQfB70oedFtwCSFgBiaZwp6DcU8umbdsgn8jZlU5 X-Received: by 2002:aa7:ca04:: with SMTP id y4mr39823391eds.83.1626788535014; Tue, 20 Jul 2021 06:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626788535; cv=none; d=google.com; s=arc-20160816; b=XCI4mOK1E8cH6Hsdc01ITKL1cZK03lUXO53M65v7UW9LeuEK/sXmPlYYeSlk5EgjQj Z8pyQPxTXFteFSY69xJAw9rl+ywOYHf/gcHjbELWIh3WL5u8+lDRole1TEkk7K3r9Hyi cj5PMtWYzbdVIvX4/xNL98MFqzusGav4Viz5kc2VQ34Oi4n+vk7y2gPq/9BKEenuiorA rWRUEcuzSx8W37lXxsgkNGrwDGXNLGyX/AOFxbuJ1QiC1dFOJICtY9yUJi+3vhBRFsDW mb8CH2Lt8alw1qoV5Q1/o5YOaXy2Fn5nKiIRfbcET1BJNRJBdUkzgCNY44q8taFneNFi Z80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9tQ/vkftl90fUakEYwmUtyqNIiTjMWNhtPNyLLbAXC4=; b=QADRHj62+0Un7+PlWTytgyG0NJ6Acs8iAxhRRYFtXaP3qEftdnB/HSSNlRrS9NtXMr cMNR4rXqJPDtJ7kB6OWaXmkF5b3sDIekdtvNncGGz4zu7XdBn+8R+ufJ6OE3WT6cQMm6 b4y/GELf+wtIkCRWHF0MxaKeokdyxlldbVcKRKPc3Q4aaq6L/dW4tDnBer9E6W06HCsG ouuaWq1K+b09SnwvgNQHWrEh2rxJXkCedmpulz3/IMC2LiIwssrK02FGkSmPLX3v7HTn Zp0LFUCpfLubCwc4gZ8jbq1Ig4FHgA8xeHQVCYtalo+h6nHkRXQGO5bPgXafEloZMQpv HAGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CG28sDnc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si30749355ejj.278.2021.07.20.06.41.51; Tue, 20 Jul 2021 06:42:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CG28sDnc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238622AbhGTM6L (ORCPT + 99 others); Tue, 20 Jul 2021 08:58:11 -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