File: linux-2.4.9-VFS-lock.patch

package info (click to toggle)
evms 1.0.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 9,168 kB
  • ctags: 5,853
  • sloc: ansic: 87,317; makefile: 691; sh: 238
file content (177 lines) | stat: -rw-r--r-- 4,965 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Index: linux-2.4/drivers/evms/evms.c
--- linux-2.4/drivers/evms/evms.c	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/drivers/evms/evms.c	11 Mar 2002 16:18:45 -0000
@@ -55,7 +55,7 @@
 #include <linux/smp_lock.h>
 #include <linux/evms/evms_kernel.h>
 
-//#define VFS_PATCH_PRESENT
+#define VFS_PATCH_PRESENT
 
 /* prefix used in logging messages */
 #define LOG_PREFIX
Index: linux-2.4/drivers/md/lvm.c
--- linux-2.4/drivers/md/lvm.c	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/drivers/md/lvm.c	11 Mar 2002 16:18:45 -0000
@@ -162,7 +162,7 @@
 #define	DEVICE_OFF(device)
 
 /* lvm_do_lv_create calls fsync_dev_lockfs()/unlockfs() */
-/* #define	LVM_VFS_ENHANCEMENT */
+#define	LVM_VFS_ENHANCEMENT
 
 #include <linux/config.h>
 #include <linux/version.h>
Index: linux-2.4/fs/buffer.c
--- linux-2.4/fs/buffer.c	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/fs/buffer.c	11 Mar 2002 16:18:45 -0000
@@ -372,6 +372,34 @@
 	fsync_dev(dev);
 }
 
+int fsync_dev_lockfs(kdev_t dev)
+{
+	/* you are not allowed to try locking all the filesystems
+	** on the system, your chances of getting through without
+	** total deadlock are slim to none.
+	*/
+	if (!dev)
+		return fsync_dev(dev) ;
+
+	sync_buffers(dev, 0);
+
+	lock_kernel();
+	/* note, the FS might need to start transactions to 
+	** sync the inodes, or the quota, no locking until
+	** after these are done
+	*/
+	sync_inodes(dev);
+	DQUOT_SYNC(dev);
+	/* if inodes or quotas could be dirtied during the
+	** sync_supers_lockfs call, the FS is responsible for getting
+	** them on disk, without deadlocking against the lock
+	*/
+	sync_supers_lockfs(dev) ;
+	unlock_kernel();
+
+	return sync_buffers(dev, 1) ;
+}
+
 asmlinkage long sys_sync(void)
 {
 	fsync_dev(0);
Index: linux-2.4/fs/reiserfs/super.c
--- linux-2.4/fs/reiserfs/super.c	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/fs/reiserfs/super.c	11 Mar 2002 16:18:45 -0000
@@ -80,7 +80,7 @@
     reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
     journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
     reiserfs_block_writes(&th) ;
-    journal_end(&th, s, 1) ;
+    journal_end_sync(&th, s, 1) ;
   }
   s->s_dirt = dirty;
   unlock_kernel() ;
Index: linux-2.4/fs/super.c
--- linux-2.4/fs/super.c	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/fs/super.c	11 Mar 2002 16:18:45 -0000
@@ -681,6 +681,18 @@
 			sb->s_op->write_super(sb);
 	unlock_super(sb);
 }
+
+static inline void write_super_lockfs(struct super_block *sb)
+{
+	lock_super(sb);
+	if (sb->s_root && sb->s_op) {
+		if (sb->s_dirt && sb->s_op->write_super)
+			sb->s_op->write_super(sb);
+		if (sb->s_op->write_super_lockfs)
+			sb->s_op->write_super_lockfs(sb);
+	}
+	unlock_super(sb);
+}
  
 /*
  * Note: check the dirty flag before waiting, so we don't
@@ -714,6 +726,48 @@
 		} else
 			sb = sb_entry(sb->s_list.next);
 	spin_unlock(&sb_lock);
+}
+
+/*
+ * Note: don't check the dirty flag before waiting, we want the lock
+ * to happen every time this is called.  dev must be non-zero
+ */
+void sync_supers_lockfs(kdev_t dev)
+{
+	struct super_block * sb;
+
+	if (dev) {
+		sb = get_super(dev);
+		if (sb) {
+			write_super_lockfs(sb);
+			drop_super(sb);
+		}
+	}
+}
+
+void unlockfs(kdev_t dev)
+{
+	struct super_block * sb;
+
+	if (dev) {
+		/* we cannot lock the super here because someone
+		** might be waiting on the unlock with the
+		** super already locked
+		**
+		** so, we grab the mount semaphore instead, we have
+		** to make sure nobody is mounting during our
+		** unlock operation.  The FS won't unmount because it
+		** was locked.
+		*/
+		down(&mount_sem);
+		sb = get_super(dev);
+		if (sb) {
+			if (sb->s_op && sb->s_op->unlockfs)
+				sb->s_op->unlockfs(sb) ;
+			drop_super(sb);
+		}
+		up(&mount_sem);
+	}
 }
 
 /**
Index: linux-2.4/include/linux/fs.h
--- linux-2.4/include/linux/fs.h	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/include/linux/fs.h	11 Mar 2002 16:18:45 -0000
@@ -1161,6 +1161,7 @@
 extern void write_inode_now(struct inode *, int);
 extern void sync_dev(kdev_t);
 extern int fsync_dev(kdev_t);
+extern int fsync_dev_lockfs(kdev_t);
 extern int fsync_super(struct super_block *);
 extern int fsync_no_super(kdev_t);
 extern void sync_inodes_sb(struct super_block *);
@@ -1170,6 +1171,8 @@
 extern void filemap_fdatasync(struct address_space *);
 extern void filemap_fdatawait(struct address_space *);
 extern void sync_supers(kdev_t);
+extern void sync_supers_lockfs(kdev_t);
+extern void unlockfs(kdev_t);
 extern int bmap(struct inode *, int);
 extern int notify_change(struct dentry *, struct iattr *);
 extern int permission(struct inode *, int);
Index: linux-2.4/kernel/ksyms.c
--- linux-2.4/kernel/ksyms.c	8 Mar 2002 23:50:12 -0000
+++ linux-2.4/kernel/ksyms.c	11 Mar 2002 16:18:45 -0000
@@ -177,6 +177,8 @@
 EXPORT_SYMBOL(invalidate_inode_pages);
 EXPORT_SYMBOL(truncate_inode_pages);
 EXPORT_SYMBOL(fsync_dev);
+EXPORT_SYMBOL(fsync_dev_lockfs);
+EXPORT_SYMBOL(unlockfs);
 EXPORT_SYMBOL(fsync_no_super);
 EXPORT_SYMBOL(permission);
 EXPORT_SYMBOL(vfs_permission);