Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* -*- linux-c -*- */ |
| 2 | |
| 3 | /* fs/reiserfs/procfs.c */ |
| 4 | |
| 5 | /* |
| 6 | * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README |
| 7 | */ |
| 8 | |
| 9 | /* proc info support a la one created by Sizif@Botik.RU for PGC */ |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/module.h> |
| 12 | #include <linux/time.h> |
| 13 | #include <linux/seq_file.h> |
Fabian Frederick | 1709399 | 2014-08-08 14:21:12 -0700 | [diff] [blame] | 14 | #include <linux/uaccess.h> |
Al Viro | f466c6f | 2012-03-17 01:16:43 -0400 | [diff] [blame] | 15 | #include "reiserfs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/init.h> |
| 17 | #include <linux/proc_fs.h> |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | /* |
| 20 | * LOCKING: |
| 21 | * |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 22 | * These guys are evicted from procfs as the very first step in ->kill_sb(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | * |
| 24 | */ |
| 25 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 26 | static int show_version(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 28 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | char *format; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 30 | |
| 31 | if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | format = "3.6"; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 33 | } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | format = "3.5"; |
| 35 | } else { |
| 36 | format = "unknown"; |
| 37 | } |
| 38 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 39 | seq_printf(m, "%s format\twith checks %s\n", format, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #if defined( CONFIG_REISERFS_CHECK ) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 41 | "on" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #else |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 43 | "off" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 45 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | return 0; |
| 47 | } |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define SF( x ) ( r -> x ) |
| 50 | #define SFP( x ) SF( s_proc_info_data.x ) |
| 51 | #define SFPL( x ) SFP( x[ level ] ) |
| 52 | #define SFPF( x ) SFP( scan_bitmap.x ) |
| 53 | #define SFPJ( x ) SFP( journal.x ) |
| 54 | |
| 55 | #define D2C( x ) le16_to_cpu( x ) |
| 56 | #define D4C( x ) le32_to_cpu( x ) |
| 57 | #define DF( x ) D2C( rs -> s_v1.x ) |
| 58 | #define DFL( x ) D4C( rs -> s_v1.x ) |
| 59 | |
| 60 | #define objectid_map( s, rs ) (old_format_only (s) ? \ |
Al Viro | 3e8962b | 2005-05-01 08:59:18 -0700 | [diff] [blame] | 61 | (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \ |
| 62 | (__le32 *)(rs + 1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #define MAP( i ) D4C( objectid_map( sb, rs )[ i ] ) |
| 64 | |
| 65 | #define DJF( x ) le32_to_cpu( rs -> x ) |
| 66 | #define DJV( x ) le32_to_cpu( s_v1 -> x ) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 67 | #define DJP( x ) le32_to_cpu( jp -> x ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | #define JF( x ) ( r -> s_journal -> x ) |
| 69 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 70 | static int show_super(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 72 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 75 | seq_printf(m, "state: \t%s\n" |
| 76 | "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n" |
| 77 | "gen. counter: \t%i\n" |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 78 | "s_disk_reads: \t%i\n" |
| 79 | "s_disk_writes: \t%i\n" |
| 80 | "s_fix_nodes: \t%i\n" |
| 81 | "s_do_balance: \t%i\n" |
| 82 | "s_unneeded_left_neighbor: \t%i\n" |
| 83 | "s_good_search_by_key_reada: \t%i\n" |
| 84 | "s_bmaps: \t%i\n" |
| 85 | "s_bmaps_without_search: \t%i\n" |
| 86 | "s_direct2indirect: \t%i\n" |
| 87 | "s_indirect2direct: \t%i\n" |
| 88 | "\n" |
| 89 | "max_hash_collisions: \t%i\n" |
| 90 | "breads: \t%lu\n" |
| 91 | "bread_misses: \t%lu\n" |
| 92 | "search_by_key: \t%lu\n" |
| 93 | "search_by_key_fs_changed: \t%lu\n" |
| 94 | "search_by_key_restarted: \t%lu\n" |
| 95 | "insert_item_restarted: \t%lu\n" |
| 96 | "paste_into_item_restarted: \t%lu\n" |
| 97 | "cut_from_item_restarted: \t%lu\n" |
| 98 | "delete_solid_item_restarted: \t%lu\n" |
| 99 | "delete_item_restarted: \t%lu\n" |
| 100 | "leaked_oid: \t%lu\n" |
| 101 | "leaves_removable: \t%lu\n", |
| 102 | SF(s_mount_state) == REISERFS_VALID_FS ? |
| 103 | "REISERFS_VALID_FS" : "REISERFS_ERROR_FS", |
| 104 | reiserfs_r5_hash(sb) ? "FORCE_R5 " : "", |
| 105 | reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "", |
| 106 | reiserfs_tea_hash(sb) ? "FORCE_TEA " : "", |
| 107 | reiserfs_hash_detect(sb) ? "DETECT_HASH " : "", |
| 108 | reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ", |
| 109 | reiserfs_no_unhashed_relocation(sb) ? |
| 110 | "NO_UNHASHED_RELOCATION " : "", |
| 111 | reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "", |
| 112 | reiserfs_test4(sb) ? "TEST4 " : "", |
| 113 | have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ? |
| 114 | "SMALL_TAILS " : "NO_TAILS ", |
| 115 | replay_only(sb) ? "REPLAY_ONLY " : "", |
| 116 | convert_reiserfs(sb) ? "CONV " : "", |
Pekka Enberg | d739b42 | 2006-02-01 03:06:43 -0800 | [diff] [blame] | 117 | atomic_read(&r->s_generation_counter), |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 118 | SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes), |
| 119 | SF(s_do_balance), SF(s_unneeded_left_neighbor), |
| 120 | SF(s_good_search_by_key_reada), SF(s_bmaps), |
| 121 | SF(s_bmaps_without_search), SF(s_direct2indirect), |
| 122 | SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads), |
| 123 | SFP(bread_miss), SFP(search_by_key), |
| 124 | SFP(search_by_key_fs_changed), SFP(search_by_key_restarted), |
| 125 | SFP(insert_item_restarted), SFP(paste_into_item_restarted), |
| 126 | SFP(cut_from_item_restarted), |
| 127 | SFP(delete_solid_item_restarted), SFP(delete_item_restarted), |
| 128 | SFP(leaked_oid), SFP(leaves_removable)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | return 0; |
| 131 | } |
| 132 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 133 | static int show_per_level(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 135 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
| 137 | int level; |
| 138 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 139 | seq_printf(m, "level\t" |
| 140 | " balances" |
| 141 | " [sbk: reads" |
| 142 | " fs_changed" |
| 143 | " restarted]" |
| 144 | " free space" |
| 145 | " items" |
| 146 | " can_remove" |
| 147 | " lnum" |
| 148 | " rnum" |
| 149 | " lbytes" |
| 150 | " rbytes" |
| 151 | " get_neig" |
| 152 | " get_neig_res" " need_l_neig" " need_r_neig" "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 154 | for (level = 0; level < MAX_HEIGHT; ++level) { |
| 155 | seq_printf(m, "%i\t" |
| 156 | " %12lu" |
| 157 | " %12lu" |
| 158 | " %12lu" |
| 159 | " %12lu" |
| 160 | " %12lu" |
| 161 | " %12lu" |
| 162 | " %12lu" |
| 163 | " %12li" |
| 164 | " %12li" |
| 165 | " %12li" |
| 166 | " %12li" |
| 167 | " %12lu" |
| 168 | " %12lu" |
| 169 | " %12lu" |
| 170 | " %12lu" |
| 171 | "\n", |
| 172 | level, |
| 173 | SFPL(balance_at), |
| 174 | SFPL(sbk_read_at), |
| 175 | SFPL(sbk_fs_changed), |
| 176 | SFPL(sbk_restarted), |
| 177 | SFPL(free_at), |
| 178 | SFPL(items_at), |
| 179 | SFPL(can_node_be_removed), |
| 180 | SFPL(lnum), |
| 181 | SFPL(rnum), |
| 182 | SFPL(lbytes), |
| 183 | SFPL(rbytes), |
| 184 | SFPL(get_neighbors), |
| 185 | SFPL(get_neighbors_restart), |
| 186 | SFPL(need_l_neighbor), SFPL(need_r_neighbor) |
| 187 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } |
| 189 | return 0; |
| 190 | } |
| 191 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 192 | static int show_bitmap(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 194 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
| 196 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 197 | seq_printf(m, "free_block: %lu\n" |
| 198 | " scan_bitmap:" |
| 199 | " wait" |
| 200 | " bmap" |
| 201 | " retry" |
| 202 | " stolen" |
| 203 | " journal_hint" |
| 204 | "journal_nohint" |
| 205 | "\n" |
| 206 | " %14lu" |
| 207 | " %14lu" |
| 208 | " %14lu" |
| 209 | " %14lu" |
| 210 | " %14lu" |
| 211 | " %14lu" |
| 212 | " %14lu" |
| 213 | "\n", |
| 214 | SFP(free_block), |
| 215 | SFPF(call), |
| 216 | SFPF(wait), |
| 217 | SFPF(bmap), |
| 218 | SFPF(retry), |
| 219 | SFPF(stolen), |
| 220 | SFPF(in_journal_hint), SFPF(in_journal_nohint)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 225 | static int show_on_disk_super(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 227 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 229 | struct reiserfs_super_block *rs = sb_info->s_rs; |
| 230 | int hash_code = DFL(s_hash_function_code); |
| 231 | __u32 flags = DJF(s_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 233 | seq_printf(m, "block_count: \t%i\n" |
| 234 | "free_blocks: \t%i\n" |
| 235 | "root_block: \t%i\n" |
| 236 | "blocksize: \t%i\n" |
| 237 | "oid_maxsize: \t%i\n" |
| 238 | "oid_cursize: \t%i\n" |
| 239 | "umount_state: \t%i\n" |
| 240 | "magic: \t%10.10s\n" |
| 241 | "fs_state: \t%i\n" |
| 242 | "hash: \t%s\n" |
| 243 | "tree_height: \t%i\n" |
| 244 | "bmap_nr: \t%i\n" |
| 245 | "version: \t%i\n" |
| 246 | "flags: \t%x[%s]\n" |
| 247 | "reserved_for_journal: \t%i\n", |
| 248 | DFL(s_block_count), |
| 249 | DFL(s_free_blocks), |
| 250 | DFL(s_root_block), |
| 251 | DF(s_blocksize), |
| 252 | DF(s_oid_maxsize), |
| 253 | DF(s_oid_cursize), |
| 254 | DF(s_umount_state), |
| 255 | rs->s_v1.s_magic, |
| 256 | DF(s_fs_state), |
| 257 | hash_code == TEA_HASH ? "tea" : |
| 258 | (hash_code == YURA_HASH) ? "rupasov" : |
| 259 | (hash_code == R5_HASH) ? "r5" : |
| 260 | (hash_code == UNSET_HASH) ? "unset" : "unknown", |
| 261 | DF(s_tree_height), |
| 262 | DF(s_bmap_nr), |
| 263 | DF(s_version), flags, (flags & reiserfs_attrs_cleared) |
| 264 | ? "attrs_cleared" : "", DF(s_reserved_for_journal)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | |
| 266 | return 0; |
| 267 | } |
| 268 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 269 | static int show_oidmap(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 271 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 273 | struct reiserfs_super_block *rs = sb_info->s_rs; |
| 274 | unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | unsigned long total_used = 0; |
| 276 | int i; |
| 277 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 278 | for (i = 0; i < mapsize; ++i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | __u32 right; |
| 280 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 281 | right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | seq_printf(m, "%s: [ %x .. %x )\n", |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 283 | (i & 1) ? "free" : "used", MAP(i), right); |
| 284 | if (!(i & 1)) { |
| 285 | total_used += right - MAP(i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } |
| 287 | } |
| 288 | #if defined( REISERFS_USE_OIDMAPF ) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 289 | if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) { |
Al Viro | 496ad9a | 2013-01-23 17:07:38 -0500 | [diff] [blame] | 290 | loff_t size = file_inode(sb_info->oidmap.mapf)->i_size; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 291 | total_used += size / sizeof(reiserfs_oidinterval_d_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | } |
| 293 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 294 | seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n", |
| 295 | mapsize, |
| 296 | mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | return 0; |
| 298 | } |
| 299 | |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 300 | static int show_journal(struct seq_file *m, void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 302 | struct super_block *sb = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 304 | struct reiserfs_super_block *rs = r->s_rs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | struct journal_params *jp = &rs->s_v1.s_journal; |
| 306 | char b[BDEVNAME_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 308 | seq_printf(m, /* on-disk fields */ |
| 309 | "jp_journal_1st_block: \t%i\n" |
| 310 | "jp_journal_dev: \t%s[%x]\n" |
| 311 | "jp_journal_size: \t%i\n" |
| 312 | "jp_journal_trans_max: \t%i\n" |
| 313 | "jp_journal_magic: \t%i\n" |
| 314 | "jp_journal_max_batch: \t%i\n" |
| 315 | "jp_journal_max_commit_age: \t%i\n" |
| 316 | "jp_journal_max_trans_age: \t%i\n" |
| 317 | /* incore fields */ |
| 318 | "j_1st_reserved_block: \t%i\n" |
| 319 | "j_state: \t%li\n" |
Jeff Mahoney | 600ed41 | 2009-03-30 14:02:17 -0400 | [diff] [blame] | 320 | "j_trans_id: \t%u\n" |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 321 | "j_mount_id: \t%lu\n" |
| 322 | "j_start: \t%lu\n" |
| 323 | "j_len: \t%lu\n" |
| 324 | "j_len_alloc: \t%lu\n" |
| 325 | "j_wcount: \t%i\n" |
| 326 | "j_bcount: \t%lu\n" |
| 327 | "j_first_unflushed_offset: \t%lu\n" |
Jeff Mahoney | 600ed41 | 2009-03-30 14:02:17 -0400 | [diff] [blame] | 328 | "j_last_flush_trans_id: \t%u\n" |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 329 | "j_trans_start_time: \t%li\n" |
| 330 | "j_list_bitmap_index: \t%i\n" |
| 331 | "j_must_wait: \t%i\n" |
| 332 | "j_next_full_flush: \t%i\n" |
| 333 | "j_next_async_flush: \t%i\n" |
| 334 | "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n" |
| 335 | /* reiserfs_proc_info_data_t.journal fields */ |
| 336 | "in_journal: \t%12lu\n" |
| 337 | "in_journal_bitmap: \t%12lu\n" |
| 338 | "in_journal_reusable: \t%12lu\n" |
| 339 | "lock_journal: \t%12lu\n" |
| 340 | "lock_journal_wait: \t%12lu\n" |
| 341 | "journal_begin: \t%12lu\n" |
| 342 | "journal_relock_writers: \t%12lu\n" |
| 343 | "journal_relock_wcount: \t%12lu\n" |
| 344 | "mark_dirty: \t%12lu\n" |
| 345 | "mark_dirty_already: \t%12lu\n" |
| 346 | "mark_dirty_notjournal: \t%12lu\n" |
| 347 | "restore_prepared: \t%12lu\n" |
| 348 | "prepare: \t%12lu\n" |
| 349 | "prepare_retry: \t%12lu\n", |
| 350 | DJP(jp_journal_1st_block), |
| 351 | bdevname(SB_JOURNAL(sb)->j_dev_bd, b), |
| 352 | DJP(jp_journal_dev), |
| 353 | DJP(jp_journal_size), |
| 354 | DJP(jp_journal_trans_max), |
| 355 | DJP(jp_journal_magic), |
| 356 | DJP(jp_journal_max_batch), |
| 357 | SB_JOURNAL(sb)->j_max_commit_age, |
| 358 | DJP(jp_journal_max_trans_age), |
| 359 | JF(j_1st_reserved_block), |
| 360 | JF(j_state), |
| 361 | JF(j_trans_id), |
| 362 | JF(j_mount_id), |
| 363 | JF(j_start), |
| 364 | JF(j_len), |
| 365 | JF(j_len_alloc), |
| 366 | atomic_read(&r->s_journal->j_wcount), |
| 367 | JF(j_bcount), |
| 368 | JF(j_first_unflushed_offset), |
| 369 | JF(j_last_flush_trans_id), |
| 370 | JF(j_trans_start_time), |
| 371 | JF(j_list_bitmap_index), |
| 372 | JF(j_must_wait), |
| 373 | JF(j_next_full_flush), |
| 374 | JF(j_next_async_flush), |
| 375 | JF(j_cnode_used), |
| 376 | JF(j_cnode_free), |
| 377 | SFPJ(in_journal), |
| 378 | SFPJ(in_journal_bitmap), |
| 379 | SFPJ(in_journal_reusable), |
| 380 | SFPJ(lock_journal), |
| 381 | SFPJ(lock_journal_wait), |
| 382 | SFPJ(journal_being), |
| 383 | SFPJ(journal_relock_writers), |
| 384 | SFPJ(journal_relock_wcount), |
| 385 | SFPJ(mark_dirty), |
| 386 | SFPJ(mark_dirty_already), |
| 387 | SFPJ(mark_dirty_notjournal), |
| 388 | SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry) |
| 389 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | return 0; |
| 391 | } |
| 392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | static int r_open(struct inode *inode, struct file *file) |
| 394 | { |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 395 | return single_open(file, PDE_DATA(inode), |
| 396 | proc_get_parent_data(inode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 399 | static const struct file_operations r_file_operations = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 400 | .open = r_open, |
| 401 | .read = seq_read, |
| 402 | .llseek = seq_lseek, |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 403 | .release = single_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | }; |
| 405 | |
| 406 | static struct proc_dir_entry *proc_info_root = NULL; |
| 407 | static const char proc_info_root_name[] = "fs/reiserfs"; |
| 408 | |
| 409 | static void add_file(struct super_block *sb, char *name, |
Al Viro | 672fe15 | 2013-08-05 17:37:37 +0400 | [diff] [blame] | 410 | int (*func) (struct seq_file *, void *)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | { |
Denis V. Lunev | 19b4fc5 | 2008-04-29 01:02:09 -0700 | [diff] [blame] | 412 | proc_create_data(name, 0, REISERFS_SB(sb)->procdir, |
| 413 | &r_file_operations, func); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 416 | int reiserfs_proc_info_init(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | { |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 418 | char b[BDEVNAME_SIZE]; |
| 419 | char *s; |
| 420 | |
| 421 | /* Some block devices use /'s */ |
Al Viro | 2ccdc41 | 2013-11-22 13:25:39 -0500 | [diff] [blame] | 422 | strlcpy(b, sb->s_id, BDEVNAME_SIZE); |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 423 | s = strchr(b, '/'); |
| 424 | if (s) |
| 425 | *s = '!'; |
| 426 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 427 | spin_lock_init(&__PINFO(sb).lock); |
David Howells | 270b5ac | 2013-04-12 02:48:30 +0100 | [diff] [blame] | 428 | REISERFS_SB(sb)->procdir = proc_mkdir_data(b, 0, proc_info_root, sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 429 | if (REISERFS_SB(sb)->procdir) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | add_file(sb, "version", show_version); |
| 431 | add_file(sb, "super", show_super); |
| 432 | add_file(sb, "per-level", show_per_level); |
| 433 | add_file(sb, "bitmap", show_bitmap); |
| 434 | add_file(sb, "on-disk-super", show_on_disk_super); |
| 435 | add_file(sb, "oidmap", show_oidmap); |
| 436 | add_file(sb, "journal", show_journal); |
| 437 | return 0; |
| 438 | } |
Jeff Mahoney | 45b03d5 | 2009-03-30 14:02:21 -0400 | [diff] [blame] | 439 | reiserfs_warning(sb, "cannot create /proc/%s/%s", |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 440 | proc_info_root_name, b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | return 1; |
| 442 | } |
| 443 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 444 | int reiserfs_proc_info_done(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | { |
| 446 | struct proc_dir_entry *de = REISERFS_SB(sb)->procdir; |
| 447 | if (de) { |
Al Viro | 121daf5 | 2013-03-30 20:16:20 -0400 | [diff] [blame] | 448 | char b[BDEVNAME_SIZE]; |
| 449 | char *s; |
| 450 | |
| 451 | /* Some block devices use /'s */ |
Al Viro | 2ccdc41 | 2013-11-22 13:25:39 -0500 | [diff] [blame] | 452 | strlcpy(b, sb->s_id, BDEVNAME_SIZE); |
Al Viro | 121daf5 | 2013-03-30 20:16:20 -0400 | [diff] [blame] | 453 | s = strchr(b, '/'); |
| 454 | if (s) |
| 455 | *s = '!'; |
| 456 | |
| 457 | remove_proc_subtree(b, proc_info_root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | REISERFS_SB(sb)->procdir = NULL; |
| 459 | } |
| 460 | return 0; |
| 461 | } |
| 462 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 463 | int reiserfs_proc_info_global_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 465 | if (proc_info_root == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | proc_info_root = proc_mkdir(proc_info_root_name, NULL); |
Alexey Dobriyan | 99b7623 | 2009-03-25 22:48:06 +0300 | [diff] [blame] | 467 | if (!proc_info_root) { |
Jeff Mahoney | 45b03d5 | 2009-03-30 14:02:21 -0400 | [diff] [blame] | 468 | reiserfs_warning(NULL, "cannot create /proc/%s", |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 469 | proc_info_root_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | return 1; |
| 471 | } |
| 472 | } |
| 473 | return 0; |
| 474 | } |
| 475 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 476 | int reiserfs_proc_info_global_done(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 478 | if (proc_info_root != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | proc_info_root = NULL; |
| 480 | remove_proc_entry(proc_info_root_name, NULL); |
| 481 | } |
| 482 | return 0; |
| 483 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | * Revision 1.1.8.2 2001/07/15 17:08:42 god |
| 486 | * . use get_super() in procfs.c |
| 487 | * . remove remove_save_link() from reiserfs_do_truncate() |
| 488 | * |
| 489 | * I accept terms and conditions stated in the Legal Agreement |
| 490 | * (available at http://www.namesys.com/legalese.html) |
| 491 | * |
| 492 | * Revision 1.1.8.1 2001/07/11 16:48:50 god |
| 493 | * proc info support |
| 494 | * |
| 495 | * I accept terms and conditions stated in the Legal Agreement |
| 496 | * (available at http://www.namesys.com/legalese.html) |
| 497 | * |
| 498 | */ |
| 499 | |
Jeff Mahoney | 0222e65 | 2009-03-30 14:02:44 -0400 | [diff] [blame] | 500 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | * Make Linus happy. |
| 502 | * Local variables: |
| 503 | * c-indentation-style: "K&R" |
| 504 | * mode-name: "LC" |
| 505 | * c-basic-offset: 8 |
| 506 | * tab-width: 8 |
| 507 | * End: |
| 508 | */ |