All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rbtree: fix jffs2 build issue due to renamed __rb_parent_color field
@ 2012-07-18 11:31 ` Michel Lespinasse
  0 siblings, 0 replies; 4+ messages in thread
From: Michel Lespinasse @ 2012-07-18 11:31 UTC (permalink / raw)
  To: aarcange, dwmw2, riel, peterz, daniel.santos, axboe, ebiederm, akpm
  Cc: linux-mm, linux-kernel, torvalds

When renaming rb_parent_color into __rb_parent_color to highlight the
fact that people aren't expected to directly manipulate this, I broke
the jffs2 build which was doing such direct manipulation in
fs/jffs2/readinode.c . Fix this and add a comment explaining why
this direct use is safe here.

Signed-off-by: Michel Lespinasse <walken@google.com>
---
 fs/jffs2/readinode.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index dc0437e..b00fc50 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -395,7 +395,9 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c,
 
 /* Trivial function to remove the last node in the tree. Which by definition
    has no right-hand -- so can be removed just by making its only child (if
-   any) take its place under its parent. */
+   any) take its place under its parent. Note that we don't maintain the
+   usual rbtree invariants as there won't be further insert or erase
+   operations on the tree.*/
 static void eat_last(struct rb_root *root, struct rb_node *node)
 {
 	struct rb_node *parent = rb_parent(node);
@@ -414,7 +416,7 @@ static void eat_last(struct rb_root *root, struct rb_node *node)
 	*link = node->rb_left;
 	/* Colour doesn't matter now. Only the parent pointer. */
 	if (node->rb_left)
-		node->rb_left->rb_parent_color = node->rb_parent_color;
+		node->rb_left->__rb_parent_color = node->__rb_parent_color;
 }
 
 /* We put this in reverse order, so we can just use eat_last */
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] rbtree: fix jffs2 build issue due to renamed __rb_parent_color field
@ 2012-07-18 11:31 ` Michel Lespinasse
  0 siblings, 0 replies; 4+ messages in thread
From: Michel Lespinasse @ 2012-07-18 11:31 UTC (permalink / raw)
  To: aarcange, dwmw2, riel, peterz, daniel.santos, axboe, ebiederm, akpm
  Cc: linux-mm, linux-kernel, torvalds

When renaming rb_parent_color into __rb_parent_color to highlight the
fact that people aren't expected to directly manipulate this, I broke
the jffs2 build which was doing such direct manipulation in
fs/jffs2/readinode.c . Fix this and add a comment explaining why
this direct use is safe here.

Signed-off-by: Michel Lespinasse <walken@google.com>
---
 fs/jffs2/readinode.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index dc0437e..b00fc50 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -395,7 +395,9 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c,
 
 /* Trivial function to remove the last node in the tree. Which by definition
    has no right-hand -- so can be removed just by making its only child (if
-   any) take its place under its parent. */
+   any) take its place under its parent. Note that we don't maintain the
+   usual rbtree invariants as there won't be further insert or erase
+   operations on the tree.*/
 static void eat_last(struct rb_root *root, struct rb_node *node)
 {
 	struct rb_node *parent = rb_parent(node);
@@ -414,7 +416,7 @@ static void eat_last(struct rb_root *root, struct rb_node *node)
 	*link = node->rb_left;
 	/* Colour doesn't matter now. Only the parent pointer. */
 	if (node->rb_left)
-		node->rb_left->rb_parent_color = node->rb_parent_color;
+		node->rb_left->__rb_parent_color = node->__rb_parent_color;
 }
 
 /* We put this in reverse order, so we can just use eat_last */
-- 
1.7.7.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rbtree: fix jffs2 build issue due to renamed __rb_parent_color field
  2012-07-18 11:31 ` Michel Lespinasse
  (?)
@ 2012-07-18 11:40 ` David Woodhouse
  2012-07-18 15:16   ` David Woodhouse
  -1 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2012-07-18 11:40 UTC (permalink / raw)
  To: Michel Lespinasse
  Cc: aarcange, riel, peterz, daniel.santos, axboe, ebiederm, akpm,
	linux-mm, linux-kernel, torvalds

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

On Wed, 2012-07-18 at 04:31 -0700, Michel Lespinasse wrote:
> Fix this and add a comment explaining why this direct use is safe
> here.

Note that there was already a comment which was *intended* to have that
effect, right before the assignment:

        /* Colour doesn't matter now. Only the parent pointer. */

If you're going to make that comment redundant, you might as well remove
it. And you might as well say that the trees are being *destroyed*
(consumed) at this point, rather than just that there will be no further
insert or erase operations.

-- 
dwmw2

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6171 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] rbtree: fix jffs2 build issue due to renamed __rb_parent_color field
  2012-07-18 11:40 ` David Woodhouse
@ 2012-07-18 15:16   ` David Woodhouse
  0 siblings, 0 replies; 4+ messages in thread
From: David Woodhouse @ 2012-07-18 15:16 UTC (permalink / raw)
  To: Michel Lespinasse
  Cc: aarcange, riel, peterz, daniel.santos, axboe, ebiederm, akpm,
	linux-mm, linux-kernel, torvalds

[-- Attachment #1: Type: text/plain, Size: 2466 bytes --]

... and clean up the comments to better explain why it's acceptable to
do it this way instead of using rb_erase() "properly".

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
On Wed, 2012-07-18 at 12:40 +0100, David Woodhouse wrote:
> If you're going to make that comment redundant, you might as well remove
> it. And you might as well say that the trees are being *destroyed*
> (consumed) at this point, rather than just that there will be no further
> insert or erase operations. 

The comment on ver_insert() confused me too while I was looking at this,
so I've improved that as well.

A quick and dirty benchmark shows about a 10% performance improvement
when mounting a RAM-backed JFFS2 file system on Westmere. Thanks.

Acked-By: David Woodhouse <David.Woodhouse@intel.com> for the rest of
the series.

diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 1ea349f..ae81b01 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -394,8 +394,11 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c,
 }
 
 /* Trivial function to remove the last node in the tree. Which by definition
-   has no right-hand -- so can be removed just by making its only child (if
-   any) take its place under its parent. */
+   has no right-hand child — so can be removed just by making its left-hand
+   child (if any) take its place under its parent. Since this is only done
+   when we're consuming the whole tree, there's no need to use rb_erase()
+   and let it worry about adjusting colours and balancing the tree. That
+   would just be a waste of time. */
 static void eat_last(struct rb_root *root, struct rb_node *node)
 {
 	struct rb_node *parent = rb_parent(node);
@@ -412,12 +415,12 @@ static void eat_last(struct rb_root *root, struct rb_node *node)
 		link = &parent->rb_right;
 
 	*link = node->rb_left;
-	/* Colour doesn't matter now. Only the parent pointer. */
 	if (node->rb_left)
-		node->rb_left->rb_parent_color = node->rb_parent_color;
+		node->rb_left->__rb_parent_color = node->__rb_parent_color;
 }
 
-/* We put this in reverse order, so we can just use eat_last */
+/* We put the version tree in reverse order, so we can use the same eat_last()
+   function that we use to consume the tmpnode tree (tn_root). */
 static void ver_insert(struct rb_root *ver_root, struct jffs2_tmp_dnode_info *tn)
 {
 	struct rb_node **link = &ver_root->rb_node;

-- 
dwmw2

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6171 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-18 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-18 11:31 [PATCH] rbtree: fix jffs2 build issue due to renamed __rb_parent_color field Michel Lespinasse
2012-07-18 11:31 ` Michel Lespinasse
2012-07-18 11:40 ` David Woodhouse
2012-07-18 15:16   ` David Woodhouse

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.