Lines Matching refs:mp
180 static void insmntque(vnode_t vp, mount_t mp);
430 vnode_iterate_setup(mount_t mp)
432 while (mp->mnt_lflag & MNT_LITER) {
433 mp->mnt_lflag |= MNT_LITERWAIT;
434 msleep((caddr_t)mp, &mp->mnt_mlock, PVFS, "vnode_iterate_setup", NULL);
437 mp->mnt_lflag |= MNT_LITER;
442 vnode_umount_preflight(mount_t mp, vnode_t skipvp, int flags)
446 TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
476 vnode_iterate_prepare(mount_t mp)
480 if (TAILQ_EMPTY(&mp->mnt_vnodelist)) {
485 vp = TAILQ_FIRST(&mp->mnt_vnodelist);
486 vp->v_mntvnodes.tqe_prev = &(mp->mnt_workerqueue.tqh_first);
487 mp->mnt_workerqueue.tqh_first = mp->mnt_vnodelist.tqh_first;
488 mp->mnt_workerqueue.tqh_last = mp->mnt_vnodelist.tqh_last;
490 TAILQ_INIT(&mp->mnt_vnodelist);
491 if (mp->mnt_newvnodes.tqh_first != NULL)
493 TAILQ_INIT(&mp->mnt_newvnodes);
501 vnode_iterate_reloadq(mount_t mp)
506 if (!TAILQ_EMPTY(&mp->mnt_workerqueue)) {
508 mvp = TAILQ_LAST(&mp->mnt_vnodelist, vnodelst);
512 mvp->v_mntvnodes.tqe_next = mp->mnt_workerqueue.tqh_first;
514 mp->mnt_vnodelist.tqh_first = mp->mnt_workerqueue.tqh_first;
515 mp->mnt_workerqueue.tqh_first->v_mntvnodes.tqe_prev = mp->mnt_vnodelist.tqh_last;
516 mp->mnt_vnodelist.tqh_last = mp->mnt_workerqueue.tqh_last;
517 TAILQ_INIT(&mp->mnt_workerqueue);
521 if (!TAILQ_EMPTY(&mp->mnt_newvnodes)) {
523 nlvp = TAILQ_LAST(&mp->mnt_newvnodes, vnodelst);
525 mp->mnt_newvnodes.tqh_first->v_mntvnodes.tqe_prev = &mp->mnt_vnodelist.tqh_first;
526 nlvp->v_mntvnodes.tqe_next = mp->mnt_vnodelist.tqh_first;
527 if(mp->mnt_vnodelist.tqh_first)
528 mp->mnt_vnodelist.tqh_first->v_mntvnodes.tqe_prev = &nlvp->v_mntvnodes.tqe_next;
530 mp->mnt_vnodelist.tqh_last = mp->mnt_newvnodes.tqh_last;
531 mp->mnt_vnodelist.tqh_first = mp->mnt_newvnodes.tqh_first;
532 TAILQ_INIT(&mp->mnt_newvnodes);
541 vnode_iterate_clear(mount_t mp)
543 mp->mnt_lflag &= ~MNT_LITER;
544 if (mp->mnt_lflag & MNT_LITERWAIT) {
545 mp->mnt_lflag &= ~MNT_LITERWAIT;
546 wakeup(mp);
552 vnode_iterate(mount_t mp, int flags, int (*callout)(struct vnode *, void *),
559 mount_lock(mp);
561 vnode_iterate_setup(mp);
564 retval = vnode_iterate_prepare(mp);
567 vnode_iterate_clear(mp);
568 mount_unlock(mp);
573 while (!TAILQ_EMPTY(&mp->mnt_workerqueue)) {
574 vp = TAILQ_FIRST(&mp->mnt_workerqueue);
575 TAILQ_REMOVE(&mp->mnt_workerqueue, vp, v_mntvnodes);
576 TAILQ_INSERT_TAIL(&mp->mnt_vnodelist, vp, v_mntvnodes);
578 if ((vp->v_data == NULL) || (vp->v_type == VNON) || (vp->v_mount != mp)) {
581 mount_unlock(mp);
584 mount_lock(mp);
595 mount_lock(mp);
607 mount_lock(mp);
614 mount_lock(mp);
621 mount_lock(mp);
625 (void)vnode_iterate_reloadq(mp);
626 vnode_iterate_clear(mp);
627 mount_unlock(mp);
632 mount_lock_renames(mount_t mp)
634 lck_mtx_lock(&mp->mnt_renamelock);
638 mount_unlock_renames(mount_t mp)
640 lck_mtx_unlock(&mp->mnt_renamelock);
644 mount_lock(mount_t mp)
646 lck_mtx_lock(&mp->mnt_mlock);
650 mount_unlock(mount_t mp)
652 lck_mtx_unlock(&mp->mnt_mlock);
657 mount_ref(mount_t mp, int locked)
660 mount_lock(mp);
662 mp->mnt_count++;
665 mount_unlock(mp);
670 mount_drop(mount_t mp, int locked)
673 mount_lock(mp);
675 mp->mnt_count--;
677 if (mp->mnt_count == 0 && (mp->mnt_lflag & MNT_LDRAIN))
678 wakeup(&mp->mnt_lflag);
681 mount_unlock(mp);
686 mount_iterref(mount_t mp, int locked)
692 if (mp->mnt_iterref < 0) {
695 mp->mnt_iterref++;
703 mount_isdrained(mount_t mp, int locked)
709 if (mp->mnt_iterref < 0)
719 mount_iterdrop(mount_t mp)
722 mp->mnt_iterref--;
723 wakeup(&mp->mnt_iterref);
728 mount_iterdrain(mount_t mp)
731 while (mp->mnt_iterref)
732 msleep((caddr_t)&mp->mnt_iterref, mnt_list_mtx_lock, PVFS, "mount_iterdrain", NULL);
734 mp->mnt_iterref = -1;
738 mount_iterreset(mount_t mp)
741 if (mp->mnt_iterref == -1)
742 mp->mnt_iterref = 0;
748 mount_refdrain(mount_t mp)
750 if (mp->mnt_lflag & MNT_LDRAIN)
752 mp->mnt_lflag |= MNT_LDRAIN;
754 while (mp->mnt_count)
755 msleep((caddr_t)&mp->mnt_lflag, &mp->mnt_mlock, PVFS, "mount_drain", NULL);
757 if (mp->mnt_vnodelist.tqh_first != NULL)
760 mp->mnt_lflag &= ~MNT_LDRAIN;
771 vfs_busy(mount_t mp, int flags)
775 if (mp->mnt_lflag & MNT_LDEAD)
778 if (mp->mnt_lflag & MNT_LUNMOUNT) {
782 mount_lock(mp);
784 if (mp->mnt_lflag & MNT_LDEAD) {
785 mount_unlock(mp);
788 if (mp->mnt_lflag & MNT_LUNMOUNT) {
789 mp->mnt_lflag |= MNT_LWAIT;
796 msleep((caddr_t)mp, &mp->mnt_mlock, (PVFS | PDROP), "vfsbusy", NULL);
799 mount_unlock(mp);
802 lck_rw_lock_shared(&mp->mnt_rwlock);
808 if (mp->mnt_lflag & (MNT_LDEAD | MNT_LUNMOUNT)) {
809 lck_rw_done(&mp->mnt_rwlock);
820 vfs_unbusy(mount_t mp)
822 lck_rw_done(&mp->mnt_rwlock);
828 vfs_rootmountfailed(mount_t mp) {
831 mp->mnt_vtable->vfc_refcount--;
834 vfs_unbusy(mp);
836 mount_lock_destroy(mp);
839 mac_mount_label_destroy(mp);
842 FREE_ZONE(mp, sizeof(struct mount), M_MOUNT);
854 mount_t mp;
856 mp = _MALLOC_ZONE((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
857 bzero((char *)mp, (u_long)sizeof(struct mount));
860 mp->mnt_maxreadcnt = mp->mnt_maxwritecnt = MAXPHYS;
861 mp->mnt_segreadcnt = mp->mnt_segwritecnt = 32;
862 mp->mnt_maxsegreadsize = mp->mnt_maxreadcnt;
863 mp->mnt_maxsegwritesize = mp->mnt_maxwritecnt;
864 mp->mnt_devblocksize = DEV_BSIZE;
865 mp->mnt_alignmentmask = PAGE_MASK;
866 mp->mnt_ioflags = 0;
867 mp->mnt_realrootvp = NULLVP;
868 mp->mnt_authcache_ttl = CACHED_LOOKUP_RIGHT_TTL;
870 mount_lock_init(mp);
871 (void)vfs_busy(mp, LK_NOWAIT);
873 TAILQ_INIT(&mp->mnt_vnodelist);
874 TAILQ_INIT(&mp->mnt_workerqueue);
875 TAILQ_INIT(&mp->mnt_newvnodes);
877 mp->mnt_vtable = vfsp;
878 mp->mnt_op = vfsp->vfc_vfsops;
879 mp->mnt_flag = MNT_RDONLY | MNT_ROOTFS;
880 mp->mnt_vnodecovered = NULLVP;
881 //mp->mnt_stat.f_type = vfsp->vfc_typenum;
882 mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
888 strncpy(mp->mnt_vfsstat.f_fstypename, vfsp->vfc_name, MFSTYPENAMELEN);
889 mp->mnt_vfsstat.f_mntonname[0] = '/';
891 (void) copystr((const void *)devname, mp->mnt_vfsstat.f_mntfromname, MAXPATHLEN - 1, NULL);
894 mac_mount_label_init(mp);
895 mac_mount_label_associate(vfs_context_kernel(), mp);
897 return (mp);
939 mount_t mp;
963 mp = vfs_rootmountalloc_internal(vfsp, "root_device");
964 mp->mnt_devvp = rootvp;
966 if ((error = (*vfsp->vfc_mountroot)(mp, rootvp, ctx)) == 0) {
976 mp->mnt_devvp = rootvp;
981 mp->mnt_devvp->v_specflags |= SI_MOUNTEDON;
983 vfs_unbusy(mp);
985 mount_list_add(mp);
993 vfs_init_io_attributes(rootvp, mp);
998 if (mp->mnt_vtable->vfc_vfsflags & VFC_VFSNATIVEXATTR) {
999 mp->mnt_kern_flag |= MNTK_EXTENDED_ATTRS;
1001 if (mp->mnt_vtable->vfc_vfsflags & VFC_VFSPREFLIGHT) {
1002 mp->mnt_kern_flag |= MNTK_UNMOUNT_PREFLIGHT;
1008 (void)VFS_START(mp, 0, ctx);
1012 if (vfs_getattr(mp, &vfsattr, ctx) == 0 &&
1016 mp->mnt_kern_flag |= MNTK_EXTENDED_ATTRS;
1021 mp->mnt_kern_flag |= MNTK_NAMED_STREAMS;
1026 mp->mnt_kern_flag |= MNTK_PATH_FROM_ID;
1039 if ((vfs_flags(mp) & MNT_MULTILABEL) == 0)
1042 error = VFS_ROOT(mp, &vp, ctx);
1046 dounmount(mp, MNT_FORCE, 0, ctx);
1051 error = vnode_label(mp, NULL, vp, NULL, 0, ctx);
1055 dounmount(mp, MNT_FORCE, 0, ctx);
1064 vfs_rootmountfailed(mp);
1093 mount_t mp;
1096 TAILQ_FOREACH(mp, &mountlist, mnt_list) {
1097 if (!strncmp(mp->mnt_vfsstat.f_mntonname, path,
1098 sizeof(mp->mnt_vfsstat.f_mntonname))) {
1099 retmp = mp;
1114 vfs_getnewfsid(struct mount *mp)
1124 mtype = mp->mnt_vtable->vfc_typenum;
1137 mp->mnt_vfsstat.f_fsid.val[0] = tfsid.val[0];
1138 mp->mnt_vfsstat.f_fsid.val[1] = tfsid.val[1];
1153 insmntque(vnode_t vp, mount_t mp)
1188 if ((vp->v_mount = mp) != NULL) {
1189 mount_lock(mp);
1192 if (mp->mnt_lflag & MNT_LITER)
1193 TAILQ_INSERT_HEAD(&mp->mnt_newvnodes, vp, v_mntvnodes);
1195 TAILQ_INSERT_HEAD(&mp->mnt_vnodelist, vp, v_mntvnodes);
1199 mount_ref(mp, 1);
1200 mount_unlock(mp);
1705 * Remove any vnodes in the vnode table belonging to mount point mp.
1720 vflush(struct mount *mp, struct vnode *skipvp, int flags)
1728 mount_lock(mp);
1729 vnode_iterate_setup(mp);
1737 if (((flags & FORCECLOSE)==0) && ((mp->mnt_kern_flag & MNTK_UNMOUNT_PREFLIGHT) != 0)) {
1738 if (vnode_umount_preflight(mp, skipvp, flags)) {
1739 vnode_iterate_clear(mp);
1740 mount_unlock(mp);
1746 retval = vnode_iterate_prepare(mp);
1749 vnode_iterate_clear(mp);
1750 mount_unlock(mp);
1755 while (!TAILQ_EMPTY(&mp->mnt_workerqueue)) {
1756 vp = TAILQ_FIRST(&mp->mnt_workerqueue);
1757 TAILQ_REMOVE(&mp->mnt_workerqueue, vp, v_mntvnodes);
1758 TAILQ_INSERT_TAIL(&mp->mnt_vnodelist, vp, v_mntvnodes);
1759 if ( (vp->v_mount != mp) || (vp == skipvp)) {
1763 mount_unlock(mp);
1768 mount_lock(mp);
1779 mount_lock(mp);
1787 mount_lock(mp);
1795 mount_lock(mp);
1805 mount_lock(mp);
1824 mount_lock(mp);
1849 mount_lock(mp);
1857 mount_lock(mp);
1865 (void)vnode_iterate_reloadq(mp);
1871 if ( vnode_iterate_reloadq(mp) != 0) {
1875 vnode_iterate_clear(mp);
1876 mount_unlock(mp);
2617 struct mount *mp;
2625 mp = TAILQ_LAST(&mountlist, mntlist);
2627 error = dounmount(mp, MNT_FORCE, 0, vfs_context_current());
2629 printf("unmount of %s failed (", mp->mnt_vfsstat.f_mntonname);
2632 TAILQ_REMOVE(&mountlist, mp, mnt_list);
2636 printf("unmount of %x failed (", (unsigned int)mp);
2671 vfs_init_io_attributes(vnode_t devvp, mount_t mp)
2700 mp->mnt_kern_flag |= MNTK_ROOTDEV;
2705 mp->mnt_kern_flag |= MNTK_ROOTDEV;
2720 mp->mnt_devblocksize = blksize;
2724 mp->mnt_kern_flag |= MNTK_VIRTUALDEV;
2776 mp->mnt_maxreadcnt = (u_int32_t)temp;
2787 mp->mnt_maxwritecnt = (u_int32_t)temp;
2791 mp->mnt_segreadcnt = (u_int16_t)temp;
2795 mp->mnt_segwritecnt = (u_int16_t)temp;
2800 temp = mp->mnt_maxreadcnt;
2801 mp->mnt_maxsegreadsize = (u_int32_t)temp;
2806 temp = mp->mnt_maxwritecnt;
2807 mp->mnt_maxsegwritesize = (u_int32_t)temp;
2813 mp->mnt_alignmentmask = temp;
2816 mp->mnt_ioflags |= MNT_IOFLAGS_FUA_SUPPORTED;
2868 struct mount *mp;
2873 TAILQ_FOREACH(mp, &mountlist, mnt_list) {
2875 fsidlst[actual] = mp->mnt_vfsstat.f_fsid;
2894 struct mount *mp;
2898 TAILQ_FOREACH(mp, &mountlist, mnt_list) {
2901 fsidlst[(*actual) - 1] = mp->mnt_vfsstat.f_fsid;
2964 struct mount *mp;
2984 mp = mount_list_lookupby_fsid(&user_vc.vc_fsid, 0, 1);
2994 mp = mount_list_lookupby_fsid(&vc.vc_fsid, 0, 1);
2996 if (mp == NULL) {
3008 if (mp->mnt_op->vfs_sysctl != NULL) {
3010 if (vfs_64bitready(mp)) {
3011 error = mp->mnt_op->vfs_sysctl(name, namelen,
3021 error = mp->mnt_op->vfs_sysctl(name, namelen,
3045 mount_ref(mp, 0);
3046 mount_iterdrop(mp);
3049 error = safedounmount(mp, flags, ctx);
3064 sp = &mp->mnt_vfsstat;
3066 (error = vfs_update_vfsstat(mp, ctx, VFS_USER_EVENT)))
3071 sfs.f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
3072 sfs.f_type = mp->mnt_vtable->vfc_typenum;
3092 sfs.f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
3093 sfs.f_type = mp->mnt_vtable->vfc_typenum;
3150 mount_iterdrop(mp);
4107 mount_t mp;
4124 mp = mount_list_lookupby_fsid(&fsid_list[i], 0, 1);
4126 if(mp == (struct mount *)0)
4128 mount_lock(mp);
4129 if (mp->mnt_lflag & (MNT_LDEAD | MNT_LUNMOUNT)) {
4130 mount_unlock(mp);
4131 mount_iterdrop(mp);
4135 mount_unlock(mp);
4138 ret = callout(mp, arg);
4140 mount_iterdrop(mp);
4173 vfs_update_vfsstat(mount_t mp, vfs_context_t ctx, __unused int eventtype)
4194 error = mac_mount_check_getattr(ctx, mp, &va);
4200 if ((error = vfs_getattr(mp, &va, ctx)) != 0) {
4225 mp->mnt_vfsstat.f_bsize = (va.f_bsize > 0 ? va.f_bsize : 512);
4227 mp->mnt_vfsstat.f_bsize = mp->mnt_devblocksize; /* default from the device block size */
4230 mp->mnt_vfsstat.f_iosize = va.f_iosize;
4232 mp->mnt_vfsstat.f_iosize = 1024 * 1024; /* 1MB sensible I/O size */
4235 mp->mnt_vfsstat.f_blocks = va.f_blocks;
4237 mp->mnt_vfsstat.f_bfree = va.f_bfree;
4239 mp->mnt_vfsstat.f_bavail = va.f_bavail;
4241 mp->mnt_vfsstat.f_bused = va.f_bused;
4243 mp->mnt_vfsstat.f_files = va.f_files;
4245 mp->mnt_vfsstat.f_ffree = va.f_ffree;
4249 mp->mnt_vfsstat.f_fssubtype = va.f_fssubtype;
4255 mount_list_add(mount_t mp)
4258 TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
4264 mount_list_remove(mount_t mp)
4267 TAILQ_REMOVE(&mountlist, mp, mnt_list);
4269 mp->mnt_list.tqe_next = NULL;
4270 mp->mnt_list.tqe_prev = NULL;
4279 mount_t mp;
4282 TAILQ_FOREACH(mp, &mountlist, mnt_list) {
4283 if (!(mp->mnt_kern_flag & MNTK_UNMOUNT) &&
4284 (mp->mnt_kern_flag & MNTK_PATH_FROM_ID) &&
4285 (mp->mnt_vfsstat.f_fsid.val[0] == volfs_id)) {
4286 cur_mount = mp;
4299 mp = cur_mount;
4300 if (vfs_busy(mp, LK_NOWAIT) != 0) {
4303 mount_iterdrop(mp);
4315 mount_t mp;
4319 TAILQ_FOREACH(mp, &mountlist, mnt_list)
4320 if (mp->mnt_vfsstat.f_fsid.val[0] == fsid->val[0] &&
4321 mp->mnt_vfsstat.f_fsid.val[1] == fsid->val[1]) {
4322 retmp = mp;
5280 mount_t mp;
5308 mp = vp->v_mount;
5309 if (mp != NULL) {
5313 (vfs_flags(mp) & MNT_NOUSERXATTR)) {
6438 vfs_setlocklocal(mount_t mp)
6442 mount_lock(mp);
6443 mp->mnt_kern_flag |= MNTK_LOCK_LOCAL;
6449 TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
6452 TAILQ_FOREACH(vp, &mp->mnt_workerqueue, v_mntvnodes) {
6455 TAILQ_FOREACH(vp, &mp->mnt_newvnodes, v_mntvnodes) {
6458 mount_unlock(mp);