fed up with those stupid warnings
[mmotm.git] / fs / reiser4 / super.h
blob58c9efd06aadda9f700076fbd213a25616a8db1d
1 /* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by
2 * reiser4/README */
4 /* Super-block functions. See super.c for details. */
6 #if !defined(__REISER4_SUPER_H__)
7 #define __REISER4_SUPER_H__
9 #include <linux/exportfs.h>
11 #include "tree.h"
12 #include "entd.h"
13 #include "wander.h"
14 #include "fsdata.h"
15 #include "plugin/object.h"
16 #include "plugin/space/space_allocator.h"
19 * Flush algorithms parameters.
21 struct flush_params {
22 unsigned relocate_threshold;
23 unsigned relocate_distance;
24 unsigned written_threshold;
25 unsigned scan_maxnodes;
28 typedef enum {
30 * True if this file system doesn't support hard-links (multiple names)
31 * for directories: this is default UNIX behavior.
33 * If hard-links on directoires are not allowed, file system is Acyclic
34 * Directed Graph (modulo dot, and dotdot, of course).
36 * This is used by reiser4_link().
38 REISER4_ADG = 0,
40 * set if all nodes in internal tree have the same node layout plugin.
41 * If so, znode_guess_plugin() will return tree->node_plugin in stead
42 * of guessing plugin by plugin id stored in the node.
44 REISER4_ONE_NODE_PLUGIN = 1,
45 /* if set, bsd gid assignment is supported. */
46 REISER4_BSD_GID = 2,
47 /* [mac]_time are 32 bit in inode */
48 REISER4_32_BIT_TIMES = 3,
49 /* load all bitmap blocks at mount time */
50 REISER4_DONT_LOAD_BITMAP = 5,
51 /* enforce atomicity during write(2) */
52 REISER4_ATOMIC_WRITE = 6,
53 /* don't use write barriers in the log writer code. */
54 REISER4_NO_WRITE_BARRIER = 7
55 } reiser4_fs_flag;
58 * VFS related operation vectors.
60 struct object_ops {
61 struct super_operations super;
62 struct dentry_operations dentry;
63 struct export_operations export;
66 /* reiser4-specific part of super block
68 Locking
70 Fields immutable after mount:
72 ->oid*
73 ->space*
74 ->default_[ug]id
75 ->mkfs_id
76 ->trace_flags
77 ->debug_flags
78 ->fs_flags
79 ->df_plug
80 ->optimal_io_size
81 ->plug
82 ->flush
83 ->u (bad name)
84 ->txnmgr
85 ->ra_params
86 ->fsuid
87 ->journal_header
88 ->journal_footer
90 Fields protected by ->lnode_guard
92 ->lnode_htable
94 Fields protected by per-super block spin lock
96 ->block_count
97 ->blocks_used
98 ->blocks_free
99 ->blocks_free_committed
100 ->blocks_grabbed
101 ->blocks_fake_allocated_unformatted
102 ->blocks_fake_allocated
103 ->blocks_flush_reserved
104 ->eflushed
105 ->blocknr_hint_default
107 After journal replaying during mount,
109 ->last_committed_tx
111 is protected by ->tmgr.commit_mutex
113 Invariants involving this data-type:
115 [sb-block-counts]
116 [sb-grabbed]
117 [sb-fake-allocated]
119 struct reiser4_super_info_data {
121 * guard spinlock which protects reiser4 super block fields (currently
122 * blocks_free, blocks_free_committed)
124 spinlock_t guard;
126 /* next oid that will be returned by oid_allocate() */
127 oid_t next_to_use;
128 /* total number of used oids */
129 oid_t oids_in_use;
131 /* space manager plugin */
132 reiser4_space_allocator space_allocator;
134 /* reiser4 internal tree */
135 reiser4_tree tree;
138 * default user id used for light-weight files without their own
139 * stat-data.
141 uid_t default_uid;
144 * default group id used for light-weight files without their own
145 * stat-data.
147 gid_t default_gid;
149 /* mkfs identifier generated at mkfs time. */
150 __u32 mkfs_id;
151 /* amount of blocks in a file system */
152 __u64 block_count;
154 /* inviolable reserve */
155 __u64 blocks_reserved;
157 /* amount of blocks used by file system data and meta-data. */
158 __u64 blocks_used;
161 * amount of free blocks. This is "working" free blocks counter. It is
162 * like "working" bitmap, please see block_alloc.c for description.
164 __u64 blocks_free;
167 * free block count for fs committed state. This is "commit" version of
168 * free block counter.
170 __u64 blocks_free_committed;
173 * number of blocks reserved for further allocation, for all
174 * threads.
176 __u64 blocks_grabbed;
178 /* number of fake allocated unformatted blocks in tree. */
179 __u64 blocks_fake_allocated_unformatted;
181 /* number of fake allocated formatted blocks in tree. */
182 __u64 blocks_fake_allocated;
184 /* number of blocks reserved for flush operations. */
185 __u64 blocks_flush_reserved;
187 /* number of blocks reserved for cluster operations. */
188 __u64 blocks_clustered;
190 /* unique file-system identifier */
191 __u32 fsuid;
193 /* On-disk format version. If does not equal to the disk_format
194 plugin version, some format updates (e.g. enlarging plugin
195 set, etc) may have place on mount. */
196 int version;
198 /* file-system wide flags. See reiser4_fs_flag enum */
199 unsigned long fs_flags;
201 /* transaction manager */
202 txn_mgr tmgr;
204 /* ent thread */
205 entd_context entd;
207 /* fake inode used to bind formatted nodes */
208 struct inode *fake;
209 /* inode used to bind bitmaps (and journal heads) */
210 struct inode *bitmap;
211 /* inode used to bind copied on capture nodes */
212 struct inode *cc;
214 /* disk layout plugin */
215 disk_format_plugin *df_plug;
217 /* disk layout specific part of reiser4 super info data */
218 union {
219 format40_super_info format40;
220 } u;
222 /* value we return in st_blksize on stat(2) */
223 unsigned long optimal_io_size;
225 /* parameters for the flush algorithm */
226 struct flush_params flush;
228 /* pointers to jnodes for journal header and footer */
229 jnode *journal_header;
230 jnode *journal_footer;
232 journal_location jloc;
234 /* head block number of last committed transaction */
235 __u64 last_committed_tx;
238 * we remember last written location for using as a hint for new block
239 * allocation
241 __u64 blocknr_hint_default;
243 /* committed number of files (oid allocator state variable ) */
244 __u64 nr_files_committed;
246 struct formatted_ra_params ra_params;
249 * A mutex for serializing cut tree operation if out-of-free-space:
250 * the only one cut_tree thread is allowed to grab space from reserved
251 * area (it is 5% of disk space)
253 struct mutex delete_mutex;
254 /* task owning ->delete_mutex */
255 struct task_struct *delete_mutex_owner;
257 /* Diskmap's blocknumber */
258 __u64 diskmap_block;
260 /* What to do in case of error */
261 int onerror;
263 /* operations for objects on this file system */
264 struct object_ops ops;
267 * structure to maintain d_cursors. See plugin/file_ops_readdir.c for
268 * more details
270 struct d_cursor_info d_info;
272 #ifdef CONFIG_REISER4_BADBLOCKS
273 /* Alternative master superblock offset (in bytes) */
274 unsigned long altsuper;
275 #endif
276 struct repacker *repacker;
277 struct page *status_page;
278 struct bio *status_bio;
280 #if REISER4_DEBUG
282 * minimum used blocks value (includes super blocks, bitmap blocks and
283 * other fs reserved areas), depends on fs format and fs size.
285 __u64 min_blocks_used;
288 * when debugging is on, all jnodes (including znodes, bitmaps, etc.)
289 * are kept on a list anchored at sbinfo->all_jnodes. This list is
290 * protected by sbinfo->all_guard spin lock. This lock should be taken
291 * with _irq modifier, because it is also modified from interrupt
292 * contexts (by RCU).
294 spinlock_t all_guard;
295 /* list of all jnodes */
296 struct list_head all_jnodes;
297 #endif
298 struct dentry *debugfs_root;
301 extern reiser4_super_info_data *get_super_private_nocheck(const struct
302 super_block * super);
304 /* Return reiser4-specific part of super block */
305 static inline reiser4_super_info_data *get_super_private(const struct
306 super_block * super)
308 assert("nikita-447", super != NULL);
310 return (reiser4_super_info_data *) super->s_fs_info;
313 /* get ent context for the @super */
314 static inline entd_context *get_entd_context(struct super_block *super)
316 return &get_super_private(super)->entd;
319 /* "Current" super-block: main super block used during current system
320 call. Reference to this super block is stored in reiser4_context. */
321 static inline struct super_block *reiser4_get_current_sb(void)
323 return get_current_context()->super;
326 /* Reiser4-specific part of "current" super-block: main super block used
327 during current system call. Reference to this super block is stored in
328 reiser4_context. */
329 static inline reiser4_super_info_data *get_current_super_private(void)
331 return get_super_private(reiser4_get_current_sb());
334 static inline struct formatted_ra_params *get_current_super_ra_params(void)
336 return &(get_current_super_private()->ra_params);
340 * true, if file system on @super is read-only
342 static inline int rofs_super(struct super_block *super)
344 return super->s_flags & MS_RDONLY;
348 * true, if @tree represents read-only file system
350 static inline int rofs_tree(reiser4_tree * tree)
352 return rofs_super(tree->super);
356 * true, if file system where @inode lives on, is read-only
358 static inline int rofs_inode(struct inode *inode)
360 return rofs_super(inode->i_sb);
364 * true, if file system where @node lives on, is read-only
366 static inline int rofs_jnode(jnode * node)
368 return rofs_tree(jnode_get_tree(node));
371 extern __u64 reiser4_current_block_count(void);
373 extern void build_object_ops(struct super_block *super, struct object_ops *ops);
375 #define REISER4_SUPER_MAGIC 0x52345362 /* (*(__u32 *)"R4Sb"); */
377 static inline void spin_lock_reiser4_super(reiser4_super_info_data *sbinfo)
379 spin_lock(&(sbinfo->guard));
382 static inline void spin_unlock_reiser4_super(reiser4_super_info_data *sbinfo)
384 assert_spin_locked(&(sbinfo->guard));
385 spin_unlock(&(sbinfo->guard));
388 extern __u64 reiser4_flush_reserved(const struct super_block *);
389 extern int reiser4_is_set(const struct super_block *super, reiser4_fs_flag f);
390 extern long reiser4_statfs_type(const struct super_block *super);
391 extern __u64 reiser4_block_count(const struct super_block *super);
392 extern void reiser4_set_block_count(const struct super_block *super, __u64 nr);
393 extern __u64 reiser4_data_blocks(const struct super_block *super);
394 extern void reiser4_set_data_blocks(const struct super_block *super, __u64 nr);
395 extern __u64 reiser4_free_blocks(const struct super_block *super);
396 extern void reiser4_set_free_blocks(const struct super_block *super, __u64 nr);
397 extern __u32 reiser4_mkfs_id(const struct super_block *super);
399 extern __u64 reiser4_free_committed_blocks(const struct super_block *super);
401 extern __u64 reiser4_grabbed_blocks(const struct super_block *);
402 extern __u64 reiser4_fake_allocated(const struct super_block *);
403 extern __u64 reiser4_fake_allocated_unformatted(const struct super_block *);
404 extern __u64 reiser4_clustered_blocks(const struct super_block *);
406 extern long reiser4_reserved_blocks(const struct super_block *super, uid_t uid,
407 gid_t gid);
409 extern reiser4_space_allocator *
410 reiser4_get_space_allocator(const struct super_block *super);
411 extern reiser4_oid_allocator *
412 reiser4_get_oid_allocator(const struct super_block *super);
413 extern struct inode *reiser4_get_super_fake(const struct super_block *super);
414 extern struct inode *reiser4_get_cc_fake(const struct super_block *super);
415 extern struct inode *reiser4_get_bitmap_fake(const struct super_block *super);
416 extern reiser4_tree *reiser4_get_tree(const struct super_block *super);
417 extern int is_reiser4_super(const struct super_block *super);
419 extern int reiser4_blocknr_is_sane(const reiser4_block_nr * blk);
420 extern int reiser4_blocknr_is_sane_for(const struct super_block *super,
421 const reiser4_block_nr * blk);
422 extern int reiser4_fill_super(struct super_block *s, void *data, int silent);
423 extern int reiser4_done_super(struct super_block *s);
425 /* step of fill super */
426 extern int reiser4_init_fs_info(struct super_block *);
427 extern void reiser4_done_fs_info(struct super_block *);
428 extern int reiser4_init_super_data(struct super_block *, char *opt_string);
429 extern int reiser4_init_read_super(struct super_block *, int silent);
430 extern int reiser4_init_root_inode(struct super_block *);
431 extern reiser4_plugin *get_default_plugin(pset_member memb);
433 /* Maximal possible object id. */
434 #define ABSOLUTE_MAX_OID ((oid_t)~0)
436 #define OIDS_RESERVED (1 << 16)
437 int oid_init_allocator(struct super_block *, oid_t nr_files, oid_t next);
438 oid_t oid_allocate(struct super_block *);
439 int oid_release(struct super_block *, oid_t);
440 oid_t oid_next(const struct super_block *);
441 void oid_count_allocated(void);
442 void oid_count_released(void);
443 long oids_used(const struct super_block *);
445 #if REISER4_DEBUG
446 void print_fs_info(const char *prefix, const struct super_block *);
447 #endif
449 extern void destroy_reiser4_cache(struct kmem_cache **);
451 extern struct super_operations reiser4_super_operations;
452 extern struct export_operations reiser4_export_operations;
453 extern struct dentry_operations reiser4_dentry_operations;
455 /* __REISER4_SUPER_H__ */
456 #endif
459 * Local variables:
460 * c-indentation-style: "K&R"
461 * mode-name: "LC"
462 * c-basic-offset: 8
463 * tab-width: 8
464 * fill-column: 120
465 * End: