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.h71
1 files changed, 63 insertions, 8 deletions
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index dd31e7bae35..a05b4a20768 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -52,11 +52,63 @@
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/*
66 * Several mutexes depend on the write lock.
67 * However sometimes we want to relax the write lock while we hold
68 * these mutexes, according to the release/reacquire on schedule()
69 * properties of the Bkl that were used.
70 * Reiserfs performances and locking were based on this scheme.
71 * Now that the write lock is a mutex and not the bkl anymore, doing so
72 * may result in a deadlock:
73 *
74 * A acquire write_lock
75 * A acquire j_commit_mutex
76 * A release write_lock and wait for something
77 * B acquire write_lock
78 * B can't acquire j_commit_mutex and sleep
79 * A can't acquire write lock anymore
80 * deadlock
81 *
82 * What we do here is avoiding such deadlock by playing the same game
83 * than the Bkl: if we can't acquire a mutex that depends on the write lock,
84 * we release the write lock, wait a bit and then retry.
85 *
86 * The mutexes concerned by this hack are:
87 * - The commit mutex of a journal list
88 * - The flush mutex
89 * - The journal lock
90 * - The inode mutex
91 */
92static inline void reiserfs_mutex_lock_safe(struct mutex *m,
93 struct super_block *s)
94{
95 reiserfs_write_unlock(s);
96 mutex_lock(m);
97 reiserfs_write_lock(s);
98}
99
100/*
101 * When we schedule, we usually want to also release the write lock,
102 * according to the previous bkl based locking scheme of reiserfs.
103 */
104static inline void reiserfs_cond_resched(struct super_block *s)
105{
106 if (need_resched()) {
107 reiserfs_write_unlock(s);
108 schedule();
109 reiserfs_write_lock(s);
110 }
111}
60 112
61struct fid; 113struct fid;
62 114
@@ -1329,7 +1381,11 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
1329#define get_generation(s) atomic_read (&fs_generation(s)) 1381#define get_generation(s) atomic_read (&fs_generation(s))
1330#define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen) 1382#define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
1331#define __fs_changed(gen,s) (gen != get_generation (s)) 1383#define __fs_changed(gen,s) (gen != get_generation (s))
1332#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);}) 1384#define fs_changed(gen,s) \
1385({ \
1386 reiserfs_cond_resched(s); \
1387 __fs_changed(gen, s); \
1388})
1333 1389
1334/***************************************************************************/ 1390/***************************************************************************/
1335/* FIXATE NODES */ 1391/* FIXATE NODES */
@@ -2258,8 +2314,7 @@ __u32 r5_hash(const signed char *msg, int len);
2258#define SPARE_SPACE 500 2314#define SPARE_SPACE 500
2259 2315
2260/* prototypes from ioctl.c */ 2316/* prototypes from ioctl.c */
2261int reiserfs_ioctl(struct inode *inode, struct file *filp, 2317long 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, 2318long reiserfs_compat_ioctl(struct file *filp,
2264 unsigned int cmd, unsigned long arg); 2319 unsigned int cmd, unsigned long arg);
2265int reiserfs_unpack(struct inode *inode, struct file *filp); 2320int reiserfs_unpack(struct inode *inode, struct file *filp);