git: 9a00da73a3dc - stable/13 - ffs: retire unused fsckpid mount option

From: Robert Wing <rew_at_FreeBSD.org>
Date: Sat, 23 Oct 2021 01:54:12 UTC
The branch stable/13 has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=9a00da73a3dc15b5316e6eea805da8d2eeac4310

commit 9a00da73a3dc15b5316e6eea805da8d2eeac4310
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2021-10-02 23:11:40 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2021-10-23 01:37:17 +0000

    ffs: retire unused fsckpid mount option
    
    The fsckpid mount option was introduced in 927a12ae16433b50 along with a
    couple sysctl's to support SU+J with snapshots. However, those sysctl's
    were never used and eventually removed in f2620e9ceb3ede02.
    
    There are no in-tree consumers of this mount option.
    
    Reviewed by:    mckusick, kib
    Differential Revision:  https://reviews.freebsd.org/D32015
    
    (cherry picked from commit 9acea16404117f2f54475640ff036c12130707d8)
---
 sys/ufs/ffs/ffs_alloc.c  |   3 +-
 sys/ufs/ffs/ffs_inode.c  |   2 +-
 sys/ufs/ffs/ffs_vfsops.c | 117 ++---------------------------------------------
 sys/ufs/ufs/ufsmount.h   |   2 -
 4 files changed, 6 insertions(+), 118 deletions(-)

diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 771377b7cefc..6a262a798d1b 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -3236,8 +3236,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
 		return (EINVAL);
 	}
 	ump = VFSTOUFS(mp);
