From a2f55f02a18aa0b106c7623e6a636e8ede3c75cf Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 14 Apr 2016 14:32:21 -0700 Subject: [PATCH] scoutfs: avoid stale btree block pointer The btree walk was storing a pointer to the current btree block that it was working on. It later used this when the walk continues and the block becomes a parent. But it didn't update this pointer if splitting changed the block to traverse. By removing this pointer and using the block data pointers directly we remove the risk of the pointer going stale. Signed-off-by: Zach Brown --- kmod/src/btree.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kmod/src/btree.c b/kmod/src/btree.c index 60f63622..069a50bf 100644 --- a/kmod/src/btree.c +++ b/kmod/src/btree.c @@ -621,7 +621,6 @@ static struct scoutfs_block *btree_walk(struct super_block *sb, { struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); struct scoutfs_btree_block *parent = NULL; - struct scoutfs_btree_block *bt; struct scoutfs_btree_root *root; struct scoutfs_block *par_bl = NULL; struct scoutfs_block *bl = NULL; @@ -659,10 +658,9 @@ static struct scoutfs_block *btree_walk(struct super_block *sb, } if (IS_ERR(bl)) break; - bt = bl->data; /* see if a search needs to move to the next parent ref */ - if (next_leaf(parent, &item, bt, op, level, key)) { + if (next_leaf(parent, &item, bl->data, op, level, key)) { ref = (void *)item->val; level++; scoutfs_put_block(bl); @@ -686,7 +684,7 @@ static struct scoutfs_block *btree_walk(struct super_block *sb, unlock_block(sbi, par_bl, dirty); scoutfs_put_block(par_bl); par_bl = bl; - parent = bt; + parent = par_bl->data; /* there should always be a parent item */ item = bt_after(parent, key);