Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 1 | /* |
Christoph Hellwig | 3dcf545 | 2008-04-29 18:13:32 -0400 | [diff] [blame] | 2 | * ext4_sb.h |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1992, 1993, 1994, 1995 |
| 5 | * Remy Card (card@masi.ibp.fr) |
| 6 | * Laboratoire MASI - Institut Blaise Pascal |
| 7 | * Universite Pierre et Marie Curie (Paris VI) |
| 8 | * |
| 9 | * from |
| 10 | * |
| 11 | * linux/include/linux/minix_fs_sb.h |
| 12 | * |
| 13 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 14 | */ |
| 15 | |
Christoph Hellwig | 3dcf545 | 2008-04-29 18:13:32 -0400 | [diff] [blame] | 16 | #ifndef _EXT4_SB |
| 17 | #define _EXT4_SB |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 18 | |
| 19 | #ifdef __KERNEL__ |
| 20 | #include <linux/timer.h> |
| 21 | #include <linux/wait.h> |
| 22 | #include <linux/blockgroup_lock.h> |
| 23 | #include <linux/percpu_counter.h> |
| 24 | #endif |
| 25 | #include <linux/rbtree.h> |
| 26 | |
| 27 | /* |
Shen Feng | 8a35694 | 2008-07-11 19:27:31 -0400 | [diff] [blame] | 28 | * fourth extended-fs super-block data in memory |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 29 | */ |
Mingming Cao | 617ba13 | 2006-10-11 01:20:53 -0700 | [diff] [blame] | 30 | struct ext4_sb_info { |
Alexandre Ratchov | 0d1ee42 | 2006-10-11 01:21:14 -0700 | [diff] [blame] | 31 | unsigned long s_desc_size; /* Size of a group descriptor in bytes */ |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 32 | unsigned long s_inodes_per_block;/* Number of inodes per block */ |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 33 | unsigned long s_blocks_per_group;/* Number of blocks in a group */ |
| 34 | unsigned long s_inodes_per_group;/* Number of inodes in a group */ |
| 35 | unsigned long s_itb_per_group; /* Number of inode table blocks per group */ |
| 36 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ |
| 37 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ |
Avantika Mathur | fd2d429 | 2008-01-28 23:58:27 -0500 | [diff] [blame] | 38 | ext4_group_t s_groups_count; /* Number of groups in the fs */ |
Badari Pulavarty | 5e70030 | 2007-07-15 23:42:00 -0700 | [diff] [blame] | 39 | unsigned long s_overhead_last; /* Last calculated overhead */ |
| 40 | unsigned long s_blocks_last; /* Last seen block count */ |
Eric Sandeen | e2b4657 | 2008-01-28 23:58:27 -0500 | [diff] [blame] | 41 | loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */ |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 42 | struct buffer_head * s_sbh; /* Buffer containing the super block */ |
Theodore Ts'o | af5bc92 | 2008-09-08 22:25:24 -0400 | [diff] [blame] | 43 | struct ext4_super_block *s_es; /* Pointer to the super block in the buffer */ |
| 44 | struct buffer_head **s_group_desc; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 45 | unsigned long s_mount_opt; |
Miklos Szeredi | d9c9bef1 | 2007-10-16 23:26:27 -0700 | [diff] [blame] | 46 | ext4_fsblk_t s_sb_block; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 47 | uid_t s_resuid; |
| 48 | gid_t s_resgid; |
| 49 | unsigned short s_mount_state; |
| 50 | unsigned short s_pad; |
| 51 | int s_addr_per_block_bits; |
| 52 | int s_desc_per_block_bits; |
| 53 | int s_inode_size; |
| 54 | int s_first_ino; |
Theodore Ts'o | 240799c | 2008-10-09 23:53:47 -0400 | [diff] [blame] | 55 | unsigned int s_inode_readahead_blks; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 56 | spinlock_t s_next_gen_lock; |
| 57 | u32 s_next_generation; |
| 58 | u32 s_hash_seed[4]; |
| 59 | int s_def_hash_version; |
Theodore Ts'o | f99b258 | 2008-10-28 13:21:44 -0400 | [diff] [blame] | 60 | int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */ |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 61 | struct percpu_counter s_freeblocks_counter; |
| 62 | struct percpu_counter s_freeinodes_counter; |
| 63 | struct percpu_counter s_dirs_counter; |
Aneesh Kumar K.V | 6bc6e63 | 2008-10-10 09:39:00 -0400 | [diff] [blame] | 64 | struct percpu_counter s_dirtyblocks_counter; |
Pekka Enberg | 705895b | 2009-02-15 18:07:52 -0500 | [diff] [blame] | 65 | struct blockgroup_lock *s_blockgroup_lock; |
Theodore Ts'o | 9f6200b | 2008-09-23 09:18:24 -0400 | [diff] [blame] | 66 | struct proc_dir_entry *s_proc; |
Theodore Ts'o | 3197ebd | 2009-03-31 09:10:09 -0400 | [diff] [blame] | 67 | struct kobject s_kobj; |
| 68 | struct completion s_kobj_unregister; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 69 | |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 70 | /* Journaling */ |
Theodore Ts'o | af5bc92 | 2008-09-08 22:25:24 -0400 | [diff] [blame] | 71 | struct inode *s_journal_inode; |
| 72 | struct journal_s *s_journal; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 73 | struct list_head s_orphan; |
| 74 | unsigned long s_commit_interval; |
Theodore Ts'o | 3077384 | 2009-01-03 20:27:38 -0500 | [diff] [blame] | 75 | u32 s_max_batch_time; |
| 76 | u32 s_min_batch_time; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 77 | struct block_device *journal_bdev; |
Jose R. Santos | e23291b | 2007-07-18 08:57:06 -0400 | [diff] [blame] | 78 | #ifdef CONFIG_JBD2_DEBUG |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 79 | struct timer_list turn_ro_timer; /* For turning read-only (crash simulation) */ |
| 80 | wait_queue_head_t ro_wait_queue; /* For people waiting for the fs to go read-only */ |
| 81 | #endif |
| 82 | #ifdef CONFIG_QUOTA |
| 83 | char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */ |
| 84 | int s_jquota_fmt; /* Format of quota to use */ |
| 85 | #endif |
Kalpak Shah | ef7f383 | 2007-07-18 09:15:20 -0400 | [diff] [blame] | 86 | unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */ |
Alex Tomas | a86c618 | 2006-10-11 01:21:03 -0700 | [diff] [blame] | 87 | |
| 88 | #ifdef EXTENTS_STATS |
| 89 | /* ext4 extents stats */ |
| 90 | unsigned long s_ext_min; |
| 91 | unsigned long s_ext_max; |
| 92 | unsigned long s_depth_max; |
| 93 | spinlock_t s_ext_stats_lock; |
| 94 | unsigned long s_ext_blocks; |
| 95 | unsigned long s_ext_extents; |
| 96 | #endif |
Alex Tomas | c9de560 | 2008-01-29 00:19:52 -0500 | [diff] [blame] | 97 | |
| 98 | /* for buddy allocator */ |
| 99 | struct ext4_group_info ***s_group_info; |
| 100 | struct inode *s_buddy_cache; |
| 101 | long s_blocks_reserved; |
| 102 | spinlock_t s_reserve_lock; |
Alex Tomas | c9de560 | 2008-01-29 00:19:52 -0500 | [diff] [blame] | 103 | spinlock_t s_md_lock; |
| 104 | tid_t s_last_transaction; |
Yasunori Goto | ff7ef32 | 2008-12-17 00:48:39 -0500 | [diff] [blame] | 105 | unsigned short *s_mb_offsets; |
| 106 | unsigned int *s_mb_maxs; |
Alex Tomas | c9de560 | 2008-01-29 00:19:52 -0500 | [diff] [blame] | 107 | |
| 108 | /* tunables */ |
| 109 | unsigned long s_stripe; |
Theodore Ts'o | 5e8814f | 2008-09-23 18:07:35 -0400 | [diff] [blame] | 110 | unsigned int s_mb_stream_request; |
| 111 | unsigned int s_mb_max_to_scan; |
| 112 | unsigned int s_mb_min_to_scan; |
| 113 | unsigned int s_mb_stats; |
| 114 | unsigned int s_mb_order2_reqs; |
| 115 | unsigned int s_mb_group_prealloc; |
Alex Tomas | c9de560 | 2008-01-29 00:19:52 -0500 | [diff] [blame] | 116 | /* where last allocation was done - for stream allocation */ |
| 117 | unsigned long s_mb_last_group; |
| 118 | unsigned long s_mb_last_start; |
| 119 | |
| 120 | /* history to debug policy */ |
| 121 | struct ext4_mb_history *s_mb_history; |
| 122 | int s_mb_history_cur; |
| 123 | int s_mb_history_max; |
| 124 | int s_mb_history_num; |
Alex Tomas | c9de560 | 2008-01-29 00:19:52 -0500 | [diff] [blame] | 125 | spinlock_t s_mb_history_lock; |
| 126 | int s_mb_history_filter; |
| 127 | |
| 128 | /* stats for buddy allocator */ |
| 129 | spinlock_t s_mb_pa_lock; |
| 130 | atomic_t s_bal_reqs; /* number of reqs with len > 1 */ |
| 131 | atomic_t s_bal_success; /* we found long enough chunks */ |
| 132 | atomic_t s_bal_allocated; /* in blocks */ |
| 133 | atomic_t s_bal_ex_scanned; /* total extents scanned */ |
| 134 | atomic_t s_bal_goals; /* goal hits */ |
| 135 | atomic_t s_bal_breaks; /* too long searches */ |
| 136 | atomic_t s_bal_2orders; /* 2^order hits */ |
| 137 | spinlock_t s_bal_lock; |
| 138 | unsigned long s_mb_buddies_generated; |
| 139 | unsigned long long s_mb_generation_time; |
| 140 | atomic_t s_mb_lost_chunks; |
| 141 | atomic_t s_mb_preallocated; |
| 142 | atomic_t s_mb_discarded; |
| 143 | |
| 144 | /* locality groups */ |
| 145 | struct ext4_locality_group *s_locality_groups; |
Jose R. Santos | 772cb7c | 2008-07-11 19:27:31 -0400 | [diff] [blame] | 146 | |
Theodore Ts'o | afc32f7 | 2009-02-28 19:39:58 -0500 | [diff] [blame] | 147 | /* for write statistics */ |
| 148 | unsigned long s_sectors_written_start; |
| 149 | u64 s_kbytes_written; |
| 150 | |
Jose R. Santos | 772cb7c | 2008-07-11 19:27:31 -0400 | [diff] [blame] | 151 | unsigned int s_log_groups_per_flex; |
| 152 | struct flex_groups *s_flex_groups; |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
Pekka Enberg | c644f0e | 2009-01-04 12:00:48 -0800 | [diff] [blame] | 155 | static inline spinlock_t * |
| 156 | sb_bgl_lock(struct ext4_sb_info *sbi, unsigned int block_group) |
| 157 | { |
Pekka Enberg | 705895b | 2009-02-15 18:07:52 -0500 | [diff] [blame] | 158 | return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group); |
Pekka Enberg | c644f0e | 2009-01-04 12:00:48 -0800 | [diff] [blame] | 159 | } |
| 160 | |
Christoph Hellwig | 3dcf545 | 2008-04-29 18:13:32 -0400 | [diff] [blame] | 161 | #endif /* _EXT4_SB */ |