mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 22:22:08 +02:00
btrfs: use btrfs_find_first_inode() at btrfs_prune_dentries()
Currently btrfs_prune_dentries() has open code to find the first inode in a root with a minimum inode number. Remove that code and make it use the helper btrfs_find_first_inode() for that task. Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5e485ac6f0
commit
26c0fae3e7
|
|
@ -4416,64 +4416,26 @@ static noinline int may_destroy_subvol(struct btrfs_root *root)
|
|||
static void btrfs_prune_dentries(struct btrfs_root *root)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
struct rb_node *node;
|
||||
struct rb_node *prev;
|
||||
struct btrfs_inode *entry;
|
||||
struct inode *inode;
|
||||
u64 objectid = 0;
|
||||
struct btrfs_inode *inode;
|
||||
u64 min_ino = 0;
|
||||
|
||||
if (!BTRFS_FS_ERROR(fs_info))
|
||||
WARN_ON(btrfs_root_refs(&root->root_item) != 0);
|
||||
|
||||
spin_lock(&root->inode_lock);
|
||||
again:
|
||||
node = root->inode_tree.rb_node;
|
||||
prev = NULL;
|
||||
while (node) {
|
||||
prev = node;
|
||||
entry = rb_entry(node, struct btrfs_inode, rb_node);
|
||||
inode = btrfs_find_first_inode(root, min_ino);
|
||||
while (inode) {
|
||||
if (atomic_read(&inode->vfs_inode.i_count) > 1)
|
||||
d_prune_aliases(&inode->vfs_inode);
|
||||
|
||||
if (objectid < btrfs_ino(entry))
|
||||
node = node->rb_left;
|
||||
else if (objectid > btrfs_ino(entry))
|
||||
node = node->rb_right;
|
||||
else
|
||||
break;
|
||||
min_ino = btrfs_ino(inode) + 1;
|
||||
/*
|
||||
* btrfs_drop_inode() will have it removed from the inode
|
||||
* cache when its usage count hits zero.
|
||||
*/
|
||||
iput(&inode->vfs_inode);
|
||||
cond_resched();
|
||||
inode = btrfs_find_first_inode(root, min_ino);
|
||||
}
|
||||
if (!node) {
|
||||
while (prev) {
|
||||
entry = rb_entry(prev, struct btrfs_inode, rb_node);
|
||||
if (objectid <= btrfs_ino(entry)) {
|
||||
node = prev;
|
||||
break;
|
||||
}
|
||||
prev = rb_next(prev);
|
||||
}
|
||||
}
|
||||
while (node) {
|
||||
entry = rb_entry(node, struct btrfs_inode, rb_node);
|
||||
objectid = btrfs_ino(entry) + 1;
|
||||
inode = igrab(&entry->vfs_inode);
|
||||
if (inode) {
|
||||
spin_unlock(&root->inode_lock);
|
||||
if (atomic_read(&inode->i_count) > 1)
|
||||
d_prune_aliases(inode);
|
||||
/*
|
||||
* btrfs_drop_inode will have it removed from the inode
|
||||
* cache when its usage count hits zero.
|
||||
*/
|
||||
iput(inode);
|
||||
cond_resched();
|
||||
spin_lock(&root->inode_lock);
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (cond_resched_lock(&root->inode_lock))
|
||||
goto again;
|
||||
|
||||
node = rb_next(node);
|
||||
}
|
||||
spin_unlock(&root->inode_lock);
|
||||
}
|
||||
|
||||
int btrfs_delete_subvolume(struct btrfs_inode *dir, struct dentry *dentry)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user