diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 1244e5470766..8fcb651fe5d0 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -41,7 +41,6 @@ /* For 4.3 integer FS ID compatibility */ #include "opt_compat.h" -#include "opt_ffs.h" #include #include @@ -92,6 +91,7 @@ static int vfs_nmount(struct thread *td, int, struct uio *); static int usermount = 0; /* if 1, non-root can mount fs. */ int (*union_dircheckp)(struct thread *td, struct vnode **, struct file *); +int (*softdep_fsync_hook)(struct vnode *); SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, ""); @@ -3486,10 +3486,9 @@ fsync(td, uap) vm_object_page_clean(obj, 0, 0, 0); } error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td); -#ifdef SOFTUPDATES - if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP)) - error = softdep_fsync(vp); -#endif + if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) + && softdep_fsync_hook != NULL) + error = (*softdep_fsync_hook)(vp); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 6aaaa30a6d26..a20e637e146d 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -43,7 +43,6 @@ * External virtual filesystem routines */ #include "opt_ddb.h" -#include "opt_ffs.h" #include #include @@ -236,6 +235,9 @@ static int vnlru_nowhere; SYSCTL_INT(_debug, OID_AUTO, vnlru_nowhere, CTLFLAG_RW, &vnlru_nowhere, 0, "Number of times the vnlru process ran without success"); +/* Hook for calling soft updates */ +int (*softdep_process_worklist_hook)(struct mount *); + #ifdef DEBUG_VFS_LOCKS /* Print lock violations */ int vfs_badlock_print = 1; @@ -1383,9 +1385,8 @@ sched_sync(void) /* * Do soft update processing. */ -#ifdef SOFTUPDATES - softdep_process_worklist(NULL); -#endif + if (softdep_process_worklist_hook != NULL) + (*softdep_process_worklist_hook)(NULL); /* * The variable rushjob allows the kernel to speed up the diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 1244e5470766..8fcb651fe5d0 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -41,7 +41,6 @@ /* For 4.3 integer FS ID compatibility */ #include "opt_compat.h" -#include "opt_ffs.h" #include #include @@ -92,6 +91,7 @@ static int vfs_nmount(struct thread *td, int, struct uio *); static int usermount = 0; /* if 1, non-root can mount fs. */ int (*union_dircheckp)(struct thread *td, struct vnode **, struct file *); +int (*softdep_fsync_hook)(struct vnode *); SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, ""); @@ -3486,10 +3486,9 @@ fsync(td, uap) vm_object_page_clean(obj, 0, 0, 0); } error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td); -#ifdef SOFTUPDATES - if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP)) - error = softdep_fsync(vp); -#endif + if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) + && softdep_fsync_hook != NULL) + error = (*softdep_fsync_hook)(vp); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 0bace92f1b9c..70331a8bf007 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -579,6 +579,8 @@ struct vattr; struct vnode; extern int (*lease_check_hook)(struct vop_lease_args *); +extern int (*softdep_fsync_hook)(struct vnode *); +extern int (*softdep_process_worklist_hook)(struct mount *); struct vnode *addaliasu(struct vnode *vp, udev_t nvp_rdev); int bdevvp(dev_t dev, struct vnode **vpp); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 4921344f4578..f03615099af9 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1123,6 +1123,10 @@ softdep_initialize() newblk_hashtbl = hashinit(64, M_NEWBLK, &newblk_hash); sema_init(&newblk_in_progress, "newblk", PRIBIO, 0); + /* hooks through which the main kernel code calls us */ + softdep_process_worklist_hook = softdep_process_worklist; + softdep_fsync_hook = softdep_fsync; + /* initialise bioops hack */ bioops.io_start = softdep_disk_io_initiation; bioops.io_complete = softdep_disk_write_complete; @@ -1139,6 +1143,8 @@ void softdep_uninitialize() { + softdep_process_worklist_hook = NULL; + softdep_fsync_hook = NULL; hashdestroy(pagedep_hashtbl, M_PAGEDEP, pagedep_hash); hashdestroy(inodedep_hashtbl, M_INODEDEP, inodedep_hash); hashdestroy(newblk_hashtbl, M_NEWBLK, newblk_hash);