From owner-svn-src-all@FreeBSD.ORG Mon Feb 14 15:36:39 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DD271065673; Mon, 14 Feb 2011 15:36:39 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D96C28FC1E; Mon, 14 Feb 2011 15:36:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p1EFac5B097529; Mon, 14 Feb 2011 15:36:38 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p1EFacxX097527; Mon, 14 Feb 2011 15:36:38 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201102141536.p1EFacxX097527@svn.freebsd.org> From: Alan Cox Date: Mon, 14 Feb 2011 15:36:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218681 - head/sys/fs/tmpfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 14 Feb 2011 15:36:39 -0000 Author: alc Date: Mon Feb 14 15:36:38 2011 New Revision: 218681 URL: http://svn.freebsd.org/changeset/base/218681 Log: Further simplify tmpfs_reg_resize(). Also, update its comments, including style fixes. Modified: head/sys/fs/tmpfs/tmpfs_subr.c Modified: head/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_subr.c Mon Feb 14 14:26:14 2011 (r218680) +++ head/sys/fs/tmpfs/tmpfs_subr.c Mon Feb 14 15:36:38 2011 (r218681) @@ -874,9 +874,9 @@ tmpfs_dir_whiteout_remove(struct vnode * /* --------------------------------------------------------------------- */ /* - * Resizes the aobj associated to the regular file pointed to by vp to - * the size newsize. 'vp' must point to a vnode that represents a regular - * file. 'newsize' must be positive. + * Resizes the aobj associated with the regular file pointed to by 'vp' to the + * size 'newsize'. 'vp' must point to a vnode that represents a regular file. + * 'newsize' must be positive. * * Returns zero on success or an appropriate error code on failure. */ @@ -890,7 +890,6 @@ tmpfs_reg_resize(struct vnode *vp, off_t vm_pindex_t newpages, oldpages; off_t oldsize; size_t zerolen; - int error; MPASS(vp->v_type == VREG); MPASS(newsize >= 0); @@ -899,20 +898,19 @@ tmpfs_reg_resize(struct vnode *vp, off_t uobj = node->tn_reg.tn_aobj; tmp = VFS_TO_TMPFS(vp->v_mount); - /* Convert the old and new sizes to the number of pages needed to + /* + * Convert the old and new sizes to the number of pages needed to * store them. It may happen that we do not need to do anything * because the last allocated page can accommodate the change on - * its own. */ + * its own. + */ oldsize = node->tn_size; oldpages = OFF_TO_IDX(oldsize + PAGE_MASK); MPASS(oldpages == uobj->size); newpages = OFF_TO_IDX(newsize + PAGE_MASK); - if (newpages > oldpages && - newpages - oldpages > TMPFS_PAGES_AVAIL(tmp)) { - error = ENOSPC; - goto out; - } + newpages - oldpages > TMPFS_PAGES_AVAIL(tmp)) + return (ENOSPC); TMPFS_LOCK(tmp); tmp->tm_pages_used += (newpages - oldpages); @@ -923,7 +921,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t VM_OBJECT_LOCK(uobj); if (newsize < oldsize) { /* - * free "backing store" + * Release any swap space and free any whole pages. */ if (newpages < oldpages) { swap_pager_freespace(uobj, newpages, oldpages - @@ -932,7 +930,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t } /* - * zero out the truncated part of the last page. + * Zero the truncated part of the last page. */ zerolen = round_page(newsize) - newsize; if (zerolen > 0) { @@ -943,10 +941,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t } uobj->size = newpages; VM_OBJECT_UNLOCK(uobj); - error = 0; - -out: - return (error); + return (0); } /* --------------------------------------------------------------------- */