rebase to v4.7-rc1
[ext4-patch-queue.git] / add-encryption-debug-files
bloba38542bbaaa4bfcf260dd28c4ca550e16e1d92f2
1 ext4: add debugging counters for crypto allocations
3 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 ---
5  fs/ext4/counter_debug_list.h |  3 +++
6  fs/ext4/ext4.h               |  6 ++++++
7  fs/ext4/page-io.c            |  2 ++
8  fs/ext4/sysfs.c              | 19 +++++++++++++++++++
9  4 files changed, 30 insertions(+)
11 diff --git a/fs/ext4/counter_debug_list.h b/fs/ext4/counter_debug_list.h
12 new file mode 100644
13 index 0000000..a0eb6d2
14 --- /dev/null
15 +++ b/fs/ext4/counter_debug_list.h
16 @@ -0,0 +1,3 @@
17 +EXT4_COUNTER_DEBUG(pageio_bio_submit)
18 +EXT4_COUNTER_DEBUG(pageio_bio_finish)
20 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
21 index 766b7f7..e4990ac 100644
22 --- a/fs/ext4/ext4.h
23 +++ b/fs/ext4/ext4.h
24 @@ -59,6 +59,12 @@
25  #define ext4_debug(fmt, ...)   no_printk(fmt, ##__VA_ARGS__)
26  #endif
28 +#define EXT4_DEBUG_COUNTER(x) atomic_inc(&ext4_##x)
30 +#define EXT4_COUNTER_DEBUG(x) extern atomic_t ext4_##x;
31 +#include "counter_debug_list.h"
32 +#undef EXT4_COUNTER_DEBUG
34  /*
35   * Turn on EXT_DEBUG to get lots of info about extents operations.
36   */
37 diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
38 index 17fbe38..29b5d61 100644
39 --- a/fs/ext4/page-io.c
40 +++ b/fs/ext4/page-io.c
41 @@ -63,6 +63,7 @@ static void ext4_finish_bio(struct bio *bio)
42         int i;
43         struct bio_vec *bvec;
45 +       EXT4_DEBUG_COUNTER(pageio_bio_finish);
46         bio_for_each_segment_all(bvec, bio, i) {
47                 struct page *page = bvec->bv_page;
48  #ifdef CONFIG_EXT4_FS_ENCRYPTION
49 @@ -358,6 +359,7 @@ void ext4_io_submit(struct ext4_io_submit *io)
50                             WRITE_SYNC : WRITE;
51                 bio_get(io->io_bio);
52                 submit_bio(io_op, io->io_bio);
53 +               EXT4_DEBUG_COUNTER(pageio_bio_submit);
54                 bio_put(io->io_bio);
55         }
56         io->io_bio = NULL;
57 diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
58 index 62bef0f..12aa1bd 100644
59 --- a/fs/ext4/sysfs.c
60 +++ b/fs/ext4/sysfs.c
61 @@ -233,6 +233,24 @@ static struct attribute *ext4_feat_attrs[] = {
62         NULL,
63  };
65 +#define EXT4_ATTR_DEBUG_COUNTER(_name) \
66 +       EXT4_ATTR_PTR(_name, 0444, pointer_atomic, &ext4_##_name)
68 +#define EXT4_COUNTER_DEBUG(x) atomic_t ext4_##x;
69 +#include "counter_debug_list.h"
70 +#undef EXT4_COUNTER_DEBUG
72 +#define EXT4_COUNTER_DEBUG(x) EXT4_ATTR_DEBUG_COUNTER(x);
73 +#include "counter_debug_list.h"
74 +#undef EXT4_COUNTER_DEBUG
76 +#define EXT4_COUNTER_DEBUG(x) ATTR_LIST(x),
77 +static struct attribute *ext4_global_attrs[] = {
78 +#include "counter_debug_list.h"
79 +       NULL,
80 +};
81 +#undef EXT4_COUNTER_DEBUG
83  static void *calc_ptr(struct ext4_attr *a, struct ext4_sb_info *sbi)
84  {
85         switch (a->attr_ptr) {
86 @@ -334,6 +352,7 @@ static struct kobj_type ext4_sb_ktype = {
87  };
89  static struct kobj_type ext4_ktype = {
90 +       .default_attrs  = ext4_global_attrs,
91         .sysfs_ops      = &ext4_attr_ops,
92  };