All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 3/4] btrfs: Record delta directly in transaction_kthread
Date: Thu,  8 Oct 2020 15:24:29 +0300	[thread overview]
Message-ID: <20201008122430.93433-4-nborisov@suse.com> (raw)
In-Reply-To: <20201008122430.93433-1-nborisov@suse.com>

Rename 'now' to 'delta' and store there the delta between transaction
start time and current time. This is in preparation for optimising the
sleep logic in the next patch. No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/disk-io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b9fbbf66ccee..c5d3e7f75066 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1715,7 +1715,7 @@ static int transaction_kthread(void *arg)
 	struct btrfs_trans_handle *trans;
 	struct btrfs_transaction *cur;
 	u64 transid;
-	time64_t now;
+	time64_t delta;
 	unsigned long delay;
 	bool cannot_commit;
 
@@ -1731,9 +1731,9 @@ static int transaction_kthread(void *arg)
 			goto sleep;
 		}
 
-		now = ktime_get_seconds();
+		delta = ktime_get_seconds() - cur->start_time;
 		if (cur->state < TRANS_STATE_COMMIT_START &&
-		    (now - cur->start_time < fs_info->commit_interval)) {
+		    delta < fs_info->commit_interval) {
 			spin_unlock(&fs_info->trans_lock);
 			delay = msecs_to_jiffies(5000);
 			goto sleep;
-- 
2.17.1


  parent reply	other threads:[~2020-10-08 12:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 12:24 [PATCH 0/4] Small QOI fixes for transaction_kthread Nikolay Borisov
2020-10-08 12:24 ` [PATCH 1/4] btrfs: Use helpers to convert from seconds to jiffies in transaction_kthread Nikolay Borisov
2020-10-21 14:51   ` Josef Bacik
2020-10-21 15:03     ` Nikolay Borisov
2020-10-23 17:06       ` David Sterba
2020-10-08 12:24 ` [PATCH 2/4] btrfs: Remove redundant check Nikolay Borisov
2020-10-08 12:24 ` Nikolay Borisov [this message]
2020-10-08 12:24 ` [PATCH 4/4] btrfs: Be smarter when sleeping in transaction_kthread Nikolay Borisov
2020-10-16 14:20   ` David Sterba
2020-10-16 16:26     ` Nikolay Borisov
2020-10-19  7:21       ` Nikolay Borisov
2020-10-20  9:44     ` [PATCH v2] " Nikolay Borisov
2020-10-16 14:26 ` [PATCH 0/4] Small QOI fixes for transaction_kthread David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201008122430.93433-4-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.