From owner-svn-src-projects@freebsd.org Mon May 13 23:30:07 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6CA78159D5E2 for ; Mon, 13 May 2019 23:30:07 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 10A8C72585; Mon, 13 May 2019 23:30:07 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB7C018D35; Mon, 13 May 2019 23:30:06 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4DNU63L003359; Mon, 13 May 2019 23:30:06 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4DNU63x003357; Mon, 13 May 2019 23:30:06 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201905132330.x4DNU63x003357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 13 May 2019 23:30:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r347554 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 347554 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 10A8C72585 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.960,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 May 2019 23:30:07 -0000 Author: asomers Date: Mon May 13 23:30:06 2019 New Revision: 347554 URL: https://svnweb.freebsd.org/changeset/base/347554 Log: fusefs: eliminate superfluous FUSE_GETATTR when filesize=0 fuse_vnode_refreshsize was using 0 as a flag value for filesize meaning "uninitialized" (thanks to the malloc(...M_ZERO) in fuse_vnode_alloc. But this led to unnecessary getattr operations when the filesize legitimately happened to be zero. Fix by adding a distinct flag value. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_node.c projects/fuse2/sys/fs/fuse/fuse_node.h Modified: projects/fuse2/sys/fs/fuse/fuse_node.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.c Mon May 13 22:17:11 2019 (r347553) +++ projects/fuse2/sys/fs/fuse/fuse_node.c Mon May 13 23:30:06 2019 (r347554) @@ -143,6 +143,7 @@ fuse_vnode_init(struct vnode *vp, struct fuse_vnode_da fvdat->nid = nodeid; LIST_INIT(&fvdat->handles); vattr_null(&fvdat->cached_attrs); + fvdat->filesize = FUSE_FILESIZE_UNINITIALIZED; if (nodeid == FUSE_ROOT_ID) { vp->v_vflag |= VV_ROOT; } @@ -388,15 +389,10 @@ fuse_vnode_refreshsize(struct vnode *vp, struct ucred if ((fvdat->flag & FN_SIZECHANGE) != 0 || fuse_data_cache_mode == FUSE_CACHE_UC || - fvdat->filesize != 0) + fvdat->filesize != FUSE_FILESIZE_UNINITIALIZED) return 0; - /* - * TODO: replace VOP_GETATTR with fuse_internal_getattr to use the - * cached attributes. Better yet, replace fvdat->filesize with - * attrs->va_size - */ - err = VOP_GETATTR(vp, &va, cred); + err = fuse_internal_getattr(vp, &va, cred, curthread); SDT_PROBE2(fusefs, , node, trace, 1, "refreshed file size"); return err; } Modified: projects/fuse2/sys/fs/fuse/fuse_node.h ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_node.h Mon May 13 22:17:11 2019 (r347553) +++ projects/fuse2/sys/fs/fuse/fuse_node.h Mon May 13 23:30:06 2019 (r347554) @@ -71,6 +71,8 @@ #define FN_SIZECHANGE 0x00000100 #define FN_DIRECTIO 0x00000200 +#define FUSE_FILESIZE_UNINITIALIZED -1 + struct fuse_vnode_data { /** self **/ uint64_t nid; @@ -89,7 +91,11 @@ struct fuse_vnode_data { /* The monotonic time after which the attr cache is invalid */ struct bintime attr_cache_timeout; struct vattr cached_attrs; - /* TODO: use cached_attrs.size instead */ + /* + * File size according to the kernel, not the daemon. + * May differ from cached_attrs.st_size due to write caching. Unlike + * cached_attrs.st_size, filesize never expires. + */ off_t filesize; uint64_t nlookup; enum vtype vtype;