introduce "ufs_ops" and use it for ITIMES.

This commit is contained in:
yamt 2005-09-27 06:48:55 +00:00
parent 050407b699
commit baee927713
8 changed files with 49 additions and 37 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_subr.c,v 1.16 2005/09/12 20:21:18 christos Exp $ */
/* $NetBSD: ext2fs_subr.c,v 1.17 2005/09/27 06:48:55 yamt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.16 2005/09/12 20:21:18 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_subr.c,v 1.17 2005/09/27 06:48:55 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -117,7 +117,9 @@ ext2fs_itimes(struct inode *ip, const struct timespec *acc,
{
struct timespec *ts = NULL, tsb;
KASSERT(ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY));
if (!(ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY))) {
return;
}
if (ip->i_flag & IN_ACCESS) {
if (acc == NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_vfsops.c,v 1.91 2005/09/23 12:10:33 jmmv Exp $ */
/* $NetBSD: ext2fs_vfsops.c,v 1.92 2005/09/27 06:48:55 yamt Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.91 2005/09/23 12:10:33 jmmv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.92 2005/09/27 06:48:55 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@ -149,6 +149,10 @@ static const struct genfs_ops ext2fs_genfsops = {
.gop_markupdate = ufs_gop_markupdate,
};
static const struct ufs_ops ext2fs_ufsops = {
.uo_itimes = ext2fs_itimes,
};
/*
* XXX Same structure as FFS inodes? Should we share a common pool?
*/
@ -169,7 +173,6 @@ ext2fs_init(void)
"ext2dinopl", &pool_allocator_nointr);
#endif
ufs_init();
ext2fs_itimesfn = ext2fs_itimes;
}
void
@ -186,7 +189,6 @@ ext2fs_done(void)
pool_destroy(&ext2fs_inode_pool);
pool_destroy(&ext2fs_dinode_pool);
#endif
ext2fs_itimesfn = NULL;
}
/*
@ -624,6 +626,7 @@ ext2fs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
memset(ump, 0, sizeof *ump);
ump->um_fstype = UFS1;
ump->um_ops = &ext2fs_ufsops;
ump->um_e2fs = malloc(sizeof(struct m_ext2fs), M_UFSMNT, M_WAITOK);
memset(ump->um_e2fs, 0, sizeof(struct m_ext2fs));
e2fs_sbload((struct ext2fs*)bp->b_data, &ump->um_e2fs->e2fs);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_inode.c,v 1.75 2005/09/12 20:26:44 christos Exp $ */
/* $NetBSD: ffs_inode.c,v 1.76 2005/09/27 06:48:55 yamt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.75 2005/09/12 20:26:44 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.76 2005/09/27 06:48:55 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -655,7 +655,9 @@ ffs_itimes(struct inode *ip, const struct timespec *acc,
{
struct timespec *ts = NULL, tsb;
KASSERT(ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY));
if (!(ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY))) {
return;
}
if (ip->i_flag & IN_ACCESS) {
if (acc == NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_vfsops.c,v 1.174 2005/09/23 12:10:33 jmmv Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.175 2005/09/27 06:48:55 yamt Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.174 2005/09/23 12:10:33 jmmv Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.175 2005/09/27 06:48:55 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -118,6 +118,10 @@ static const struct genfs_ops ffs_genfsops = {
.gop_markupdate = ufs_gop_markupdate,
};
static const struct ufs_ops ffs_ufsops = {
.uo_itimes = ffs_itimes,
};
POOL_INIT(ffs_inode_pool, sizeof(struct inode), 0, 0, 0, "ffsinopl",
&pool_allocator_nointr);
POOL_INIT(ffs_dinode1_pool, sizeof(struct ufs1_dinode), 0, 0, 0, "dino1pl",
@ -803,6 +807,7 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
memset(ump, 0, sizeof *ump);
TAILQ_INIT(&ump->um_snapshots);
ump->um_fs = fs;
ump->um_ops = &ffs_ufsops;
#ifdef FFS_EI
if (needswap) {
@ -1552,7 +1557,6 @@ ffs_init(void)
if (ffs_initcount++ > 0)
return;
ffs_itimesfn = ffs_itimes;
#ifdef _LKM
pool_init(&ffs_inode_pool, sizeof(struct inode), 0, 0, 0,
"ffsinopl", &pool_allocator_nointr);
@ -1585,7 +1589,6 @@ ffs_done(void)
pool_destroy(&ffs_dinode1_pool);
pool_destroy(&ffs_inode_pool);
#endif
ffs_itimesfn = NULL;
}
SYSCTL_SETUP(sysctl_vfs_ffs_setup, "sysctl vfs.ffs subtree setup")

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_vfsops.c,v 1.187 2005/09/23 12:10:34 jmmv Exp $ */
/* $NetBSD: lfs_vfsops.c,v 1.188 2005/09/27 06:48:56 yamt Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.187 2005/09/23 12:10:34 jmmv Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.188 2005/09/27 06:48:56 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -167,6 +167,10 @@ const struct genfs_ops lfs_genfsops = {
.gop_markupdate = ufs_gop_markupdate,
};
static const struct ufs_ops lfs_ufsops = {
.uo_itimes = NULL,
};
/*
* XXX Same structure as FFS inodes? Should we share a common pool?
*/
@ -1051,6 +1055,7 @@ lfs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK | M_ZERO);
ump->um_lfs = fs;
ump->um_ops = &lfs_ufsops;
ump->um_fstype = UFS1;
if (sizeof(struct lfs) < LFS_SBPAD) { /* XXX why? */
bp->b_flags |= B_INVAL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: inode.h,v 1.44 2005/09/12 20:23:04 christos Exp $ */
/* $NetBSD: inode.h,v 1.45 2005/09/27 06:48:56 yamt Exp $ */
/*
* Copyright (c) 1982, 1989, 1993
@ -266,17 +266,6 @@ struct indir {
#define VTOI(vp) ((struct inode *)(vp)->v_data)
#define ITOV(ip) ((ip)->i_vnode)
typedef void (*ufs_itimes_t)(struct inode *ip, const struct timespec *,
const struct timespec *, const struct timespec *);
extern ufs_itimes_t ffs_itimesfn, ext2fs_itimesfn;
#define ITIMES(ip, acc, mod, cre) \
while ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE | IN_MODIFY)) \
IS_EXT2_VNODE((ip)->i_vnode) ? \
(*ext2fs_itimesfn)(ip, acc, mod, cre) : \
(*ffs_itimesfn)(ip, acc, mod, cre)
/* Determine if soft dependencies are being done */
#define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_vnops.c,v 1.134 2005/09/12 20:23:04 christos Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.135 2005/09/27 06:48:56 yamt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993, 1995
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.134 2005/09/12 20:23:04 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.135 2005/09/27 06:48:56 yamt Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -90,8 +90,6 @@ static const struct dirtemplate mastertemplate = {
0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
};
ufs_itimes_t ffs_itimesfn = NULL, ext2fs_itimesfn = NULL;
/*
* Create a regular file
*/
@ -222,7 +220,7 @@ ufs_close(void *v)
ip = VTOI(vp);
simple_lock(&vp->v_interlock);
if (vp->v_usecount > 1)
ITIMES(ip, NULL, NULL, NULL);
UFS_ITIMES(vp, NULL, NULL, NULL);
simple_unlock(&vp->v_interlock);
return (0);
}
@ -299,7 +297,7 @@ ufs_getattr(void *v)
vp = ap->a_vp;
ip = VTOI(vp);
vap = ap->a_vap;
ITIMES(ip, NULL, NULL, NULL);
UFS_ITIMES(vp, NULL, NULL, NULL);
/*
* Copy from inode table
@ -1839,7 +1837,7 @@ ufsspec_close(void *v)
ip = VTOI(vp);
simple_lock(&vp->v_interlock);
if (vp->v_usecount > 1)
ITIMES(ip, NULL, NULL, NULL);
UFS_ITIMES(vp, NULL, NULL, NULL);
simple_unlock(&vp->v_interlock);
return (VOCALL (spec_vnodeop_p, VOFFSET(vop_close), ap));
}
@ -1905,7 +1903,7 @@ ufsfifo_close(void *v)
ip = VTOI(vp);
simple_lock(&vp->v_interlock);
if (ap->a_vp->v_usecount > 1)
ITIMES(ip, NULL, NULL, NULL);
UFS_ITIMES(vp, NULL, NULL, NULL);
simple_unlock(&vp->v_interlock);
return (VOCALL (fifo_vnodeop_p, VOFFSET(vop_close), ap));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufsmount.h,v 1.22 2005/09/27 06:48:16 yamt Exp $ */
/* $NetBSD: ufsmount.h,v 1.23 2005/09/27 06:48:56 yamt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -102,8 +102,18 @@ struct ufsmount {
int um_maxsymlinklen;
int um_dirblksiz;
u_int64_t um_maxfilesize;
const struct ufs_ops *um_ops;
};
struct ufs_ops {
void (*uo_itimes)(struct inode *ip, const struct timespec *,
const struct timespec *, const struct timespec *);
};
#define UFS_ITIMES(vp, acc, mod, cre) \
(*VFSTOUFS((vp)->v_mount)->um_ops->uo_itimes)((ip), (acc), (mod), (cre))
/* UFS-specific flags */
#define UFS_NEEDSWAP 0x01 /* filesystem metadata need byte-swapping */
#define UFS_ISAPPLEUFS 0x02 /* filesystem is Apple UFS */