From owner-svn-src-stable@freebsd.org Thu Oct 10 08:49:10 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8B4EA14EDB7; Thu, 10 Oct 2019 08:49:10 +0000 (UTC) (envelope-from kib@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 46plBG2v2yz4pdD; Thu, 10 Oct 2019 08:49:10 +0000 (UTC) (envelope-from kib@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 46760276B4; Thu, 10 Oct 2019 08:49:10 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9A8nAXI053684; Thu, 10 Oct 2019 08:49:10 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9A8nA3J053683; Thu, 10 Oct 2019 08:49:10 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201910100849.x9A8nA3J053683@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 10 Oct 2019 08:49:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r353387 - stable/11/sys/fs/tmpfs X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/fs/tmpfs X-SVN-Commit-Revision: 353387 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Oct 2019 08:49:10 -0000 Author: kib Date: Thu Oct 10 08:49:09 2019 New Revision: 353387 URL: https://svnweb.freebsd.org/changeset/base/353387 Log: MFC r353064: tmpfs_rename: style. Modified: stable/11/sys/fs/tmpfs/tmpfs_vnops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- stable/11/sys/fs/tmpfs/tmpfs_vnops.c Thu Oct 10 08:46:50 2019 (r353386) +++ stable/11/sys/fs/tmpfs/tmpfs_vnops.c Thu Oct 10 08:49:09 2019 (r353387) @@ -787,23 +787,24 @@ tmpfs_rename(struct vop_rename_args *v) struct vnode *tvp = v->a_tvp; struct componentname *tcnp = v->a_tcnp; struct mount *mp = NULL; - char *newname; - int error; struct tmpfs_dirent *de; struct tmpfs_mount *tmp; struct tmpfs_node *fdnode; struct tmpfs_node *fnode; struct tmpfs_node *tnode; struct tmpfs_node *tdnode; + int error; MPASS(VOP_ISLOCKED(tdvp)); MPASS(IMPLIES(tvp != NULL, VOP_ISLOCKED(tvp))); MPASS(fcnp->cn_flags & HASBUF); MPASS(tcnp->cn_flags & HASBUF); - /* Disallow cross-device renames. - * XXX Why isn't this done by the caller? */ + /* + * Disallow cross-device renames. + * XXX Why isn't this done by the caller? + */ if (fvp->v_mount != tdvp->v_mount || (tvp != NULL && fvp->v_mount != tvp->v_mount)) { error = EXDEV; @@ -816,8 +817,10 @@ tmpfs_rename(struct vop_rename_args *v) goto out; } - /* If we need to move the directory between entries, lock the - * source so that we can safely operate on it. */ + /* + * If we need to move the directory between entries, lock the + * source so that we can safely operate on it. + */ if (fdvp != tdvp && fdvp != tvp) { if (vn_lock(fdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) { mp = tdvp->v_mount; @@ -853,8 +856,10 @@ tmpfs_rename(struct vop_rename_args *v) fnode = VP_TO_TMPFS_NODE(fvp); de = tmpfs_dir_lookup(fdnode, fnode, fcnp); - /* Entry can disappear before we lock fdvp, - * also avoid manipulating '.' and '..' entries. */ + /* + * Entry can disappear before we lock fdvp, + * also avoid manipulating '.' and '..' entries. + */ if (de == NULL) { if ((fcnp->cn_flags & ISDOTDOT) != 0 || (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.')) @@ -865,11 +870,13 @@ tmpfs_rename(struct vop_rename_args *v) } MPASS(de->td_node == fnode); - /* If re-naming a directory to another preexisting directory + /* + * If re-naming a directory to another preexisting directory * ensure that the target directory is empty so that its * removal causes no side effects. * Kern_rename guarantees the destination to be a directory - * if the source is one. */ + * if the source is one. + */ if (tvp != NULL) { MPASS(tnode != NULL); @@ -902,29 +909,39 @@ tmpfs_rename(struct vop_rename_args *v) goto out_locked; } - /* Ensure that we have enough memory to hold the new name, if it - * has to be changed. */ + /* + * Ensure that we have enough memory to hold the new name, if it + * has to be changed. + */ if (fcnp->cn_namelen != tcnp->cn_namelen || bcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fcnp->cn_namelen) != 0) { newname = malloc(tcnp->cn_namelen, M_TMPFSNAME, M_WAITOK); } else newname = NULL; - /* If the node is being moved to another directory, we have to do - * the move. */ + /* + * If the node is being moved to another directory, we have to do + * the move. + */ if (fdnode != tdnode) { - /* In case we are moving a directory, we have to adjust its - * parent to point to the new parent. */ + /* + * In case we are moving a directory, we have to adjust its + * parent to point to the new parent. + */ if (de->td_node->tn_type == VDIR) { struct tmpfs_node *n; - /* Ensure the target directory is not a child of the + /* + * Ensure the target directory is not a child of the * directory being moved. Otherwise, we'd end up - * with stale nodes. */ + * with stale nodes. + */ n = tdnode; - /* TMPFS_LOCK garanties that no nodes are freed while + /* + * TMPFS_LOCK guaranties that no nodes are freed while * traversing the list. Nodes can only be marked as - * removed: tn_parent == NULL. */ + * removed: tn_parent == NULL. + */ TMPFS_LOCK(tmp); TMPFS_NODE_LOCK(n); while (n != n->tn_dir.tn_parent) { @@ -967,9 +984,11 @@ tmpfs_rename(struct vop_rename_args *v) de->td_node->tn_dir.tn_parent = tdnode; TMPFS_NODE_UNLOCK(de->td_node); - /* As a result of changing the target of the '..' + /* + * As a result of changing the target of the '..' * entry, the link count of the source and target - * directories has to be adjusted. */ + * directories has to be adjusted. + */ TMPFS_NODE_LOCK(tdnode); TMPFS_ASSERT_LOCKED(tdnode); tdnode->tn_links++; @@ -982,8 +1001,10 @@ tmpfs_rename(struct vop_rename_args *v) } } - /* Do the move: just remove the entry from the source directory - * and insert it into the target one. */ + /* + * Do the move: just remove the entry from the source directory + * and insert it into the target one. + */ tmpfs_dir_detach(fdvp, de); if (fcnp->cn_flags & DOWHITEOUT) @@ -991,8 +1012,10 @@ tmpfs_rename(struct vop_rename_args *v) if (tcnp->cn_flags & ISWHITEOUT) tmpfs_dir_whiteout_remove(tdvp, tcnp); - /* If the name has changed, we need to make it effective by changing - * it in the directory entry. */ + /* + * If the name has changed, we need to make it effective by changing + * it in the directory entry. + */ if (newname != NULL) { MPASS(tcnp->cn_namelen <= MAXNAMLEN); @@ -1004,8 +1027,10 @@ tmpfs_rename(struct vop_rename_args *v) tdnode->tn_status |= TMPFS_NODE_MODIFIED; } - /* If we are overwriting an entry, we have to remove the old one - * from the target directory. */ + /* + * If we are overwriting an entry, we have to remove the old one + * from the target directory. + */ if (tvp != NULL) { struct tmpfs_dirent *tde; @@ -1013,9 +1038,11 @@ tmpfs_rename(struct vop_rename_args *v) tde = tmpfs_dir_lookup(tdnode, tnode, tcnp); tmpfs_dir_detach(tdvp, tde); - /* Free the directory entry we just deleted. Note that the + /* + * Free the directory entry we just deleted. Note that the * node referred by it will not be removed until the vnode is - * really reclaimed. */ + * really reclaimed. + */ tmpfs_free_dirent(VFS_TO_TMPFS(tvp->v_mount), tde); } @@ -1035,9 +1062,11 @@ out_locked: VOP_UNLOCK(fdvp, 0); out: - /* Release target nodes. */ - /* XXX: I don't understand when tdvp can be the same as tvp, but - * other code takes care of this... */ + /* + * Release target nodes. + * XXX: I don't understand when tdvp can be the same as tvp, but + * other code takes care of this... + */ if (tdvp == tvp) vrele(tdvp); else @@ -1052,7 +1081,7 @@ out: if (mp != NULL) vfs_unbusy(mp); - return error; + return (error); } static int