提交 a176affe 编写于 作者: F Filipe Manana 提交者: David Sterba

btrfs: assert that delayed item is a dir index item when adding it

All delayed items are for dir index items, we don't support any other item
types at the moment. So simplify __btrfs_add_delayed_item() and add an
assertion for checking the item's key type. This also allows the next
change to be simpler and avoid to check key types. In case we add support
for different item types in the future, then we'll hit the assertion
during development and be able to adjust any code that is assuming delayed
items are always associated to dir index items.
Reviewed-by: NNikolay Borisov <nborisov@suse.com>
Signed-off-by: NFilipe Manana <fdmanana@suse.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 4bd02d90
...@@ -438,10 +438,12 @@ static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node, ...@@ -438,10 +438,12 @@ static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node,
ins->delayed_node = delayed_node; ins->delayed_node = delayed_node;
ins->ins_or_del = action; ins->ins_or_del = action;
if (ins->key.type == BTRFS_DIR_INDEX_KEY && /* Delayed items are always for dir index items. */
action == BTRFS_DELAYED_INSERTION_ITEM && ASSERT(ins->key.type == BTRFS_DIR_INDEX_KEY);
if (action == BTRFS_DELAYED_INSERTION_ITEM &&
ins->key.offset >= delayed_node->index_cnt) ins->key.offset >= delayed_node->index_cnt)
delayed_node->index_cnt = ins->key.offset + 1; delayed_node->index_cnt = ins->key.offset + 1;
delayed_node->count++; delayed_node->count++;
atomic_inc(&delayed_node->root->fs_info->delayed_root->items); atomic_inc(&delayed_node->root->fs_info->delayed_root->items);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册