[PATCH 18/21] btrfs: check if writeback pages exist before starting writeback

Goldwyn Rodrigues
2023-03-02T22:25:51Z

Check if there are still pages to writeback after locking. This avoids
calls to check for extents.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
fs/btrfs/inode.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 70cf852a3efd..c4e5eb5d9ee4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7773,6 +7773,11 @@ static int btrfs_writepages_async(struct btrfs_inode *inode, struct writeback_co

lock_extent(&inode->io_tree, start, end, NULL);

+ if (!filemap_range_has_writeback(inode->vfs_inode.i_mapping, start, end)) {
+ unlock_extent(&inode->io_tree, start, end, NULL);
+ return 0;
+ }
+
while (cur_start < end) {
bool found;
last_start = cur_start;
--
2.39.2