From 09fbc1c8e7b00e260b18049af71bf8ca8c4cba99 Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Thu, 1 Sep 2022 14:18:26 +0100 Subject: [PATCH] btrfs: allow fiemap to be interruptible Doing fiemap on a file with a very large number of extents can take a very long time, and we have reports of it being too slow (two recent examples in the Link tags below), so make it interruptible. Link: https://lore.kernel.org/linux-btrfs/21dd32c6-f1f9-f44a-466a-e18fdc6788a7@virtuozzo.com/ Link: https://lore.kernel.org/linux-btrfs/Ysace25wh5BbLd5f@atmark-techno.com/ Reviewed-by: Josef Bacik Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/extent_io.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8f143c10d81b..28e49a4a9eb9 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5623,6 +5623,11 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, ret = 0; goto out_free; } + + if (fatal_signal_pending(current)) { + ret = -EINTR; + goto out_free; + } } out_free: if (!ret)