Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 May 2021 12:16:59 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f784da883fd5 - main - Move mnt_maxsymlinklen into appropriate fs mount data structures
Message-ID:  <202105221216.14MCGxZp011829@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

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

commit f784da883fd5a744fcaf4ccfc550ca497ea5d7a6
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-05-18 01:42:03 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-05-22 12:16:09 +0000

    Move mnt_maxsymlinklen into appropriate fs mount data structures
    
    Reviewed by:    mckusick
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    X-MFC-Note:     struct mount layout
    Differential revision:  https://reviews.freebsd.org/D30325
---
 sys/fs/cd9660/cd9660_vfsops.c |  1 -
 sys/fs/ext2fs/ext2_inode.c    |  2 +-
 sys/fs/ext2fs/ext2_vfsops.c   |  2 +-
 sys/fs/ext2fs/ext2_vnops.c    |  7 ++++---
 sys/fs/ext2fs/ext2fs.h        |  1 +
 sys/kern/vfs_subr.c           |  2 --
 sys/sys/mount.h               |  1 -
 sys/ufs/ffs/ffs_inode.c       |  2 +-
 sys/ufs/ffs/ffs_vfsops.c      |  4 ++--
 sys/ufs/ffs/ffs_vnops.c       |  2 +-
 sys/ufs/ufs/ufs_dirhash.c     |  1 -
 sys/ufs/ufs/ufs_lookup.c      |  8 ++------
 sys/ufs/ufs/ufs_vnops.c       | 14 +++++++-------
 sys/ufs/ufs/ufsmount.h        |  5 +++++
 14 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
index 21d3c3e13a8f..5d475bec93b8 100644
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ b/sys/fs/cd9660/cd9660_vfsops.c
@@ -378,7 +378,6 @@ iso_mountfs(devvp, mp)
 	mp->mnt_data = isomp;
 	mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
 	mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
-	mp->mnt_maxsymlinklen = 0;
 	MNT_ILOCK(mp);
 	if (isverified)
 		mp->mnt_flag |= MNT_VERIFIED;
