From aeb7f53982182dae810b53e9a2d29f74621998ff Mon Sep 17 00:00:00 2001 From: natano Date: Fri, 12 Aug 2016 20:18:44 +0000 Subject: [PATCH] Dedup vnode type information. Fuse stores the vnode type in two places: vtype in struct fusefs_node and v_type in struct vnode. Given the fact, that fusefs_node structs are never allocated without an associated vnode and those two fields are always in sync, one of those locations is superfluous. While there remove the unused nlookup field. ok mpi --- sys/miscfs/fuse/fuse_lookup.c | 7 ++----- sys/miscfs/fuse/fuse_vfsops.c | 5 +---- sys/miscfs/fuse/fuse_vnops.c | 19 ++++++------------- sys/miscfs/fuse/fusefs_node.h | 4 +--- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/sys/miscfs/fuse/fuse_lookup.c b/sys/miscfs/fuse/fuse_lookup.c index e9bf8bfc02c..aa33ce5cc0c 100644 --- a/sys/miscfs/fuse/fuse_lookup.c +++ b/sys/miscfs/fuse/fuse_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_lookup.c,v 1.11 2016/03/19 12:04:15 natano Exp $ */ +/* $OpenBSD: fuse_lookup.c,v 1.12 2016/08/12 20:18:44 natano Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon * @@ -147,7 +147,6 @@ fusefs_lookup(void *v) goto out; tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode); - VTOI(tdp)->vtype = tdp->v_type; *vpp = tdp; cnp->cn_flags |= SAVENAME; @@ -183,10 +182,8 @@ fusefs_lookup(void *v) } else { error = VFS_VGET(fmp->mp, nid, &tdp); - if (!error) { + if (!error) tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode); - VTOI(tdp)->vtype = tdp->v_type; - } update_vattr(fmp->mp, &fbuf->fb_vattr); diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c index 60073bbd0d9..c98ec6cd403 100644 --- a/sys/miscfs/fuse/fuse_vfsops.c +++ b/sys/miscfs/fuse/fuse_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vfsops.c,v 1.23 2016/06/19 11:54:33 natano Exp $ */ +/* $OpenBSD: fuse_vfsops.c,v 1.24 2016/08/12 20:18:44 natano Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon * @@ -170,15 +170,12 @@ int fusefs_root(struct mount *mp, struct vnode **vpp) { struct vnode *nvp; - struct fusefs_node *ip; int error; if ((error = VFS_VGET(mp, (ino_t)FUSE_ROOTINO, &nvp)) != 0) return (error); - ip = VTOI(nvp); nvp->v_type = VDIR; - ip->vtype = VDIR; *vpp = nvp; return (0); diff --git a/sys/miscfs/fuse/fuse_vnops.c b/sys/miscfs/fuse/fuse_vnops.c index 904081da58a..39d8e087643 100644 --- a/sys/miscfs/fuse/fuse_vnops.c +++ b/sys/miscfs/fuse/fuse_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vnops.c,v 1.28 2016/06/19 11:54:33 natano Exp $ */ +/* $OpenBSD: fuse_vnops.c,v 1.29 2016/08/12 20:18:44 natano Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon * @@ -235,7 +235,7 @@ fusefs_open(void *v) return (ENXIO); isdir = 0; - if (ip->vtype == VDIR) + if (ap->a_vp->v_type == VDIR) isdir = 1; else { if ((ap->a_mode & FREAD) && (ap->a_mode & FWRITE)) { @@ -274,7 +274,7 @@ fusefs_close(void *v) if (!fmp->sess_init) return (0); - if (ip->vtype == VDIR) { + if (ap->a_vp->v_type == VDIR) { isdir = 1; if (ip->fufh[fufh_type].fh_type != FUFH_INVALID) @@ -665,7 +665,6 @@ fusefs_symlink(void *v) } tdp->v_type = VLNK; - VTOI(tdp)->vtype = tdp->v_type; VTOI(tdp)->parent = dp->ufs_ino.i_number; VN_KNOTE(ap->a_dvp, NOTE_WRITE); @@ -762,7 +761,7 @@ fusefs_inactive(void *v) fufh = &(ip->fufh[type]); if (fufh->fh_type != FUFH_INVALID) fusefs_file_close(fmp, ip, fufh->fh_type, type, - (ip->vtype == VDIR), ap->a_p); + (vp->v_type == VDIR), ap->a_p); } error = VOP_GETATTR(vp, &vattr, cred, p); @@ -835,7 +834,7 @@ fusefs_reclaim(void *v) if (fufh->fh_type != FUFH_INVALID) { printf("fusefs: vnode being reclaimed is valid\n"); fusefs_file_close(fmp, ip, fufh->fh_type, type, - (ip->vtype == VDIR), ap->a_p); + (vp->v_type == VDIR), ap->a_p); } } /* @@ -932,8 +931,6 @@ fusefs_create(void *v) } tdp->v_type = IFTOVT(fbuf->fb_io_mode); - VTOI(tdp)->vtype = tdp->v_type; - if (dvp != NULL && dvp->v_type == VDIR) VTOI(tdp)->parent = ip->ufs_ino.i_number; @@ -998,8 +995,6 @@ fusefs_mknod(void *v) } tdp->v_type = IFTOVT(fbuf->fb_io_mode); - VTOI(tdp)->vtype = tdp->v_type; - if (dvp != NULL && dvp->v_type == VDIR) VTOI(tdp)->parent = ip->ufs_ino.i_number; @@ -1211,7 +1206,7 @@ abortit: * "ls" or "pwd" with the "." directory entry missing, and "cd .." * doesn't work if the ".." entry is missing. */ - if (ip->vtype == VDIR) { + if (fvp->v_type == VDIR) { /* * Avoid ".", "..", and aliases of "." for obvious reasons. */ @@ -1325,8 +1320,6 @@ fusefs_mkdir(void *v) } tdp->v_type = IFTOVT(fbuf->fb_io_mode); - VTOI(tdp)->vtype = tdp->v_type; - if (dvp != NULL && dvp->v_type == VDIR) VTOI(tdp)->parent = ip->ufs_ino.i_number; diff --git a/sys/miscfs/fuse/fusefs_node.h b/sys/miscfs/fuse/fusefs_node.h index d3c146daa00..da66248bd1d 100644 --- a/sys/miscfs/fuse/fusefs_node.h +++ b/sys/miscfs/fuse/fusefs_node.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fusefs_node.h,v 1.2 2014/02/01 09:30:38 syl Exp $ */ +/* $OpenBSD: fusefs_node.h,v 1.3 2016/08/12 20:18:44 natano Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon * @@ -46,8 +46,6 @@ struct fusefs_node { /** meta **/ off_t filesize; - uint64_t nlookup; - enum vtype vtype; }; #ifdef ITOV -- 2.20.1