All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Mahoney <jeffm@suse.com>
To: ReiserFS Development List <reiserfs-devel@vger.kernel.org>
Cc: Jan Kara <jack@suse.cz>, Dave Jones <davej@redhat.com>
Subject: [patch 12/29] reiserfs: balance_leaf refactor, reformat balance_leaf comments
Date: Wed, 23 Apr 2014 10:00:45 -0400	[thread overview]
Message-ID: <20140423151140.665133094@suse.com> (raw)
In-Reply-To: 20140423140033.704113918@suse.com

[-- Attachment #1: reiserfs/reiserfs-balance_leaf-refactor-reformat-balance_leaf-comments --]
[-- Type: text/plain, Size: 5272 bytes --]

The comments in balance_leaf are as bad as the code. This patch shifts
them around to fit in 80 columns and be easier to read.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/reiserfs/do_balan.c |   84 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 52 insertions(+), 32 deletions(-)

--- a/fs/reiserfs/do_balan.c
+++ b/fs/reiserfs/do_balan.c
@@ -290,31 +290,43 @@ static int balance_leaf_when_delete(stru
 	return 0;
 }
 
-static int balance_leaf(struct tree_balance *tb, struct item_head *ih,	/* item header of inserted item (this is on little endian) */
-			const char *body,	/* body  of inserted item or bytes to paste */
-			int flag,	/* i - insert, d - delete, c - cut, p - paste
-					   (see comment to do_balance) */
-			struct item_head *insert_key,	/* in our processing of one level we sometimes determine what
-							   must be inserted into the next higher level.  This insertion
-							   consists of a key or two keys and their corresponding
-							   pointers */
-			struct buffer_head **insert_ptr	/* inserted node-ptrs for the next level */
-    )
+/**
+ * balance_leaf - reiserfs tree balancing algorithm
+ * @tb: tree balance state
+ * @ih: item header of inserted item (little endian)
+ * @body: body of inserted item or bytes to paste
+ * @flag: i - insert, d - delete, c - cut, p - paste (see do_balance)
+ * passed back:
+ * @insert_key: key to insert new nodes
+ * @insert_ptr: array of nodes to insert at the next level
+ *
+ * In our processing of one level we sometimes determine what must be
+ * inserted into the next higher level.  This insertion consists of a
+ * key or two keys and their corresponding pointers.
+ */
+static int balance_leaf(struct tree_balance *tb, struct item_head *ih,
+			const char *body, int flag,
+			struct item_head *insert_key,
+			struct buffer_head **insert_ptr)
 {
 	struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
-	int item_pos = PATH_LAST_POSITION(tb->tb_path);	/*  index into the array of item headers in S[0]
-							   of the affected item */
+	/* index into the array of item headers in S[0] of the affected item */
+	int item_pos = PATH_LAST_POSITION(tb->tb_path);
 	struct buffer_info bi;
-	struct buffer_head *S_new[2];	/* new nodes allocated to hold what could not fit into S */
-	int snum[2];		/* number of items that will be placed
-				   into S_new (includes partially shifted
-				   items) */
-	int sbytes[2];		/* if an item is partially shifted into S_new then
-				   if it is a directory item
-				   it is the number of entries from the item that are shifted into S_new
-				   else
-				   it is the number of bytes from the item that are shifted into S_new
-				 */
+	/* new nodes allocated to hold what could not fit into S */
+	struct buffer_head *S_new[2];
+	/*
+	 * number of items that will be placed into S_new
+	 * (includes partially shifted items)
+	 */
+	int snum[2];
+	/*
+	 * if an item is partially shifted into S_new then if it is a
+	 * directory item it is the number of entries from the item that
+	 * are shifted into S_new else it is the number of bytes from
+	 * the item that are shifted into S_new
+	 */
+	int sbytes[2];
 	int n, i;
 	int ret_val;
 	int pos_in_item;
@@ -331,8 +343,10 @@ static int balance_leaf(struct tree_bala
 		zeros_num = ih_item_len(ih);
 
 	pos_in_item = tb->tb_path->pos_in_item;
-	/* for indirect item pos_in_item is measured in unformatted node
-	   pointers. Recalculate to bytes */
+	/*
+	 * for indirect item pos_in_item is measured in unformatted node
+	 * pointers. Recalculate to bytes
+	 */
 	if (flag != M_INSERT
 	    && is_indirect_le_ih(item_head(tbS0, item_pos)))
 		pos_in_item *= UNFM_P_SIZE;
@@ -792,16 +806,20 @@ static int balance_leaf(struct tree_bala
 	RFALSE(tb->blknum[0] < 0,
 	       "PAP-12185: blknum can not be %d. It must be >= 0", tb->blknum[0]);
 
-	/* if while adding to a node we discover that it is possible to split
-	   it in two, and merge the left part into the left neighbor and the
-	   right part into the right neighbor, eliminating the node */
+	/*
+	 * if while adding to a node we discover that it is possible to split
+	 * it in two, and merge the left part into the left neighbor and the
+	 * right part into the right neighbor, eliminating the node
+	 */
 	if (tb->blknum[0] == 0) {	/* node S[0] is empty now */
 
 		RFALSE(!tb->lnum[0] || !tb->rnum[0],
 		       "PAP-12190: lnum and rnum must not be zero");
-		/* if insertion was done before 0-th position in R[0], right
-		   delimiting key of the tb->L[0]'s and left delimiting key are
-		   not set correctly */
+		/*
+		 * if insertion was done before 0-th position in R[0], right
+		 * delimiting key of the tb->L[0]'s and left delimiting key are
+		 * not set correctly
+		 */
 		if (tb->CFL[0]) {
 			if (!tb->CFR[0])
 				reiserfs_panic(tb->tb_sb, "vs-12195",
@@ -1159,9 +1177,11 @@ static int balance_leaf(struct tree_bala
 			       "PAP-12290", "insert_size is still not 0 (%d)",
 			       tb->insert_size[0]);
 	}
-#endif				/* CONFIG_REISERFS_CHECK */
+#endif
+
+	/* Leaf level of the tree is balanced (end of balance_leaf) */
 	return 0;
-}				/* Leaf level of the tree is balanced (end of balance_leaf) */
+}
 
 /* Make empty node */
 void make_empty_node(struct buffer_info *bi)



  parent reply	other threads:[~2014-04-23 14:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23 14:00 [patch 00/29] reiserfs cleanup patchset Jeff Mahoney
2014-04-23 14:00 ` [patch 01/29] reiserfs: use per-fs commit workqueues Jeff Mahoney
2014-04-23 14:00 ` [patch 02/29] reiserfs: cleanup, rename key and item accessors to more friendly names Jeff Mahoney
2014-04-23 14:00 ` [patch 04/29] reiserfs: cleanup, remove nblocks argument from journal_end Jeff Mahoney
2014-04-23 14:00 ` [patch 05/29] reiserfs: cleanup, remove sb " Jeff Mahoney
2014-04-23 14:00 ` [patch 06/29] reiserfs: cleanup, remove sb argument from journal_mark_dirty Jeff Mahoney
2014-04-23 14:00 ` [patch 07/29] reiserfs: cleanup, remove blocks arg from journal_join Jeff Mahoney
2014-04-23 14:00 ` [patch 08/29] reiserfs: cleanup, remove leading whitespace from labels Jeff Mahoney
2014-04-23 14:00 ` [patch 09/29] reiserfs: cleanup, remove unnecessary parens Jeff Mahoney
2014-04-23 14:00 ` [patch 10/29] reiserfs: cleanup, remove unnecessary parens in dirent creation Jeff Mahoney
2014-04-23 14:00 ` [patch 11/29] reiserfs: cleanup, make hash detection saner Jeff Mahoney
2014-05-06 21:27   ` Jan Kara
2014-05-07 12:16     ` Jeff Mahoney
2014-05-07 15:50       ` Jan Kara
2014-04-23 14:00 ` Jeff Mahoney [this message]
2014-04-23 14:00 ` [patch 13/29] reiserfs: balance_leaf refactor, move state variables into tree_balance Jeff Mahoney
2014-04-23 14:00 ` [patch 14/29] reiserfs: balance_leaf refactor, pull out balance_leaf_insert_left Jeff Mahoney
2014-04-23 14:00 ` [patch 15/29] reiserfs: balance_leaf refactor, pull out balance_leaf_paste_left Jeff Mahoney
2014-04-23 14:00 ` [patch 16/29] reiserfs: balance_leaf refactor, pull out balance_leaf_insert_right Jeff Mahoney
2014-04-23 14:00 ` [patch 17/29] reiserfs: balance_leaf refactor, pull out balance_leaf_paste_right Jeff Mahoney
2014-04-23 14:00 ` [patch 18/29] reiserfs: balance_leaf refactor, pull out balance_leaf_new_nodes_insert Jeff Mahoney
2014-04-23 14:00 ` [patch 19/29] reiserfs: balance_leaf refactor, pull out balance_leaf_new_nodes_paste Jeff Mahoney
2014-04-23 14:00 ` [patch 20/29] reiserfs: balance_leaf refactor pull out balance_leaf_finish_node_insert Jeff Mahoney
2014-04-23 14:00 ` [patch 21/29] reiserfs: balance_leaf refactor, pull out balance_leaf_finish_node_paste Jeff Mahoney
2014-04-23 14:00 ` [patch 22/29] reiserfs: balance_leaf refactor, pull out balance_leaf{left, right, new_nodes, finish_node} Jeff Mahoney
2014-04-23 14:00 ` [patch 23/29] reiserfs: balance_leaf refactor, format balance_leaf_insert_left Jeff Mahoney
2014-04-23 14:00 ` [patch 24/29] reiserfs: balance_leaf refactor, format balance_leaf_paste_left Jeff Mahoney
2014-04-23 14:00 ` [patch 25/29] reiserfs: balance_leaf refactor, format balance_leaf_insert_right Jeff Mahoney
2014-04-23 14:00 ` [patch 26/29] reiserfs: balance_leaf refactor, format balance_leaf_paste_right Jeff Mahoney
2014-04-23 14:01 ` [patch 27/29] reiserfs: balance_leaf refactor, format balance_leaf_new_nodes_paste Jeff Mahoney
2014-04-23 14:01 ` [patch 28/29] reiserfs: balance_leaf refactor, format balance_leaf_finish_node Jeff Mahoney
2014-04-23 14:01 ` [patch 29/29] reiserfs: balance_leaf refactor, split up balance_leaf_when_delete Jeff Mahoney
2014-04-26  3:46 ` [patch 00/29] reiserfs cleanup patchset doiggl
2014-04-26 15:14   ` Jeff Mahoney
2014-05-16 10:47     ` doiggl
2014-05-22  8:24       ` doiggl
2014-05-22 13:51         ` Jeff Mahoney
2014-05-26  4:12           ` doiggl
2014-05-26 18:24             ` Jeff Mahoney
2014-06-12 14:31           ` doiggl
2014-06-12 14:38             ` Jeff Mahoney
2014-06-13  4:20               ` doiggl
2014-06-13  4:25                 ` Jeff Mahoney
2014-06-13 15:09                   ` Jeff Mahoney
2014-05-13 14:13 ` Jan Kara
2014-05-13 14:15   ` Jeff Mahoney
2014-05-27  9:23 ` doiggl
2014-05-27 12:36   ` Jeff Mahoney
2014-06-05  3:21     ` Jose R R
     [not found]       ` <47aabceb9575031270f0940059da157c@mail.velocitynet.com.au>
2014-06-26 14:27         ` [patch 00/29] reiserfs cleanup patchset - 03/29 attached [reiserfs: cleanup, reformat comments to normal kernel style] Jose R R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140423151140.665133094@suse.com \
    --to=jeffm@suse.com \
    --cc=davej@redhat.com \
    --cc=jack@suse.cz \
    --cc=reiserfs-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.