diff options
author | mckusick <mckusick@FreeBSD.org> | 2001-04-17 05:06:37 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2001-04-17 05:06:37 +0000 |
commit | 6ea67910b6c31062d12f1309cbdd9e4c86881ff7 (patch) | |
tree | df3791eefa49a26c70486ec0bbadbcc4cb530cf1 /sys/ufs/ffs/ffs_alloc.c | |
parent | 678b28a5326b5f9f0c89994243ff154e40df7804 (diff) | |
download | FreeBSD-src-6ea67910b6c31062d12f1309cbdd9e4c86881ff7.zip FreeBSD-src-6ea67910b6c31062d12f1309cbdd9e4c86881ff7.tar.gz |
Background fsck sysctl operations must use vn_start_write and
vn_finished_write so that they do not attempt to modify a
suspended filesystem.
Diffstat (limited to 'sys/ufs/ffs/ffs_alloc.c')
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 81fb75e..f569dc1 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1893,11 +1893,15 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) return (ERPCMISMATCH); if ((error = getvnode(curproc->p_fd, cmd.handle, &fp)) != 0) return (error); - mp = ((struct vnode *)fp->f_data)->v_mount; - if (strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN)) + vn_start_write((struct vnode *)fp->f_data, &mp, V_WAIT); + if (mp == 0 || strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN)) { + vn_finished_write(mp); return (EINVAL); - if (mp->mnt_flag & MNT_RDONLY) + } + if (mp->mnt_flag & MNT_RDONLY) { + vn_finished_write(mp); return (EROFS); + } ump = VFSTOUFS(mp); fs = ump->um_fs; filetype = IFREG; @@ -1925,7 +1929,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) } #endif /* DEBUG */ if ((error = VFS_VGET(mp, (ino_t)cmd.value, &vp)) != 0) - return (error); + break; ip = VTOI(vp); ip->i_nlink += cmd.size; ip->i_effnlink += cmd.size; @@ -1944,7 +1948,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) } #endif /* DEBUG */ if ((error = VFS_VGET(mp, (ino_t)cmd.value, &vp)) != 0) - return (error); + break; ip = VTOI(vp); ip->i_blocks += cmd.size; ip->i_flag |= IN_CHANGE; @@ -1976,7 +1980,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) tip.i_fs = fs; while (cmd.size > 0) { if ((error = ffs_freefile(&tip, cmd.value, filetype))) - return (error); + break; cmd.size -= 1; cmd.value += 1; } @@ -2023,8 +2027,10 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) oidp->oid_number); } #endif /* DEBUG */ - return(EINVAL); + error = EINVAL; + break; } - return (0); + vn_finished_write(mp); + return (error); } |