Skip to contentSkip to conversation

2.4.25--pre4 VFS lvm_snapshots

PATCH In review Xose Vazquez Perez 3 participants 3 messages Jan 7, 2004 – Jan 8, 2004 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.25--pre4 VFS lvm_snapshots

hi,

This patch is necessary to be able to mount snapshots of journalling filesystems. It was flying around lvm for long time, years!!. And LiNUX distributions bring it, Red Hat at least since 7.x. So, it should be sure.

Last thread about it [1] is recent and the patch still is pending...

[1] http://marc.theaimsgroup.com/?t=106623259800004&r=1&w=2

-thanks-

drivers/md/lvm.c +0 -9
diff -Nuar a/drivers/md/lvm.c b/drivers/md/lvm.c
@@ -236,9 +236,6 @@
 #define DEVICE_OFF(device)
 #define LOCAL_END_REQUEST
 
-/* lvm_do_lv_create calls fsync_dev_lockfs()/unlockfs() */
-/* #define	LVM_VFS_ENHANCEMENT */
-
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -2250,12 +2247,8 @@
 	if (lv_ptr->lv_access & LV_SNAPSHOT) {
 		lv_t *org = lv_ptr->lv_snapshot_org, *last;
 
-		/* sync the original logical volume */
-		fsync_dev(org->lv_dev);
-#ifdef	LVM_VFS_ENHANCEMENT
 		/* VFS function call to sync and lock the filesystem */
 		fsync_dev_lockfs(org->lv_dev);
-#endif
 
 		down_write(&org->lv_lock);
 		org->lv_access |= LV_SNAPSHOT_ORG;
@@ -2281,11 +2274,9 @@
 	else
 		set_device_ro(lv_ptr->lv_dev, 1);
 
-#ifdef	LVM_VFS_ENHANCEMENT
 /* VFS function call to unlock the filesystem */
 	if (lv_ptr->lv_access & LV_SNAPSHOT)
 		unlockfs(lv_ptr->lv_snapshot_org->lv_dev);
-#endif
 
 	lvm_gendisk.part[MINOR(lv_ptr->lv_dev)].de =
 	    lvm_fs_create_lv(vg_ptr, lv_ptr);
fs/buffer.c +28 -0
diff -Nuar a/fs/buffer.c b/fs/buffer.c
@@ -419,6 +419,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);
fs/reiserfs/super.c +1 -1
diff -Nuar a/fs/reiserfs/super.c b/fs/reiserfs/super.c
@@ -73,7 +73,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() ;
fs/super.c +59 -0

108 lines not on this page · raw message

include/linux/fs.h +3 -0
diff -Nuar a/include/linux/fs.h b/include/linux/fs.h
@@ -1277,6 +1277,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 *);
@@ -1295,6 +1296,8 @@
 extern int filemap_fdatasync(struct address_space *);
 extern int filemap_fdatawait(struct address_space *);
 extern void sync_supers(kdev_t dev, int wait);
+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);
kernel/ksyms.c +2 -0
diff -Nuar a/kernel/ksyms.c b/kernel/ksyms.c
@@ -194,6 +194,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);
#1 lore raw
Quoted 6 lines · Xose Vazquez Perez

hi,

This patch is necessary to be able to mount snapshots of journalling filesystems. It was flying around lvm for long time, years!!. And LiNUX distributions bring it, Red Hat at least since 7.x. So, it should be sure.

The patch still doesn't get better by that. And even if it was this would clearly be a feature for 2.6, not 2.4.

#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Xose Vazquez Perez

hi,

This patch is necessary to be able to mount snapshots of journalling filesystems. It was flying around lvm for long time, years!!. And LiNUX distributions bring it, Red Hat at least since 7.x. So, it should be sure.

The patch still doesn't get better by that. And even if it was this would clearly be a feature for 2.6, not 2.4.

I have not started looking at 2.6 yet, but somehow I assumed it would already have the automatic freeze invocation logic in it.

Too bad that it doesn't, but with 2.4 and XFS I initiate the freeze from user space and don't depend on the patch being installed.

I assume all of the various filesystems have a way to invoke the freeze from userspace. If so, this patch is a nicety, not a neccesity.

Greg

Signature · 1 line
Greg Freemyer