1 ext4 crypto: trace events for encrypt and decrypt
3 From: Michael Halcrow <mhalcrow@google.com>
5 Signed-off-by: Michael Halcrow <mhalcrow@google.com>
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 fs/ext4/crypto.c | 34 ++++++++++++++++++++++++++++++++-
9 include/trace/events/ext4.h | 46 +++++++++++++++++++++++++++++++++++++++++++++
10 2 files changed, 79 insertions(+), 1 deletion(-)
12 diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
13 index e16170f..30cfaa9 100644
14 --- a/fs/ext4/crypto.c
15 +++ b/fs/ext4/crypto.c
20 +#include <trace/events/ext4.h>
22 /* Encryption added and removed here! (L: */
24 mempool_t *ext4_bounce_page_pool = NULL;
25 @@ -447,6 +449,13 @@ struct page *ext4_encrypt(struct ext4_crypto_ctx *ctx,
26 struct page *plaintext_page)
28 struct page *ciphertext_page = NULL;
29 + char c0, c4095, p0, p4095;
32 + page_virt = kmap(plaintext_page);
34 + p4095 = page_virt[PAGE_CACHE_SIZE - 1];
35 + kunmap(plaintext_page);
37 BUG_ON(!PageLocked(plaintext_page));
39 @@ -464,8 +473,16 @@ struct page *ext4_encrypt(struct ext4_crypto_ctx *ctx,
43 - if (!IS_ERR_OR_NULL(ciphertext_page))
44 + if (!IS_ERR_OR_NULL(ciphertext_page)) {
45 ext4_prep_pages_for_write(ciphertext_page, plaintext_page, ctx);
47 + page_virt = kmap(ciphertext_page);
49 + c4095 = page_virt[PAGE_CACHE_SIZE - 1];
50 + kunmap(ciphertext_page);
52 + trace_ext4_encrypt(plaintext_page, p0, p4095, c0, c4095);
54 return ciphertext_page;
57 @@ -549,6 +566,13 @@ bool __ext4_debug_is_page_zero(struct page *page)
58 int ext4_decrypt(struct ext4_crypto_ctx *ctx, struct page *page)
61 + char c0, c4095, p0, p4095;
64 + page_virt = kmap(page);
66 + c4095 = page_virt[PAGE_CACHE_SIZE - 1];
69 BUG_ON(!PageLocked(page));
70 BUG_ON(__ext4_debug_is_page_zero(page));
71 @@ -564,6 +588,14 @@ int ext4_decrypt(struct ext4_crypto_ctx *ctx, struct page *page)
76 + page_virt = kmap(page);
78 + p4095 = page_virt[PAGE_CACHE_SIZE - 1];
81 + trace_ext4_decrypt(page, p0, p4095, c0, c4095);
86 diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
87 index d4f70a7..91835b1 100644
88 --- a/include/trace/events/ext4.h
89 +++ b/include/trace/events/ext4.h
90 @@ -494,6 +494,38 @@ DECLARE_EVENT_CLASS(ext4__page_op,
91 (unsigned long) __entry->index)
94 +DECLARE_EVENT_CLASS(ext4__page_crypt_op,
95 + TP_PROTO(struct page *page, char p0, char p4095, char c0, char c4095),
97 + TP_ARGS(page, p0, p4095, c0, c4095),
100 + __field( ino_t, ino )
101 + __field( pgoff_t, index )
102 + __field( char, p0 )
103 + __field( char, p4095 )
104 + __field( char, c0 )
105 + __field( char, c4095 )
109 + __entry->ino = page->mapping->host->i_ino;
110 + __entry->index = page->index;
112 + __entry->p4095 = p4095;
114 + __entry->c4095 = c4095;
117 + TP_printk("ino %lu page_index %lu p0 %.2x p4095 %.2x c0 %.2x c4095 %.2x",
118 + (unsigned long) __entry->ino,
119 + (unsigned long) __entry->index,
120 + (unsigned char) __entry->p0,
121 + (unsigned char) __entry->p4095,
122 + (unsigned char) __entry->c0,
123 + (unsigned char) __entry->c4095)
126 DEFINE_EVENT(ext4__page_op, ext4_writepage,
128 TP_PROTO(struct page *page),
129 @@ -515,6 +547,20 @@ DEFINE_EVENT(ext4__page_op, ext4_releasepage,
133 +DEFINE_EVENT(ext4__page_crypt_op, ext4_encrypt,
135 + TP_PROTO(struct page *page, char p0, char p4095, char c0, char c4095),
137 + TP_ARGS(page, p0, p4095, c0, c4095)
140 +DEFINE_EVENT(ext4__page_crypt_op, ext4_decrypt,
142 + TP_PROTO(struct page *page, char p0, char p4095, char c0, char c4095),
144 + TP_ARGS(page, p0, p4095, c0, c4095)
147 DECLARE_EVENT_CLASS(ext4_invalidatepage_op,
148 TP_PROTO(struct page *page, unsigned int offset, unsigned int length),
151 2.1.0.rc2.206.gedb03e5