+static int del_dir_item(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct radix_tree_root *radix,
+ unsigned long radix_index,
+ struct btrfs_path *path)
+{
+ int ret;
+ unsigned long *ptr;
+ u64 file_objectid;
+ struct btrfs_dir_item *di;
+
+ /* find the inode number of the file */
+ di = btrfs_item_ptr(&path->nodes[0]->leaf, path->slots[0],
+ struct btrfs_dir_item);
+ file_objectid = btrfs_disk_key_objectid(&di->location);
+
+ /* delete the directory item */
+ ret = btrfs_del_item(trans, root, path);
+ if (ret)
+ goto out_release;
+ btrfs_release_path(path);
+
+ /* delete the inode */
+ btrfs_init_path(path);
+ ret = btrfs_lookup_inode(trans, root, path, file_objectid, -1);
+ if (ret)
+ goto out_release;
+ ret = btrfs_del_item(trans, root, path);
+ if (ret)
+ goto out_release;
+ btrfs_release_path(path);
+
+ if (root->fs_info->last_inode_alloc > file_objectid)
+ root->fs_info->last_inode_alloc = file_objectid;
+ ptr = radix_tree_delete(radix, radix_index);
+ if (!ptr) {
+ ret = -5555;
+ goto out;
+ }
+ return 0;
+out_release:
+ btrfs_release_path(path);
+out:
+ printf("failed to delete %lu %d\n", radix_index, ret);
+ return ret;
+}
+
+static int del_one(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+ struct radix_tree_root *radix)