patch-2.1.52 linux/fs/super.c

Next file: linux/include/asm-i386/string.h
Previous file: linux/fs/smbfs/sock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.51/linux/fs/super.c linux/fs/super.c
@@ -553,7 +553,7 @@
 static int d_umount(struct super_block * sb)
 {
 	struct dentry * root = sb->s_root;
-	struct dentry * covers = root->d_covers;
+	struct dentry * covered = root->d_covers;
 
 	if (root->d_count != 1)
 		return -EBUSY;
@@ -563,22 +563,23 @@
 
 	sb->s_root = NULL;
 
-	covers->d_mounts = covers;
-	root->d_covers = root;
-
-	dput(covers);
+	if (covered != root) {
+		root->d_covers = root;
+		covered->d_mounts = covered;
+		dput(covered);
+	}
 	dput(root);
 	return 0;
 }
 
-static void d_mount(struct dentry *covers, struct dentry *dentry)
+static void d_mount(struct dentry *covered, struct dentry *dentry)
 {
-	if (covers->d_mounts != covers) {
+	if (covered->d_mounts != covered) {
 		printk("VFS: mount - already mounted\n");
 		return;
 	}
-	covers->d_mounts = dentry;
-	dentry->d_covers = covers;
+	covered->d_mounts = dentry;
+	dentry->d_covers = covered;
 }
 
 static int do_umount(kdev_t dev,int unmount_root)
@@ -1124,6 +1125,15 @@
 	}
 	ROOT_DEV = new_root_dev;
 	do_mount_root();
+	dput(old_root);
+	dput(old_pwd);
+#if 1
+	shrink_dcache();
+	printk("do_change_root: old root has d_count=%d\n", old_root->d_count);
+#endif
+	/*
+	 * Get the new mount directory
+	 */
 	dir_d = lookup_dentry(put_old, NULL, 1);
 	if (IS_ERR(dir_d)) {
 		error = PTR_ERR(dir_d);
@@ -1141,20 +1151,18 @@
 		dput(dir_d);
 		error = -ENOTDIR;
 	}
-	printk("do_change_root: old root d_count=%d\n", old_root->d_count);
-	dput(old_root);
-	dput(old_pwd);
 	if (error) {
 		int umount_error;
 
 		printk(KERN_NOTICE "Trying to unmount old root ... ");
 		umount_error = do_umount(old_root_dev,1);
-		if (umount_error) printk(KERN_ERR "error %d\n",umount_error);
-		else {
+		if (!umount_error) {
 			printk("okay\n");
 			invalidate_buffers(old_root_dev);
+			return 0;
 		}
-		return umount_error ? error : 0;
+		printk(KERN_ERR "error %d\n",umount_error);
+		return error;
 	}
 	remove_vfsmnt(old_root_dev);
 	vfsmnt = add_vfsmnt(old_root_dev,"/dev/root.old",put_old);
@@ -1165,7 +1173,6 @@
 		return 0;
 	}
 	printk(KERN_CRIT "Trouble: add_vfsmnt failed\n");
-	dput(old_root);
 	return -ENOMEM;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov