All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Khlebnikov <khlebnikov@openvz.org>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: "Ondrej Zary" <linux@rainbow-software.org>,
	"Hugh Dickins" <hughd@google.com>,
	"Kernel development list" <linux-kernel@vger.kernel.org>,
	"Dave Jones" <davej@redhat.com>,
	"Hans de Bruin" <jmdebruin@xmsnet.nl>,
	"Linux NFS mailing list" <linux-nfs@vger.kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Toralf Förster" <toralf.foerster@gmx.de>,
	"richard -rw- weinberger" <richard.weinberger@gmail.com>
Subject: Re: [bisected commit 0fc9d10] NFS-server corruption with 3.4
Date: Tue, 05 Jun 2012 19:59:10 +0400	[thread overview]
Message-ID: <4FCE2CCE.9000900@openvz.org> (raw)
In-Reply-To: <4FCE2256.7010804@openvz.org>

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

Proper fix in attachment.

Konstantin Khlebnikov wrote:
> OGAWA Hirofumi wrote:
>> Konstantin Khlebnikov<khlebnikov@openvz.org>   writes:
>>
>>> Hmm, very interesting!
>>> Please try this patch, it must fix the problem and print some numbers to debug.
>>>
>>
>> I think the bug is in radix_tree_for_each_contig().
>>
>> radix_tree_next_slot() returns NULL if the slot was NULL (i.e. there is
>> hole). But, slot == NULL is not meaning to stop iterate here. Actually,
>> if slot is NULL, it gets next chunk.
>>
>> Bang.
>
> Yeah, you are right, I already found this too.
> Currently I think how to fix this more accurately...
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


[-- Attachment #2: radix-tree-fix-contiguous-iterator --]
[-- Type: text/plain, Size: 1868 bytes --]

radix-tree: fix contiguous iterator

From: Konstantin Khlebnikov <khlebnikov@openvz.org>

This patch fixes bug in macro radix_tree_for_each_contig().
If radix_tree_next_slot() sees NULL in next slot it returns NULL, but following
radix_tree_next_chunk() switches iterating into next chunk. As result iterating
becomes non-contiguous and breaks vfs "splice" and all its users.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Reported-and-bisected-by: Hans de Bruin <jmdebruin@xmsnet.nl>
Reported-and-bisected-by: Ondrej Zary <linux@rainbow-software.org>
Reported-and-bisected-by: Toralf Förster <toralf.foerster@gmx.de>
---
 include/linux/radix-tree.h |    5 ++++-
 lib/radix-tree.c           |    3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 0d04cd6..ffc444c 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -368,8 +368,11 @@ radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
 			iter->index++;
 			if (likely(*slot))
 				return slot;
-			if (flags & RADIX_TREE_ITER_CONTIG)
+			if (flags & RADIX_TREE_ITER_CONTIG) {
+				/* forbid switching to the next chunk */
+				iter->next_index = 0;
 				break;
+			}
 		}
 	}
 	return NULL;
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 86516f5..3ac50dc 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -673,6 +673,9 @@ void **radix_tree_next_chunk(struct radix_tree_root *root,
 	 * during iterating; it can be zero only at the beginning.
 	 * And we cannot overflow iter->next_index in a single step,
 	 * because RADIX_TREE_MAP_SHIFT < BITS_PER_LONG.
+	 *
+	 * This condition also used by radix_tree_next_slot() to stop
+	 * contiguous iterating, and forbid swithing to the next chunk.
 	 */
 	index = iter->next_index;
 	if (!index && iter->index)

  reply	other threads:[~2012-06-05 15:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05  9:16 [bisected] NFS corruption with 3.4 Ondrej Zary
2012-06-05 12:45 ` Dave Jones
2012-06-05 13:45   ` Holger Hoffstaette
2012-06-05 14:11   ` Ondrej Zary
2012-06-05 13:32 ` [bisected commit 0fc9d10] NFS-server " Konstantin Khlebnikov
2012-06-05 14:20   ` Ondrej Zary
2012-06-05 14:52     ` Konstantin Khlebnikov
2012-06-05 15:07       ` OGAWA Hirofumi
2012-06-05 15:14         ` Konstantin Khlebnikov
2012-06-05 15:59           ` Konstantin Khlebnikov [this message]
2012-06-05 16:18             ` OGAWA Hirofumi
2012-06-05 16:39               ` Konstantin Khlebnikov
2012-06-05 22:30                 ` Hans de Bruin
2012-06-06 10:54                   ` Konstantin Khlebnikov
2012-06-05 17:03             ` Toralf Förster
2012-06-05 17:17               ` Konstantin Khlebnikov
2012-06-06  8:55             ` Ondrej Zary
2012-06-05 14:21   ` Toralf Förster

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=4FCE2CCE.9000900@openvz.org \
    --to=khlebnikov@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=hughd@google.com \
    --cc=jmdebruin@xmsnet.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=richard.weinberger@gmail.com \
    --cc=toralf.foerster@gmx.de \
    /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.