Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 4/4] btrfs: Be smarter when sleeping in transaction_kthread
Date: Mon, 19 Oct 2020 10:21:37 +0300	[thread overview]
Message-ID: <851adc75-24a3-e76f-7542-a2943393cab1@suse.com> (raw)
In-Reply-To: <f7d242d5-aaa7-6cb6-f2a8-8f45766b1874@suse.com>



On 16.10.20 г. 19:26 ч., Nikolay Borisov wrote:
> 
> 
> On 16.10.20 г. 17:20 ч., David Sterba wrote:
>> On Thu, Oct 08, 2020 at 03:24:30PM +0300, Nikolay Borisov wrote:
>>> If transaction_kthread is woken up before
>>> btrfs_fs_info::commit_interval seconds have elapsed it will sleep for a
>>> fixed period of 5 seconds. This is not a problem per-se but is not
>>> accuaret, instead the code should sleep for an interval which guarantees
>>> on next wakeup commit_interval would have passed. Since time tracking is
>>> not accurate add 1 second to ensure next wake up would be after
>>> commit_interval.
>>>
>>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>>> ---
>>>  fs/btrfs/disk-io.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>>> index c5d3e7f75066..a1fe99cf0831 100644
>>> --- a/fs/btrfs/disk-io.c
>>> +++ b/fs/btrfs/disk-io.c
>>> @@ -1735,7 +1735,7 @@ static int transaction_kthread(void *arg)
>>>  		if (cur->state < TRANS_STATE_COMMIT_START &&
>>>  		    delta < fs_info->commit_interval) {
>>>  			spin_unlock(&fs_info->trans_lock);
>>> -			delay = msecs_to_jiffies(5000);
>>> +			delay = msecs_to_jiffies((1+delta) * 1000);
>>
>> This does not seem right. Delta is number of seconds since the
>> transaction started, so we need to sleep for the remaining time. Which
>> is commit_interval - delta.
> 
> Doh, you are right. The correct line should be :
> 
> delay -= msecs_to_jiffies((1+delta) * 1000);

Correction it should be :

delay -= msecs_to_jiffies((delta-1) * 1000);

> 
> The + 1  is needed so that upon next wake up we are guaranteed next
> delta is  >= commit_interval. Shall I send a fixed patch or are you
> going to modify it and merge it?
> 
>>
> 

  reply	other threads:[~2020-10-19  7:21 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 ` [PATCH 3/4] btrfs: Record delta directly in transaction_kthread Nikolay Borisov
2020-10-08 12:24 ` [PATCH 4/4] btrfs: Be smarter when sleeping " Nikolay Borisov
2020-10-16 14:20   ` David Sterba
2020-10-16 16:26     ` Nikolay Borisov
2020-10-19  7:21       ` Nikolay Borisov [this message]
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=851adc75-24a3-e76f-7542-a2943393cab1@suse.com \
    --to=nborisov@suse.com \
    --cc=dsterba@suse.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox