From owner-svn-src-all@FreeBSD.ORG Fri Apr 10 19:04:40 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BC5DEEF1; Fri, 10 Apr 2015 19:04:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A795C74A; Fri, 10 Apr 2015 19:04:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3AJ4etk064154; Fri, 10 Apr 2015 19:04:40 GMT (envelope-from will@FreeBSD.org) Received: (from will@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3AJ4eiK064153; Fri, 10 Apr 2015 19:04:40 GMT (envelope-from will@FreeBSD.org) Message-Id: <201504101904.t3AJ4eiK064153@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: will set sender to will@FreeBSD.org using -f From: Will Andrews Date: Fri, 10 Apr 2015 19:04:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281378 - head/sys/fs/tmpfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Apr 2015 19:04:40 -0000 Author: will Date: Fri Apr 10 19:04:39 2015 New Revision: 281378 URL: https://svnweb.freebsd.org/changeset/base/281378 Log: tmpfs_getattr(): Return more correct allocated byte counts. For VREG vnodes, return the resident page count (multiplied by PAGE_SIZE) for the tmpfs node's anonymous VM object that stores actual file contents. For all other vnodes, return the tmpfs_node's tn_size, which should not be rounded to a page. This change allows using stat(2) to identify a sparse file on tmpfs. Reviewed by: kib MFC after: 1 week Modified: head/sys/fs/tmpfs/tmpfs_vnops.c Modified: head/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vnops.c Fri Apr 10 18:49:43 2015 (r281377) +++ head/sys/fs/tmpfs/tmpfs_vnops.c Fri Apr 10 19:04:39 2015 (r281378) @@ -342,7 +342,7 @@ tmpfs_getattr(struct vop_getattr_args *v { struct vnode *vp = v->a_vp; struct vattr *vap = v->a_vap; - + vm_object_t obj; struct tmpfs_node *node; node = VP_TO_TMPFS_NODE(vp); @@ -366,7 +366,11 @@ tmpfs_getattr(struct vop_getattr_args *v vap->va_flags = node->tn_flags; vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ? node->tn_rdev : NODEV; - vap->va_bytes = round_page(node->tn_size); + if (vp->v_type == VREG) { + obj = node->tn_reg.tn_aobj; + vap->va_bytes = (u_quad_t)obj->resident_page_count * PAGE_SIZE; + } else + vap->va_bytes = node->tn_size; vap->va_filerev = 0; return 0;