git: b5c4616582ce - main - Fix MNT_IGNORE for devfs, fdescfs and nullfs

From: Doug Rabson <dfr_at_FreeBSD.org>
Date: Sat, 26 Aug 2023 14:31:00 UTC
The branch main has been updated by dfr:

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

commit b5c4616582cebdcf4dee909a3c2f5b113c4ae59e
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2023-08-26 09:32:32 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-08-26 11:08:37 +0000

    Fix MNT_IGNORE for devfs, fdescfs and nullfs
    
    The MNT_IGNORE flag can be used to mark certain filesystem mounts so
    that utilities such as df(1) and mount(8) can filter out those mounts by
    default. This can be used, for instance, to reduce the noise from
    running container workloads inside jails which often have at least three
    and sometimes as many as ten mounts per container.
    
    The flag is supplied by the nmount(2) system call and is recorded so
    that it can be reported by statfs(2). Unfortunately several filesystems
    override the default behaviour and mask out the flag, defeating its
    purpose. This change preserves the MNT_IGNORE flag for those filesystems
    so that it can be reported correctly.
    
    MFC after:      1 week
---
 sys/fs/devfs/devfs_vfsops.c   | 2 +-
 sys/fs/fdescfs/fdesc_vfsops.c | 2 +-
 sys/fs/nullfs/null_vfsops.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c
index a81a63ebf27a..dbc29fbe4d78 100644
--- a/sys/fs/devfs/devfs_vfsops.c
+++ b/sys/fs/devfs/devfs_vfsops.c
@@ -224,7 +224,7 @@ static int
 devfs_statfs(struct mount *mp, struct statfs *sbp)
 {
 
-	sbp->f_flags = 0;
+	sbp->f_flags = mp->mnt_flag & MNT_IGNORE;
 	sbp->f_bsize = DEV_BSIZE;
 	sbp->f_iosize = DEV_BSIZE;
 	sbp->f_blocks = 2;		/* 1K to keep df happy */
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
index 309134798374..30924580dece 100644
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ b/sys/fs/fdescfs/fdesc_vfsops.c
@@ -219,7 +219,7 @@ fdesc_statfs(struct mount *mp, struct statfs *sbp)
 		freefd += (lim - fdp->fd_nfiles);
 	FILEDESC_SUNLOCK(fdp);
 
-	sbp->f_flags = 0;
+	sbp->f_flags = mp->mnt_flag & MNT_IGNORE;
 	sbp->f_bsize = DEV_BSIZE;
 	sbp->f_iosize = DEV_BSIZE;
 	sbp->f_blocks = 2;		/* 1K to keep df happy */
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
index 6acff89189f5..4b2954d5bea1 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -360,7 +360,7 @@ nullfs_statfs(struct mount *mp, struct statfs *sbp)
 	/* now copy across the "interesting" information and fake the rest */
 	sbp->f_type = mstat->f_type;
 	sbp->f_flags = (sbp->f_flags & (MNT_RDONLY | MNT_NOEXEC | MNT_NOSUID |
-	    MNT_UNION | MNT_NOSYMFOLLOW | MNT_AUTOMOUNTED)) |
+	    MNT_UNION | MNT_NOSYMFOLLOW | MNT_AUTOMOUNTED | MNT_IGNORE)) |
 	    (mstat->f_flags & ~(MNT_ROOTFS | MNT_AUTOMOUNTED));
 	sbp->f_bsize = mstat->f_bsize;
 	sbp->f_iosize = mstat->f_iosize;