aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/reiserfs_fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/reiserfs_fs.h')
-rw-r--r--include/linux/reiserfs_fs.h132
1 files changed, 110 insertions, 22 deletions
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index dd31e7bae35c..1ba3cf6edfbb 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -52,11 +52,89 @@
52#define REISERFS_IOC32_GETVERSION FS_IOC32_GETVERSION 52#define REISERFS_IOC32_GETVERSION FS_IOC32_GETVERSION
53#define REISERFS_IOC32_SETVERSION FS_IOC32_SETVERSION 53#define REISERFS_IOC32_SETVERSION FS_IOC32_SETVERSION
54 54
55/* Locking primitives */ 55/*
56/* Right now we are still falling back to (un)lock_kernel, but eventually that 56 * Locking primitives. The write lock is a per superblock
57 would evolve into real per-fs locks */ 57 * special mutex that has properties close to the Big Kernel Lock
58#define reiserfs_write_lock( sb ) lock_kernel() 58 * which was used in the previous locking scheme.
59#define reiserfs_write_unlock( sb ) unlock_kernel() 59 */
60void reiserfs_write_lock(struct super_block *s);
61void reiserfs_write_unlock(struct super_block *s);
62int reiserfs_write_lock_once(struct super_block *s);
63void reiserfs_write_unlock_once(struct super_block *s, int lock_depth);
64
65#ifdef CONFIG_REISERFS_CHECK
66void reiserfs_lock_check_recursive(struct super_block *s);
67#else
68static inline void reiserfs_lock_check_recursive(struct super_block *s) { }
69#endif
70
71/*
72 * Several mutexes depend on the write lock.
73 * However sometimes we want to relax the write lock while we hold
74 * these mutexes, according to the release/reacquire on schedule()
75 * properties of the Bkl that were used.
76 * Reiserfs performances and locking were based on this scheme.
77 * Now that the write lock is a mutex and not the bkl anymore, doing so
78 * may result in a deadlock:
79 *
80 * A acquire write_lock
81 * A acquire j_commit_mutex
82 * A release write_lock and wait for something
83 * B acquire write_lock
84 * B can't acquire j_commit_mutex and sleep
85 * A can't acquire write lock anymore
86 * deadlock
87 *
88 * What we do here is avoiding such deadlock by playing the same game
89 * than the Bkl: if we can't acquire a mutex that depends on the write lock,
90 * we release the write lock, wait a bit and then retry.
91 *
92 * The mutexes concerned by this hack are:
93 * - The commit mutex of a journal list
94 * - The flush mutex
95 * - The journal lock
96 * - The inode mutex
97 */
98static inline void reiserfs_mutex_lock_safe(struct mutex *m,
99 struct super_block *s)
100{
101 reiserfs_lock_check_recursive(s);
102 reiserfs_write_unlock(s);
103 mutex_lock(m);
104 reiserfs_write_lock(s);
105}
106
107static inline void
108reiserfs_mutex_lock_nested_safe(struct mutex *m, unsigned int subclass,
109 struct super_block *s)
110{
111 reiserfs_lock_check_recursive(s);
112 reiserfs_write_unlock(s);
113 mutex_lock_nested(m, subclass);
114 reiserfs_write_lock(s);
115}
116
117static inline void
118reiserfs_down_read_safe(struct rw_semaphore *sem, struct super_block *s)
119{
120 reiserfs_lock_check_recursive(s);
121 reiserfs_write_unlock(s);
122 down_read(sem);
123 reiserfs_write_lock(s);
124}
125
126/*
127 * When we schedule, we usually want to also release the write lock,
128 * according to the previous bkl based locking scheme of reiserfs.
129 */
130static inline void reiserfs_cond_resched(struct super_block *s)
131{
132 if (need_resched()) {
133 reiserfs_write_unlock(s);
134 schedule();
135 reiserfs_write_lock(s);
136 }
137}
60 138
61struct fid; 139struct fid;
62 140
@@ -1329,7 +1407,11 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
1329#define get_generation(s) atomic_read (&fs_generation(s)) 1407#define get_generation(s) atomic_read (&fs_generation(s))
1330#define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen) 1408#define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
1331#define __fs_changed(gen,s) (gen != get_generation (s)) 1409#define __fs_changed(gen,s) (gen != get_generation (s))
1332#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);}) 1410#define fs_changed(gen,s) \
1411({ \
1412 reiserfs_cond_resched(s); \
1413 __fs_changed(gen, s); \
1414})
1333 1415
1334/***************************************************************************/ 1416/***************************************************************************/
1335/* FIXATE NODES */ 1417/* FIXATE NODES */
@@ -1995,25 +2077,12 @@ void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
1995int search_by_entry_key(struct super_block *sb, const struct cpu_key *key, 2077int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
1996 struct treepath *path, struct reiserfs_dir_entry *de); 2078 struct treepath *path, struct reiserfs_dir_entry *de);
1997struct dentry *reiserfs_get_parent(struct dentry *); 2079struct dentry *reiserfs_get_parent(struct dentry *);
1998/* procfs.c */
1999
2000#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
2001#define REISERFS_PROC_INFO
2002#else
2003#undef REISERFS_PROC_INFO
2004#endif
2005 2080
2081#ifdef CONFIG_REISERFS_PROC_INFO
2006int reiserfs_proc_info_init(struct super_block *sb); 2082int reiserfs_proc_info_init(struct super_block *sb);
2007int reiserfs_proc_info_done(struct super_block *sb); 2083int reiserfs_proc_info_done(struct super_block *sb);
2008struct proc_dir_entry *reiserfs_proc_register_global(char *name,
2009 read_proc_t * func);
2010void reiserfs_proc_unregister_global(const char *name);
2011int reiserfs_proc_info_global_init(void); 2084int reiserfs_proc_info_global_init(void);
2012int reiserfs_proc_info_global_done(void); 2085int reiserfs_proc_info_global_done(void);
2013int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
2014 int count, int *eof, void *data);
2015
2016#if defined( REISERFS_PROC_INFO )
2017 2086
2018#define PROC_EXP( e ) e 2087#define PROC_EXP( e ) e
2019 2088
@@ -2028,6 +2097,26 @@ int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
2028 PROC_INFO_ADD( sb, free_at[ ( level ) ], B_FREE_SPACE( bh ) ); \ 2097 PROC_INFO_ADD( sb, free_at[ ( level ) ], B_FREE_SPACE( bh ) ); \
2029 PROC_INFO_ADD( sb, items_at[ ( level ) ], B_NR_ITEMS( bh ) ) 2098 PROC_INFO_ADD( sb, items_at[ ( level ) ], B_NR_ITEMS( bh ) )
2030#else 2099#else
2100static inline int reiserfs_proc_info_init(struct super_block *sb)
2101{
2102 return 0;
2103}
2104
2105static inline int reiserfs_proc_info_done(struct super_block *sb)
2106{
2107 return 0;
2108}
2109
2110static inline int reiserfs_proc_info_global_init(void)
2111{
2112 return 0;
2113}
2114
2115static inline int reiserfs_proc_info_global_done(void)
2116{
2117 return 0;
2118}
2119
2031#define PROC_EXP( e ) 2120#define PROC_EXP( e )
2032#define VOID_V ( ( void ) 0 ) 2121#define VOID_V ( ( void ) 0 )
2033#define PROC_INFO_MAX( sb, field, value ) VOID_V 2122#define PROC_INFO_MAX( sb, field, value ) VOID_V
@@ -2258,8 +2347,7 @@ __u32 r5_hash(const signed char *msg, int len);
2258#define SPARE_SPACE 500 2347#define SPARE_SPACE 500
2259 2348
2260/* prototypes from ioctl.c */ 2349/* prototypes from ioctl.c */
2261int reiserfs_ioctl(struct inode *inode, struct file *filp, 2350long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
2262 unsigned int cmd, unsigned long arg);
2263long reiserfs_compat_ioctl(struct file *filp, 2351long reiserfs_compat_ioctl(struct file *filp,
2264 unsigned int cmd, unsigned long arg); 2352 unsigned int cmd, unsigned long arg);
2265int reiserfs_unpack(struct inode *inode, struct file *filp); 2353int reiserfs_unpack(struct inode *inode, struct file *filp);