diff --git a/sys/fs/ext2fs/ext2_inode.c b/sys/fs/ext2fs/ext2_inode.c
index 1412017b4b3c..b27c0b0ec4ec 100644
--- a/sys/fs/ext2fs/ext2_inode.c
+++ b/sys/fs/ext2fs/ext2_inode.c
@@ -562,7 +562,7 @@ ext2_truncate(struct vnode *vp, off_t length, int flags, struct ucred *cred,
 
 	ip = VTOI(vp);
 	if (vp->v_type == VLNK &&
-	    ip->i_size < vp->v_mount->mnt_maxsymlinklen) {
+	    ip->i_size < VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) {
 #ifdef INVARIANTS
 		if (length != 0)
 			panic("ext2_truncate: partial truncate of symlink");
diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c
index 43cfdf3a1a0b..d15fed3d2913 100644
--- a/sys/fs/ext2fs/ext2_vfsops.c
+++ b/sys/fs/ext2fs/ext2_vfsops.c
@@ -924,6 +924,7 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp)
 	 */
 	e2fs_maxcontig = MAX(1, maxphys / ump->um_e2fs->e2fs_bsize);
 	ump->um_e2fs->e2fs_contigsumsize = MIN(e2fs_maxcontig, EXT2_MAXCONTIG);
+	ump->um_e2fs->e2fs_maxsymlinklen = EXT2_MAXSYMLINKLEN;
 	if (ump->um_e2fs->e2fs_contigsumsize > 0) {
 		size = ump->um_e2fs->e2fs_gcount * sizeof(int32_t);
 		ump->um_e2fs->e2fs_maxcluster = malloc(size, M_EXT2MNT, M_WAITOK);
@@ -957,7 +958,6 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp)
 	mp->mnt_data = ump;
 	mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
 	mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
-	mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN;
 	MNT_ILOCK(mp);
 	mp->mnt_flag |= MNT_LOCAL;
 	MNT_IUNLOCK(mp);
diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c
index 2721aa535b40..367d48ab68f1 100644
--- a/sys/fs/ext2fs/ext2_vnops.c
+++ b/sys/fs/ext2fs/ext2_vnops.c
@@ -1533,7 +1533,7 @@ ext2_symlink(struct vop_symlink_args *ap)
 		return (error);
 	vp = *vpp;
 	len = strlen(ap->a_target);
-	if (len < vp->v_mount->mnt_maxsymlinklen) {
+	if (len < VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) {
 		ip = VTOI(vp);
 		bcopy(ap->a_target, (char *)ip->i_shortlink, len);
 		ip->i_size = len;
@@ -1558,7 +1558,7 @@ ext2_readlink(struct vop_readlink_args *ap)
 	int isize;
 
 	isize = ip->i_size;
-	if (isize < vp->v_mount->mnt_maxsymlinklen) {
+	if (isize < VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen) {
 		uiomove((char *)ip->i_shortlink, isize, ap->a_uio);
 		return (0);
 	}
@@ -2075,7 +2075,8 @@ ext2_read(struct vop_read_args *ap)
 		panic("%s: mode", "ext2_read");
 
 	if (vp->v_type == VLNK) {
-		if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen)
+		if ((int)ip->i_size <
+		    VFSTOEXT2(vp->v_mount)->um_e2fs->e2fs_maxsymlinklen)
 			panic("%s: short symlink", "ext2_read");
 	} else if (vp->v_type != VREG && vp->v_type != VDIR)
 		panic("%s: type %d", "ext2_read", vp->v_type);
diff --git a/sys/fs/ext2fs/ext2fs.h b/sys/fs/ext2fs/ext2fs.h
index b11ccc0b5b5a..1761f31454fd 100644
--- a/sys/fs/ext2fs/ext2fs.h
+++ b/sys/fs/ext2fs/ext2fs.h
@@ -184,6 +184,7 @@ struct m_ext2fs {
 	struct   csum *e2fs_clustersum; /* cluster summary in each cyl group */
 	int32_t  e2fs_uhash;	  /* 3 if hash should be signed, 0 if not */
 	uint32_t e2fs_csum_seed;  /* sb checksum seed */
+	uint64_t e2fs_maxsymlinklen; /* max size of short symlink */
 };
 
 /* cluster summary information */
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 620d3e974397..979cccf0e0dc 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -4464,8 +4464,6 @@ DB_SHOW_COMMAND(mount, db_show_mount)
 	    mp->mnt_lazyvnodelistsize);
 	db_printf("    mnt_writeopcount = %d (with %d in the struct)\n",
 	    vfs_mount_fetch_counter(mp, MNT_COUNT_WRITEOPCOUNT), mp->mnt_writeopcount);
-	db_printf("    mnt_maxsymlinklen = %jd\n",
-	    (uintmax_t)mp->mnt_maxsymlinklen);
 	db_printf("    mnt_iosize_max = %d\n", mp->mnt_iosize_max);
 	db_printf("    mnt_hashseed = %u\n", mp->mnt_hashseed);
 	db_printf("    mnt_lockref = %d (with %d in the struct)\n",
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index f341370ecd86..a1d4bfd15ddb 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -224,7 +224,6 @@ struct mount {
 	int		mnt_writeopcount;	/* (i) write syscalls pending */
 	struct vfsoptlist *mnt_opt;		/* current mount options */
 	struct vfsoptlist *mnt_optnew;		/* new options passed to fs */
-	uint64_t	mnt_maxsymlinklen;	/* max size of short symlink */
 	struct statfs	mnt_stat;		/* cache of filesystem stats */
 	struct ucred	*mnt_cred;		/* credentials of mounter */
 	void *		mnt_data;		/* private data */
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c
index 8fe7f7ab97de..b3d41aa023f9 100644
--- a/sys/ufs/ffs/ffs_inode.c
+++ b/sys/ufs/ffs/ffs_inode.c
@@ -329,7 +329,7 @@ ffs_truncate(vp, length, flags, cred)
 	}
 	if ((flags & IO_NORMAL) == 0)
 		return (0);
-	if (vp->v_type == VLNK && ip->i_size < vp->v_mount->mnt_maxsymlinklen) {
+	if (vp->v_type == VLNK && ip->i_size < ump->um_maxsymlinklen) {
 #ifdef INVARIANTS
 		if (length != 0)
 			panic("ffs_truncate: partial truncate of symlink");
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 321ed03f7f67..6b7407eb88f9 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -932,7 +932,7 @@ ffs_reload(struct mount *mp, struct thread *td, int flags)
 	sblockloc = fs->fs_sblockloc;
 	bcopy(newfs, fs, (u_int)fs->fs_sbsize);
 	brelse(bp);
-	mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen;
+	ump->um_maxsymlinklen = fs->fs_maxsymlinklen;
 	ffs_oldfscompat_read(fs, VFSTOUFS(mp), sblockloc);
 	UFS_LOCK(ump);
 	if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) {
@@ -1192,7 +1192,7 @@ ffs_mountfs(odevvp, mp, td)
 			vfs_rel(nmp);
 		vfs_getnewfsid(mp);
 	}
-	mp->mnt_maxsymlinklen = fs->fs_maxsymlinklen;
+	ump->um_maxsymlinklen = fs->fs_maxsymlinklen;
 	MNT_ILOCK(mp);
 	mp->mnt_flag |= MNT_LOCAL;
 	MNT_IUNLOCK(mp);
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 05eb19c0ee13..a10afd86f8e6 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -675,7 +675,7 @@ ffs_read(ap)
 		panic("ffs_read: mode");
 
 	if (vp->v_type == VLNK) {
-		if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen)
+		if ((int)ip->i_size < VFSTOUFS(vp->v_mount)->um_maxsymlinklen)
 			panic("ffs_read: short symlink");
 	} else if (vp->v_type != VREG && vp->v_type != VDIR)
 		panic("ffs_read: type %d",  vp->v_type);
diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c
index d1e1bed0bde4..8981ffdfc269 100644
--- a/sys/ufs/ufs/ufs_dirhash.c
+++ b/sys/ufs/ufs/ufs_dirhash.c
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
 
 #define WRAPINCR(val, limit)	(((val) + 1 == (limit)) ? 0 : ((val) + 1))
 #define WRAPDECR(val, limit)	(((val) == 0) ? ((limit) - 1) : ((val) - 1))
-#define OFSFMT(vp)		((vp)->v_mount->mnt_maxsymlinklen <= 0)
 #define BLKFREE2IDX(n)		((n) > DH_NFSTATS ? DH_NFSTATS : (n))
 
 static MALLOC_DEFINE(M_DIRHASH, "ufs_dirhash", "UFS directory hash tables");
diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c
index 0509185c4663..b7bf4eb6c86c 100644
--- a/sys/ufs/ufs/ufs_lookup.c
+++ b/sys/ufs/ufs/ufs_lookup.c
@@ -76,9 +76,6 @@ static int	dirchk = 0;
 
 SYSCTL_INT(_debug, OID_AUTO, dircheck, CTLFLAG_RW, &dirchk, 0, "");
 
-/* true if old FS format...*/
-#define OFSFMT(vp)	((vp)->v_mount->mnt_maxsymlinklen <= 0)
-
 static int
 ufs_delete_denied(struct vnode *vdp, struct vnode *tdp, struct ucred *cred,
     struct thread *td)
@@ -440,8 +437,7 @@ foundentry:
 				 * reclen in ndp->ni_ufs area, and release
 				 * directory buffer.
 				 */
-				if (vdp->v_mount->mnt_maxsymlinklen > 0 &&
-				    ep->d_type == DT_WHT) {
+				if (!OFSFMT(vdp) && ep->d_type == DT_WHT) {
 					slotstatus = FOUND;
 					slotoffset = i_offset;
 					slotsize = ep->d_reclen;
@@ -854,7 +850,7 @@ ufs_makedirentry(ip, cnp, newdirp)
 
 	bcopy(cnp->cn_nameptr, newdirp->d_name, namelen);
 
-	if (ITOV(ip)->v_mount->mnt_maxsymlinklen > 0)
+	if (!OFSFMT(ITOV(ip)))
 		newdirp->d_type = IFTODT(ip->i_mode);
 	else {
 		newdirp->d_type = 0;
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 70bf1a1d9036..ef288a32e815 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1155,7 +1155,7 @@ ufs_whiteout(ap)
 	switch (ap->a_flags) {
 	case LOOKUP:
 		/* 4.4 format directories support whiteout operations */
-		if (dvp->v_mount->mnt_maxsymlinklen > 0)
+		if (!OFSFMT(dvp))
 			return (0);
 		return (EOPNOTSUPP);
 
@@ -1164,7 +1164,7 @@ ufs_whiteout(ap)
 #ifdef INVARIANTS
 		if ((cnp->cn_flags & SAVENAME) == 0)
 			panic("ufs_whiteout: missing name");
-		if (dvp->v_mount->mnt_maxsymlinklen <= 0)
+		if (OFSFMT(dvp))
 			panic("ufs_whiteout: old format filesystem");
 #endif
 
@@ -1178,7 +1178,7 @@ ufs_whiteout(ap)
 	case DELETE:
 		/* remove an existing directory whiteout */
 #ifdef INVARIANTS
-		if (dvp->v_mount->mnt_maxsymlinklen <= 0)
+		if (OFSFMT(dvp))
 			panic("ufs_whiteout: old format filesystem");
 #endif
 
@@ -2083,7 +2083,7 @@ ufs_mkdir(ap)
 	/*
 	 * Initialize directory with "." and ".." from static template.
 	 */
-	if (dvp->v_mount->mnt_maxsymlinklen > 0)
+	if (!OFSFMT(dvp))
 		dtp = &mastertemplate;
 	else
 		dtp = (struct dirtemplate *)&omastertemplate;
@@ -2287,7 +2287,7 @@ ufs_symlink(ap)
 		return (error);
 	vp = *vpp;
 	len = strlen(ap->a_target);
-	if (len < vp->v_mount->mnt_maxsymlinklen) {
+	if (len < VFSTOUFS(vp->v_mount)->um_maxsymlinklen) {
 		ip = VTOI(vp);
 		bcopy(ap->a_target, SHORTLINK(ip), len);
 		ip->i_size = len;
@@ -2377,7 +2377,7 @@ ufs_readdir(ap)
 			}
 #if BYTE_ORDER == LITTLE_ENDIAN
 			/* Old filesystem format. */
-			if (vp->v_mount->mnt_maxsymlinklen <= 0) {
+			if (OFSFMT(vp)) {
 				dstdp.d_namlen = dp->d_type;
 				dstdp.d_type = dp->d_namlen;
 			} else
@@ -2458,7 +2458,7 @@ ufs_readlink(ap)
 	doff_t isize;
 
 	isize = ip->i_size;
-	if (isize < vp->v_mount->mnt_maxsymlinklen)
+	if (isize < VFSTOUFS(vp->v_mount)->um_maxsymlinklen)
 		return (uiomove(SHORTLINK(ip), isize, ap->a_uio));
 	return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred));
 }
diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h
index 0dfcecb178af..6071faec795c 100644
--- a/sys/ufs/ufs/ufsmount.h
+++ b/sys/ufs/ufs/ufsmount.h
@@ -100,6 +100,8 @@ struct ufsmount {
 	u_long	um_nindir;			/* (c) indirect ptrs per blk */
 	u_long	um_bptrtodb;			/* (c) indir disk block ptr */
 	u_long	um_seqinc;			/* (c) inc between seq blocks */
+	uint64_t um_maxsymlinklen;		/* (c) max size of short
+						       symlink */
 	struct	mtx um_lock;			/* (c) Protects ufsmount & fs */
 	pid_t	um_fsckpid;			/* (u) PID can do fsck sysctl */
 	struct	mount_softdeps *um_softdep;	/* (c) softdep mgmt structure */
@@ -194,4 +196,7 @@ struct ufsmount {
 #define	blkptrtodb(ump, b)		((b) << (ump)->um_bptrtodb)
 #define	is_sequential(ump, a, b)	((b) == (a) + ump->um_seqinc)
 
+/* true if old FS format...*/
+#define OFSFMT(vp)	(VFSTOUFS((vp)->v_mount)->um_maxsymlinklen <= 0)
+
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105221216.14MCGxZp011829>