From 2f05c7ff5759f89a12f6e94afad53ac6fd536043 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Fri, 13 Apr 2012 17:46:42 -0700 Subject: [PATCH] kernel -- Per-mount threaded syncer infrastructure. Do not shut down syncer thread when unmount fails. Reminded-by: dillon@ --- sys/kern/vfs_sync.c | 13 ++++++++++--- sys/kern/vfs_vfsops.c | 12 +++++++++--- sys/sys/vnode.h | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_sync.c b/sys/kern/vfs_sync.c index 4591043c0f..59d2f253a9 100644 --- a/sys/kern/vfs_sync.c +++ b/sys/kern/vfs_sync.c @@ -265,15 +265,21 @@ vn_syncer_thr_create(struct mount *mp) "syncer%d", ++syncalloc); } +void * +vn_syncer_thr_getctx(struct mount *mp) +{ + return (mp->mnt_syncer_ctx); +} + /* * Stop per-filesystem syncer process */ void -vn_syncer_thr_stop(struct mount *mp) +vn_syncer_thr_stop(void *ctxp) { struct syncer_ctx *ctx; - ctx = mp->mnt_syncer_ctx; + ctx = ctxp; lwkt_gettoken(&ctx->sc_token); @@ -285,7 +291,6 @@ vn_syncer_thr_stop(struct mount *mp) while ((ctx->sc_flags & SC_FLAG_DONE) == 0) tsleep(&ctx->sc_flags, 0, "syncexit", hz); - mp->mnt_syncer_ctx = NULL; lwkt_reltoken(&ctx->sc_token); kfree(ctx->syncer_workitem_pending, M_DEVBUF); @@ -309,6 +314,8 @@ syncer_thread(void *_ctx) int sc_flags; int vnodes_synced = 0; + atomic_clear_int(&curthread->td_flags, TDF_VERBOSE); + /* * syncer0 runs till system shutdown; per-filesystem syncers are * terminated on filesystem unmount diff --git a/sys/kern/vfs_vfsops.c b/sys/kern/vfs_vfsops.c index f5b0937d1f..9d52a3e605 100644 --- a/sys/kern/vfs_vfsops.c +++ b/sys/kern/vfs_vfsops.c @@ -130,13 +130,19 @@ vfs_unmount(struct mount *mp, int mntflags) { VFS_MPLOCK_DECLARE; int error; + int flags; + void *ctx; VFS_MPLOCK1(mp); - if (mp->mnt_kern_flag & MNTK_THR_SYNC) - vn_syncer_thr_stop(mp); error = (mp->mnt_op->vfs_acdone)(mp); - if (error == 0) + if (error == 0) { + flags = mp->mnt_kern_flag; + ctx = vn_syncer_thr_getctx(mp); error = (mp->mnt_op->vfs_unmount)(mp, mntflags); + } + if (error == 0 && + flags & MNTK_THR_SYNC) + vn_syncer_thr_stop(ctx); VFS_MPUNLOCK(mp); return (error); } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index b829510c9c..f699f7332b 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -551,7 +551,8 @@ void mount_init(struct mount *mp); void vn_syncer_add(struct vnode *, int); void vn_syncer_remove(struct vnode *); void vn_syncer_thr_create(struct mount *); -void vn_syncer_thr_stop(struct mount *); +void *vn_syncer_thr_getctx(struct mount *); +void vn_syncer_thr_stop(void *); void vnlru_proc_wait(void); -- 2.41.0