fuse: dedup vnode type

2016-08-12 Thread Martin Natano
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.

Ok?

natano


Index: miscfs/fuse/fuse_lookup.c
===
RCS file: /cvs/src/sys/miscfs/fuse/fuse_lookup.c,v
retrieving revision 1.11
diff -u -p -r1.11 fuse_lookup.c
--- miscfs/fuse/fuse_lookup.c   19 Mar 2016 12:04:15 -  1.11
+++ miscfs/fuse/fuse_lookup.c   11 Aug 2016 10:26:51 -
@@ -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, );
 
-   if (!error) {
+   if (!error)
tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode);
-   VTOI(tdp)->vtype = tdp->v_type;
-   }
 
update_vattr(fmp->mp, >fb_vattr);
 
Index: miscfs/fuse/fuse_vfsops.c
===
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vfsops.c,v
retrieving revision 1.23
diff -u -p -r1.23 fuse_vfsops.c
--- miscfs/fuse/fuse_vfsops.c   19 Jun 2016 11:54:33 -  1.23
+++ miscfs/fuse/fuse_vfsops.c   11 Aug 2016 10:26:51 -
@@ -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, )) != 0)
return (error);
 
-   ip = VTOI(nvp);
nvp->v_type = VDIR;
-   ip->vtype = VDIR;
 
*vpp = nvp;
return (0);
Index: miscfs/fuse/fuse_vnops.c
===
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
retrieving revision 1.28
diff -u -p -r1.28 fuse_vnops.c
--- miscfs/fuse/fuse_vnops.c19 Jun 2016 11:54:33 -  1.28
+++ miscfs/fuse/fuse_vnops.c11 Aug 2016 10:26:51 -
@@ -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, , 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;
 
Index: miscfs/fuse/fusefs_node.h

Re: fuse: dedup vnode type

2016-08-12 Thread Martin Natano
> Index: miscfs/fuse/fusefs_node.h
> ===
> RCS file: /cvs/src/sys/miscfs/fuse/fusefs_node.h,v
> retrieving revision 1.2
> diff -u -p -r1.2 fusefs_node.h
> --- miscfs/fuse/fusefs_node.h 1 Feb 2014 09:30:38 -   1.2
> +++ miscfs/fuse/fusefs_node.h 11 Aug 2016 10:26:51 -
> @@ -46,8 +46,6 @@ struct fusefs_node {
>  
>   /** meta **/
>   off_t filesize;
> - uint64_t  nlookup;
> - enum vtypevtype;
>  };

While there I also removed the unused 'nlookup' field,