On Tue, Aug 27, 2019 at 02:46:30PM +0300, Nikolay Borisov wrote:
> By not opencoding btrfs_find_name_in_backref most of the local variables
> can be removed, this in turn alleviates stack pressure. Additionally,
> backref_in_log is only used as predicate so make it return bool.
While it is used as bool, it returns error numbers so the callsites
should be updated to distinguish errors from true/false.
> Signed-off-by: Nikolay Borisov <nborisov@xxxxxxxx>
> ---
> fs/btrfs/tree-log.c | 57 +++++++++++++--------------------------------
> 1 file changed, 16 insertions(+), 41 deletions(-)
>
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 7d45a4869bc9..070016e023b8 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -938,60 +938,35 @@ static noinline int inode_in_dir(struct btrfs_root *root,
> * want to delete valid links to a file from the subvolume if that
> * link is also in the log.
> */
> -static noinline int backref_in_log(struct btrfs_root *log,
> - struct btrfs_key *key,
> - u64 ref_objectid,
> - const char *name, int namelen)
> +static noinline bool backref_in_log(struct btrfs_root *log,
> + struct btrfs_key *key,
> + u64 ref_objectid,
> + const char *name, int namelen)
> {
> struct btrfs_path *path;
> - struct btrfs_inode_ref *ref;
> - unsigned long ptr;
> - unsigned long ptr_end;
> - unsigned long name_ptr;
> - int found_name_len;
> - int item_size;
> + bool found = false;
> int ret;
> - int match = 0;
>
> path = btrfs_alloc_path();
> if (!path)
> - return -ENOMEM;
> + return false;
There would have to be a very good reasoning behind that but I doubt
it's correct.
> ret = btrfs_search_slot(NULL, log, key, path, 0, 0);
> if (ret != 0)
This should also check for errors, though it's not changed in your
patch.
So if you want to de-opencode btrfs_find_name_in_backref, then fine, but
the other changes should be separate and possibly updating the whole
callchain.