Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 2019 08:49:10 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
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
Message-ID:  <201910100849.x9A8nA3J053683@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910100849.x9A8nA3J053683>