Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_mount.c
Show First 20 Lines • Show All 443 Lines • ▼ Show 20 Lines | sys_nmount(struct thread *td, struct nmount_args *uap) | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* --------------------------------------------------------------------- | * --------------------------------------------------------------------- | ||||
* Various utility functions | * Various utility functions | ||||
*/ | */ | ||||
/* | |||||
* Get a reference on a mount point from a vnode. | |||||
* | |||||
* The vnode is allowed to be passed unlocked and race against dooming. Note in | |||||
* such case there are no guarantees the referenced mount point will still be | |||||
* associated with it after the function returns. | |||||
*/ | |||||
struct mount * | |||||
vfs_ref_from_vp(struct vnode *vp) | |||||
{ | |||||
struct mount *mp; | |||||
struct mount_pcpu *mpcpu; | |||||
mp = atomic_load_ptr(&vp->v_mount); | |||||
if (__predict_false(mp == NULL)) { | |||||
return (mp); | |||||
} | |||||
if (vfs_op_thread_enter(mp, mpcpu)) { | |||||
if (__predict_true(mp == vp->v_mount)) { | |||||
vfs_mp_count_add_pcpu(mpcpu, ref, 1); | |||||
vfs_op_thread_exit(mp, mpcpu); | |||||
} else { | |||||
vfs_op_thread_exit(mp, mpcpu); | |||||
mp = NULL; | |||||
} | |||||
} else { | |||||
MNT_ILOCK(mp); | |||||
if (mp == vp->v_mount) { | |||||
MNT_REF(mp); | |||||
MNT_IUNLOCK(mp); | |||||
} else { | |||||
MNT_IUNLOCK(mp); | |||||
mp = NULL; | |||||
} | |||||
} | |||||
return (mp); | |||||
} | |||||
void | void | ||||
vfs_ref(struct mount *mp) | vfs_ref(struct mount *mp) | ||||
{ | { | ||||
struct mount_pcpu *mpcpu; | struct mount_pcpu *mpcpu; | ||||
CTR2(KTR_VFS, "%s: mp %p", __func__, mp); | CTR2(KTR_VFS, "%s: mp %p", __func__, mp); | ||||
if (vfs_op_thread_enter(mp, mpcpu)) { | if (vfs_op_thread_enter(mp, mpcpu)) { | ||||
vfs_mp_count_add_pcpu(mpcpu, ref, 1); | vfs_mp_count_add_pcpu(mpcpu, ref, 1); | ||||
▲ Show 20 Lines • Show All 2,148 Lines • Show Last 20 Lines |