patch-2.4.0-test3 linux/kernel/fork.c

Next file: linux/kernel/itimer.c
Previous file: linux/kernel/exit.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test2/linux/kernel/fork.c linux/kernel/fork.c
@@ -425,9 +425,12 @@
 static inline struct fs_struct *__copy_fs_struct(struct fs_struct *old)
 {
 	struct fs_struct *fs = kmalloc(sizeof(*old), GFP_KERNEL);
+	/* We don't need to lock fs - think why ;-) */
 	if (fs) {
 		atomic_set(&fs->count, 1);
+		fs->lock = RW_LOCK_UNLOCKED;
 		fs->umask = old->umask;
+		read_lock(&old->lock);
 		fs->rootmnt = mntget(old->rootmnt);
 		fs->root = dget(old->root);
 		fs->pwdmnt = mntget(old->pwdmnt);
@@ -439,6 +442,7 @@
 			fs->altrootmnt = NULL;
 			fs->altroot = NULL;
 		}	
+		read_unlock(&old->lock);
 	}
 	return fs;
 }
@@ -795,5 +799,5 @@
 					 SLAB_HWCACHE_ALIGN,
 					 NULL, NULL);
 	if (!files_cachep) 
-		panic("Cannot create files cache"); 
+		panic("Cannot create files cache");
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)