mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Luca Stefani <luca.stefani.ge1@gmail.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: Don't block system suspend during fstrim
Date: Mon, 2 Sep 2024 20:31:22 +0930	[thread overview]
Message-ID: <e4903dac-cfd6-4513-b7ae-7f64c80fc8b6@gmx.com> (raw)
In-Reply-To: <94178c8f-c9d6-4c3e-9d1d-6d465d379e0f@gmx.com>



在 2024/9/2 18:47, Qu Wenruo 写道:
[...]
> Forgot to mention that, even for error case, we should copy the
> fstrim_range structure to the ioctl parameter to indicate any progress
> we made.

Sorry to bother you again, I should have notice it earlier.

There is another possible cause of the huge delay for freezing, that's
the blkdev_issue_discard() calls inside btrfs_issue_discard() itself.

The problem here is, we can have a very large disk, e.g. 8TiB device,
mostly empty.

In that case, although we will do the split according to our super block
locations, the last super block ends at 256G, we can submit a huge
discard for the range [256G, 8T), causing a super large delay.

So the proper way here is to limit the size of each discard (e.g. limit
it to 1GiB, just as the chunk stripe size limit), and do the check after
each 1GiB discard.

So this may be a larger problem than we thought.

I would recommend to split the fix into the following parts:

- Simple small fixes
   Like always update the fstrim_range structure, no matter the return
   value.

- Proper discard size split and new freezing checks

Thanks,
Qu
>
> Thanks,
> Qu
>>
>> Just please update the commit message to explicitly mention that, we
>> have a free extent discarding phase, which can trim a lot of unallocated
>> space, and there is no limits on the trim size (unlike the block group
>> part).
>>
>> Thanks,
>> Qu
>>>
>>>     Thanks,
>>>     Qu
>>>
>>>      >>       }
>>>      >>       mutex_unlock(&fs_devices->device_list_mutex);
>>>      >
>>>
>>

  parent reply	other threads:[~2024-09-02 11:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 16:48 Luca Stefani
2024-09-02  8:32 ` Luca Stefani
2024-09-02  8:49   ` Qu Wenruo
     [not found]     ` <CAO0HQ0X3zk6aau50Ew2nmNP-pwNEkmgAoC2Ewmi30sGi7uQwDA@mail.gmail.com>
2024-09-02  9:12       ` Qu Wenruo
2024-09-02  9:17         ` Qu Wenruo
2024-09-02  9:31           ` Luca Stefani
2024-09-02  9:40             ` Qu Wenruo
2024-09-02 11:01           ` Qu Wenruo [this message]
2024-09-02 11:10             ` Luca Stefani
2024-09-02  9:14     ` Luca Stefani

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=e4903dac-cfd6-4513-b7ae-7f64c80fc8b6@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.stefani.ge1@gmail.com \
    /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

all inboxes | Powered by JetHome®