Use indirect function pointer hooks instead of #ifdef SOFTUPDATES

direct calls for the two places where the kernel calls into soft
updates code. Set up the hooks in softdep_initialize() and NULL
them out in softdep_uninitialize(). This change allows soft updates
to function correctly when ufs is loaded as a module.

Reviewed by:	mckusick
This commit is contained in:
Ian Dowse 2002-07-01 17:59:40 +00:00
parent b0346d3494
commit 6bd521df93
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99220
5 changed files with 21 additions and 14 deletions

View File

@ -41,7 +41,6 @@
/* For 4.3 integer FS ID compatibility */
#include "opt_compat.h"
#include "opt_ffs.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -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);

View File

@ -43,7 +43,6 @@
* External virtual filesystem routines
*/
#include "opt_ddb.h"
#include "opt_ffs.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -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

View File

@ -41,7 +41,6 @@
/* For 4.3 integer FS ID compatibility */
#include "opt_compat.h"
#include "opt_ffs.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -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);

View File

@ -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);

View File

@ -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);