From: Dmitry Monakhov <dmonakhov@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, Dmitry Monakhov <dmonakhov@gmail.com>
Subject: [PATCH 1/2] ext4: Use raw numbers for EXT4_MAP_XXX flags
Date: Thu, 14 Nov 2019 07:03:29 +0000 [thread overview]
Message-ID: <20191114070330.14115-2-dmonakhov@gmail.com> (raw)
In-Reply-To: <20191114070330.14115-1-dmonakhov@gmail.com>
Trace's macro __print_flags() produce raw event's decraration w/o knowing actual flags value
cat /sys/kernel/debug/tracing/events/ext4/ext4_ext_map_blocks_exit/format
..
__print_flags(REC->mflags, "", { (1 << BH_New),
..
This means that perf-script can not decode bintrace file because BH_XXX is just a text and it is
unknown for perf's userspace. As result perf will dump this field as raw hex number
This patch use explicit numbers to describe EXT4_MAP_XXX flags so __print_flags will works as expected.
#Before patch
ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 2 flags lblk 0 pblk 4177 len 1 mflags 0x20 ret 1
ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 12 flags CREATE lblk 0 pblk 34304 len 1 mflags 0x60 ret 1
#With patch
ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 2 flags lblk 0 pblk 4177 len 1 mflags M ret 1
ext4:ext4_ext_map_blocks_exit: dev 253,0 ino 12 flags CREATE lblk 0 pblk 34816 len 1 mflags NM ret 1
Signed-off-by: Dmitry Monakhov <dmonakhov@gmail.com>
---
fs/ext4/ext4.h | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index bf660aa..9ccf736 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -169,14 +169,32 @@ struct ext4_allocation_request {
* This structure is used to pass requests into ext4_map_blocks() as
* well as to store the information returned by ext4_map_blocks(). It
* takes less room on the stack than a struct buffer_head.
+ *
+ * Use explicit mapping of EXT4_MAP_XXX flags to corresponding BH_XXX bits
*/
-#define EXT4_MAP_NEW (1 << BH_New)
-#define EXT4_MAP_MAPPED (1 << BH_Mapped)
-#define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten)
-#define EXT4_MAP_BOUNDARY (1 << BH_Boundary)
+#define EXT4_MAP_NEW 0x40
+#define EXT4_MAP_MAPPED 0x20
+#define EXT4_MAP_UNWRITTEN 0x1000
+#define EXT4_MAP_BOUNDARY 0x400
#define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY)
+/*
+ * Assert that EXT4_MAP_XX is consistent with respect to BH_XXX. If all is well,
+ * the macros will be dropped, so, it won't cost any extra space in the compiled
+ * kernel image, otherwise, the build will fail.
+ */
+#define TEST_MAP_VALUE(FLAG, BIT) (EXT4_MAP_##FLAG == (1 << BH_##BIT))
+#define CHECK_MAP_VALUE(FLAG, BIT) BUILD_BUG_ON(!TEST_MAP_VALUE(FLAG, BIT))
+
+static inline void ext4_check_map_values(void)
+{
+ CHECK_MAP_VALUE(NEW, New);
+ CHECK_MAP_VALUE(MAPPED, Mapped);
+ CHECK_MAP_VALUE(UNWRITTEN, Unwritten);
+ CHECK_MAP_VALUE(BOUNDARY, Boundary);
+}
+
struct ext4_map_blocks {
ext4_fsblk_t m_pblk;
ext4_lblk_t m_lblk;
--
2.7.4
next prev parent reply other threads:[~2019-11-14 7:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 7:03 [PATCH 0/2] ext4: Workaround trace event flag decoding issues Dmitry Monakhov
2019-11-14 7:03 ` Dmitry Monakhov [this message]
2019-11-14 7:03 ` [PATCH 2/2] ext4: Fix extent_status trace events Dmitry Monakhov
2019-11-14 15:52 ` Darrick J. Wong
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=20191114070330.14115-2-dmonakhov@gmail.com \
--to=dmonakhov@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).