]> git.pld-linux.org Git - packages/kernel.git/blame - linux-2.4.19-pre8-VFS-lock.patch
- replaced by linux-2.4-sfq.patch
[packages/kernel.git] / linux-2.4.19-pre8-VFS-lock.patch
CommitLineData
14f0972a
JR
1Index: linux-2.4/drivers/evms/evms.c
2--- linux-2.4/drivers/evms/evms.c 8 Mar 2002 23:50:12 -0000
3+++ linux-2.4/drivers/evms/evms.c 11 Mar 2002 16:14:27 -0000
4@@ -59,7 +59,7 @@
5 #include <linux/compiler.h>
6 #include <linux/evms/evms_kernel.h>
7
8-//#define VFS_PATCH_PRESENT
9+#define VFS_PATCH_PRESENT
10
11 /* prefix used in logging messages */
12 #define LOG_PREFIX
13diff -Nru a/drivers/md/lvm.c b/drivers/md/lvm.c
14--- a/drivers/md/lvm.c Wed May 22 10:43:49 2002
15+++ b/drivers/md/lvm.c Wed May 22 10:43:49 2002
16@@ -223,9 +223,6 @@
17 #define DEVICE_OFF(device)
18 #define LOCAL_END_REQUEST
19
20-/* lvm_do_lv_create calls fsync_dev_lockfs()/unlockfs() */
21-/* #define LVM_VFS_ENHANCEMENT */
22-
23 #include <linux/config.h>
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26@@ -2178,12 +2175,8 @@
27 if (lv_ptr->lv_access & LV_SNAPSHOT) {
28 lv_t *org = lv_ptr->lv_snapshot_org, *last;
29
30- /* sync the original logical volume */
31- fsync_dev(org->lv_dev);
32-#ifdef LVM_VFS_ENHANCEMENT
33 /* VFS function call to sync and lock the filesystem */
34 fsync_dev_lockfs(org->lv_dev);
35-#endif
36
37 down_write(&org->lv_lock);
38 org->lv_access |= LV_SNAPSHOT_ORG;
39@@ -2209,11 +2202,9 @@
40 else
41 set_device_ro(lv_ptr->lv_dev, 1);
42
43-#ifdef LVM_VFS_ENHANCEMENT
44 /* VFS function call to unlock the filesystem */
45 if (lv_ptr->lv_access & LV_SNAPSHOT)
46 unlockfs(lv_ptr->lv_snapshot_org->lv_dev);
47-#endif
48
49 lvm_gendisk.part[MINOR(lv_ptr->lv_dev)].de =
50 lvm_fs_create_lv(vg_ptr, lv_ptr);
51diff -Nru a/fs/buffer.c b/fs/buffer.c
52--- a/fs/buffer.c Wed May 22 10:43:49 2002
53+++ b/fs/buffer.c Wed May 22 10:43:49 2002
54@@ -363,6 +363,34 @@
55 fsync_dev(dev);
56 }
57
58+int fsync_dev_lockfs(kdev_t dev)
59+{
60+ /* you are not allowed to try locking all the filesystems
61+ ** on the system, your chances of getting through without
62+ ** total deadlock are slim to none.
63+ */
64+ if (!dev)
65+ return fsync_dev(dev) ;
66+
67+ sync_buffers(dev, 0);
68+
69+ lock_kernel();
70+ /* note, the FS might need to start transactions to
71+ ** sync the inodes, or the quota, no locking until
72+ ** after these are done
73+ */
74+ sync_inodes(dev);
75+ DQUOT_SYNC_DEV(dev);
76+ /* if inodes or quotas could be dirtied during the
77+ ** sync_supers_lockfs call, the FS is responsible for getting
78+ ** them on disk, without deadlocking against the lock
79+ */
80+ sync_supers_lockfs(dev) ;
81+ unlock_kernel();
82+
83+ return sync_buffers(dev, 1) ;
84+}
85+
86 asmlinkage long sys_sync(void)
87 {
88 fsync_dev(0);
89diff -Nru a/fs/reiserfs/super.c b/fs/reiserfs/super.c
90--- a/fs/reiserfs/super.c Wed May 22 10:43:49 2002
91+++ b/fs/reiserfs/super.c Wed May 22 10:43:49 2002
92@@ -66,7 +66,7 @@
93 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
94 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
95 reiserfs_block_writes(&th) ;
96- journal_end(&th, s, 1) ;
97+ journal_end_sync(&th, s, 1) ;
98 }
99 s->s_dirt = dirty;
100 unlock_kernel() ;
101diff -Nru a/fs/super.c b/fs/super.c
102--- a/fs/super.c Wed May 22 10:43:49 2002
103+++ b/fs/super.c Wed May 22 10:43:49 2002
104@@ -37,6 +37,13 @@
105 LIST_HEAD(super_blocks);
106 spinlock_t sb_lock = SPIN_LOCK_UNLOCKED;
107
108+/*
109+ * lock/unlockfs grab a read lock on s_umount, but you need this lock to
110+ * make sure no lockfs runs are in progress before inserting/removing
111+ * supers from the list.
112+ */
113+static DECLARE_MUTEX(lockfs_sem);
114+
115 /*
116 * Handling of filesystem drivers list.
117 * Rules:
118@@ -431,6 +438,19 @@
119 put_super(sb);
120 }
121
122+static void write_super_lockfs(struct super_block *sb)
123+{
124+ lock_super(sb);
125+ if (sb->s_root && sb->s_op) {
126+ if (sb->s_dirt && sb->s_op->write_super)
127+ sb->s_op->write_super(sb);
128+ if (sb->s_op->write_super_lockfs) {
129+ sb->s_op->write_super_lockfs(sb);
130+ }
131+ }
132+ unlock_super(sb);
133+}
134+
135 static inline void write_super(struct super_block *sb)
136 {
137 lock_super(sb);
138@@ -474,6 +494,39 @@
139 spin_unlock(&sb_lock);
140 }
141
142+/*
143+ * Note: don't check the dirty flag before waiting, we want the lock
144+ * to happen every time this is called. dev must be non-zero
145+ */
146+void sync_supers_lockfs(kdev_t dev)
147+{
148+ struct super_block * sb;
149+
150+ down(&lockfs_sem) ;
151+ if (dev) {
152+ sb = get_super(dev);
153+ if (sb) {
154+ write_super_lockfs(sb);
155+ drop_super(sb);
156+ }
157+ }
158+}
159+
160+void unlockfs(kdev_t dev)
161+{
162+ struct super_block * sb;
163+
164+ if (dev) {
165+ sb = get_super(dev);
166+ if (sb) {
167+ if (sb->s_op && sb->s_op->unlockfs)
168+ sb->s_op->unlockfs(sb) ;
169+ drop_super(sb);
170+ }
171+ }
172+ up(&lockfs_sem) ;
173+}
174+
175 /**
176 * get_super - get the superblock of a device
177 * @dev: device to get the superblock for
178@@ -694,6 +747,7 @@
179 goto out1;
180
181 error = -EBUSY;
182+ down(&lockfs_sem);
183 restart:
184 spin_lock(&sb_lock);
185
186@@ -705,6 +759,7 @@
187 ((flags ^ old->s_flags) & MS_RDONLY)) {
188 spin_unlock(&sb_lock);
189 destroy_super(s);
190+ up(&lockfs_sem);
191 goto out1;
192 }
193 if (!grab_super(old))
194@@ -712,12 +767,14 @@
195 destroy_super(s);
196 blkdev_put(bdev, BDEV_FS);
197 path_release(&nd);
198+ up(&lockfs_sem);
199 return old;
200 }
201 s->s_dev = dev;
202 s->s_bdev = bdev;
203 s->s_flags = flags;
204 insert_super(s, fs_type);
205+ up(&lockfs_sem);
206 if (!fs_type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0))
207 goto Einval;
208 s->s_flags |= MS_ACTIVE;
209@@ -825,7 +882,10 @@
210 if (!deactivate_super(sb))
211 return;
212
213+ down(&lockfs_sem);
214 down_write(&sb->s_umount);
215+ up(&lockfs_sem);
216+
217 sb->s_root = NULL;
218 /* Need to clean after the sucker */
219 if (fs->fs_flags & FS_LITTER)
220diff -Nru a/include/linux/fs.h b/include/linux/fs.h
221--- a/include/linux/fs.h Wed May 22 10:43:49 2002
222+++ b/include/linux/fs.h Wed May 22 10:43:49 2002
223@@ -1218,6 +1218,7 @@
224 extern int sync_buffers(kdev_t, int);
225 extern void sync_dev(kdev_t);
226 extern int fsync_dev(kdev_t);
227+extern int fsync_dev_lockfs(kdev_t);
228 extern int fsync_super(struct super_block *);
229 extern int fsync_no_super(kdev_t);
230 extern void sync_inodes_sb(struct super_block *);
231@@ -1234,6 +1235,8 @@
232 extern int filemap_fdatasync(struct address_space *);
233 extern int filemap_fdatawait(struct address_space *);
234 extern void sync_supers(kdev_t);
235+extern void sync_supers_lockfs(kdev_t);
236+extern void unlockfs(kdev_t);
237 extern int bmap(struct inode *, int);
238 extern int notify_change(struct dentry *, struct iattr *);
239 extern int permission(struct inode *, int);
240diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
241--- a/kernel/ksyms.c Wed May 22 10:43:49 2002
242+++ b/kernel/ksyms.c Wed May 22 10:43:49 2002
243@@ -180,6 +180,8 @@
244 EXPORT_SYMBOL(invalidate_inode_pages);
245 EXPORT_SYMBOL(truncate_inode_pages);
246 EXPORT_SYMBOL(fsync_dev);
247+EXPORT_SYMBOL(fsync_dev_lockfs);
248+EXPORT_SYMBOL(unlockfs);
249 EXPORT_SYMBOL(fsync_no_super);
250 EXPORT_SYMBOL(permission);
251 EXPORT_SYMBOL(vfs_permission);
This page took 0.251486 seconds and 4 git commands to generate.