Browse Source

vfs: flatten vop vectors

This eliminates the following loop from all VOP calls:

while(vop != NULL && \
    vop->vop_spare2 == NULL && vop->vop_bypass == NULL)
        vop = vop->vop_default;

Reviewed by:	jeff
Tesetd by:	pho
Differential Revision:	https://reviews.freebsd.org/D22738
freebsd/current/master
mjg 8 months ago
parent
commit
048a894ebc
27 changed files with 96 additions and 5 deletions
  1. +3
    -0
      sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
  2. +3
    -0
      sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  3. +1
    -0
      sys/fs/autofs/autofs_vnops.c
  4. +2
    -0
      sys/fs/cd9660/cd9660_vnops.c
  5. +1
    -0
      sys/fs/deadfs/dead_vnops.c
  6. +2
    -0
      sys/fs/devfs/devfs_vnops.c
  7. +2
    -0
      sys/fs/ext2fs/ext2_vnops.c
  8. +1
    -0
      sys/fs/fdescfs/fdesc_vnops.c
  9. +1
    -0
      sys/fs/fifofs/fifo_vnops.c
  10. +2
    -0
      sys/fs/fuse/fuse_vnops.c
  11. +1
    -0
      sys/fs/msdosfs/msdosfs_vnops.c
  12. +4
    -0
      sys/fs/nfsclient/nfs_clvnops.c
  13. +1
    -0
      sys/fs/nullfs/null_vnops.c
  14. +1
    -0
      sys/fs/pseudofs/pseudofs_vnops.c
  15. +1
    -0
      sys/fs/smbfs/smbfs_vnops.c
  16. +1
    -0
      sys/fs/tmpfs/tmpfs_fifoops.c
  17. +2
    -0
      sys/fs/tmpfs/tmpfs_vnops.c
  18. +2
    -0
      sys/fs/udf/udf_vnops.c
  19. +1
    -0
      sys/fs/unionfs/union_vnops.c
  20. +1
    -0
      sys/kern/uipc_mqueue.c
  21. +1
    -0
      sys/kern/vfs_default.c
  22. +5
    -0
      sys/kern/vfs_lookup.c
  23. +5
    -0
      sys/kern/vfs_subr.c
  24. +8
    -0
      sys/sys/vnode.h
  25. +38
    -5
      sys/tools/vnode_if.awk
  26. +4
    -0
      sys/ufs/ffs/ffs_vnops.c
  27. +2
    -0
      sys/ufs/ufs/ufs_vnops.c

+ 3
- 0
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c View File

@@ -826,6 +826,7 @@ static struct vop_vector zfsctl_ops_root = {
.vop_pathconf = zfsctl_common_pathconf,
.vop_getacl = zfsctl_common_getacl,
};
VFS_VOP_VECTOR_REGISTER(zfsctl_ops_root);

static int
zfsctl_snapshot_zname(vnode_t *vp, const char *name, int len, char *zname)
@@ -1159,6 +1160,7 @@ static struct vop_vector zfsctl_ops_snapdir = {
.vop_pathconf = zfsctl_common_pathconf,
.vop_getacl = zfsctl_common_getacl,
};
VFS_VOP_VECTOR_REGISTER(zfsctl_ops_snapdir);

static int
zfsctl_snapshot_inactive(ap)
@@ -1257,6 +1259,7 @@ static struct vop_vector zfsctl_ops_snapshot = {
.vop_advlockpurge = vop_stdadvlockpurge, /* called by vgone */
.vop_print = zfsctl_common_print,
};
VFS_VOP_VECTOR_REGISTER(zfsctl_ops_snapshot);

int
zfsctl_lookup_objset(vfs_t *vfsp, uint64_t objsetid, zfsvfs_t **zfsvfsp)


+ 3
- 0
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c View File

@@ -5995,6 +5995,7 @@ struct vop_vector zfs_vnodeops = {
.vop_unlock = vop_unlock,
.vop_islocked = vop_islocked,
};
VFS_VOP_VECTOR_REGISTER(zfs_vnodeops);

