Changeset View
Changeset View
Standalone View
Standalone View
head/sys/ufs/ffs/ffs_vfsops.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include <vm/vm_page.h> | #include <vm/vm_page.h> | ||||
#include <geom/geom.h> | #include <geom/geom.h> | ||||
#include <geom/geom_vfs.h> | #include <geom/geom_vfs.h> | ||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
static uma_zone_t uma_inode, uma_ufs1, uma_ufs2; | static uma_zone_t uma_inode, uma_ufs1, uma_ufs2; | ||||
VFS_SMR_DECLARE; | |||||
static int ffs_mountfs(struct vnode *, struct mount *, struct thread *); | static int ffs_mountfs(struct vnode *, struct mount *, struct thread *); | ||||
static void ffs_oldfscompat_read(struct fs *, struct ufsmount *, | static void ffs_oldfscompat_read(struct fs *, struct ufsmount *, | ||||
ufs2_daddr_t); | ufs2_daddr_t); | ||||
static void ffs_ifree(struct ufsmount *ump, struct inode *ip); | static void ffs_ifree(struct ufsmount *ump, struct inode *ip); | ||||
static int ffs_sync_lazy(struct mount *mp); | static int ffs_sync_lazy(struct mount *mp); | ||||
static int ffs_use_bread(void *devfd, off_t loc, void **bufp, int size); | static int ffs_use_bread(void *devfd, off_t loc, void **bufp, int size); | ||||
static int ffs_use_bwrite(void *devfd, off_t loc, void *buf, int size); | static int ffs_use_bwrite(void *devfd, off_t loc, void *buf, int size); | ||||
▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | uma_inode = uma_zcreate("FFS inode", | ||||
sizeof(struct inode), NULL, NULL, NULL, NULL, | sizeof(struct inode), NULL, NULL, NULL, NULL, | ||||
UMA_ALIGN_PTR, 0); | UMA_ALIGN_PTR, 0); | ||||
uma_ufs1 = uma_zcreate("FFS1 dinode", | uma_ufs1 = uma_zcreate("FFS1 dinode", | ||||
sizeof(struct ufs1_dinode), NULL, NULL, NULL, NULL, | sizeof(struct ufs1_dinode), NULL, NULL, NULL, NULL, | ||||
UMA_ALIGN_PTR, 0); | UMA_ALIGN_PTR, 0); | ||||
uma_ufs2 = uma_zcreate("FFS2 dinode", | uma_ufs2 = uma_zcreate("FFS2 dinode", | ||||
sizeof(struct ufs2_dinode), NULL, NULL, NULL, NULL, | sizeof(struct ufs2_dinode), NULL, NULL, NULL, NULL, | ||||
UMA_ALIGN_PTR, 0); | UMA_ALIGN_PTR, 0); | ||||
VFS_SMR_ZONE_SET(uma_inode); | |||||
} | } | ||||
vfs_deleteopt(mp->mnt_optnew, "groupquota"); | vfs_deleteopt(mp->mnt_optnew, "groupquota"); | ||||
vfs_deleteopt(mp->mnt_optnew, "userquota"); | vfs_deleteopt(mp->mnt_optnew, "userquota"); | ||||
fspec = vfs_getopts(mp->mnt_optnew, "from", &error); | fspec = vfs_getopts(mp->mnt_optnew, "from", &error); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | if (mntorflags & MNT_ACLS) { | ||||
"\"acls\" and \"nfsv4acls\" options " | "\"acls\" and \"nfsv4acls\" options " | ||||
"are mutually exclusive"); | "are mutually exclusive"); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
mntorflags |= MNT_NFS4ACLS; | mntorflags |= MNT_NFS4ACLS; | ||||
} | } | ||||
MNT_ILOCK(mp); | MNT_ILOCK(mp); | ||||
mp->mnt_kern_flag &= ~MNTK_FPLOOKUP; | |||||
mp->mnt_flag |= mntorflags; | mp->mnt_flag |= mntorflags; | ||||
MNT_IUNLOCK(mp); | MNT_IUNLOCK(mp); | ||||
/* | /* | ||||
* If updating, check whether changing from read-only to | * If updating, check whether changing from read-only to | ||||
* read/write; if there is no device name, that's all we do. | * read/write; if there is no device name, that's all we do. | ||||
*/ | */ | ||||
if (mp->mnt_flag & MNT_UPDATE) { | if (mp->mnt_flag & MNT_UPDATE) { | ||||
ump = VFSTOUFS(mp); | ump = VFSTOUFS(mp); | ||||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | if (fsckpid > 0) { | ||||
if (fs->fs_snapinum[0] != 0) | if (fs->fs_snapinum[0] != 0) | ||||
ffs_snapshot_mount(mp); | ffs_snapshot_mount(mp); | ||||
fs->fs_mtime = time_second; | fs->fs_mtime = time_second; | ||||
fs->fs_clean = 0; | fs->fs_clean = 0; | ||||
(void) ffs_sbupdate(ump, MNT_WAIT, 0); | (void) ffs_sbupdate(ump, MNT_WAIT, 0); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
MNT_ILOCK(mp); | |||||
/* | |||||
* This is racy versus lookup, see ufs_fplookup_vexec for details. | |||||
*/ | |||||
if ((mp->mnt_kern_flag & MNTK_FPLOOKUP) != 0) | |||||
panic("MNTK_FPLOOKUP set on mount %p when it should not be", mp); | |||||
if ((mp->mnt_flag & (MNT_ACLS | MNT_NFS4ACLS)) == 0) | |||||
mp->mnt_kern_flag |= MNTK_FPLOOKUP; | |||||
MNT_IUNLOCK(mp); | |||||
vfs_mountedfrom(mp, fspec); | vfs_mountedfrom(mp, fspec); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Compatibility with old mount system call. | * Compatibility with old mount system call. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,157 Lines • ▼ Show 20 Lines | ffs_vgetf(mp, ino, flags, vpp, ffs_flags) | ||||
* We do not lock vnode creation as it is believed to be too | * We do not lock vnode creation as it is believed to be too | ||||
* expensive for such rare case as simultaneous creation of vnode | * expensive for such rare case as simultaneous creation of vnode | ||||
* for same ino by different processes. We just allow them to race | * for same ino by different processes. We just allow them to race | ||||
* and check later to decide who wins. Let the race begin! | * and check later to decide who wins. Let the race begin! | ||||
*/ | */ | ||||
ump = VFSTOUFS(mp); | ump = VFSTOUFS(mp); | ||||
fs = ump->um_fs; | fs = ump->um_fs; | ||||
ip = uma_zalloc(uma_inode, M_WAITOK | M_ZERO); | ip = uma_zalloc_smr(uma_inode, M_WAITOK | M_ZERO); | ||||
/* Allocate a new vnode/inode. */ | /* Allocate a new vnode/inode. */ | ||||
error = getnewvnode("ufs", mp, fs->fs_magic == FS_UFS1_MAGIC ? | error = getnewvnode("ufs", mp, fs->fs_magic == FS_UFS1_MAGIC ? | ||||
&ffs_vnodeops1 : &ffs_vnodeops2, &vp); | &ffs_vnodeops1 : &ffs_vnodeops2, &vp); | ||||
if (error) { | if (error) { | ||||
*vpp = NULL; | *vpp = NULL; | ||||
uma_zfree(uma_inode, ip); | uma_zfree_smr(uma_inode, ip); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* FFS supports recursive locking. | * FFS supports recursive locking. | ||||
*/ | */ | ||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); | lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL); | ||||
VN_LOCK_AREC(vp); | VN_LOCK_AREC(vp); | ||||
vp->v_data = ip; | vp->v_data = ip; | ||||
Show All 12 Lines | for (i = 0; i < MAXQUOTAS; i++) | ||||
ip->i_dquot[i] = NODQUOT; | ip->i_dquot[i] = NODQUOT; | ||||
} | } | ||||
#endif | #endif | ||||
if (ffs_flags & FFSV_FORCEINSMQ) | if (ffs_flags & FFSV_FORCEINSMQ) | ||||
vp->v_vflag |= VV_FORCEINSMQ; | vp->v_vflag |= VV_FORCEINSMQ; | ||||
error = insmntque(vp, mp); | error = insmntque(vp, mp); | ||||
if (error != 0) { | if (error != 0) { | ||||
uma_zfree(uma_inode, ip); | uma_zfree_smr(uma_inode, ip); | ||||
*vpp = NULL; | *vpp = NULL; | ||||
return (error); | return (error); | ||||
} | } | ||||
vp->v_vflag &= ~VV_FORCEINSMQ; | vp->v_vflag &= ~VV_FORCEINSMQ; | ||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp, NULL, NULL); | error = vfs_hash_insert(vp, ino, flags, curthread, vpp, NULL, NULL); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
if (*vpp != NULL) { | if (*vpp != NULL) { | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
ffs_ifree(struct ufsmount *ump, struct inode *ip) | ffs_ifree(struct ufsmount *ump, struct inode *ip) | ||||
{ | { | ||||
if (ump->um_fstype == UFS1 && ip->i_din1 != NULL) | if (ump->um_fstype == UFS1 && ip->i_din1 != NULL) | ||||
uma_zfree(uma_ufs1, ip->i_din1); | uma_zfree(uma_ufs1, ip->i_din1); | ||||
else if (ip->i_din2 != NULL) | else if (ip->i_din2 != NULL) | ||||
uma_zfree(uma_ufs2, ip->i_din2); | uma_zfree(uma_ufs2, ip->i_din2); | ||||
uma_zfree(uma_inode, ip); | uma_zfree_smr(uma_inode, ip); | ||||
} | } | ||||
static int dobkgrdwrite = 1; | static int dobkgrdwrite = 1; | ||||
SYSCTL_INT(_debug, OID_AUTO, dobkgrdwrite, CTLFLAG_RW, &dobkgrdwrite, 0, | SYSCTL_INT(_debug, OID_AUTO, dobkgrdwrite, CTLFLAG_RW, &dobkgrdwrite, 0, | ||||
"Do background writes (honoring the BV_BKGRDWRITE flag)?"); | "Do background writes (honoring the BV_BKGRDWRITE flag)?"); | ||||
/* | /* | ||||
* Complete a background write started from bwrite. | * Complete a background write started from bwrite. | ||||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |