btrfs: use btrfs_for_each_slot in btrfs_real_readdir
This function can be simplified by refactoring to use the new iterator macro. No functional changes. Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com> Signed-off-by: Gabriel Niebler <gniebler@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Родитель
9dcbe16fcc
Коммит
a8ce68fd04
|
@ -5781,8 +5781,6 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
|
||||||
struct list_head ins_list;
|
struct list_head ins_list;
|
||||||
struct list_head del_list;
|
struct list_head del_list;
|
||||||
int ret;
|
int ret;
|
||||||
struct extent_buffer *leaf;
|
|
||||||
int slot;
|
|
||||||
char *name_ptr;
|
char *name_ptr;
|
||||||
int name_len;
|
int name_len;
|
||||||
int entries = 0;
|
int entries = 0;
|
||||||
|
@ -5809,35 +5807,19 @@ again:
|
||||||
key.offset = ctx->pos;
|
key.offset = ctx->pos;
|
||||||
key.objectid = btrfs_ino(BTRFS_I(inode));
|
key.objectid = btrfs_ino(BTRFS_I(inode));
|
||||||
|
|
||||||
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
btrfs_for_each_slot(root, &key, &found_key, path, ret) {
|
||||||
if (ret < 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
struct dir_entry *entry;
|
struct dir_entry *entry;
|
||||||
|
struct extent_buffer *leaf = path->nodes[0];
|
||||||
leaf = path->nodes[0];
|
|
||||||
slot = path->slots[0];
|
|
||||||
if (slot >= btrfs_header_nritems(leaf)) {
|
|
||||||
ret = btrfs_next_leaf(root, path);
|
|
||||||
if (ret < 0)
|
|
||||||
goto err;
|
|
||||||
else if (ret > 0)
|
|
||||||
break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
btrfs_item_key_to_cpu(leaf, &found_key, slot);
|
|
||||||
|
|
||||||
if (found_key.objectid != key.objectid)
|
if (found_key.objectid != key.objectid)
|
||||||
break;
|
break;
|
||||||
if (found_key.type != BTRFS_DIR_INDEX_KEY)
|
if (found_key.type != BTRFS_DIR_INDEX_KEY)
|
||||||
break;
|
break;
|
||||||
if (found_key.offset < ctx->pos)
|
if (found_key.offset < ctx->pos)
|
||||||
goto next;
|
continue;
|
||||||
if (btrfs_should_delete_dir_index(&del_list, found_key.offset))
|
if (btrfs_should_delete_dir_index(&del_list, found_key.offset))
|
||||||
goto next;
|
continue;
|
||||||
di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item);
|
di = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item);
|
||||||
name_len = btrfs_dir_name_len(leaf, di);
|
name_len = btrfs_dir_name_len(leaf, di);
|
||||||
if ((total_len + sizeof(struct dir_entry) + name_len) >=
|
if ((total_len + sizeof(struct dir_entry) + name_len) >=
|
||||||
PAGE_SIZE) {
|
PAGE_SIZE) {
|
||||||
|
@ -5864,9 +5846,11 @@ again:
|
||||||
entries++;
|
entries++;
|
||||||
addr += sizeof(struct dir_entry) + name_len;
|
addr += sizeof(struct dir_entry) + name_len;
|
||||||
total_len += sizeof(struct dir_entry) + name_len;
|
total_len += sizeof(struct dir_entry) + name_len;
|
||||||
next:
|
|
||||||
path->slots[0]++;
|
|
||||||
}
|
}
|
||||||
|
/* Catch error encountered during iteration */
|
||||||
|
if (ret < 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
btrfs_release_path(path);
|
btrfs_release_path(path);
|
||||||
|
|
||||||
ret = btrfs_filldir(private->filldir_buf, entries, ctx);
|
ret = btrfs_filldir(private->filldir_buf, entries, ctx);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче