cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [Patch 24/44] fsck.gfs2 pass2: Refactor function set_dotdor_dir
@ 2011-08-11 21:09 Bob Peterson
  2011-08-12  9:47 ` Steven Whitehouse
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Peterson @ 2011-08-11 21:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

From 7a2fc9138955e93fd525f5ec035e7ab2b57f0a8c Mon Sep 17 00:00:00 2001
From: Bob Peterson <rpeterso@redhat.com>
Date: Tue, 9 Aug 2011 12:45:18 -0500
Subject: [PATCH 24/44] fsck.gfs pass2: Refactor function set_dotdor_dir

This patch refactors function set_dotdot_dir to make it more readable.

rhbz#675723
---
 gfs2/fsck/pass2.c |   53 +++++++++++++++++++++++++++--------------------------
 1 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 01f8000..870a792 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -61,39 +61,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 %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;
-			}
-			di->dotdot_parent = parentblock;
-		}
-	} else {
-		log_err( _("Unable to find block %llu (0x%llx"
-			   ") in dir_info list\n"),
-			(unsigned long long)childblock,
-			(unsigned long long)childblock);
+	if (!di) {
+		log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64
+			   ") 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,
-- 
1.7.4.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Cluster-devel] [Patch 24/44] fsck.gfs2 pass2: Refactor function set_dotdor_dir
  2011-08-11 21:09 [Cluster-devel] [Patch 24/44] fsck.gfs2 pass2: Refactor function set_dotdor_dir Bob Peterson
@ 2011-08-12  9:47 ` Steven Whitehouse
  2011-08-12 14:09   ` Bob Peterson
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Whitehouse @ 2011-08-12  9:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Thu, 2011-08-11 at 17:09 -0400, Bob Peterson wrote:
> >From 7a2fc9138955e93fd525f5ec035e7ab2b57f0a8c Mon Sep 17 00:00:00 2001
> From: Bob Peterson <rpeterso@redhat.com>
> Date: Tue, 9 Aug 2011 12:45:18 -0500
> Subject: [PATCH 24/44] fsck.gfs pass2: Refactor function set_dotdor_dir
> 
> This patch refactors function set_dotdot_dir to make it more readable.
> 
> rhbz#675723
> ---
>  gfs2/fsck/pass2.c |   53 +++++++++++++++++++++++++++--------------------------
>  1 files changed, 27 insertions(+), 26 deletions(-)
> 
> diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
> index 01f8000..870a792 100644
> --- a/gfs2/fsck/pass2.c
> +++ b/gfs2/fsck/pass2.c
> @@ -61,39 +61,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 %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;
> -			}
Should this apply to the master inode too?

Steve.

> -			di->dotdot_parent = parentblock;
> -		}
> -	} else {
> -		log_err( _("Unable to find block %llu (0x%llx"
> -			   ") in dir_info list\n"),
> -			(unsigned long long)childblock,
> -			(unsigned long long)childblock);
> +	if (!di) {
> +		log_err( _("Unable to find block %"PRIu64" (0x%" PRIx64
> +			   ") 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,




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Cluster-devel] [Patch 24/44] fsck.gfs2 pass2: Refactor function set_dotdor_dir
  2011-08-12  9:47 ` Steven Whitehouse
@ 2011-08-12 14:09   ` Bob Peterson
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Peterson @ 2011-08-12 14:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
| Hi,
| 
(snip)
| Should this apply to the master inode too?
| 
| Steve.

Hi,

It's not an issue because the master directory, like all
system directories (jindex and per_node), are skipped by pass2.c
via the following code snippet:

		if (is_system_dir(sdp, dirblk))
			continue;

Regards,

Bob Peterson
Red Hat File Systems



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-12 14:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-11 21:09 [Cluster-devel] [Patch 24/44] fsck.gfs2 pass2: Refactor function set_dotdor_dir Bob Peterson
2011-08-12  9:47 ` Steven Whitehouse
2011-08-12 14:09   ` Bob Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).