There are three callers of update_vattr(). Two of them don't use the
updated struct vattr afterwards, so the call can be removed. Following
diff removes both calls and the function itself, inlining the last
remaining call.
While there I removed this gem:
#if (S_BLKSIZE == 512)
v->va_bytes = v->va_bytes << 9;
#else
v->va_bytes = v->va_bytes * S_BLKSIZE;
#endif
Our compiler is mature enough to figure that out by itself. The checksum
of the generated object file doesn't change regardless which branch is
compiled in. Even if that wasn't the case, that's not what's gonna make
fuse slow.
Ok? Objections?
natano
Index: miscfs/fuse/fuse_lookup.c
===================================================================
RCS file: /cvs/src/sys/miscfs/fuse/fuse_lookup.c,v
retrieving revision 1.13
diff -u -p -r1.13 fuse_lookup.c
--- miscfs/fuse/fuse_lookup.c 16 Aug 2016 21:32:58 -0000 1.13
+++ miscfs/fuse/fuse_lookup.c 17 Aug 2016 20:40:38 -0000
@@ -174,14 +174,10 @@ fusefs_lookup(void *v)
error = 0;
} else {
error = VFS_VGET(fmp->mp, nid, &tdp);
-
- if (!error)
- tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode);
-
- update_vattr(fmp->mp, &fbuf->fb_vattr);
-
if (error)
goto out;
+
+ tdp->v_type = IFTOVT(fbuf->fb_vattr.va_mode);
if (vdp != NULL && vdp->v_type == VDIR)
VTOI(tdp)->parent = dp->ufs_ino.i_number;
Index: miscfs/fuse/fuse_vnops.c
===================================================================
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
retrieving revision 1.30
diff -u -p -r1.30 fuse_vnops.c
--- miscfs/fuse/fuse_vnops.c 16 Aug 2016 21:32:58 -0000 1.30
+++ miscfs/fuse/fuse_vnops.c 17 Aug 2016 20:40:38 -0000
@@ -203,19 +203,6 @@ filt_fusefsvnode(struct knote *kn, long
return (kn->kn_fflags != 0);
}
-void
-update_vattr(struct mount *mp, struct vattr *v)
-{
- v->va_fsid = mp->mnt_stat.f_fsid.val[0];
- v->va_type = IFTOVT(v->va_mode);
-#if (S_BLKSIZE == 512)
- v->va_bytes = v->va_bytes << 9;
-#else
- v->va_bytes = v->va_bytes * S_BLKSIZE;
-#endif
- v->va_mode = v->va_mode & ~S_IFMT;
-}
-
int
fusefs_open(void *v)
{
@@ -401,8 +388,13 @@ fusefs_getattr(void *v)
return (error);
}
- update_vattr(fmp->mp, &fbuf->fb_vattr);
memcpy(vap, &fbuf->fb_vattr, sizeof(*vap));
+
+ vap->va_fsid = fmp->mp->mnt_stat.f_fsid.val[0];
+ vap->va_type = IFTOVT(vap->va_mode);
+ vap->va_bytes *= S_BLKSIZE;
+ vap->va_mode &= ~S_IFMT;
+
fb_delete(fbuf);
return (error);
}
@@ -518,15 +510,12 @@ fusefs_setattr(void *v)
}
error = fb_queue(fmp->dev, fbuf);
-
if (error) {
if (error == ENOSYS)
fmp->undef_op |= UNDEF_SETATTR;
goto out;
}
- update_vattr(fmp->mp, &fbuf->fb_vattr);
- memcpy(vap, &fbuf->fb_vattr, sizeof(*vap));
VN_KNOTE(ap->a_vp, NOTE_ATTRIB);
out:
Index: miscfs/fuse/fusefs.h
===================================================================
RCS file: /cvs/src/sys/miscfs/fuse/fusefs.h,v
retrieving revision 1.7
diff -u -p -r1.7 fusefs.h
--- miscfs/fuse/fusefs.h 20 May 2014 13:32:22 -0000 1.7
+++ miscfs/fuse/fusefs.h 17 Aug 2016 20:40:38 -0000
@@ -72,7 +72,6 @@ extern struct pool fusefs_fbuf_pool;
/* fuse helpers */
#define TSLEEP_TIMEOUT 5
-void update_vattr(struct mount *mp, struct vattr *v);
/* files helpers. */
int fusefs_file_open(struct fusefs_mnt *, struct fusefs_node *, enum fufh_type,