1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 06_rt.dpatch by Julian Andres Klode <jak@jak-linux.org>
4
## DP: Add support for RT Kernels, based on patch/rt-compat.patch
7
diff -urNad aufs-0+20080317~/fs/aufs/branch.c aufs-0+20080317/fs/aufs/branch.c
8
--- aufs-0+20080317~/fs/aufs/branch.c 2008-03-10 05:41:38.000000000 +0100
9
+++ aufs-0+20080317/fs/aufs/branch.c 2008-03-17 13:38:26.000000000 +0100
11
if (!br_writable(mod->perm)) {
12
/* rw --> ro, file might be mmapped */
13
struct file *file, *hf;
17
DiMustNoWaiters(root);
19
* since BKL (and sbinfo) is locked
21
AuDebugOn(!kernel_locked());
22
- list_for_each_entry(file, &sb->s_files, f_u.fu_list) {
23
+ idx = au_rt_s_files_lock(sb);
24
+ au_rt_s_files_loop(file, sb) {
25
LKTRTrace("%.*s\n", AuDLNPair(file->f_dentry));
26
if (!au_test_aufs_file(file))
29
FiMustNoWaiters(file);
32
+ au_rt_s_files_unlock(sb, idx);
34
/* aufs_write_lock() calls ..._child() */
35
di_write_lock_child(root);
36
diff -urNad aufs-0+20080317~/fs/aufs/debug.c aufs-0+20080317/fs/aufs/debug.c
37
--- aufs-0+20080317~/fs/aufs/debug.c 2008-03-17 00:46:30.000000000 +0100
38
+++ aufs-0+20080317/fs/aufs/debug.c 2008-03-17 13:38:26.000000000 +0100
41
i_size_read(inode), (u64)inode->i_blocks,
42
timespec_to_ns(&inode->i_ctime) & 0x0ffff,
43
- inode->i_mapping ? inode->i_mapping->nrpages : 0,
44
+ inode->i_mapping ? au_mapping_nrpages(inode->i_mapping) : 0,
45
inode->i_state, inode->i_flags, inode->i_generation,
46
l ? ", wh " : "", l, n);
48
diff -urNad aufs-0+20080317~/fs/aufs/misc.h aufs-0+20080317/fs/aufs/misc.h
49
--- aufs-0+20080317~/fs/aufs/misc.h 2008-03-17 00:44:47.000000000 +0100
50
+++ aufs-0+20080317/fs/aufs/misc.h 2008-03-17 13:38:26.000000000 +0100
52
#include <linux/version.h>
53
#include <linux/aufs_type.h>
56
+/* ---------------------------------------------------------------------- */
59
+ * support for RT patch (testing).
60
+ * it uses 'standard compat_rw_semaphore' instead of 'realtime rw_semaphore.'
61
+ * sigh, wrapper for wrapper...
64
+#ifndef CONFIG_PREEMPT_RT
66
+#define au_rw_semaphore rw_semaphore
67
+#define au_init_rwsem init_rwsem
68
+#define au_down_read down_read
69
+#define au_down_read_nested down_read_nested
70
+#define au_down_read_trylock down_read_trylock
71
+#define au_up_read up_read
72
+#define au_downgrade_write downgrade_write
73
+#define au_down_write down_write
74
+#define au_down_write_nested down_write_nested
75
+#define au_down_write_trylock down_write_trylock
76
+#define au_up_write up_write
78
+static inline int au_rt_s_files_lock(struct super_block *sb)
84
+static inline void au_rt_s_files_unlock(struct super_block *sb, int idx)
89
+#define au_rt_s_files_loop(pos, sb) \
90
+ list_for_each_entry(pos, &(sb)->s_files, f_u.fu_list)
91
+#define au_rt_s_files_loop_break(pos) do {} while (0)
93
+static inline unsigned long au_mapping_nrpages(struct address_space *mapping)
95
+ return mapping->nrpages;
98
+#else /* CONFIG_PREEMPT_RT */
100
+#define au_rw_semaphore compat_rw_semaphore
101
+#define au_init_rwsem compat_init_rwsem
102
+#define au_down_read compat_down_read
103
+#define au_down_read_nested compat_down_read_nested
104
+#define au_down_read_trylock compat_down_read_trylock
105
+#define au_up_read compat_up_read
106
+#define au_downgrade_write compat_downgrade_write
107
+#define au_down_write compat_down_write
108
+#define au_down_write_nested compat_down_write_nested
109
+#define au_down_write_trylock compat_down_write_trylock
110
+#define au_up_write compat_up_write
112
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
114
+static inline int au_rt_s_files_lock(struct super_block *sb)
117
+ idx = qrcu_read_lock(&sb->s_qrcu);
118
+ percpu_list_fold(&sb->s_files);
122
+static inline void au_rt_s_files_unlock(struct super_block *sb, int idx)
124
+ qrcu_read_unlock(&sb->s_qrcu, idx);
127
+#define au_rt_s_files_loop(pos, sb) \
128
+ lock_list_for_each_entry(pos, percpu_list_head(&(sb)->s_files), \
131
+#define au_rt_s_files_loop_break(pos) \
132
+ lock_list_for_each_entry_stop(pos, f_u.fu_llist);
134
+static inline unsigned long au_mapping_nrpages(struct address_space *mapping)
136
+ return mapping_nrpages(mapping);
139
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
141
+static inline int au_rt_s_files_lock(struct super_block *sb)
143
+ //barrier_lock(&sb->s_barrier);
144
+ filevec_add_drain_all();
148
+static inline void au_rt_s_files_unlock(struct super_block *sb, int idx)
150
+ //barrier_unlock(&sb->s_barrier);
153
+#define au_rt_s_files_loop(pos, sb) \
154
+ lock_list_for_each_entry(pos, &(sb)->s_files, f_u.fu_llist)
156
+#define au_rt_s_files_loop_break(pos) \
157
+ lock_list_for_each_entry_stop(pos, f_u.fu_llist);
159
+static inline unsigned long au_mapping_nrpages(struct address_space *mapping)
161
+ return mapping->nrpages;
166
+static inline int au_rt_s_files_lock(struct super_block *sb)
172
+static inline void au_rt_s_files_unlock(struct super_block *sb, int idx)
177
+#define au_rt_s_files_loop(pos, sb) \
178
+ list_for_each_entry(pos, &(sb)->s_files, f_u.fu_list)
179
+#define au_rt_s_files_loop_break(pos) do {} while (0)
181
+static inline unsigned long au_mapping_nrpages(struct address_space *mapping)
183
+ return mapping->nrpages;
186
+#endif /* LINUX_VERSION_CODE */
187
+#endif /* CONFIG_PREEMPT_RT */
189
+/* ---------------------------------------------------------------------- */
191
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
192
#define I_MUTEX_QUOTA 0
193
#define lockdep_off() do {} while (0)
195
/* ---------------------------------------------------------------------- */
198
- struct rw_semaphore rwsem;
199
+ struct au_rw_semaphore rwsem;
200
#ifdef CONFIG_AUFS_DEBUG
204
static inline void rw_init_nolock(struct aufs_rwsem *rw)
207
- init_rwsem(&rw->rwsem);
208
+ au_init_rwsem(&rw->rwsem);
211
static inline void rw_init_wlock(struct aufs_rwsem *rw)
214
- down_write(&rw->rwsem);
215
+ au_down_write(&rw->rwsem);
218
static inline void rw_init_wlock_nested(struct aufs_rwsem *rw, unsigned int lsc)
221
- down_write_nested(&rw->rwsem, lsc);
222
+ au_down_write_nested(&rw->rwsem, lsc);
225
static inline void rw_read_lock(struct aufs_rwsem *rw)
227
- down_read(&rw->rwsem);
228
+ au_down_read(&rw->rwsem);
232
static inline void rw_read_lock_nested(struct aufs_rwsem *rw, unsigned int lsc)
234
- down_read_nested(&rw->rwsem, lsc);
235
+ au_down_read_nested(&rw->rwsem, lsc);
239
static inline void rw_read_unlock(struct aufs_rwsem *rw)
242
- up_read(&rw->rwsem);
243
+ au_up_read(&rw->rwsem);
246
static inline void rw_dgrade_lock(struct aufs_rwsem *rw)
249
- downgrade_write(&rw->rwsem);
250
+ au_downgrade_write(&rw->rwsem);
253
static inline void rw_write_lock(struct aufs_rwsem *rw)
255
- down_write(&rw->rwsem);
256
+ au_down_write(&rw->rwsem);
259
static inline void rw_write_lock_nested(struct aufs_rwsem *rw, unsigned int lsc)
261
- down_write_nested(&rw->rwsem, lsc);
262
+ au_down_write_nested(&rw->rwsem, lsc);
265
static inline void rw_write_unlock(struct aufs_rwsem *rw)
267
- up_write(&rw->rwsem);
268
+ au_up_write(&rw->rwsem);
271
/* why is not _nested version defined */
272
static inline int rw_read_trylock(struct aufs_rwsem *rw)
274
- int ret = down_read_trylock(&rw->rwsem);
275
+ int ret = au_down_read_trylock(&rw->rwsem);
281
static inline int rw_write_trylock(struct aufs_rwsem *rw)
283
- return down_write_trylock(&rw->rwsem);
284
+ return au_down_write_trylock(&rw->rwsem);
290
/* to debug easier, do not make them inlined functions */
291
#define RwMustNoWaiters(rw) AuDebugOn(!list_empty(&(rw)->rwsem.wait_list))
292
-#define RwMustAnyLock(rw) AuDebugOn(down_write_trylock(&(rw)->rwsem))
293
+#define RwMustAnyLock(rw) AuDebugOn(au_down_write_trylock(&(rw)->rwsem))
294
#ifdef CONFIG_AUFS_DEBUG
295
#define RwMustReadLock(rw) do { \