Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_mount.c
Show First 20 Lines • Show All 498 Lines • ▼ Show 20 Lines | if (vfs_op_thread_enter(mp, mpcpu)) { | ||||
return; | return; | ||||
} | } | ||||
MNT_ILOCK(mp); | MNT_ILOCK(mp); | ||||
MNT_REF(mp); | MNT_REF(mp); | ||||
MNT_IUNLOCK(mp); | MNT_IUNLOCK(mp); | ||||
} | } | ||||
struct mount * | |||||
vfs_pin_from_vp(struct vnode *vp) | |||||
{ | |||||
struct mount *mp; | |||||
mp = atomic_load_ptr(&vp->v_mount); | |||||
if (mp == NULL) | |||||
return (NULL); | |||||
MNT_ILOCK(mp); | |||||
if ((mp != vp->v_mount) || (mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) { | |||||
kib: Extra () in the expression before ||. | |||||
MNT_IUNLOCK(mp); | |||||
return (NULL); | |||||
} | |||||
++mp->mnt_pinned_count; | |||||
kibUnsubmitted Not Done Inline ActionsIt might be worth to add the check that we do not overflow there. kib: It might be worth to add the check that we do not overflow there. | |||||
MNT_IUNLOCK(mp); | |||||
return (mp); | |||||
} | |||||
void | void | ||||
vfs_unpin(struct mount *mp) | |||||
{ | |||||
KASSERT(mp != NULL, ("NULL mount")); | |||||
kibUnsubmitted Not Done Inline ActionsWe usually do not assert that pointers are not NULL, leaving it to hw to do the check. kib: We usually do not assert that pointers are not NULL, leaving it to hw to do the check. | |||||
MNT_ILOCK(mp); | |||||
--mp->mnt_pinned_count; | |||||
KASSERT(mp->mnt_pinned_count >= 0, ("mnt pinned count underflow")); | |||||
kibUnsubmitted Not Done Inline ActionsIt makes more sense to assert that count >= 1 before decrement, IMO. kib: It makes more sense to assert that count >= 1 before decrement, IMO. | |||||
MNT_IUNLOCK(mp); | |||||
} | |||||
void | |||||
vfs_rel(struct mount *mp) | vfs_rel(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_sub_pcpu(mpcpu, ref, 1); | vfs_mp_count_sub_pcpu(mpcpu, ref, 1); | ||||
vfs_op_thread_exit(mp, mpcpu); | vfs_op_thread_exit(mp, mpcpu); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp, const char *fspath, | ||||
strlcpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN); | strlcpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN); | ||||
mp->mnt_iosize_max = DFLTPHYS; | mp->mnt_iosize_max = DFLTPHYS; | ||||
#ifdef MAC | #ifdef MAC | ||||
mac_mount_init(mp); | mac_mount_init(mp); | ||||
mac_mount_create(cred, mp); | mac_mount_create(cred, mp); | ||||
#endif | #endif | ||||
arc4rand(&mp->mnt_hashseed, sizeof mp->mnt_hashseed, 0); | arc4rand(&mp->mnt_hashseed, sizeof mp->mnt_hashseed, 0); | ||||
TAILQ_INIT(&mp->mnt_uppers); | TAILQ_INIT(&mp->mnt_uppers); | ||||
mp->mnt_pinned_count = 0; | |||||
return (mp); | return (mp); | ||||
} | } | ||||
/* | /* | ||||
* Destroy the mount struct previously allocated by vfs_mount_alloc(). | * Destroy the mount struct previously allocated by vfs_mount_alloc(). | ||||
*/ | */ | ||||
void | void | ||||
vfs_mount_destroy(struct mount *mp) | vfs_mount_destroy(struct mount *mp) | ||||
Show All 22 Lines | vfs_mount_destroy(struct mount *mp) | ||||
atomic_subtract_rel_int(&mp->mnt_vfc->vfc_refcount, 1); | atomic_subtract_rel_int(&mp->mnt_vfc->vfc_refcount, 1); | ||||
if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) { | if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) { | ||||
struct vnode *vp; | struct vnode *vp; | ||||
TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) | TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) | ||||
vn_printf(vp, "dangling vnode "); | vn_printf(vp, "dangling vnode "); | ||||
panic("unmount: dangling vnode"); | panic("unmount: dangling vnode"); | ||||
} | } | ||||
KASSERT(mp->mnt_pinned_count == 0, | |||||
("mnt_pinned_count = %d", mp->mnt_pinned_count)); | |||||
KASSERT(TAILQ_EMPTY(&mp->mnt_uppers), ("mnt_uppers")); | KASSERT(TAILQ_EMPTY(&mp->mnt_uppers), ("mnt_uppers")); | ||||
if (mp->mnt_nvnodelistsize != 0) | if (mp->mnt_nvnodelistsize != 0) | ||||
panic("vfs_mount_destroy: nonzero nvnodelistsize"); | panic("vfs_mount_destroy: nonzero nvnodelistsize"); | ||||
if (mp->mnt_lazyvnodelistsize != 0) | if (mp->mnt_lazyvnodelistsize != 0) | ||||
panic("vfs_mount_destroy: nonzero lazyvnodelistsize"); | panic("vfs_mount_destroy: nonzero lazyvnodelistsize"); | ||||
if (mp->mnt_lockref != 0) | if (mp->mnt_lockref != 0) | ||||
panic("vfs_mount_destroy: nonzero lock refcount"); | panic("vfs_mount_destroy: nonzero lock refcount"); | ||||
MNT_IUNLOCK(mp); | MNT_IUNLOCK(mp); | ||||
▲ Show 20 Lines • Show All 1,190 Lines • ▼ Show 20 Lines | dounmount(struct mount *mp, int flags, struct thread *td) | ||||
} | } | ||||
vfs_op_enter(mp); | vfs_op_enter(mp); | ||||
vn_start_write(NULL, &mp, V_WAIT | V_MNTREF); | vn_start_write(NULL, &mp, V_WAIT | V_MNTREF); | ||||
MNT_ILOCK(mp); | MNT_ILOCK(mp); | ||||
if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0 || | if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0 || | ||||
(mp->mnt_flag & MNT_UPDATE) != 0 || | (mp->mnt_flag & MNT_UPDATE) != 0 || | ||||
!TAILQ_EMPTY(&mp->mnt_uppers)) { | mp->mnt_pinned_count != 0) { | ||||
dounmount_cleanup(mp, coveredvp, 0); | dounmount_cleanup(mp, coveredvp, 0); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
mp->mnt_kern_flag |= MNTK_UNMOUNT; | mp->mnt_kern_flag |= MNTK_UNMOUNT; | ||||
rootvp = vfs_cache_root_clear(mp); | rootvp = vfs_cache_root_clear(mp); | ||||
if (coveredvp != NULL) | if (coveredvp != NULL) | ||||
vn_seqc_write_begin(coveredvp); | vn_seqc_write_begin(coveredvp); | ||||
if (flags & MNT_NONBUSY) { | if (flags & MNT_NONBUSY) { | ||||
▲ Show 20 Lines • Show All 823 Lines • Show Last 20 Lines |
Extra () in the expression before ||.