mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 06:31:52 +00:00
btrfs: send: directly return from did_overwrite_ref() and simplify it
There are no resources to release before did_overwrite_ref() returns, so we don't really need the 'out' label and jumping to it when conditions are met - we can directly return and get rid of the label and jumps. Also we can deal with -ENOENT and other errors in a single if-else logic, as it's more straightforward. This helps the next patch in the series to be more simple as well. This patch is part of a larger patchset and the changelog of the last patch in the series contains a sample performance test and results. The patches that comprise the patchset are the following: btrfs: send: directly return from did_overwrite_ref() and simplify it btrfs: send: avoid unnecessary generation search at did_overwrite_ref() btrfs: send: directly return from will_overwrite_ref() and simplify it btrfs: send: avoid extra b+tree searches when checking reference overrides btrfs: send: remove send_progress argument from can_rmdir() btrfs: send: avoid duplicated orphan dir allocation and initialization btrfs: send: avoid unnecessary orphan dir rbtree search at can_rmdir() btrfs: send: reduce searches on parent root when checking if dir can be removed btrfs: send: iterate waiting dir move rbtree only once when processing refs btrfs: send: initialize all the red black trees earlier btrfs: send: genericize the backref cache to allow it to be reused btrfs: adapt lru cache to allow for 64 bits keys on 32 bits systems btrfs: send: cache information about created directories btrfs: allow a generation number to be associated with lru cache entries btrfs: add an api to delete a specific entry from the lru cache btrfs: send: use the lru cache to implement the name cache btrfs: send: update size of roots array for backref cache entries btrfs: send: cache utimes operations for directories if possible Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b7625f461d
commit
e739ba307f
@ -2192,48 +2192,44 @@ static int did_overwrite_ref(struct send_ctx *sctx,
|
||||
u64 ino, u64 ino_gen,
|
||||
const char *name, int name_len)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
u64 gen;
|
||||
u64 ow_inode;
|
||||
|
||||
if (!sctx->parent_root)
|
||||
goto out;
|
||||
return 0;
|
||||
|
||||
ret = is_inode_existent(sctx, dir, dir_gen);
|
||||
if (ret <= 0)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
if (dir != BTRFS_FIRST_FREE_OBJECTID) {
|
||||
ret = get_inode_gen(sctx->send_root, dir, &gen);
|
||||
if (ret < 0 && ret != -ENOENT)
|
||||
goto out;
|
||||
if (ret) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
if (ret == -ENOENT)
|
||||
return 0;
|
||||
else if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (gen != dir_gen)
|
||||
goto out;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check if the ref was overwritten by another ref */
|
||||
ret = lookup_dir_item_inode(sctx->send_root, dir, name, name_len,
|
||||
&ow_inode);
|
||||
if (ret < 0 && ret != -ENOENT)
|
||||
goto out;
|
||||
if (ret) {
|
||||
if (ret == -ENOENT) {
|
||||
/* was never and will never be overwritten */
|
||||
ret = 0;
|
||||
goto out;
|
||||
return 0;
|
||||
} else if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = get_inode_gen(sctx->send_root, ow_inode, &gen);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
if (ow_inode == ino && gen == ino_gen) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
if (ow_inode == ino && gen == ino_gen)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* We know that it is or will be overwritten. Check this now.
|
||||
@ -2244,12 +2240,9 @@ static int did_overwrite_ref(struct send_ctx *sctx,
|
||||
if ((ow_inode < sctx->send_progress) ||
|
||||
(ino != sctx->cur_ino && ow_inode == sctx->cur_ino &&
|
||||
gen == sctx->cur_inode_gen))
|
||||
ret = 1;
|
||||
else
|
||||
ret = 0;
|
||||
return 1;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user