blob: 039b6ea1a0429b30e5e95253b42ed83d24494869 [file] [log] [blame]
Dave Kleikampac27a0e2006-10-11 01:20:50 -07001/*
Christoph Hellwig3dcf5452008-04-29 18:13:32 -04002 * ext4_sb.h
Dave Kleikampac27a0e2006-10-11 01:20:50 -07003 *
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 Hellwig3dcf5452008-04-29 18:13:32 -040016#ifndef _EXT4_SB
17#define _EXT4_SB
Dave Kleikampac27a0e2006-10-11 01:20:50 -070018
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 Feng8a356942008-07-11 19:27:31 -040028 * fourth extended-fs super-block data in memory
Dave Kleikampac27a0e2006-10-11 01:20:50 -070029 */
Mingming Cao617ba132006-10-11 01:20:53 -070030struct ext4_sb_info {
Alexandre Ratchov0d1ee422006-10-11 01:21:14 -070031 unsigned long s_desc_size; /* Size of a group descriptor in bytes */
Dave Kleikampac27a0e2006-10-11 01:20:50 -070032 unsigned long s_inodes_per_block;/* Number of inodes per block */
Dave Kleikampac27a0e2006-10-11 01:20:50 -070033 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 Mathurfd2d4292008-01-28 23:58:27 -050038 ext4_group_t s_groups_count; /* Number of groups in the fs */
Badari Pulavarty5e700302007-07-15 23:42:00 -070039 unsigned long s_overhead_last; /* Last calculated overhead */
40 unsigned long s_blocks_last; /* Last seen block count */
Eric Sandeene2b46572008-01-28 23:58:27 -050041 loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
Dave Kleikampac27a0e2006-10-11 01:20:50 -070042 struct buffer_head * s_sbh; /* Buffer containing the super block */
Theodore Ts'oaf5bc922008-09-08 22:25:24 -040043 struct ext4_super_block *s_es; /* Pointer to the super block in the buffer */
44 struct buffer_head **s_group_desc;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070045 unsigned long s_mount_opt;
Miklos Szeredid9c9bef12007-10-16 23:26:27 -070046 ext4_fsblk_t s_sb_block;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070047 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'o240799c2008-10-09 23:53:47 -040055 unsigned int s_inode_readahead_blks;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070056 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'of99b2582008-10-28 13:21:44 -040060 int s_hash_unsigned; /* 3 if hash should be signed, 0 if not */
Dave Kleikampac27a0e2006-10-11 01:20:50 -070061 struct percpu_counter s_freeblocks_counter;
62 struct percpu_counter s_freeinodes_counter;
63 struct percpu_counter s_dirs_counter;
Aneesh Kumar K.V6bc6e632008-10-10 09:39:00 -040064 struct percpu_counter s_dirtyblocks_counter;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070065 struct blockgroup_lock s_blockgroup_lock;
Theodore Ts'o9f6200b2008-09-23 09:18:24 -040066 struct proc_dir_entry *s_proc;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070067
68 /* root of the per fs reservation window tree */
69 spinlock_t s_rsv_window_lock;
70 struct rb_root s_rsv_window_root;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070071
72 /* Journaling */
Theodore Ts'oaf5bc922008-09-08 22:25:24 -040073 struct inode *s_journal_inode;
74 struct journal_s *s_journal;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070075 struct list_head s_orphan;
76 unsigned long s_commit_interval;
Theodore Ts'o30773842009-01-03 20:27:38 -050077 u32 s_max_batch_time;
78 u32 s_min_batch_time;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070079 struct block_device *journal_bdev;
Jose R. Santose23291b2007-07-18 08:57:06 -040080#ifdef CONFIG_JBD2_DEBUG
Dave Kleikampac27a0e2006-10-11 01:20:50 -070081 struct timer_list turn_ro_timer; /* For turning read-only (crash simulation) */
82 wait_queue_head_t ro_wait_queue; /* For people waiting for the fs to go read-only */
83#endif
84#ifdef CONFIG_QUOTA
85 char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
86 int s_jquota_fmt; /* Format of quota to use */
87#endif
Kalpak Shahef7f3832007-07-18 09:15:20 -040088 unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
Alex Tomasa86c6182006-10-11 01:21:03 -070089
90#ifdef EXTENTS_STATS
91 /* ext4 extents stats */
92 unsigned long s_ext_min;
93 unsigned long s_ext_max;
94 unsigned long s_depth_max;
95 spinlock_t s_ext_stats_lock;
96 unsigned long s_ext_blocks;
97 unsigned long s_ext_extents;
98#endif
Alex Tomasc9de5602008-01-29 00:19:52 -050099
100 /* for buddy allocator */
101 struct ext4_group_info ***s_group_info;
102 struct inode *s_buddy_cache;
103 long s_blocks_reserved;
104 spinlock_t s_reserve_lock;
Alex Tomasc9de5602008-01-29 00:19:52 -0500105 spinlock_t s_md_lock;
106 tid_t s_last_transaction;
Yasunori Gotoff7ef322008-12-17 00:48:39 -0500107 unsigned short *s_mb_offsets;
108 unsigned int *s_mb_maxs;
Alex Tomasc9de5602008-01-29 00:19:52 -0500109
110 /* tunables */
111 unsigned long s_stripe;
Theodore Ts'o5e8814f2008-09-23 18:07:35 -0400112 unsigned int s_mb_stream_request;
113 unsigned int s_mb_max_to_scan;
114 unsigned int s_mb_min_to_scan;
115 unsigned int s_mb_stats;
116 unsigned int s_mb_order2_reqs;
117 unsigned int s_mb_group_prealloc;
Alex Tomasc9de5602008-01-29 00:19:52 -0500118 /* where last allocation was done - for stream allocation */
119 unsigned long s_mb_last_group;
120 unsigned long s_mb_last_start;
121
122 /* history to debug policy */
123 struct ext4_mb_history *s_mb_history;
124 int s_mb_history_cur;
125 int s_mb_history_max;
126 int s_mb_history_num;
Alex Tomasc9de5602008-01-29 00:19:52 -0500127 spinlock_t s_mb_history_lock;
128 int s_mb_history_filter;
129
130 /* stats for buddy allocator */
131 spinlock_t s_mb_pa_lock;
132 atomic_t s_bal_reqs; /* number of reqs with len > 1 */
133 atomic_t s_bal_success; /* we found long enough chunks */
134 atomic_t s_bal_allocated; /* in blocks */
135 atomic_t s_bal_ex_scanned; /* total extents scanned */
136 atomic_t s_bal_goals; /* goal hits */
137 atomic_t s_bal_breaks; /* too long searches */
138 atomic_t s_bal_2orders; /* 2^order hits */
139 spinlock_t s_bal_lock;
140 unsigned long s_mb_buddies_generated;
141 unsigned long long s_mb_generation_time;
142 atomic_t s_mb_lost_chunks;
143 atomic_t s_mb_preallocated;
144 atomic_t s_mb_discarded;
145
146 /* locality groups */
147 struct ext4_locality_group *s_locality_groups;
Jose R. Santos772cb7c2008-07-11 19:27:31 -0400148
149 unsigned int s_log_groups_per_flex;
150 struct flex_groups *s_flex_groups;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700151};
152
Pekka Enbergc644f0e2009-01-04 12:00:48 -0800153static inline spinlock_t *
154sb_bgl_lock(struct ext4_sb_info *sbi, unsigned int block_group)
155{
156 return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group);
157}
158
Christoph Hellwig3dcf5452008-04-29 18:13:32 -0400159#endif /* _EXT4_SB */