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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
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:14:27 -0000
@@ -56,7 +56,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:14:27 -0000
@@ -188,7 +188,7 @@
#define LOCAL_END_REQUEST
/* lvm_do_lv_create calls fsync_dev_lockfs()/unlockfs() */
-/* #define LVM_VFS_ENHANCEMENT */
+#define LVM_VFS_ENHANCEMENT
#include <linux/config.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:14:27 -0000
@@ -361,6 +361,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:14:27 -0000
@@ -66,7 +66,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:14:27 -0000
@@ -54,6 +54,13 @@
LIST_HEAD(super_blocks);
spinlock_t sb_lock = SPIN_LOCK_UNLOCKED;
+/*
+ * lock/unlockfs grab a read lock on s_umount, but you need this lock to
+ * make sure no lockfs runs are in progress before inserting/removing
+ * supers from the list.
+ */
+static DECLARE_MUTEX(lockfs_sem);
+
/*
* Handling of filesystem drivers list.
* Rules:
@@ -453,6 +460,19 @@
put_super(sb);
}
+static 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);
+}
+
static inline void write_super(struct super_block *sb)
{
lock_super(sb);
@@ -496,6 +516,39 @@
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;
+
+ down(&lockfs_sem) ;
+ 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) {
+ sb = get_super(dev);
+ if (sb) {
+ if (sb->s_op && sb->s_op->unlockfs)
+ sb->s_op->unlockfs(sb) ;
+ drop_super(sb);
+ }
+ }
+ up(&lockfs_sem) ;
+}
+
/**
* get_super - get the superblock of a device
* @dev: device to get the superblock for
@@ -560,8 +613,10 @@
s->s_dev = dev;
s->s_bdev = bdev;
s->s_flags = flags;
+ down(&lockfs_sem);
spin_lock(&sb_lock);
insert_super(s, type);
+ up(&lockfs_sem);
lock_super(s);
if (!type->read_super(s, data, flags & MS_VERBOSE ? 1 : 0))
goto out_fail;
@@ -664,6 +719,7 @@
}
error = -EBUSY;
+ down(&lockfs_sem);
restart:
spin_lock(&sb_lock);
@@ -676,6 +732,7 @@
spin_unlock(&sb_lock);
destroy_super(s);
blkdev_put(bdev, BDEV_FS);
+ up(&lockfs_sem);
goto out;
}
if (!grab_super(old))
@@ -683,12 +740,15 @@
destroy_super(s);
blkdev_put(bdev, BDEV_FS);
path_release(&nd);
+ up(&lockfs_sem);
return old;
}
s->s_dev = dev;
s->s_bdev = bdev;
s->s_flags = flags;
+
insert_super(s, fs_type);
+ up(&lockfs_sem);
error = -EINVAL;
lock_super(s);
@@ -779,7 +839,10 @@
if (!deactivate_super(sb))
return;
+ down(&lockfs_sem);
down_write(&sb->s_umount);
+ up(&lockfs_sem);
+
lock_kernel();
sb->s_root = NULL;
/* Need to clean after the sucker */
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:14:27 -0000
@@ -1205,6 +1205,7 @@
extern int sync_buffers(kdev_t, 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 *);
@@ -1216,6 +1217,8 @@
extern int filemap_fdatasync(struct address_space *);
extern int 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:14:27 -0000
@@ -178,6 +178,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);
|