From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 3/4] btrfs: Skip first megabyte on device when trimming
Date: Mon, 3 Jun 2019 13:06:01 +0300 [thread overview]
Message-ID: <20190603100602.19362-4-nborisov@suse.com> (raw)
In-Reply-To: <20190603100602.19362-1-nborisov@suse.com>
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>
---
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 */
--
2.17.1
next prev parent reply other threads:[~2019-06-03 10:06 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 ` Nikolay Borisov [this message]
2019-06-05 8:06 ` [PATCH 3/4] btrfs: Skip first megabyte on device when trimming Johannes Thumshirn
2019-06-05 9:14 ` Qu Wenruo
2019-06-05 11:18 ` Nikolay Borisov
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=20190603100602.19362-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox