cluster: RHEL6 - fsck.gfs pass2: Refactor function set_dotdot_dir
Bob Peterson
rpeterso at fedoraproject.org
Tue Jan 24 20:45:46 UTC 2012
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=eeaa054a33190440487bace78683cae8b8744910
Commit: eeaa054a33190440487bace78683cae8b8744910
Parent: 94431db3595d647c196e2b518065ddc2b02cae38
Author: Bob Peterson <rpeterso at redhat.com>
AuthorDate: Tue Aug 9 12:45:18 2011 -0500
Committer: Bob Peterson <rpeterso at redhat.com>
CommitterDate: Fri Jan 20 08:26:26 2012 -0600
fsck.gfs pass2: Refactor function set_dotdot_dir
This patch refactors function set_dotdot_dir to make it more readable.
rhbz#675723
---
gfs2/fsck/pass2.c | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 0424241..b31d293 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -57,34 +57,40 @@ static int set_parent_dir(struct gfs2_sbd *sdp, uint64_t childblock,
/* Set's the child's '..' directory inode number in dir_info structure */
static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
- uint64_t parentblock)
+ uint64_t parentblock)
{
struct dir_info *di;
di = dirtree_find(childblock);
- if (di) {
- if (di->dinode == childblock) {
- /* Special case for root inode because we set
- * it earlier */
- if (di->dotdot_parent && sdp->md.rooti->i_di.di_num.no_addr
- != di->dinode) {
- /* This should never happen */
- log_crit( _("Dotdot parent already set for"
- " block %"PRIu64" (0x%" PRIx64 ") -> %" PRIu64
- " (0x%" PRIx64 ")\n"), childblock, childblock,
- di->dotdot_parent, di->dotdot_parent);
- return -1;
- }
- di->dotdot_parent = parentblock;
- }
- } else {
+ if (!di) {
log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64
- ") in dir_info list\n"), childblock, childblock);
+ ") in dir_info tree\n"), childblock, childblock);
return -1;
}
-
+ if (di->dinode != childblock) {
+ log_debug("'..' doesn't point to what we found: childblock "
+ "0x%llx != dinode 0x%llx\n",
+ (unsigned long long)childblock,
+ (unsigned long long)di->dinode);
+ return -1;
+ }
+ /* Special case for root inode because we set it earlier */
+ if (di->dotdot_parent &&
+ sdp->md.rooti->i_di.di_num.no_addr != di->dinode) {
+ /* This should never happen */
+ log_crit( _("Dotdot parent already set for block %llu (0x%llx)"
+ "-> %llu (0x%llx)\n"),
+ (unsigned long long)childblock,
+ (unsigned long long)childblock,
+ (unsigned long long)di->dotdot_parent,
+ (unsigned long long)di->dotdot_parent);
+ return -1;
+ }
+ log_debug("Setting '..' for directory block 0x%llx to parent 0x%llx\n",
+ (unsigned long long)childblock,
+ (unsigned long long)parentblock);
+ di->dotdot_parent = parentblock;
return 0;
-
}
static int check_eattr_indir(struct gfs2_inode *ip, uint64_t block,
More information about the cluster-commits
mailing list