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