[PATCH 2/3] Btrfs-progs: fsck: avoid pinning same block several times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This can not only give some speedups but also avoid forever loop
with a really broken filesystem.

Signed-off-by: Wang Shilong <wangsl.fnst@xxxxxxxxxxxxxx>
---
 cmds-check.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/cmds-check.c b/cmds-check.c
index 15806a4..e6fb380 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6189,6 +6189,15 @@ static int pin_down_tree_blocks(struct btrfs_fs_info *fs_info,
 	int ret;
 	int i;
 
+	/*
+	 * If we have pinned this block before, don't pin it again.
+	 * This can not only avoid forever loop with broken filesystem
+	 * but also give us some speedups.
+	 */
+	if (test_range_bit(&fs_info->pinned_extents, eb->start,
+			   eb->start + eb->len - 1, EXTENT_DIRTY, 0))
+		return 0;
+
 	btrfs_pin_extent(fs_info, eb->start, eb->len);
 
 	leafsize = btrfs_super_leafsize(fs_info->super_copy);
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux