mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-29 13:15:05 +00:00
Background fsck sysctl operations must use vn_start_write and
vn_finished_write so that they do not attempt to modify a suspended filesystem.
This commit is contained in:
parent
b114e127e6
commit
f0f3f19f05
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75572
|
@ -1893,11 +1893,15 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||||
return (ERPCMISMATCH);
|
return (ERPCMISMATCH);
|
||||||
if ((error = getvnode(curproc->p_fd, cmd.handle, &fp)) != 0)
|
if ((error = getvnode(curproc->p_fd, cmd.handle, &fp)) != 0)
|
||||||
return (error);
|
return (error);
|
||||||
mp = ((struct vnode *)fp->f_data)->v_mount;
|
vn_start_write((struct vnode *)fp->f_data, &mp, V_WAIT);
|
||||||
if (strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN))
|
if (mp == 0 || strncmp(mp->mnt_stat.f_fstypename, "ufs", MFSNAMELEN)) {
|
||||||
|
vn_finished_write(mp);
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
if (mp->mnt_flag & MNT_RDONLY)
|
}
|
||||||
|
if (mp->mnt_flag & MNT_RDONLY) {
|
||||||
|
vn_finished_write(mp);
|
||||||
return (EROFS);
|
return (EROFS);
|
||||||
|
}
|
||||||
ump = VFSTOUFS(mp);
|
ump = VFSTOUFS(mp);
|
||||||
fs = ump->um_fs;
|
fs = ump->um_fs;
|
||||||
filetype = IFREG;
|
filetype = IFREG;
|
||||||
|
@ -1925,7 +1929,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||||
}
|
}
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
if ((error = VFS_VGET(mp, (ino_t)cmd.value, &vp)) != 0)
|
if ((error = VFS_VGET(mp, (ino_t)cmd.value, &vp)) != 0)
|
||||||
return (error);
|
break;
|
||||||
ip = VTOI(vp);
|
ip = VTOI(vp);
|
||||||
ip->i_nlink += cmd.size;
|
ip->i_nlink += cmd.size;
|
||||||
ip->i_effnlink += cmd.size;
|
ip->i_effnlink += cmd.size;
|
||||||
|
@ -1944,7 +1948,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||||
}
|
}
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
if ((error = VFS_VGET(mp, (ino_t)cmd.value, &vp)) != 0)
|
if ((error = VFS_VGET(mp, (ino_t)cmd.value, &vp)) != 0)
|
||||||
return (error);
|
break;
|
||||||
ip = VTOI(vp);
|
ip = VTOI(vp);
|
||||||
ip->i_blocks += cmd.size;
|
ip->i_blocks += cmd.size;
|
||||||
ip->i_flag |= IN_CHANGE;
|
ip->i_flag |= IN_CHANGE;
|
||||||
|
@ -1976,7 +1980,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||||
tip.i_fs = fs;
|
tip.i_fs = fs;
|
||||||
while (cmd.size > 0) {
|
while (cmd.size > 0) {
|
||||||
if ((error = ffs_freefile(&tip, cmd.value, filetype)))
|
if ((error = ffs_freefile(&tip, cmd.value, filetype)))
|
||||||
return (error);
|
break;
|
||||||
cmd.size -= 1;
|
cmd.size -= 1;
|
||||||
cmd.value += 1;
|
cmd.value += 1;
|
||||||
}
|
}
|
||||||
|
@ -2023,8 +2027,10 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||||
oidp->oid_number);
|
oidp->oid_number);
|
||||||
}
|
}
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
return(EINVAL);
|
error = EINVAL;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return (0);
|
vn_finished_write(mp);
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue