aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2022-02-17 12:12:05 +0000
committerDavid Sterba <dsterba@suse.com>2022-03-14 13:13:52 +0100
commit96acb3753e0740e0a3148640927dcf3249f09f5d (patch)
tree3fb5e6b96c7ad3f8cb699ed43804f9dc01fe6902 /fs/btrfs/tree-log.c
parentbtrfs: hold on to less memory when logging checksums during full fsync (diff)
downloadlinux-dev-96acb3753e0740e0a3148640927dcf3249f09f5d.tar.xz
linux-dev-96acb3753e0740e0a3148640927dcf3249f09f5d.zip
btrfs: voluntarily relinquish cpu when doing a full fsync
Doing a full fsync may require processing many leaves of metadata, which can take some time and result in a task monopolizing a cpu for too long. So add a cond_resched() after processing a leaf when doing a full fsync, while not holding any locks on any tree (a subvolume or a log tree). Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 0b841eab6169..b6abc716aff2 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -5712,6 +5712,13 @@ next_key:
} else {
break;
}
+
+ /*
+ * We may process many leaves full of items for our inode, so
+ * avoid monopolizing a cpu for too long by rescheduling while
+ * not holding locks on any tree.
+ */
+ cond_resched();
}
if (ins_nr) {
ret = copy_items(trans, inode, dst_path, path, ins_start_slot,