struct vop_vector zfs_fifoops = {
.vop_default = &fifo_specops,
@@ -6012,6 +6013,7 @@ struct vop_vector zfs_fifoops = {
.vop_setacl = zfs_freebsd_setacl,
.vop_aclcheck = zfs_freebsd_aclcheck,
};
VFS_VOP_VECTOR_REGISTER(zfs_fifoops);

/*
* special share hidden files vnode operations template
@@ -6024,3 +6026,4 @@ struct vop_vector zfs_shareops = {
.vop_fid = zfs_freebsd_fid,
.vop_pathconf = zfs_freebsd_pathconf,
};
VFS_VOP_VECTOR_REGISTER(zfs_shareops);

+ 1
- 0
sys/fs/autofs/autofs_vnops.c View File

@@ -554,6 +554,7 @@ struct vop_vector autofs_vnodeops = {
.vop_write = VOP_EOPNOTSUPP,
.vop_reclaim = autofs_reclaim,
};
VFS_VOP_VECTOR_REGISTER(autofs_vnodeops);

int
autofs_node_new(struct autofs_node *parent, struct autofs_mount *amp,


+ 2
- 0
sys/fs/cd9660/cd9660_vnops.c View File

@@ -906,6 +906,7 @@ struct vop_vector cd9660_vnodeops = {
.vop_vptofh = cd9660_vptofh,
.vop_getpages = cd9660_getpages,
};
VFS_VOP_VECTOR_REGISTER(cd9660_vnodeops);

/*
* Special device vnode ops
@@ -920,3 +921,4 @@ struct vop_vector cd9660_fifoops = {
.vop_setattr = cd9660_setattr,
.vop_vptofh = cd9660_vptofh,
};
VFS_VOP_VECTOR_REGISTER(cd9660_fifoops);

+ 1
- 0
sys/fs/deadfs/dead_vnops.c View File

@@ -80,6 +80,7 @@ struct vop_vector dead_vnodeops = {
.vop_unset_text = dead_unset_text,
.vop_write = dead_write,
};
VFS_VOP_VECTOR_REGISTER(dead_vnodeops);

static int
dead_getwritemount(struct vop_getwritemount_args *ap)


+ 2
- 0
sys/fs/devfs/devfs_vnops.c View File

@@ -1928,6 +1928,7 @@ static struct vop_vector devfs_vnodeops = {
.vop_symlink = devfs_symlink,
.vop_vptocnp = devfs_vptocnp,
};
VFS_VOP_VECTOR_REGISTER(devfs_vnodeops);

/* Vops for VCHR vnodes in /dev. */
static struct vop_vector devfs_specops = {
@@ -1965,6 +1966,7 @@ static struct vop_vector devfs_specops = {
.vop_vptocnp = devfs_vptocnp,
.vop_write = dead_write,
};
VFS_VOP_VECTOR_REGISTER(devfs_specops);

/*
* Our calling convention to the device drivers used to be that we passed


+ 2
- 0
sys/fs/ext2fs/ext2_vnops.c View File

@@ -182,6 +182,7 @@ struct vop_vector ext2_vnodeops = {
#endif /* UFS_ACL */
.vop_vptofh = ext2_vptofh,
};
VFS_VOP_VECTOR_REGISTER(ext2_vnodeops);

struct vop_vector ext2_fifoops = {
.vop_default = &fifo_specops,
@@ -199,6 +200,7 @@ struct vop_vector ext2_fifoops = {
.vop_write = VOP_PANIC,
.vop_vptofh = ext2_vptofh,
};
VFS_VOP_VECTOR_REGISTER(ext2_fifoops);

/*
* A virgin directory (no blushing please).


+ 1
- 0
sys/fs/fdescfs/fdesc_vnops.c View File

@@ -91,6 +91,7 @@ static struct vop_vector fdesc_vnodeops = {
.vop_reclaim = fdesc_reclaim,
.vop_setattr = fdesc_setattr,
};
VFS_VOP_VECTOR_REGISTER(fdesc_vnodeops);

static void fdesc_insmntque_dtr(struct vnode *, void *);
static void fdesc_remove_entry(struct fdescnode *);


+ 1
- 0
sys/fs/fifofs/fifo_vnops.c View File

@@ -102,6 +102,7 @@ struct vop_vector fifo_specops = {
.vop_symlink = VOP_PANIC,
.vop_write = VOP_PANIC,
};
VFS_VOP_VECTOR_REGISTER(fifo_specops);

/*
* Dispose of fifo resources.


+ 2
- 0
sys/fs/fuse/fuse_vnops.c View File

@@ -174,6 +174,7 @@ struct vop_vector fuse_fifoops = {
.vop_write = VOP_PANIC,
.vop_vptofh = fuse_vnop_vptofh,
};
VFS_VOP_VECTOR_REGISTER(fuse_fifoops);

struct vop_vector fuse_vnops = {
.vop_allocate = VOP_EINVAL,
@@ -223,6 +224,7 @@ struct vop_vector fuse_vnops = {
.vop_print = fuse_vnop_print,
.vop_vptofh = fuse_vnop_vptofh,
};
VFS_VOP_VECTOR_REGISTER(fuse_vnops);

uma_zone_t fuse_pbuf_zone;



+ 1
- 0
sys/fs/msdosfs/msdosfs_vnops.c View File

@@ -1962,3 +1962,4 @@ struct vop_vector msdosfs_vnodeops = {
.vop_write = msdosfs_write,
.vop_vptofh = msdosfs_vptofh,
};
VFS_VOP_VECTOR_REGISTER(msdosfs_vnodeops);

+ 4
- 0
sys/fs/nfsclient/nfs_clvnops.c View File

@@ -200,6 +200,7 @@ static struct vop_vector newnfs_vnodeops_nosig = {
.vop_listextattr = nfs_listextattr,
.vop_deleteextattr = nfs_deleteextattr,
};
VFS_VOP_VECTOR_REGISTER(newnfs_vnodeops_nosig);

static int
nfs_vnodeops_bypass(struct vop_generic_args *a)
@@ -212,6 +213,7 @@ struct vop_vector newnfs_vnodeops = {
.vop_default = &default_vnodeops,
.vop_bypass = nfs_vnodeops_bypass,
};
VFS_VOP_VECTOR_REGISTER(newnfs_vnodeops);

static struct vop_vector newnfs_fifoops_nosig = {
.vop_default = &fifo_specops,
@@ -227,6 +229,7 @@ static struct vop_vector newnfs_fifoops_nosig = {
.vop_setattr = nfs_setattr,
.vop_write = nfsfifo_write,
};
VFS_VOP_VECTOR_REGISTER(newnfs_fifoops_nosig);

static int
nfs_fifoops_bypass(struct vop_generic_args *a)
@@ -239,6 +242,7 @@ struct vop_vector newnfs_fifoops = {
.vop_default = &default_vnodeops,
.vop_bypass = nfs_fifoops_bypass,
};
VFS_VOP_VECTOR_REGISTER(newnfs_fifoops);

static int nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp,
struct componentname *cnp, struct vattr *vap);


+ 1
- 0
sys/fs/nullfs/null_vnops.c View File

@@ -943,3 +943,4 @@ struct vop_vector null_vnodeops = {
.vop_vptofh = null_vptofh,
.vop_add_writecount = null_add_writecount,
};
VFS_VOP_VECTOR_REGISTER(null_vnodeops);

+ 1
- 0
sys/fs/pseudofs/pseudofs_vnops.c View File

@@ -1095,3 +1095,4 @@ struct vop_vector pfs_vnodeops = {
.vop_write = pfs_write,
/* XXX I've probably forgotten a few that need VOP_EOPNOTSUPP */
};
VFS_VOP_VECTOR_REGISTER(pfs_vnodeops);

+ 1
- 0
sys/fs/smbfs/smbfs_vnops.c View File

@@ -114,6 +114,7 @@ struct vop_vector smbfs_vnodeops = {
.vop_symlink = smbfs_symlink,
.vop_write = smbfs_write,
};
VFS_VOP_VECTOR_REGISTER(smbfs_vnodeops);

static int
smbfs_access(ap)


+ 1
- 0
sys/fs/tmpfs/tmpfs_fifoops.c View File

@@ -75,3 +75,4 @@ struct vop_vector tmpfs_fifoop_entries = {
.vop_pathconf = tmpfs_pathconf,
.vop_print = tmpfs_print,
};
VFS_VOP_VECTOR_REGISTER(tmpfs_fifoop_entries);

+ 2
- 0
sys/fs/tmpfs/tmpfs_vnops.c View File

@@ -1636,6 +1636,7 @@ struct vop_vector tmpfs_vnodeop_entries = {
.vop_unlock = vop_unlock,
.vop_islocked = vop_islocked,
};
VFS_VOP_VECTOR_REGISTER(tmpfs_vnodeop_entries);

/*
* Same vector for mounts which do not use namecache.
@@ -1644,3 +1645,4 @@ struct vop_vector tmpfs_vnodeop_nonc_entries = {
.vop_default = &tmpfs_vnodeop_entries,
.vop_lookup = tmpfs_lookup,
};
VFS_VOP_VECTOR_REGISTER(tmpfs_vnodeop_nonc_entries);

+ 2
- 0
sys/fs/udf/udf_vnops.c View File

@@ -97,6 +97,7 @@ static struct vop_vector udf_vnodeops = {
.vop_strategy = udf_strategy,
.vop_vptofh = udf_vptofh,
};
VFS_VOP_VECTOR_REGISTER(udf_vnodeops);

struct vop_vector udf_fifoops = {
.vop_default = &fifo_specops,
@@ -108,6 +109,7 @@ struct vop_vector udf_fifoops = {
.vop_setattr = udf_setattr,
.vop_vptofh = udf_vptofh,
};
VFS_VOP_VECTOR_REGISTER(udf_fifoops);

static MALLOC_DEFINE(M_UDFFID, "udf_fid", "UDF FileId structure");
static MALLOC_DEFINE(M_UDFDS, "udf_ds", "UDF Dirstream structure");


+ 1
- 0
sys/fs/unionfs/union_vnops.c View File

@@ -2556,3 +2556,4 @@ struct vop_vector unionfs_vnodeops = {
.vop_vptofh = unionfs_vptofh,
.vop_add_writecount = unionfs_add_writecount,
};
VFS_VOP_VECTOR_REGISTER(unionfs_vnodeops);

+ 1
- 0
sys/kern/uipc_mqueue.c View File

@@ -2690,6 +2690,7 @@ static struct vop_vector mqfs_vnodeops = {
.vop_mkdir = VOP_EOPNOTSUPP,
.vop_rmdir = VOP_EOPNOTSUPP
};
VFS_VOP_VECTOR_REGISTER(mqfs_vnodeops);

static struct vfsops mqfs_vfsops = {
.vfs_init = mqfs_init,


+ 1
- 0
sys/kern/vfs_default.c View File

@@ -145,6 +145,7 @@ struct vop_vector default_vnodeops = {
.vop_add_writecount = vop_stdadd_writecount,
.vop_copy_file_range = vop_stdcopy_file_range,
};
VFS_VOP_VECTOR_REGISTER(default_vnodeops);

/*
* Series of placeholder functions for various error returns for


+ 5
- 0
sys/kern/vfs_lookup.c View File

@@ -139,6 +139,10 @@ static struct vop_vector crossmp_vnodeops = {
.vop_lock1 = crossmp_vop_lock1,
.vop_unlock = crossmp_vop_unlock,
};
/*
* VFS_VOP_VECTOR_REGISTER(crossmp_vnodeops) is not used here since the vnode
* gets allocated early. See nameiinit for the direct call below.
*/

struct nameicap_tracker {
struct vnode *dp;
@@ -156,6 +160,7 @@ nameiinit(void *dummy __unused)
UMA_ALIGN_PTR, 0);
nt_zone = uma_zcreate("rentr", sizeof(struct nameicap_tracker),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
vfs_vector_op_register(&crossmp_vnodeops);
getnewvnode("crossmp", NULL, &crossmp_vnodeops, &vp_crossmp);
}
SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL);


