aboutsummaryrefslogtreecommitdiff
path: root/sys/ufs/ufs/ufs_quota.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/ufs/ufs/ufs_quota.c')
-rw-r--r--sys/ufs/ufs/ufs_quota.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c
index 4dff74f75945..143e0afbf1e3 100644
--- a/sys/ufs/ufs/ufs_quota.c
+++ b/sys/ufs/ufs/ufs_quota.c
@@ -492,7 +492,8 @@ chkdquot(struct inode *ip)
* Q_QUOTAON - set up a quota file for a particular filesystem.
*/
int
-quotaon(struct thread *td, struct mount *mp, int type, void *fname)
+quotaon(struct thread *td, struct mount *mp, int type, void *fname,
+ bool *mp_busy)
{
struct ufsmount *ump;
struct vnode *vp, **vpp;
@@ -502,15 +503,11 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
struct nameidata nd;
error = priv_check(td, PRIV_UFS_QUOTAON);
- if (error != 0) {
- vfs_unbusy(mp);
+ if (error != 0)
return (error);
- }
- if ((mp->mnt_flag & MNT_RDONLY) != 0) {
- vfs_unbusy(mp);
+ if ((mp->mnt_flag & MNT_RDONLY) != 0)
return (EROFS);
- }
ump = VFSTOUFS(mp);
dq = NODQUOT;
@@ -518,7 +515,9 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, td);
flags = FREAD | FWRITE;
vfs_ref(mp);
+ KASSERT(*mp_busy, ("%s called without busied mount", __func__));
vfs_unbusy(mp);
+ *mp_busy = false;
error = vn_open(&nd, &flags, 0, NULL);
if (error != 0) {
vfs_rel(mp);
@@ -529,10 +528,9 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
error = vfs_busy(mp, MBF_NOWAIT);
vfs_rel(mp);
if (error == 0) {
- if (vp->v_type != VREG) {
+ *mp_busy = true;
+ if (vp->v_type != VREG)
error = EACCES;
- vfs_unbusy(mp);
- }
}
if (error != 0) {
VOP_UNLOCK(vp);
@@ -545,7 +543,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
UFS_UNLOCK(ump);
VOP_UNLOCK(vp);
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
- vfs_unbusy(mp);
return (EALREADY);
}
ump->um_qflags[type] |= QTF_OPENING|QTF_CLOSING;
@@ -556,7 +553,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
ump->um_qflags[type] &= ~(QTF_OPENING|QTF_CLOSING);
UFS_UNLOCK(ump);
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
- vfs_unbusy(mp);
return (error);
}
VOP_UNLOCK(vp);
@@ -640,7 +636,6 @@ again:
("quotaon: leaking flags"));
UFS_UNLOCK(ump);
- vfs_unbusy(mp);
return (error);
}