Commit b1f048c1 authored by wang di's avatar wang di Committed by Greg Kroah-Hartman

staging: lustre: llite: reduce indent in ll_dir_read

Instead of making a large chunk of code conditional
based on if a page is valid we reverse the page
validity test and exit the loop if the page is invalid
instead. This allows a section of code to reduce its
indentation one level.
Signed-off-by: default avatarwang di <di.wang@intel.com>
Reviewed-on: http://review.whamcloud.com/10761
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4906Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0ddf80c1
...@@ -508,93 +508,90 @@ int ll_dir_read(struct inode *inode, struct md_op_data *op_data, ...@@ -508,93 +508,90 @@ int ll_dir_read(struct inode *inode, struct md_op_data *op_data,
while (rc == 0 && !done) { while (rc == 0 && !done) {
struct lu_dirpage *dp; struct lu_dirpage *dp;
struct lu_dirent *ent; struct lu_dirent *ent;
__u64 hash;
__u64 next;
if (IS_ERR(page)) {
rc = PTR_ERR(page);
break;
}
hash = MDS_DIR_END_OFF;
dp = page_address(page);
for (ent = lu_dirent_start(dp); ent && !done;
ent = lu_dirent_next(ent)) {
__u16 type;
int namelen;
struct lu_fid fid;
__u64 lhash;
__u64 ino;
if (!IS_ERR(page)) {
/* /*
* If page is empty (end of directory is reached), * XXX: implement correct swabbing here.
* use this value.
*/ */
__u64 hash = MDS_DIR_END_OFF;
__u64 next;
dp = page_address(page);
for (ent = lu_dirent_start(dp); ent && !done;
ent = lu_dirent_next(ent)) {
__u16 type;
int namelen;
struct lu_fid fid;
__u64 lhash;
__u64 ino;
hash = le64_to_cpu(ent->lde_hash);
if (hash < pos)
/* /*
* XXX: implement correct swabbing here. * Skip until we find target hash
* value.
*/ */
continue;
hash = le64_to_cpu(ent->lde_hash); namelen = le16_to_cpu(ent->lde_namelen);
if (hash < pos) if (namelen == 0)
/* /*
* Skip until we find target hash * Skip dummy record.
* value.
*/
continue;
namelen = le16_to_cpu(ent->lde_namelen);
if (namelen == 0)
/*
* Skip dummy record.
*/
continue;
if (api32 && hash64)
lhash = hash >> 32;
else
lhash = hash;
fid_le_to_cpu(&fid, &ent->lde_fid);
ino = cl_fid_build_ino(&fid, api32);
type = ll_dirent_type_get(ent);
ctx->pos = lhash;
/* For 'll_nfs_get_name_filldir()', it will try
* to access the 'ent' through its 'lde_name',
* so the parameter 'name' for 'ctx->actor()'
* must be part of the 'ent'.
*/ */
done = !dir_emit(ctx, ent->lde_name, continue;
namelen, ino, type);
} if (api32 && hash64)
next = le64_to_cpu(dp->ldp_hash_end); lhash = hash >> 32;
if (!done) { else
pos = next; lhash = hash;
if (pos == MDS_DIR_END_OFF) { fid_le_to_cpu(&fid, &ent->lde_fid);
/* ino = cl_fid_build_ino(&fid, api32);
* End of directory reached. type = ll_dirent_type_get(ent);
*/ ctx->pos = lhash;
done = 1; /* For 'll_nfs_get_name_filldir()', it will try
ll_release_page(page, 0); * to access the 'ent' through its 'lde_name',
} else if (1 /* chain is exhausted*/) { * so the parameter 'name' for 'ctx->actor()'
/* * must be part of the 'ent'.
* Normal case: continue to the next */
* page. done = !dir_emit(ctx, ent->lde_name,
*/ namelen, ino, type);
ll_release_page(page, }
le32_to_cpu(dp->ldp_flags) & next = le64_to_cpu(dp->ldp_hash_end);
LDF_COLLIDE); if (!done) {
next = pos; pos = next;
page = ll_get_dir_page(inode, pos, if (pos == MDS_DIR_END_OFF) {
&chain); /*
} else { * End of directory reached.
/* */
* go into overflow page. done = 1;
*/ ll_release_page(page, 0);
LASSERT(le32_to_cpu(dp->ldp_flags) & } else if (1 /* chain is exhausted*/) {
/*
* Normal case: continue to the next
* page.
*/
ll_release_page(page,
le32_to_cpu(dp->ldp_flags) &
LDF_COLLIDE); LDF_COLLIDE);
ll_release_page(page, 1); next = pos;
} page = ll_get_dir_page(inode, pos,
&chain);
} else { } else {
pos = hash; /*
ll_release_page(page, 0); * go into overflow page.
*/
LASSERT(le32_to_cpu(dp->ldp_flags) &
LDF_COLLIDE);
ll_release_page(page, 1);
} }
} else { } else {
rc = PTR_ERR(page); pos = hash;
ll_release_page(page, 0);
} }
} }
......
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