diff mbox series

[04/21] btrfs: make btrfs_qgroup_flush() non-static

Message ID 08b4b39eca92493c341831a6cb06836aac7a4967.1677793433.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series Lock extents before pages | expand

Commit Message

Goldwyn Rodrigues March 2, 2023, 10:24 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

btrfs_qgroup_flush() is used to flush data when a qgroup reservation
is unsuccessfull. This causes a writeback which takes extent locks.
If we have to make reservations under locks, we call reservation
function with nowait true, so it does not call btrfs_qgroup_flush().

btrfs_qgroup_flush() call becomes the responsibility of the function
performing reservations under locks. They must call the reservation
function with nowait=true.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/qgroup.c | 6 +++---
 fs/btrfs/qgroup.h | 1 +
 2 files changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 52a7d2fa2284..235bc78a8418 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3709,7 +3709,7 @@  static int qgroup_unreserve_range(struct btrfs_inode *inode,
  *   In theory this shouldn't provide much space, but any more qgroup space
  *   is needed.
  */
-static int try_flush_qgroup(struct btrfs_root *root)
+int btrfs_qgroup_flush(struct btrfs_root *root)
 {
 	struct btrfs_trans_handle *trans;
 	int ret;
@@ -3821,7 +3821,7 @@  int btrfs_qgroup_reserve_data(struct btrfs_inode *inode,
 	if (ret <= 0 && ret != -EDQUOT)
 		return ret;
 
-	ret = try_flush_qgroup(inode->root);
+	ret = btrfs_qgroup_flush(inode->root);
 	if (ret < 0)
 		return ret;
 	return qgroup_reserve_data(inode, reserved_ret, start, len);
@@ -4032,7 +4032,7 @@  int __btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
 	if ((ret <= 0 && ret != -EDQUOT) || noflush)
 		return ret;
 
-	ret = try_flush_qgroup(root);
+	ret = btrfs_qgroup_flush(root);
 	if (ret < 0)
 		return ret;
 	return btrfs_qgroup_reserve_meta(root, num_bytes, type, enforce);
diff --git a/fs/btrfs/qgroup.h b/fs/btrfs/qgroup.h
index 7bffa10589d6..232bc5ad3dca 100644
--- a/fs/btrfs/qgroup.h
+++ b/fs/btrfs/qgroup.h
@@ -439,5 +439,6 @@  int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
 		struct btrfs_root *root, struct extent_buffer *eb);
 void btrfs_qgroup_destroy_extent_records(struct btrfs_transaction *trans);
 bool btrfs_check_quota_leak(struct btrfs_fs_info *fs_info);
+int btrfs_qgroup_flush(struct btrfs_root *root);
 
 #endif