Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Apr 2012 00:51:28 +0000 (UTC)
From:      Grzegorz Bernacki <gber@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r234523 - projects/nand/sys/fs/nandfs
Message-ID:  <201204210051.q3L0pSPE063577@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gber
Date: Sat Apr 21 00:51:28 2012
New Revision: 234523
URL: http://svn.freebsd.org/changeset/base/234523

Log:
  nandfs: run syncer and cleaner as kernel threads instead of processes
  
  Obtained from: Semihalf
  Supported by:  FreeBSD Foundation, Juniper Networks

Modified:
  projects/nand/sys/fs/nandfs/nandfs.h
  projects/nand/sys/fs/nandfs/nandfs_cleaner.c
  projects/nand/sys/fs/nandfs/nandfs_vfsops.c

Modified: projects/nand/sys/fs/nandfs/nandfs.h
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs.h	Sat Apr 21 00:32:56 2012	(r234522)
+++ projects/nand/sys/fs/nandfs/nandfs.h	Sat Apr 21 00:51:28 2012	(r234523)
@@ -153,8 +153,8 @@ struct nandfs_device {
 	struct vnode		*nd_devvp;
 	struct g_consumer	*nd_gconsumer;
 
-	struct proc		*nd_syncer;
-	struct proc		*nd_cleaner;
+	struct thread		*nd_syncer;
+	struct thread		*nd_cleaner;
 	int			nd_syncer_exit;
 	int			nd_cleaner_exit;
 

Modified: projects/nand/sys/fs/nandfs/nandfs_cleaner.c
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_cleaner.c	Sat Apr 21 00:32:56 2012	(r234522)
+++ projects/nand/sys/fs/nandfs/nandfs_cleaner.c	Sat Apr 21 00:51:28 2012	(r234523)
@@ -79,7 +79,7 @@ nandfs_start_cleaner(struct nandfs_devic
 
 	fsdev->nd_cleaner_exit = 0;
 
-	error = kproc_create((void(*)(void *))nandfs_cleaner, fsdev,
+	error = kthread_add((void(*)(void *))nandfs_cleaner, fsdev, NULL,
 	    &fsdev->nd_cleaner, 0, 0, "nandfs_cleaner");
 	if (error)
 		printf("nandfs: could not start cleaner: %d\n", error);
@@ -461,7 +461,7 @@ nandfs_cleaner(struct nandfs_device *fsd
 	}
 
 	DPRINTF(CLEAN, ("%s: exiting\n", __func__));
-	kproc_exit(0);
+	kthread_exit();
 }
 
 static int

Modified: projects/nand/sys/fs/nandfs/nandfs_vfsops.c
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_vfsops.c	Sat Apr 21 00:32:56 2012	(r234522)
+++ projects/nand/sys/fs/nandfs/nandfs_vfsops.c	Sat Apr 21 00:51:28 2012	(r234523)
@@ -1103,7 +1103,7 @@ nandfs_gc_finished(struct nandfs_device 
 }
 
 static void
-nandfs_procbody(struct nandfsmount *nmp)
+nandfs_syncer(struct nandfsmount *nmp)
 {
 	struct nandfs_device *nffsdev;
 	struct mount *mp;
@@ -1135,17 +1135,7 @@ nandfs_procbody(struct nandfsmount *nmp)
 	nffsdev->nd_syncer = NULL;
 	MPASS(nffsdev->nd_free_base == NULL);
 
-	/*
-	 * A bit of explanation:
-	 * kproc_exit() reparents thread to init process so it can be
-	 * properly reaped, however when NANDFS was a root filesystem
-	 * vnode for init process is reclaimed and we dont want to let
-	 * init run again so it is safer to call just exit() in this case.
-	 */
-	if ((mp->mnt_flag & MNT_ROOTFS) && mp->mnt_kern_flag & MNTK_UNMOUNT)
-		exit1(curthread, 0);
-	else
-		kproc_exit(0);
+	kthread_exit();
 }
 
 static int
@@ -1159,7 +1149,7 @@ start_syncer(struct nandfsmount *nmp)
 
 	nmp->nm_nandfsdev->nd_syncer_exit = 0;
 
-	error = kproc_create((void(*)(void *))nandfs_procbody, nmp,
+	error = kthread_add((void(*)(void *))nandfs_syncer, nmp, NULL,
 	    &nmp->nm_nandfsdev->nd_syncer, 0, 0, "nandfs_syncer");
 
 	if (error)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204210051.q3L0pSPE063577>