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 <zab@versity.com>
This commit is contained in:
Zach Brown
2016-04-14 14:32:21 -07:00
parent 1c284af854
commit a2f55f02a1

View File

@@ -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);