public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/4] btrfs: Skip first megabyte on device when trimming
Date: Wed, 5 Jun 2019 14:18:13 +0300	[thread overview]
Message-ID: <58c8ee9a-8750-1d60-194f-708d9fb10698@suse.com> (raw)
In-Reply-To: <91bf1d48-dea5-45a9-4c0f-7a2fa0b22c98@gmx.com>



On 5.06.19 г. 12:14 ч., Qu Wenruo wrote:
> 
> 
> On 2019/6/3 下午6:06, Nikolay Borisov wrote:
>> Currently the first megabyte on a device housing a btrfs filesystem is
>> exempt from allocation and trimming. Currently this is not a problem
>> since 'start' is set to 1m at the beginning of btrfs_trim_free_extents
>> and find_first_clear_extent_bit always returns a range that is >= start.
>> However, in a follow up patch find_first_clear_extent_bit will be
>> changed such that it will return a range containing 'start' and this
>> range may very well be 0...>=1M so 'start'.
>>
>> Future proof the sole user of find_first_clear_extent_bit by setting
>> 'start' after the function is called. No functional changes.
>>
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> 
> Doesn't that previous patch already address this by:
> 
> +	u64 start = SZ_1M, len = 0, end = 0;

No, because with the changes introduced in the next patch start can
actually be made to point to 0 for example. One of the self-test cases
covers this, e.g. :

find_first_clear_extent_bit(&tree, SZ_512K, &start, &end,
+				    CHUNK_TRIMMED | CHUNK_ALLOCATED);

> 
> Thanks,
> Qu
> 
> 
>> ---
>>  fs/btrfs/extent-tree.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index d8c5febf7636..5a11e4988243 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -11183,6 +11183,10 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed)
>>  		 * to the caller to trim the value to the size of the device.
>>  		 */
>>  		end = min(end, device->total_bytes - 1);
>> +
>> +		/* Ensure we skip first mb in case we have a bootloader there */
>> +		start = max_t(u64, start, SZ_1M);
>> +
>>  		len = end - start + 1;
>>
>>  		/* We didn't find any extents */
>>
> 

  reply	other threads:[~2019-06-05 11:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 10:05 [PATCH 0/4] Further FITRIM improvements Nikolay Borisov
2019-06-03 10:05 ` [PATCH 1/4] btrfs: Document __etree_search Nikolay Borisov
2019-06-05  8:04   ` Johannes Thumshirn
2019-06-05  9:13   ` Qu Wenruo
2019-06-05 11:50   ` [PATCH v2] " Nikolay Borisov
2019-06-05 11:51     ` Johannes Thumshirn
2019-06-03 10:06 ` [PATCH 2/4] btrfs: Always trim all unallocated space in btrfs_trim_free_extents Nikolay Borisov
2019-06-05  9:13   ` Qu Wenruo
2019-06-03 10:06 ` [PATCH 3/4] btrfs: Skip first megabyte on device when trimming Nikolay Borisov
2019-06-05  8:06   ` Johannes Thumshirn
2019-06-05  9:14   ` Qu Wenruo
2019-06-05 11:18     ` Nikolay Borisov [this message]
2019-06-03 10:06 ` [PATCH 4/4] btrfs: Don't trim returned range based on input value in find_first_clear_extent_bit Nikolay Borisov
2019-06-05  9:25   ` Qu Wenruo
2019-06-07 13:28 ` [PATCH 0/4] Further FITRIM improvements 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=58c8ee9a-8750-1d60-194f-708d9fb10698@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.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