From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 1/5] btrfs: remove redundant check in up check_setget_bounds
Date: Thu, 3 Feb 2022 18:26:24 +0100 [thread overview]
Message-ID: <0cccec1104fd7058b4b19c6960dd4c10da646058.1643904960.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1643904960.git.dsterba@suse.com>
There are two separate checks in the bounds checker, the first one being
a special case of the second. As this function is performance critical
due to checking access to any eb member, reducing the size can slightly
improve performance.
On a release build on x86_64 the helper is completely inlined so the
function call overhead is also gone.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/struct-funcs.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
index f429256f56db..12455b2b41de 100644
--- a/fs/btrfs/struct-funcs.c
+++ b/fs/btrfs/struct-funcs.c
@@ -12,15 +12,10 @@ static bool check_setget_bounds(const struct extent_buffer *eb,
{
const unsigned long member_offset = (unsigned long)ptr + off;
- if (member_offset > eb->len) {
+ if (unlikely(member_offset + size > eb->len)) {
btrfs_warn(eb->fs_info,
- "bad eb member start: ptr 0x%lx start %llu member offset %lu size %d",
- (unsigned long)ptr, eb->start, member_offset, size);
- return false;
- }
- if (member_offset + size > eb->len) {
- btrfs_warn(eb->fs_info,
- "bad eb member end: ptr 0x%lx start %llu member offset %lu size %d",
+ "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d",
+ (member_offset > eb->len ? "start" : "end"),
(unsigned long)ptr, eb->start, member_offset, size);
return false;
}
--
2.34.1
next prev parent reply other threads:[~2022-02-03 17:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 17:26 [PATCH 0/5] Speedups and check_setget_bounds reporting updates David Sterba
2022-02-03 17:26 ` David Sterba [this message]
2022-02-10 17:52 ` [PATCH 1/5] btrfs: remove redundant check in up check_setget_bounds David Sterba
2022-02-03 17:26 ` [PATCH 2/5] btrfs: factor out reporting when check_setget_bounds fails David Sterba
2022-02-03 17:26 ` [PATCH 3/5] btrfs: store details about first setget bounds check failure David Sterba
2022-02-04 11:31 ` Filipe Manana
2022-02-10 17:27 ` David Sterba
2022-02-03 17:26 ` [PATCH 4/5] btrfs: fail transaction when a setget bounds check failure is detected David Sterba
2022-02-04 11:29 ` Filipe Manana
2022-02-04 13:38 ` Filipe Manana
2022-02-10 17:50 ` David Sterba
2022-02-11 11:23 ` Filipe Manana
2022-02-03 17:26 ` [PATCH 5/5] btrfs: move check_setget_bounds out of ASSERT David Sterba
2022-02-04 8:35 ` [PATCH 0/5] Speedups and check_setget_bounds reporting updates Johannes Thumshirn
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=0cccec1104fd7058b4b19c6960dd4c10da646058.1643904960.git.dsterba@suse.com \
--to=dsterba@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;
as well as URLs for NNTP newsgroup(s).