diff options
Diffstat (limited to 'include/linux/reiserfs_fs.h')
-rw-r--r-- | include/linux/reiserfs_fs.h | 106 |
1 files changed, 84 insertions, 22 deletions
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index dd31e7bae35c..c96c1858fe2c 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 | */ |
60 | void reiserfs_write_lock(struct super_block *s); | ||
61 | void reiserfs_write_unlock(struct super_block *s); | ||
62 | int reiserfs_write_lock_once(struct super_block *s); | ||
63 | void 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 | */ | ||
92 | static 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 | */ | ||
104 | static 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 | ||
61 | struct fid; | 113 | struct 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 */ |
@@ -1995,25 +2051,12 @@ void set_de_name_and_namelen(struct reiserfs_dir_entry *de); | |||
1995 | int search_by_entry_key(struct super_block *sb, const struct cpu_key *key, | 2051 | int search_by_entry_key(struct super_block *sb, const struct cpu_key *key, |
1996 | struct treepath *path, struct reiserfs_dir_entry *de); | 2052 | struct treepath *path, struct reiserfs_dir_entry *de); |
1997 | struct dentry *reiserfs_get_parent(struct dentry *); | 2053 | struct 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 | 2054 | ||
2055 | #ifdef CONFIG_REISERFS_PROC_INFO | ||
2006 | int reiserfs_proc_info_init(struct super_block *sb); | 2056 | int reiserfs_proc_info_init(struct super_block *sb); |
2007 | int reiserfs_proc_info_done(struct super_block *sb); | 2057 | int reiserfs_proc_info_done(struct super_block *sb); |
2008 | struct proc_dir_entry *reiserfs_proc_register_global(char *name, | ||
2009 | read_proc_t * func); | ||
2010 | void reiserfs_proc_unregister_global(const char *name); | ||
2011 | int reiserfs_proc_info_global_init(void); | 2058 | int reiserfs_proc_info_global_init(void); |
2012 | int reiserfs_proc_info_global_done(void); | 2059 | int reiserfs_proc_info_global_done(void); |
2013 | int 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 | 2060 | ||
2018 | #define PROC_EXP( e ) e | 2061 | #define PROC_EXP( e ) e |
2019 | 2062 | ||
@@ -2028,6 +2071,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 ) ); \ | 2071 | PROC_INFO_ADD( sb, free_at[ ( level ) ], B_FREE_SPACE( bh ) ); \ |
2029 | PROC_INFO_ADD( sb, items_at[ ( level ) ], B_NR_ITEMS( bh ) ) | 2072 | PROC_INFO_ADD( sb, items_at[ ( level ) ], B_NR_ITEMS( bh ) ) |
2030 | #else | 2073 | #else |
2074 | static inline int reiserfs_proc_info_init(struct super_block *sb) | ||
2075 | { | ||
2076 | return 0; | ||
2077 | } | ||
2078 | |||
2079 | static inline int reiserfs_proc_info_done(struct super_block *sb) | ||
2080 | { | ||
2081 | return 0; | ||
2082 | } | ||
2083 | |||
2084 | static inline int reiserfs_proc_info_global_init(void) | ||
2085 | { | ||
2086 | return 0; | ||
2087 | } | ||
2088 | |||
2089 | static inline int reiserfs_proc_info_global_done(void) | ||
2090 | { | ||
2091 | return 0; | ||
2092 | } | ||
2093 | |||
2031 | #define PROC_EXP( e ) | 2094 | #define PROC_EXP( e ) |
2032 | #define VOID_V ( ( void ) 0 ) | 2095 | #define VOID_V ( ( void ) 0 ) |
2033 | #define PROC_INFO_MAX( sb, field, value ) VOID_V | 2096 | #define PROC_INFO_MAX( sb, field, value ) VOID_V |
@@ -2258,8 +2321,7 @@ __u32 r5_hash(const signed char *msg, int len); | |||
2258 | #define SPARE_SPACE 500 | 2321 | #define SPARE_SPACE 500 |
2259 | 2322 | ||
2260 | /* prototypes from ioctl.c */ | 2323 | /* prototypes from ioctl.c */ |
2261 | int reiserfs_ioctl(struct inode *inode, struct file *filp, | 2324 | long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); |
2262 | unsigned int cmd, unsigned long arg); | ||
2263 | long reiserfs_compat_ioctl(struct file *filp, | 2325 | long reiserfs_compat_ioctl(struct file *filp, |
2264 | unsigned int cmd, unsigned long arg); | 2326 | unsigned int cmd, unsigned long arg); |
2265 | int reiserfs_unpack(struct inode *inode, struct file *filp); | 2327 | int reiserfs_unpack(struct inode *inode, struct file *filp); |