• Y
    Btrfs: fix locking issue in btrfs_find_next_key · 33c66f43
    Yan Zheng 提交于
    When walking up the tree, btrfs_find_next_key assumes the upper level tree
    block is properly locked. This isn't always true even path->keep_locks is 1.
    This is because btrfs_find_next_key may advance path->slots[] several times
    instead of only once.
    
    When 'path->slots[level] >= btrfs_header_nritems(path->nodes[level])' is found,
    we can't guarantee the original value of 'path->slots[level]' is
    'btrfs_header_nritems(path->nodes[level]) - 1'. If it's not, the tree block at
    'level + 1' isn't locked.
    
    This patch fixes the issue by explicitly checking the locking state,
    re-searching the tree if it's not locked.
    Signed-off-by: NYan Zheng <zheng.yan@oracle.com>
    Signed-off-by: NChris Mason <chris.mason@oracle.com>
    33c66f43
ctree.c 109.5 KB