Commit 41e4ea0b authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba
Browse files

btrfs: make btrfs_readdir_delayed_dir_index() return a bool instead



There's no need to return errors, all we do is return 1 or 0 depending
on whether we should or should not stop iterating over delayed dir
indexes. So change the function to return bool instead of an int.

Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4106eb9b
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1753,7 +1753,7 @@ bool btrfs_should_delete_dir_index(const struct list_head *del_list, u64 index)
/*
 * Read dir info stored in the delayed tree.
 */
int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
bool btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
				     const struct list_head *ins_list)
{
	struct btrfs_dir_item *di;
@@ -1761,7 +1761,6 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
	struct btrfs_key location;
	char *name;
	int name_len;
	int over = 0;
	unsigned char d_type;

	/*
@@ -1770,6 +1769,8 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
	 * directory, nobody can delete any directory indexes now.
	 */
	list_for_each_entry_safe(curr, next, ins_list, readdir_list) {
		bool over;

		list_del(&curr->readdir_list);

		if (curr->index < ctx->pos) {
@@ -1787,17 +1788,16 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
		d_type = fs_ftype_to_dtype(btrfs_dir_flags_to_ftype(di->type));
		btrfs_disk_key_to_cpu(&location, &di->location);

		over = !dir_emit(ctx, name, name_len,
			       location.objectid, d_type);
		over = !dir_emit(ctx, name, name_len, location.objectid, d_type);

		if (refcount_dec_and_test(&curr->refs))
			kfree(curr);

		if (over)
			return 1;
			return true;
		ctx->pos++;
	}
	return 0;
	return false;
}

static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
+2 −2
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ void btrfs_readdir_put_delayed_items(struct btrfs_inode *inode,
				     struct list_head *ins_list,
				     struct list_head *del_list);
bool btrfs_should_delete_dir_index(const struct list_head *del_list, u64 index);
int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
bool btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
				     const struct list_head *ins_list);

/* Used during directory logging. */
+1 −2
Original line number Diff line number Diff line
@@ -6170,8 +6170,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
	if (ret)
		goto nopos;

	ret = btrfs_readdir_delayed_dir_index(ctx, &ins_list);
	if (ret)
	if (btrfs_readdir_delayed_dir_index(ctx, &ins_list))
		goto nopos;

	/*