+ 5
- 0
sys/kern/vfs_subr.c View File

@@ -1558,6 +1558,10 @@ getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops,
int error __unused;

CTR3(KTR_VFS, "%s: mp %p with tag %s", __func__, mp, tag);

KASSERT(vops->registered,
("%s: not registered vector op %p\n", __func__, vops));

vp = NULL;
td = curthread;
if (td->td_vp_reserv > 0) {
@@ -4502,6 +4506,7 @@ static struct vop_vector sync_vnodeops = {
.vop_unlock = vop_stdunlock, /* unlock */
.vop_islocked = vop_stdislocked, /* islocked */
};
VFS_VOP_VECTOR_REGISTER(sync_vnodeops);

/*
* Create a new filesystem syncer vnode for the specified mount point.


+ 8
- 0
sys/sys/vnode.h View File

@@ -955,6 +955,14 @@ int vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,

void vn_fsid(struct vnode *vp, struct vattr *va);

#include <sys/kernel.h>

#define VFS_VOP_VECTOR_REGISTER(vnodeops) \
SYSINIT(vfs_vector_##vnodeops##_f, SI_SUB_VFS, SI_ORDER_ANY, \
vfs_vector_op_register, &vnodeops)

void vfs_vector_op_register(struct vop_vector *vop);

#endif /* _KERNEL */

#endif /* !_SYS_VNODE_H_ */

+ 38
- 5
sys/tools/vnode_if.awk View File

@@ -323,6 +323,7 @@ while ((getline < srcfile) > 0) {
}

if (cfile) {
funcarr[name] = 1;
# Print out the vop_F_vp_offsets structure. This all depends
# on naming conventions and nothing else.
printc("static int " name "_vp_offsets[] = {");
@@ -361,9 +362,6 @@ while ((getline < srcfile) > 0) {
printc("");
printc("\tVNASSERT(a->a_gen.a_desc == &" name "_desc, a->a_" args[0]",");
printc("\t (\"Wrong a_desc in " name "(%p, %p)\", a->a_" args[0]", a));");
printc("\twhile(vop != NULL && \\");
printc("\t vop->"name" == NULL && vop->vop_bypass == NULL)")
printc("\t\tvop = vop->vop_default;")
printc("\tVNASSERT(vop != NULL, a->a_" args[0]", (\"No "name"(%p, %p)\", a->a_" args[0]", a));")
printc("\tSDT_PROBE2(vfs, vop, " name ", entry, a->a_" args[0] ", a);\n");
for (i = 0; i < numargs; ++i)
@@ -422,9 +420,44 @@ while ((getline < srcfile) > 0) {
printc("};\n");
}
}
if (pfile)

if (cfile) {
printc("void");
printc("vfs_vector_op_register(struct vop_vector *orig_vop)");
printc("{");
printc("\tstruct vop_vector *vop;");
printc("");
printc("\tif (orig_vop->registered)");
printc("\t\tpanic(\"%s: vop_vector %p already registered\",")
printc("\t\t __func__, orig_vop);");
printc("");
for (name in funcarr) {
printc("\tvop = orig_vop;");
printc("\twhile (vop != NULL && \\");
printc("\t vop->"name" == NULL && vop->vop_bypass == NULL)")
printc("\t\tvop = vop->vop_default;")
printc("\tif (vop != NULL)");
printc("\t\torig_vop->"name" = vop->"name";");
printc("");
}
printc("\tvop = orig_vop;");
printc("\twhile (vop != NULL && vop->vop_bypass == NULL)")
printc("\t\tvop = vop->vop_default;")
printc("\tif (vop != NULL)");
printc("\t\torig_vop->vop_bypass = vop->vop_bypass;");
printc("");
printc("\torig_vop->registered = true;");
printc("}")
}

if (hfile) {
printh("void vfs_vector_op_register(struct vop_vector *orig_vop);");
}

if (pfile) {
printp("\tbool\tregistered;")
printp("};")
}
if (hfile)
close(hfile);


+ 4
- 0
sys/ufs/ffs/ffs_vnops.c View File

@@ -140,6 +140,7 @@ struct vop_vector ffs_vnodeops1 = {
.vop_write = ffs_write,
.vop_vptofh = ffs_vptofh,
};
VFS_VOP_VECTOR_REGISTER(ffs_vnodeops1);

struct vop_vector ffs_fifoops1 = {
.vop_default = &ufs_fifoops,
@@ -148,6 +149,7 @@ struct vop_vector ffs_fifoops1 = {
.vop_lock1 = ffs_lock,
.vop_vptofh = ffs_vptofh,
};
VFS_VOP_VECTOR_REGISTER(ffs_fifoops1);

/* Global vfs data structures for ufs. */
struct vop_vector ffs_vnodeops2 = {
@@ -168,6 +170,7 @@ struct vop_vector ffs_vnodeops2 = {
.vop_setextattr = ffs_setextattr,
.vop_vptofh = ffs_vptofh,
};
VFS_VOP_VECTOR_REGISTER(ffs_vnodeops2);

struct vop_vector ffs_fifoops2 = {
.vop_default = &ufs_fifoops,
@@ -184,6 +187,7 @@ struct vop_vector ffs_fifoops2 = {
.vop_setextattr = ffs_setextattr,
.vop_vptofh = ffs_vptofh,
};
VFS_VOP_VECTOR_REGISTER(ffs_fifoops2);

/*
* Synch an open file.


+ 2
- 0
sys/ufs/ufs/ufs_vnops.c View File

@@ -2771,6 +2771,7 @@ struct vop_vector ufs_vnodeops = {
.vop_aclcheck = ufs_aclcheck,
#endif
};
VFS_VOP_VECTOR_REGISTER(ufs_vnodeops);

struct vop_vector ufs_fifoops = {
.vop_default = &fifo_specops,
@@ -2801,3 +2802,4 @@ struct vop_vector ufs_fifoops = {
.vop_aclcheck = ufs_aclcheck,
#endif
};
VFS_VOP_VECTOR_REGISTER(ufs_fifoops);

Loading…
Cancel
Save