Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1391954

[PATCH mmotm] radix-tree: rewrite radix_tree_locate_item fix

From Hugh Dickins <hughd@google.com>
Newsgroups linux.kernel
Subject [PATCH mmotm] radix-tree: rewrite radix_tree_locate_item fix
Date 2016-05-02 06:20 +0200
Message-ID <ruduW-4Wb-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


radix_tree_locate_item() is often returning the wrong index, causing
swapoff of shmem to hang because it cannot find the swap entry there.
__locate()'s use of base is bogus, it adds an offset twice into index.

Signed-off-by: Hugh Dickins <hughd@google.com>
---
Fix to radix-tree-rewrite-radix_tree_locate_item.patch

 lib/radix-tree.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- 4.6-rc5-mm1/lib/radix-tree.c	2016-04-30 22:55:06.067184898 -0700
+++ linux/lib/radix-tree.c	2016-05-01 18:52:06.668085420 -0700
@@ -1254,15 +1254,14 @@ struct locate_info {
 static unsigned long __locate(struct radix_tree_node *slot, void *item,
 			      unsigned long index, struct locate_info *info)
 {
-	unsigned long base, i;
+	unsigned long i;
 
 	do {
 		unsigned int shift = slot->shift;
-		base = index & ~((1UL << shift) - 1);
 
 		for (i = (index >> shift) & RADIX_TREE_MAP_MASK;
 		     i < RADIX_TREE_MAP_SIZE;
-		     i++, index = base + (i << shift)) {
+		     i++, index += (1UL << shift)) {
 			struct radix_tree_node *node =
 					rcu_dereference_raw(slot->slots[i]);
 			if (node == RADIX_TREE_RETRY)

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH mmotm] radix-tree: rewrite radix_tree_locate_item fix Hugh Dickins <hughd@google.com> - 2016-05-02 06:20 +0200
  [PATCH] radix-tree: add test for radix_tree_locate_item() Ross Zwisler <ross.zwisler@linux.intel.com> - 2016-05-03 22:30 +0200
  Re: [PATCH mmotm] radix-tree: rewrite radix_tree_locate_item fix Ross Zwisler <ross.zwisler@linux.intel.com> - 2016-05-03 22:30 +0200

csiph-web