MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vfs_allocate_syncvnode

Function vfs_allocate_syncvnode

freebsd/kern/vfs_subr.c:4968–5021  ·  view source on GitHub ↗

* Create a new filesystem syncer vnode for the specified mount point. */

Source from the content-addressed store, hash-verified

4966 * Create a new filesystem syncer vnode for the specified mount point.
4967 */
4968void
4969vfs_allocate_syncvnode(struct mount *mp)
4970{
4971 struct vnode *vp;
4972 struct bufobj *bo;
4973 static long start, incr, next;
4974 int error;
4975
4976 /* Allocate a new vnode */
4977 error = getnewvnode("syncer", mp, &sync_vnodeops, &vp);
4978 if (error != 0)
4979 panic("vfs_allocate_syncvnode: getnewvnode() failed");
4980 vp->v_type = VNON;
4981 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
4982 vp->v_vflag |= VV_FORCEINSMQ;
4983 error = insmntque(vp, mp);
4984 if (error != 0)
4985 panic("vfs_allocate_syncvnode: insmntque() failed");
4986 vp->v_vflag &= ~VV_FORCEINSMQ;
4987 VOP_UNLOCK(vp);
4988 /*
4989 * Place the vnode onto the syncer worklist. We attempt to
4990 * scatter them about on the list so that they will go off
4991 * at evenly distributed times even if all the filesystems
4992 * are mounted at once.
4993 */
4994 next += incr;
4995 if (next == 0 || next > syncer_maxdelay) {
4996 start /= 2;
4997 incr /= 2;
4998 if (start == 0) {
4999 start = syncer_maxdelay / 2;
5000 incr = syncer_maxdelay;
5001 }
5002 next = start;
5003 }
5004 bo = &vp->v_bufobj;
5005 BO_LOCK(bo);
5006 vn_syncer_add_to_worklist(bo, syncdelay > 0 ? next % syncdelay : 0);
5007 /* XXX - vn_syncer_add_to_worklist() also grabs and drops sync_mtx. */
5008 mtx_lock(&sync_mtx);
5009 sync_vnode_count++;
5010 if (mp->mnt_syncer == NULL) {
5011 mp->mnt_syncer = vp;
5012 vp = NULL;
5013 }
5014 mtx_unlock(&sync_mtx);
5015 BO_UNLOCK(bo);
5016 if (vp != NULL) {
5017 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
5018 vgone(vp);
5019 vput(vp);
5020 }
5021}
5022
5023void
5024vfs_deallocate_syncvnode(struct mount *mp)

Callers 3

vfs_domount_firstFunction · 0.85
vfs_domount_updateFunction · 0.85
dounmountFunction · 0.85

Calls 8

vn_lockFunction · 0.85
insmntqueFunction · 0.85
vgoneFunction · 0.85
vputFunction · 0.85
panicFunction · 0.70
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected