Commit b7b6160d authored by Konstantin Komarov's avatar Konstantin Komarov

fs/ntfs3: Refactoring of indx_find function

This commit makes function a bit more readable

Cc: Joe Perches <joe@perches.com>
Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
parent 724bbe49
...@@ -1042,19 +1042,16 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni, ...@@ -1042,19 +1042,16 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
{ {
int err; int err;
struct NTFS_DE *e; struct NTFS_DE *e;
const struct INDEX_HDR *hdr;
struct indx_node *node; struct indx_node *node;
if (!root) if (!root)
root = indx_get_root(&ni->dir, ni, NULL, NULL); root = indx_get_root(&ni->dir, ni, NULL, NULL);
if (!root) { if (!root) {
err = -EINVAL; /* Should not happen. */
goto out; return -EINVAL;
} }
hdr = &root->ihdr;
/* Check cache. */ /* Check cache. */
e = fnd->level ? fnd->de[fnd->level - 1] : fnd->root_de; e = fnd->level ? fnd->de[fnd->level - 1] : fnd->root_de;
if (e && !de_is_last(e) && if (e && !de_is_last(e) &&
...@@ -1068,39 +1065,35 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni, ...@@ -1068,39 +1065,35 @@ int indx_find(struct ntfs_index *indx, struct ntfs_inode *ni,
fnd_clear(fnd); fnd_clear(fnd);
/* Lookup entry that is <= to the search value. */ /* Lookup entry that is <= to the search value. */
e = hdr_find_e(indx, hdr, key, key_len, ctx, diff); e = hdr_find_e(indx, &root->ihdr, key, key_len, ctx, diff);
if (!e) if (!e)
return -EINVAL; return -EINVAL;
fnd->root_de = e; fnd->root_de = e;
err = 0;
for (;;) { for (;;) {
node = NULL; node = NULL;
if (*diff >= 0 || !de_has_vcn_ex(e)) { if (*diff >= 0 || !de_has_vcn_ex(e))
*entry = e; break;
goto out;
}
/* Read next level. */ /* Read next level. */
err = indx_read(indx, ni, de_get_vbn(e), &node); err = indx_read(indx, ni, de_get_vbn(e), &node);
if (err) if (err)
goto out; return err;
/* Lookup entry that is <= to the search value. */ /* Lookup entry that is <= to the search value. */
e = hdr_find_e(indx, &node->index->ihdr, key, key_len, ctx, e = hdr_find_e(indx, &node->index->ihdr, key, key_len, ctx,
diff); diff);
if (!e) { if (!e) {
err = -EINVAL;
put_indx_node(node); put_indx_node(node);
goto out; return -EINVAL;
} }
fnd_push(fnd, node, e); fnd_push(fnd, node, e);
} }
out: *entry = e;
return err; return 0;
} }
int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni, int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment