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
This commit is contained in:
Konstantin Belousov 2021-05-18 04:42:03 +03:00
parent ea2b64c241
commit f784da883f
14 changed files with 25 additions and 27 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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",

View File

@ -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 */

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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 @@ ufs_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname *cnp,
* 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;

View File

@ -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));
}

View File

@ -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