-	if ((mp->mnt_flag & MNT_RDONLY) &&
-	    ump->um_fsckpid != td->td_proc->p_pid) {
+	if (mp->mnt_flag & MNT_RDONLY) {
 		vn_finished_write(mp);
 		fdrop(fp, td);
 		return (EROFS);
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 6bb7521cef4c..b78f46ae4ba0 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -132,7 +132,7 @@ ffs_update(vp, waitfor)
 	if (waitfor)
 		ip->i_flag &= ~(IN_SIZEMOD | IN_IBLKDATA);
 	fs = ITOFS(ip);
-	if (fs->fs_ronly && ITOUMP(ip)->um_fsckpid == 0)
+	if (fs->fs_ronly)
 		return (0);
 	/*
 	 * If we are updating a snapshot and another process is currently
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index d5f20690793d..fb00218f5d3a 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -147,7 +147,7 @@ static struct buf_ops ffs_ops = {
  */
 static const char *ffs_opts[] = { "acls", "async", "noatime", "noclusterr",
     "noclusterw", "noexec", "export", "force", "from", "groupquota",
-    "multilabel", "nfsv4acls", "fsckpid", "snapshot", "nosuid", "suiddir",
+    "multilabel", "nfsv4acls", "snapshot", "nosuid", "suiddir",
     "nosymfollow", "sync", "union", "userquota", "untrusted", NULL };
 
 static int ffs_enxio_enable = 1;
@@ -374,7 +374,6 @@ ffs_mount(struct mount *mp)
 	struct thread *td;
 	struct ufsmount *ump = NULL;
 	struct fs *fs;
-	pid_t fsckpid = 0;
 	int error, error1, flags;
 	uint64_t mntorflags, saved_mnt_flag;
 	accmode_t accmode;
@@ -422,31 +421,6 @@ ffs_mount(struct mount *mp)
 		vfs_deleteopt(mp->mnt_opt, "snapshot");
 	}
 
-	if (vfs_getopt(mp->mnt_optnew, "fsckpid", NULL, NULL) == 0 &&
-	    vfs_scanopt(mp->mnt_optnew, "fsckpid", "%d", &fsckpid) == 1) {
-		/*
-		 * Once we have set the restricted PID, do not
-		 * persist "fsckpid" in the options list.
-		 */
-		vfs_deleteopt(mp->mnt_optnew, "fsckpid");
-		vfs_deleteopt(mp->mnt_opt, "fsckpid");
-		if (mp->mnt_flag & MNT_UPDATE) {
-			if (VFSTOUFS(mp)->um_fs->fs_ronly == 0 &&
-			     vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) == 0) {
-				vfs_mount_error(mp,
-				    "Checker enable: Must be read-only");
-				return (EINVAL);
-			}
-		} else if (vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) == 0) {
-			vfs_mount_error(mp,
-			    "Checker enable: Must be read-only");
-			return (EINVAL);
-		}
-		/* Set to -1 if we are done */
-		if (fsckpid == 0)
-			fsckpid = -1;
-	}
-
 	if (vfs_getopt(mp->mnt_optnew, "nfsv4acls", NULL, NULL) == 0) {
 		if (mntorflags & MNT_ACLS) {
 			vfs_mount_error(mp,
@@ -470,18 +444,6 @@ ffs_mount(struct mount *mp)
 		fs = ump->um_fs;
 		odevvp = ump->um_odevvp;
 		devvp = ump->um_devvp;
-		if (fsckpid == -1 && ump->um_fsckpid > 0) {
-			if ((error = ffs_flushfiles(mp, WRITECLOSE, td)) != 0 ||
-			    (error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0)
-				return (error);
-			g_topology_lock();
-			/*
-			 * Return to normal read-only mode.
-			 */
-			error = g_access(ump->um_cp, 0, -1, 0);
-			g_topology_unlock();
-			ump->um_fsckpid = 0;
-		}
 		if (fs->fs_ronly == 0 &&
 		    vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) {
 			/*
@@ -569,14 +531,6 @@ ffs_mount(struct mount *mp)
 			return (error);
 		if (fs->fs_ronly &&
 		    !vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) {
-			/*
-			 * If we are running a checker, do not allow upgrade.
-			 */
-			if (ump->um_fsckpid > 0) {
-				vfs_mount_error(mp,
-				    "Active checker, cannot upgrade to write");
-				return (EINVAL);
-			}
 			/*
 			 * If upgrade to read-write by non-root, then verify
 			 * that user has necessary permissions on the device.
@@ -686,39 +640,6 @@ ffs_mount(struct mount *mp)
 			mp->mnt_flag |= MNT_NFS4ACLS;
 			MNT_IUNLOCK(mp);
 		}
-		/*
-		 * If this is a request from fsck to clean up the filesystem,
-		 * then allow the specified pid to proceed.
-		 */
-		if (fsckpid > 0) {
-			if (ump->um_fsckpid != 0) {
-				vfs_mount_error(mp,
-				    "Active checker already running on %s",
-				    fs->fs_fsmnt);
-				return (EINVAL);
-			}
-			KASSERT(MOUNTEDSOFTDEP(mp) == 0,
-			    ("soft updates enabled on read-only file system"));
-			g_topology_lock();
-			/*
-			 * Request write access.
-			 */
-			error = g_access(ump->um_cp, 0, 1, 0);
-			g_topology_unlock();
-			if (error) {
-				vfs_mount_error(mp,
-				    "Checker activation failed on %s",
-				    fs->fs_fsmnt);
-				return (error);
-			}
-			ump->um_fsckpid = fsckpid;
-			if (fs->fs_snapinum[0] != 0)
-				ffs_snapshot_mount(mp);
-			fs->fs_mtime = time_second;
-			fs->fs_fmod = 1;
-			fs->fs_clean = 0;
-			(void) ffs_sbupdate(ump, MNT_WAIT, 0);
-		}
 
 		/*
 		 * If this is a snapshot request, take the snapshot.
@@ -798,29 +719,6 @@ ffs_mount(struct mount *mp)
 			vrele(devvp);
 			return (error);
 		}
-		if (fsckpid > 0) {
-			KASSERT(MOUNTEDSOFTDEP(mp) == 0,
-			    ("soft updates enabled on read-only file system"));
-			ump = VFSTOUFS(mp);
-			fs = ump->um_fs;
-			g_topology_lock();
-			/*
-			 * Request write access.
-			 */
-			error = g_access(ump->um_cp, 0, 1, 0);
-			g_topology_unlock();
-			if (error) {
-				printf("WARNING: %s: Checker activation "
-				    "failed\n", fs->fs_fsmnt);
-			} else { 
-				ump->um_fsckpid = fsckpid;
-				if (fs->fs_snapinum[0] != 0)
-					ffs_snapshot_mount(mp);
-				fs->fs_mtime = time_second;
-				fs->fs_clean = 0;
-				(void) ffs_sbupdate(ump, MNT_WAIT, 0);
-			}
-		}
 	}
 
 	MNT_ILOCK(mp);
@@ -1541,7 +1439,7 @@ ffs_unmount(mp, mntflags)
 	if (MOUNTEDSOFTDEP(mp))
 		softdep_unmount(mp);
 	MPASS(ump->um_softdep == NULL);
-	if (fs->fs_ronly == 0 || ump->um_fsckpid > 0) {
+	if (fs->fs_ronly == 0) {
 		fs->fs_clean = fs->fs_flags & (FS_UNCLEAN|FS_NEEDSFSCK) ? 0 : 1;
 		error = ffs_sbupdate(ump, MNT_WAIT, 0);
 		if (ffs_fsfail_cleanup(ump, error))
@@ -1561,13 +1459,6 @@ ffs_unmount(mp, mntflags)
 		free (ump->um_trimhash, M_TRIM);
 	}
 	g_topology_lock();
-	if (ump->um_fsckpid > 0) {
-		/*
-		 * Return to normal read-only mode.
-		 */
-		error = g_access(ump->um_cp, 0, -1, 0);
-		ump->um_fsckpid = 0;
-	}
 	g_vfs_close(ump->um_cp);
 	g_topology_unlock();
 	BO_LOCK(&ump->um_odevvp->v_bufobj);
@@ -1833,7 +1724,7 @@ ffs_sync(mp, waitfor)
 	suspended = 0;
 	td = curthread;
 	fs = ump->um_fs;
-	if (fs->fs_fmod != 0 && fs->fs_ronly != 0 && ump->um_fsckpid == 0)
+	if (fs->fs_fmod != 0 && fs->fs_ronly != 0)
 		panic("%s: ffs_sync: modification on read-only filesystem",
 		    fs->fs_fsmnt);
 	if (waitfor == MNT_LAZY) {
@@ -2304,7 +2195,7 @@ ffs_sbupdate(ump, waitfor, suspended)
 	fs = ump->um_fs;
 	if (fs->fs_ronly == 1 &&
 	    (ump->um_mountp->mnt_flag & (MNT_RDONLY | MNT_UPDATE)) !=
-	    (MNT_RDONLY | MNT_UPDATE) && ump->um_fsckpid == 0)
+	    (MNT_RDONLY | MNT_UPDATE))
 		panic("ffs_sbupdate: write read-only filesystem");
 	/*
 	 * We use the superblock's buf to serialize calls to ffs_sbupdate().
diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h
index 0b90cae95ff5..2e7865070025 100644
--- a/sys/ufs/ufs/ufsmount.h
+++ b/sys/ufs/ufs/ufsmount.h
@@ -85,7 +85,6 @@ struct fsfail_task {
  *	i - ufsmount interlock (UFS_LOCK / UFS_UNLOCK)
  *	q - associated quota file is locked
  *	r - ref to parent mount structure is held (vfs_busy / vfs_unbusy)
- *	u - managed by user process fsck_ufs
  */
 struct ufsmount {
 	struct	mount *um_mountp;		/* (r) filesystem vfs struct */
@@ -105,7 +104,6 @@ struct ufsmount {
 	struct	mtx um_lock;			/* (c) Protects ufsmount & fs */
 	struct	sx um_checkpath_lock;		/* (c) Protects ufs_checkpath()
 						       result */
-	pid_t	um_fsckpid;			/* (u) PID can do fsck sysctl */
 	struct	mount_softdeps *um_softdep;	/* (c) softdep mgmt structure */
 	struct	vnode *um_quotas[MAXQUOTAS];	/* (q) pointer to quota files */
 	struct	ucred *um_cred[MAXQUOTAS];	/* (q) quota file access cred */