Make ffs_mountfs() static.

Remove the malloctype from the ufs mount structure, instead add a callback
to the storage method for freeing inodes: UFS_IFREE().

Add vfs_ifree() method function which frees an inode.

Unvariablelize the malloc type used for allocating inodes.
This commit is contained in:
Poul-Henning Kamp 2002-12-27 10:06:37 +00:00
parent beb24986a7
commit 975512a907
4 changed files with 24 additions and 17 deletions

View File

@ -72,8 +72,6 @@ int ffs_freefile(struct fs *, struct vnode *, ino_t, int );
int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
void ffs_load_inode(struct buf *, struct inode *, struct malloc_type *,
struct fs *, ino_t);
int ffs_mountfs(struct vnode *, struct mount *, struct thread *,
struct malloc_type *);
int ffs_mountroot(void);
vfs_mount_t ffs_mount;
int ffs_reallocblks(struct vop_reallocblks_args *);

View File

@ -71,9 +71,11 @@ static MALLOC_DEFINE(M_FFSNODE, "FFS node", "FFS vnode private part");
static int ffs_sbupdate(struct ufsmount *, int);
int ffs_reload(struct mount *,struct ucred *,struct thread *);
static int ffs_mountfs(struct vnode *, struct mount *, struct thread *);
static void ffs_oldfscompat_read(struct fs *, struct ufsmount *,
ufs2_daddr_t);
static void ffs_oldfscompat_write(struct fs *, struct ufsmount *);
static void ffs_ifree(struct ufsmount *ump, struct inode *ip);
static vfs_init_t ffs_init;
static vfs_uninit_t ffs_uninit;
static vfs_extattrctl_t ffs_extattrctl;
@ -159,7 +161,7 @@ ffs_mount(mp, path, data, ndp, td)
return (error);
}
if ((error = ffs_mountfs(rootvp, mp, td, M_FFSNODE)) != 0)
if ((error = ffs_mountfs(rootvp, mp, td)) != 0)
return (error);
(void)VFS_STATFS(mp, &mp->mnt_stat, td);
return (0);
@ -350,7 +352,7 @@ ffs_mount(mp, path, data, ndp, td)
* the mount point is discarded by the upper level code.
* Note that vfs_mount() populates f_mntonname for us.
*/
if ((error = ffs_mountfs(devvp, mp, td, M_FFSNODE)) != 0) {
if ((error = ffs_mountfs(devvp, mp, td)) != 0) {
vrele(devvp);
return (error);
}
@ -538,12 +540,11 @@ static int sblock_try[] = SBLOCKSEARCH;
/*
* Common code for mount and mountroot
*/
int
ffs_mountfs(devvp, mp, td, malloctype)
static int
ffs_mountfs(devvp, mp, td)
struct vnode *devvp;
struct mount *mp;
struct thread *td;
struct malloc_type *malloctype;
{
struct ufsmount *ump;
struct buf *bp;
@ -674,7 +675,6 @@ ffs_mountfs(devvp, mp, td, malloctype)
fs->fs_pendinginodes = 0;
}
ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK | M_ZERO);
ump->um_malloctype = malloctype;
ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT,
M_WAITOK);
if (fs->fs_magic == FS_UFS1_MAGIC) {
@ -689,6 +689,7 @@ ffs_mountfs(devvp, mp, td, malloctype)
ump->um_update = ffs_update;
ump->um_valloc = ffs_valloc;
ump->um_vfree = ffs_vfree;
ump->um_ifree = ffs_ifree;
bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize);
if (fs->fs_sbsize < SBLOCKSIZE)
bp->b_flags |= B_INVAL | B_NOCACHE;
@ -1236,13 +1237,13 @@ ffs_vget(mp, ino, flags, vpp)
* dereferences vp->v_data (as well it should).
*/
MALLOC(ip, struct inode *, sizeof(struct inode),
ump->um_malloctype, M_WAITOK);
M_FFSNODE, M_WAITOK);
/* Allocate a new vnode/inode. */
error = getnewvnode("ufs", mp, ffs_vnodeop_p, &vp);
if (error) {
*vpp = NULL;
FREE(ip, ump->um_malloctype);
FREE(ip, M_FFSNODE);
return (error);
}
bzero((caddr_t)ip, sizeof(struct inode));
@ -1302,7 +1303,7 @@ ffs_vget(mp, ino, flags, vpp)
*vpp = NULL;
return (error);
}
ffs_load_inode(bp, ip, ump->um_malloctype, fs, ino);
ffs_load_inode(bp, ip, M_FFSNODE, fs, ino);
if (DOINGSOFTDEP(vp))
softdep_load_inodeblock(ip);
else
@ -1516,3 +1517,14 @@ ffs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp,
attrname, td));
#endif
}
static void
ffs_ifree(struct ufsmount *ump, struct inode *ip)
{
if (ump->um_fstype == UFS1)
FREE(ip->i_din1, M_FFSNODE);
else
FREE(ip->i_din2, M_FFSNODE);
FREE(ip, M_FFSNODE);
}

View File

@ -183,11 +183,7 @@ ufs_reclaim(ap)
if (ip->i_dirhash != NULL)
ufsdirhash_free(ip);
#endif
if (ump->um_fstype == UFS1)
FREE(ip->i_din1, ump->um_malloctype);
else
FREE(ip->i_din2, ump->um_malloctype);
FREE(vp->v_data, ump->um_malloctype);
UFS_IFREE(ump, ip);
vp->v_data = 0;
return (0);
}

View File

@ -77,13 +77,13 @@ struct ufsmount {
time_t um_itime[MAXQUOTAS]; /* inode quota time limit */
char um_qflags[MAXQUOTAS]; /* quota specific flags */
int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
struct malloc_type *um_malloctype; /* The inodes malloctype */
int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, int, struct buf **);
int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);
int (*um_truncate)(struct vnode *, off_t, int, struct ucred *, struct thread *);
int (*um_update)(struct vnode *, int);
int (*um_valloc)(struct vnode *, int, struct ucred *, struct vnode **);
int (*um_vfree)(struct vnode *, ino_t, int);
void (*um_ifree)(struct ufsmount *, struct inode *);
};
#define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
@ -92,6 +92,7 @@ struct ufsmount {
#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
#define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb))
/*
* Filesystem types