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> |
| 14 | #include <asm/uaccess.h> |
| 15 | #include <linux/reiserfs_fs.h> |
| 16 | #include <linux/reiserfs_fs_sb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/init.h> |
| 18 | #include <linux/proc_fs.h> |
| 19 | |
Robert P. J. Day | f87367a | 2007-05-08 00:25:01 -0700 | [diff] [blame] | 20 | #ifdef CONFIG_REISERFS_PROC_INFO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * LOCKING: |
| 24 | * |
| 25 | * We rely on new Alexander Viro's super-block locking. |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | static int show_version(struct seq_file *m, struct super_block *sb) |
| 30 | { |
| 31 | char *format; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 32 | |
| 33 | if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | format = "3.6"; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 35 | } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | format = "3.5"; |
| 37 | } else { |
| 38 | format = "unknown"; |
| 39 | } |
| 40 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 41 | seq_printf(m, "%s format\twith checks %s\n", format, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #if defined( CONFIG_REISERFS_CHECK ) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 43 | "on" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #else |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 45 | "off" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 47 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 51 | int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset, |
| 52 | int count, int *eof, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
| 54 | *start = buffer; |
| 55 | *eof = 1; |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | #define SF( x ) ( r -> x ) |
| 60 | #define SFP( x ) SF( s_proc_info_data.x ) |
| 61 | #define SFPL( x ) SFP( x[ level ] ) |
| 62 | #define SFPF( x ) SFP( scan_bitmap.x ) |
| 63 | #define SFPJ( x ) SFP( journal.x ) |
| 64 | |
| 65 | #define D2C( x ) le16_to_cpu( x ) |
| 66 | #define D4C( x ) le32_to_cpu( x ) |
| 67 | #define DF( x ) D2C( rs -> s_v1.x ) |
| 68 | #define DFL( x ) D4C( rs -> s_v1.x ) |
| 69 | |
| 70 | #define objectid_map( s, rs ) (old_format_only (s) ? \ |
Al Viro | 3e8962b | 2005-05-01 08:59:18 -0700 | [diff] [blame] | 71 | (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) : \ |
| 72 | (__le32 *)(rs + 1)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #define MAP( i ) D4C( objectid_map( sb, rs )[ i ] ) |
| 74 | |
| 75 | #define DJF( x ) le32_to_cpu( rs -> x ) |
| 76 | #define DJV( x ) le32_to_cpu( s_v1 -> x ) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 77 | #define DJP( x ) le32_to_cpu( jp -> x ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | #define JF( x ) ( r -> s_journal -> x ) |
| 79 | |
| 80 | static int show_super(struct seq_file *m, struct super_block *sb) |
| 81 | { |
| 82 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 84 | seq_printf(m, "state: \t%s\n" |
| 85 | "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n" |
| 86 | "gen. counter: \t%i\n" |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 87 | "s_disk_reads: \t%i\n" |
| 88 | "s_disk_writes: \t%i\n" |
| 89 | "s_fix_nodes: \t%i\n" |
| 90 | "s_do_balance: \t%i\n" |
| 91 | "s_unneeded_left_neighbor: \t%i\n" |
| 92 | "s_good_search_by_key_reada: \t%i\n" |
| 93 | "s_bmaps: \t%i\n" |
| 94 | "s_bmaps_without_search: \t%i\n" |
| 95 | "s_direct2indirect: \t%i\n" |
| 96 | "s_indirect2direct: \t%i\n" |
| 97 | "\n" |
| 98 | "max_hash_collisions: \t%i\n" |
| 99 | "breads: \t%lu\n" |
| 100 | "bread_misses: \t%lu\n" |
| 101 | "search_by_key: \t%lu\n" |
| 102 | "search_by_key_fs_changed: \t%lu\n" |
| 103 | "search_by_key_restarted: \t%lu\n" |
| 104 | "insert_item_restarted: \t%lu\n" |
| 105 | "paste_into_item_restarted: \t%lu\n" |
| 106 | "cut_from_item_restarted: \t%lu\n" |
| 107 | "delete_solid_item_restarted: \t%lu\n" |
| 108 | "delete_item_restarted: \t%lu\n" |
| 109 | "leaked_oid: \t%lu\n" |
| 110 | "leaves_removable: \t%lu\n", |
| 111 | SF(s_mount_state) == REISERFS_VALID_FS ? |
| 112 | "REISERFS_VALID_FS" : "REISERFS_ERROR_FS", |
| 113 | reiserfs_r5_hash(sb) ? "FORCE_R5 " : "", |
| 114 | reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "", |
| 115 | reiserfs_tea_hash(sb) ? "FORCE_TEA " : "", |
| 116 | reiserfs_hash_detect(sb) ? "DETECT_HASH " : "", |
| 117 | reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ", |
| 118 | reiserfs_no_unhashed_relocation(sb) ? |
| 119 | "NO_UNHASHED_RELOCATION " : "", |
| 120 | reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "", |
| 121 | reiserfs_test4(sb) ? "TEST4 " : "", |
| 122 | have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ? |
| 123 | "SMALL_TAILS " : "NO_TAILS ", |
| 124 | replay_only(sb) ? "REPLAY_ONLY " : "", |
| 125 | convert_reiserfs(sb) ? "CONV " : "", |
Pekka Enberg | d739b42 | 2006-02-01 03:06:43 -0800 | [diff] [blame] | 126 | atomic_read(&r->s_generation_counter), |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 127 | SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes), |
| 128 | SF(s_do_balance), SF(s_unneeded_left_neighbor), |
| 129 | SF(s_good_search_by_key_reada), SF(s_bmaps), |
| 130 | SF(s_bmaps_without_search), SF(s_direct2indirect), |
| 131 | SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads), |
| 132 | SFP(bread_miss), SFP(search_by_key), |
| 133 | SFP(search_by_key_fs_changed), SFP(search_by_key_restarted), |
| 134 | SFP(insert_item_restarted), SFP(paste_into_item_restarted), |
| 135 | SFP(cut_from_item_restarted), |
| 136 | SFP(delete_solid_item_restarted), SFP(delete_item_restarted), |
| 137 | SFP(leaked_oid), SFP(leaves_removable)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static int show_per_level(struct seq_file *m, struct super_block *sb) |
| 143 | { |
| 144 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
| 145 | int level; |
| 146 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 147 | seq_printf(m, "level\t" |
| 148 | " balances" |
| 149 | " [sbk: reads" |
| 150 | " fs_changed" |
| 151 | " restarted]" |
| 152 | " free space" |
| 153 | " items" |
| 154 | " can_remove" |
| 155 | " lnum" |
| 156 | " rnum" |
| 157 | " lbytes" |
| 158 | " rbytes" |
| 159 | " get_neig" |
| 160 | " get_neig_res" " need_l_neig" " need_r_neig" "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 162 | for (level = 0; level < MAX_HEIGHT; ++level) { |
| 163 | seq_printf(m, "%i\t" |
| 164 | " %12lu" |
| 165 | " %12lu" |
| 166 | " %12lu" |
| 167 | " %12lu" |
| 168 | " %12lu" |
| 169 | " %12lu" |
| 170 | " %12lu" |
| 171 | " %12li" |
| 172 | " %12li" |
| 173 | " %12li" |
| 174 | " %12li" |
| 175 | " %12lu" |
| 176 | " %12lu" |
| 177 | " %12lu" |
| 178 | " %12lu" |
| 179 | "\n", |
| 180 | level, |
| 181 | SFPL(balance_at), |
| 182 | SFPL(sbk_read_at), |
| 183 | SFPL(sbk_fs_changed), |
| 184 | SFPL(sbk_restarted), |
| 185 | SFPL(free_at), |
| 186 | SFPL(items_at), |
| 187 | SFPL(can_node_be_removed), |
| 188 | SFPL(lnum), |
| 189 | SFPL(rnum), |
| 190 | SFPL(lbytes), |
| 191 | SFPL(rbytes), |
| 192 | SFPL(get_neighbors), |
| 193 | SFPL(get_neighbors_restart), |
| 194 | SFPL(need_l_neighbor), SFPL(need_r_neighbor) |
| 195 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | } |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | static int show_bitmap(struct seq_file *m, struct super_block *sb) |
| 201 | { |
| 202 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
| 203 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 204 | seq_printf(m, "free_block: %lu\n" |
| 205 | " scan_bitmap:" |
| 206 | " wait" |
| 207 | " bmap" |
| 208 | " retry" |
| 209 | " stolen" |
| 210 | " journal_hint" |
| 211 | "journal_nohint" |
| 212 | "\n" |
| 213 | " %14lu" |
| 214 | " %14lu" |
| 215 | " %14lu" |
| 216 | " %14lu" |
| 217 | " %14lu" |
| 218 | " %14lu" |
| 219 | " %14lu" |
| 220 | "\n", |
| 221 | SFP(free_block), |
| 222 | SFPF(call), |
| 223 | SFPF(wait), |
| 224 | SFPF(bmap), |
| 225 | SFPF(retry), |
| 226 | SFPF(stolen), |
| 227 | SFPF(in_journal_hint), SFPF(in_journal_nohint)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | return 0; |
| 230 | } |
| 231 | |
| 232 | static int show_on_disk_super(struct seq_file *m, struct super_block *sb) |
| 233 | { |
| 234 | struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 235 | struct reiserfs_super_block *rs = sb_info->s_rs; |
| 236 | int hash_code = DFL(s_hash_function_code); |
| 237 | __u32 flags = DJF(s_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 239 | seq_printf(m, "block_count: \t%i\n" |
| 240 | "free_blocks: \t%i\n" |
| 241 | "root_block: \t%i\n" |
| 242 | "blocksize: \t%i\n" |
| 243 | "oid_maxsize: \t%i\n" |
| 244 | "oid_cursize: \t%i\n" |
| 245 | "umount_state: \t%i\n" |
| 246 | "magic: \t%10.10s\n" |
| 247 | "fs_state: \t%i\n" |
| 248 | "hash: \t%s\n" |
| 249 | "tree_height: \t%i\n" |
| 250 | "bmap_nr: \t%i\n" |
| 251 | "version: \t%i\n" |
| 252 | "flags: \t%x[%s]\n" |
| 253 | "reserved_for_journal: \t%i\n", |
| 254 | DFL(s_block_count), |
| 255 | DFL(s_free_blocks), |
| 256 | DFL(s_root_block), |
| 257 | DF(s_blocksize), |
| 258 | DF(s_oid_maxsize), |
| 259 | DF(s_oid_cursize), |
| 260 | DF(s_umount_state), |
| 261 | rs->s_v1.s_magic, |
| 262 | DF(s_fs_state), |
| 263 | hash_code == TEA_HASH ? "tea" : |
| 264 | (hash_code == YURA_HASH) ? "rupasov" : |
| 265 | (hash_code == R5_HASH) ? "r5" : |
| 266 | (hash_code == UNSET_HASH) ? "unset" : "unknown", |
| 267 | DF(s_tree_height), |
| 268 | DF(s_bmap_nr), |
| 269 | DF(s_version), flags, (flags & reiserfs_attrs_cleared) |
| 270 | ? "attrs_cleared" : "", DF(s_reserved_for_journal)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | |
| 275 | static int show_oidmap(struct seq_file *m, struct super_block *sb) |
| 276 | { |
| 277 | struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 278 | struct reiserfs_super_block *rs = sb_info->s_rs; |
| 279 | unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | unsigned long total_used = 0; |
| 281 | int i; |
| 282 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 283 | for (i = 0; i < mapsize; ++i) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | __u32 right; |
| 285 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 286 | right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | seq_printf(m, "%s: [ %x .. %x )\n", |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 288 | (i & 1) ? "free" : "used", MAP(i), right); |
| 289 | if (!(i & 1)) { |
| 290 | total_used += right - MAP(i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | #if defined( REISERFS_USE_OIDMAPF ) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 294 | if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) { |
Josef Sipek | 1fc5adb | 2006-12-08 02:37:33 -0800 | [diff] [blame] | 295 | loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 296 | total_used += size / sizeof(reiserfs_oidinterval_d_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 299 | seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n", |
| 300 | mapsize, |
| 301 | mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | static int show_journal(struct seq_file *m, struct super_block *sb) |
| 306 | { |
| 307 | struct reiserfs_sb_info *r = REISERFS_SB(sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 308 | struct reiserfs_super_block *rs = r->s_rs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | struct journal_params *jp = &rs->s_v1.s_journal; |
| 310 | char b[BDEVNAME_SIZE]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 312 | seq_printf(m, /* on-disk fields */ |
| 313 | "jp_journal_1st_block: \t%i\n" |
| 314 | "jp_journal_dev: \t%s[%x]\n" |
| 315 | "jp_journal_size: \t%i\n" |
| 316 | "jp_journal_trans_max: \t%i\n" |
| 317 | "jp_journal_magic: \t%i\n" |
| 318 | "jp_journal_max_batch: \t%i\n" |
| 319 | "jp_journal_max_commit_age: \t%i\n" |
| 320 | "jp_journal_max_trans_age: \t%i\n" |
| 321 | /* incore fields */ |
| 322 | "j_1st_reserved_block: \t%i\n" |
| 323 | "j_state: \t%li\n" |
Jeff Mahoney | 600ed41 | 2009-03-30 14:02:17 -0400 | [diff] [blame] | 324 | "j_trans_id: \t%u\n" |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 325 | "j_mount_id: \t%lu\n" |
| 326 | "j_start: \t%lu\n" |
| 327 | "j_len: \t%lu\n" |
| 328 | "j_len_alloc: \t%lu\n" |
| 329 | "j_wcount: \t%i\n" |
| 330 | "j_bcount: \t%lu\n" |
| 331 | "j_first_unflushed_offset: \t%lu\n" |
Jeff Mahoney | 600ed41 | 2009-03-30 14:02:17 -0400 | [diff] [blame] | 332 | "j_last_flush_trans_id: \t%u\n" |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 333 | "j_trans_start_time: \t%li\n" |
| 334 | "j_list_bitmap_index: \t%i\n" |
| 335 | "j_must_wait: \t%i\n" |
| 336 | "j_next_full_flush: \t%i\n" |
| 337 | "j_next_async_flush: \t%i\n" |
| 338 | "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n" |
| 339 | /* reiserfs_proc_info_data_t.journal fields */ |
| 340 | "in_journal: \t%12lu\n" |
| 341 | "in_journal_bitmap: \t%12lu\n" |
| 342 | "in_journal_reusable: \t%12lu\n" |
| 343 | "lock_journal: \t%12lu\n" |
| 344 | "lock_journal_wait: \t%12lu\n" |
| 345 | "journal_begin: \t%12lu\n" |
| 346 | "journal_relock_writers: \t%12lu\n" |
| 347 | "journal_relock_wcount: \t%12lu\n" |
| 348 | "mark_dirty: \t%12lu\n" |
| 349 | "mark_dirty_already: \t%12lu\n" |
| 350 | "mark_dirty_notjournal: \t%12lu\n" |
| 351 | "restore_prepared: \t%12lu\n" |
| 352 | "prepare: \t%12lu\n" |
| 353 | "prepare_retry: \t%12lu\n", |
| 354 | DJP(jp_journal_1st_block), |
| 355 | bdevname(SB_JOURNAL(sb)->j_dev_bd, b), |
| 356 | DJP(jp_journal_dev), |
| 357 | DJP(jp_journal_size), |
| 358 | DJP(jp_journal_trans_max), |
| 359 | DJP(jp_journal_magic), |
| 360 | DJP(jp_journal_max_batch), |
| 361 | SB_JOURNAL(sb)->j_max_commit_age, |
| 362 | DJP(jp_journal_max_trans_age), |
| 363 | JF(j_1st_reserved_block), |
| 364 | JF(j_state), |
| 365 | JF(j_trans_id), |
| 366 | JF(j_mount_id), |
| 367 | JF(j_start), |
| 368 | JF(j_len), |
| 369 | JF(j_len_alloc), |
| 370 | atomic_read(&r->s_journal->j_wcount), |
| 371 | JF(j_bcount), |
| 372 | JF(j_first_unflushed_offset), |
| 373 | JF(j_last_flush_trans_id), |
| 374 | JF(j_trans_start_time), |
| 375 | JF(j_list_bitmap_index), |
| 376 | JF(j_must_wait), |
| 377 | JF(j_next_full_flush), |
| 378 | JF(j_next_async_flush), |
| 379 | JF(j_cnode_used), |
| 380 | JF(j_cnode_free), |
| 381 | SFPJ(in_journal), |
| 382 | SFPJ(in_journal_bitmap), |
| 383 | SFPJ(in_journal_reusable), |
| 384 | SFPJ(lock_journal), |
| 385 | SFPJ(lock_journal_wait), |
| 386 | SFPJ(journal_being), |
| 387 | SFPJ(journal_relock_writers), |
| 388 | SFPJ(journal_relock_wcount), |
| 389 | SFPJ(mark_dirty), |
| 390 | SFPJ(mark_dirty_already), |
| 391 | SFPJ(mark_dirty_notjournal), |
| 392 | SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry) |
| 393 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | /* iterator */ |
| 398 | static int test_sb(struct super_block *sb, void *data) |
| 399 | { |
| 400 | return data == sb; |
| 401 | } |
| 402 | |
| 403 | static int set_sb(struct super_block *sb, void *data) |
| 404 | { |
| 405 | return -ENOENT; |
| 406 | } |
| 407 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 408 | static void *r_start(struct seq_file *m, loff_t * pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | { |
| 410 | struct proc_dir_entry *de = m->private; |
| 411 | struct super_block *s = de->parent->data; |
| 412 | loff_t l = *pos; |
| 413 | |
| 414 | if (l) |
| 415 | return NULL; |
| 416 | |
| 417 | if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, s))) |
| 418 | return NULL; |
| 419 | |
| 420 | up_write(&s->s_umount); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | return s; |
| 422 | } |
| 423 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 424 | static void *r_next(struct seq_file *m, void *v, loff_t * pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | { |
| 426 | ++*pos; |
| 427 | if (v) |
| 428 | deactivate_super(v); |
| 429 | return NULL; |
| 430 | } |
| 431 | |
| 432 | static void r_stop(struct seq_file *m, void *v) |
| 433 | { |
| 434 | if (v) |
| 435 | deactivate_super(v); |
| 436 | } |
| 437 | |
| 438 | static int r_show(struct seq_file *m, void *v) |
| 439 | { |
| 440 | struct proc_dir_entry *de = m->private; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 441 | int (*show) (struct seq_file *, struct super_block *) = de->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | return show(m, v); |
| 443 | } |
| 444 | |
Jan Engelhardt | ec26e11 | 2008-02-08 04:21:18 -0800 | [diff] [blame] | 445 | static const struct seq_operations r_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | .start = r_start, |
| 447 | .next = r_next, |
| 448 | .stop = r_stop, |
| 449 | .show = r_show, |
| 450 | }; |
| 451 | |
| 452 | static int r_open(struct inode *inode, struct file *file) |
| 453 | { |
| 454 | int ret = seq_open(file, &r_ops); |
| 455 | |
| 456 | if (!ret) { |
| 457 | struct seq_file *m = file->private_data; |
| 458 | m->private = PDE(inode); |
| 459 | } |
| 460 | return ret; |
| 461 | } |
| 462 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 463 | static const struct file_operations r_file_operations = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 464 | .open = r_open, |
| 465 | .read = seq_read, |
| 466 | .llseek = seq_lseek, |
| 467 | .release = seq_release, |
Denis V. Lunev | 19b4fc5 | 2008-04-29 01:02:09 -0700 | [diff] [blame] | 468 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | }; |
| 470 | |
| 471 | static struct proc_dir_entry *proc_info_root = NULL; |
| 472 | static const char proc_info_root_name[] = "fs/reiserfs"; |
| 473 | |
| 474 | static void add_file(struct super_block *sb, char *name, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 475 | int (*func) (struct seq_file *, struct super_block *)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | { |
Denis V. Lunev | 19b4fc5 | 2008-04-29 01:02:09 -0700 | [diff] [blame] | 477 | proc_create_data(name, 0, REISERFS_SB(sb)->procdir, |
| 478 | &r_file_operations, func); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 481 | int reiserfs_proc_info_init(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | { |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 483 | char b[BDEVNAME_SIZE]; |
| 484 | char *s; |
| 485 | |
| 486 | /* Some block devices use /'s */ |
| 487 | strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE); |
| 488 | s = strchr(b, '/'); |
| 489 | if (s) |
| 490 | *s = '!'; |
| 491 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 492 | spin_lock_init(&__PINFO(sb).lock); |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 493 | REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 494 | if (REISERFS_SB(sb)->procdir) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | REISERFS_SB(sb)->procdir->data = sb; |
| 496 | add_file(sb, "version", show_version); |
| 497 | add_file(sb, "super", show_super); |
| 498 | add_file(sb, "per-level", show_per_level); |
| 499 | add_file(sb, "bitmap", show_bitmap); |
| 500 | add_file(sb, "on-disk-super", show_on_disk_super); |
| 501 | add_file(sb, "oidmap", show_oidmap); |
| 502 | add_file(sb, "journal", show_journal); |
| 503 | return 0; |
| 504 | } |
Jeff Mahoney | 45b03d5 | 2009-03-30 14:02:21 -0400 | [diff] [blame] | 505 | reiserfs_warning(sb, "cannot create /proc/%s/%s", |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 506 | proc_info_root_name, b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | return 1; |
| 508 | } |
| 509 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 510 | int reiserfs_proc_info_done(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | { |
| 512 | struct proc_dir_entry *de = REISERFS_SB(sb)->procdir; |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 513 | char b[BDEVNAME_SIZE]; |
| 514 | char *s; |
| 515 | |
| 516 | /* Some block devices use /'s */ |
| 517 | strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE); |
| 518 | s = strchr(b, '/'); |
| 519 | if (s) |
| 520 | *s = '!'; |
| 521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | if (de) { |
| 523 | remove_proc_entry("journal", de); |
| 524 | remove_proc_entry("oidmap", de); |
| 525 | remove_proc_entry("on-disk-super", de); |
| 526 | remove_proc_entry("bitmap", de); |
| 527 | remove_proc_entry("per-level", de); |
| 528 | remove_proc_entry("super", de); |
| 529 | remove_proc_entry("version", de); |
| 530 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 531 | spin_lock(&__PINFO(sb).lock); |
| 532 | __PINFO(sb).exiting = 1; |
| 533 | spin_unlock(&__PINFO(sb).lock); |
| 534 | if (proc_info_root) { |
Jeff Mahoney | 6fbe82a | 2006-07-14 00:24:22 -0700 | [diff] [blame] | 535 | remove_proc_entry(b, proc_info_root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | REISERFS_SB(sb)->procdir = NULL; |
| 537 | } |
| 538 | return 0; |
| 539 | } |
| 540 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 541 | struct proc_dir_entry *reiserfs_proc_register_global(char *name, |
| 542 | read_proc_t * func) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 544 | return (proc_info_root) ? create_proc_read_entry(name, 0, |
| 545 | proc_info_root, |
| 546 | func, NULL) : NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 549 | void reiserfs_proc_unregister_global(const char *name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 551 | remove_proc_entry(name, proc_info_root); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | } |
| 553 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 554 | int reiserfs_proc_info_global_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 556 | if (proc_info_root == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | proc_info_root = proc_mkdir(proc_info_root_name, NULL); |
Alexey Dobriyan | 99b7623 | 2009-03-25 22:48:06 +0300 | [diff] [blame] | 558 | if (!proc_info_root) { |
Jeff Mahoney | 45b03d5 | 2009-03-30 14:02:21 -0400 | [diff] [blame] | 559 | reiserfs_warning(NULL, "cannot create /proc/%s", |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 560 | proc_info_root_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | return 1; |
| 562 | } |
| 563 | } |
| 564 | return 0; |
| 565 | } |
| 566 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 567 | int reiserfs_proc_info_global_done(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 569 | if (proc_info_root != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | proc_info_root = NULL; |
| 571 | remove_proc_entry(proc_info_root_name, NULL); |
| 572 | } |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | /* REISERFS_PROC_INFO */ |
| 577 | #else |
| 578 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 579 | int reiserfs_proc_info_init(struct super_block *sb) |
| 580 | { |
| 581 | return 0; |
| 582 | } |
| 583 | int reiserfs_proc_info_done(struct super_block *sb) |
| 584 | { |
| 585 | return 0; |
| 586 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 588 | struct proc_dir_entry *reiserfs_proc_register_global(char *name, |
| 589 | read_proc_t * func) |
| 590 | { |
| 591 | return NULL; |
| 592 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 594 | void reiserfs_proc_unregister_global(const char *name) |
| 595 | {; |
| 596 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 598 | int reiserfs_proc_info_global_init(void) |
| 599 | { |
| 600 | return 0; |
| 601 | } |
| 602 | int reiserfs_proc_info_global_done(void) |
| 603 | { |
| 604 | return 0; |
| 605 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 607 | int reiserfs_global_version_in_proc(char *buffer, char **start, |
| 608 | off_t offset, |
| 609 | int count, int *eof, void *data) |
| 610 | { |
| 611 | return 0; |
| 612 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
| 614 | /* REISERFS_PROC_INFO */ |
| 615 | #endif |
| 616 | |
| 617 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | * Revision 1.1.8.2 2001/07/15 17:08:42 god |
| 619 | * . use get_super() in procfs.c |
| 620 | * . remove remove_save_link() from reiserfs_do_truncate() |
| 621 | * |
| 622 | * I accept terms and conditions stated in the Legal Agreement |
| 623 | * (available at http://www.namesys.com/legalese.html) |
| 624 | * |
| 625 | * Revision 1.1.8.1 2001/07/11 16:48:50 god |
| 626 | * proc info support |
| 627 | * |
| 628 | * I accept terms and conditions stated in the Legal Agreement |
| 629 | * (available at http://www.namesys.com/legalese.html) |
| 630 | * |
| 631 | */ |
| 632 | |
Jeff Mahoney | 0222e65 | 2009-03-30 14:02:44 -0400 | [diff] [blame] | 633 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | * Make Linus happy. |
| 635 | * Local variables: |
| 636 | * c-indentation-style: "K&R" |
| 637 | * mode-name: "LC" |
| 638 | * c-basic-offset: 8 |
| 639 | * tab-width: 8 |
| 640 | * End: |
| 641 | */ |