[19/24] btrfs: don't pass bytes_needed to may_commit_transaction
diff mbox series

Message ID 20200203204951.517751-20-josef@toxicpanda.com
State New
Headers show
Series
  • Convert data reservations to the ticketing infrastructure
Related show

Commit Message

Josef Bacik Feb. 3, 2020, 8:49 p.m. UTC
This was put into place in order to mirror the way data flushing handled
committing the transaction.  Now that we do not loop on committing the
transaction simply force a transaction commit if we are data.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/space-info.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

Nikolay Borisov Feb. 4, 2020, 7:42 a.m. UTC | #1
On 3.02.20 г. 22:49 ч., Josef Bacik wrote:
> This was put into place in order to mirror the way data flushing handled
> committing the transaction.  Now that we do not loop on committing the
> transaction simply force a transaction commit if we are data.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Same as previous patch.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

Patch
diff mbox series

diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 8c5543328ec4..d20c338f2780 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -412,14 +412,14 @@  static void shrink_delalloc(struct btrfs_fs_info *fs_info,
  * will return -ENOSPC.
  */
 static int may_commit_transaction(struct btrfs_fs_info *fs_info,
-				  struct btrfs_space_info *space_info,
-				  u64 bytes_needed)
+				  struct btrfs_space_info *space_info)
 {
 	struct reserve_ticket *ticket = NULL;
 	struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_block_rsv;
 	struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv;
 	struct btrfs_trans_handle *trans;
 	u64 reclaim_bytes = 0;
+	u64 bytes_needed;
 	u64 cur_free_bytes = 0;
 	bool do_commit = false;
 
@@ -428,12 +428,10 @@  static int may_commit_transaction(struct btrfs_fs_info *fs_info,
 		return -EAGAIN;
 
 	/*
-	 * If we are data and have passed in U64_MAX we just want to
-	 * unconditionally commit the transaction to match the previous data
-	 * flushing behavior.
+	 * If we are data just force the commit, we aren't likely to do this
+	 * over and over again.
 	 */
-	if ((space_info->flags & BTRFS_BLOCK_GROUP_DATA) &&
-	   bytes_needed == U64_MAX) {
+	if (space_info->flags & BTRFS_BLOCK_GROUP_DATA) {
 		do_commit = true;
 		goto check_pinned;
 	}
@@ -451,7 +449,7 @@  static int may_commit_transaction(struct btrfs_fs_info *fs_info,
 	else if (!list_empty(&space_info->tickets))
 		ticket = list_first_entry(&space_info->tickets,
 					  struct reserve_ticket, list);
-	bytes_needed = (ticket) ? ticket->bytes : bytes_needed;
+	bytes_needed = (ticket) ? ticket->bytes : 0;
 
 	if (bytes_needed > cur_free_bytes)
 		bytes_needed -= cur_free_bytes;
@@ -584,7 +582,7 @@  static void flush_space(struct btrfs_fs_info *fs_info,
 		btrfs_wait_on_delayed_iputs(fs_info);
 		break;
 	case COMMIT_TRANS:
-		ret = may_commit_transaction(fs_info, space_info, num_bytes);
+		ret = may_commit_transaction(fs_info, space_info);
 		break;
 	default:
 		ret = -ENOSPC;