FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 12-15-2011, 10:32 AM
Steven Whitehouse
 
Default fsck.gfs2: Clean up pass calling code

>From 4e664f2ae4ee2d58469a83216a2e049a614b2964 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Thu, 15 Dec 2011 11:29:45 +0000
Subject: [PATCH 2/2] fsck.gfs2: Clean up pass calling code

There was a lot of repeated code for running each pass
of fsck. This cleans it up into a single function that
is called once for each pass.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
gfs2/fsck/main.c | 145 +++++++++++++++++-------------------------------------
1 files changed, 45 insertions(+), 100 deletions(-)

diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index aa354ad..9c3b06d 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -147,7 +147,7 @@ static void interrupt(int sig)
}
}

-static void check_statfs(struct gfs2_sbd *sdp)
+static int check_statfs(struct gfs2_sbd *sdp)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd;
@@ -158,7 +158,7 @@ static void check_statfs(struct gfs2_sbd *sdp)

if (sdp->gfs1 && !sdp->md.statfs->i_di.di_size) {
log_info("This GFS1 file system is not using fast_statfs.
");
- return;
+ return 0;
}
/* Read the current statfs values */
count = gfs2_readi(sdp->md.statfs, buf, 0,
@@ -185,7 +185,7 @@ static void check_statfs(struct gfs2_sbd *sdp)
sc.sc_free == (sdp->blks_total - sdp->blks_alloced) &&
sc.sc_dinodes == sdp->dinodes_alloced) {
log_info( _("The statfs file is accurate.
"));
- return;
+ return 0;
}
log_err( _("The statfs file is wrong:

"));
log_err( _("Current statfs values:
"));
@@ -213,12 +213,50 @@ static void check_statfs(struct gfs2_sbd *sdp)
errors_found++;
if (!query( _("Okay to fix the master statfs file? (y/n)"))) {
log_err( _("The statfs file was not fixed.
"));
- return;
+ return 0;
}

do_init_statfs(sdp);
log_err( _("The statfs file was fixed.
"));
errors_corrected++;
+ return 0;
+}
+
+struct fsck_pass {
+ const char *name;
+ int (*f)(struct gfs2_sbd *sdp);
+};
+
+static const struct fsck_pass passes[] = {
+ { .name = "pass1", .f = pass1 },
+ { .name = "pass1b", .f = pass1b },
+ { .name = "pass1c", .f = pass1c },
+ { .name = "pass2", .f = pass2 },
+ { .name = "pass3", .f = pass3 },
+ { .name = "pass4", .f = pass4 },
+ { .name = "pass5", .f = pass5 },
+ { .name = "check_statfs", .f = check_statfs },
+ { .name = NULL, }
+};
+
+static int fsck_pass(const struct fsck_pass *p, struct gfs2_sbd *sdp)
+{
+ int ret;
+
+ if (fsck_abort)
+ return FSCK_CANCELED;
+ pass = p->name;
+ log_notice( _("Starting %s
"), p->name);
+ ret = p->f(sdp);
+ if (ret)
+ exit(ret);
+ if (skip_this_pass || fsck_abort) {
+ skip_this_pass = 0;
+ log_notice( _("%s interrupted
"), p->name);
+ return FSCK_CANCELED;
+ }
+ log_notice( _("%s complete
"), p->name);
+ return 0;
}

int main(int argc, char **argv)
@@ -226,6 +264,7 @@ int main(int argc, char **argv)
struct gfs2_sbd sb;
struct gfs2_sbd *sdp = &sb;
int j;
+ int i;
int error = 0;
int all_clean = 0;
struct sigaction act = { .sa_handler = interrupt, };
@@ -250,102 +289,8 @@ int main(int argc, char **argv)

sigaction(SIGINT, &act, NULL);

- log_notice( _("Starting pass1
"));
- pass = "pass 1";
- last_reported_block = 0;
- if ((error = pass1(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass1 interrupted
"));
- }
- else
- log_notice( _("Pass1 complete
"));
-
- if (!fsck_abort) {
- last_reported_block = 0;
- pass = "pass 1b";
- log_notice( _("Starting pass1b
"));
- if ((error = pass1b(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass1b interrupted
"));
- }
- else
- log_notice( _("Pass1b complete
"));
- }
- if (!fsck_abort) {
- last_reported_block = 0;
- pass = "pass 1c";
- log_notice( _("Starting pass1c
"));
- if ((error = pass1c(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass1c interrupted
"));
- }
- else
- log_notice( _("Pass1c complete
"));
- }
- if (!fsck_abort) {
- last_reported_block = 0;
- pass = "pass 2";
- log_notice( _("Starting pass2
"));
- if ((error = pass2(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass2 interrupted
"));
- }
- else
- log_notice( _("Pass2 complete
"));
- }
- if (!fsck_abort) {
- last_reported_block = 0;
- pass = "pass 3";
- log_notice( _("Starting pass3
"));
- if ((error = pass3(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass3 interrupted
"));
- }
- else
- log_notice( _("Pass3 complete
"));
- }
- if (!fsck_abort) {
- last_reported_block = 0;
- pass = "pass 4";
- log_notice( _("Starting pass4
"));
- if ((error = pass4(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass4 interrupted
"));
- }
- else
- log_notice( _("Pass4 complete
"));
- }
- if (!fsck_abort) {
- last_reported_block = 0;
- pass = "pass 5";
- log_notice( _("Starting pass5
"));
- if ((error = pass5(sdp)))
- exit(error);
- if (skip_this_pass || fsck_abort) {
- skip_this_pass = FALSE;
- log_notice( _("Pass5 interrupted
"));
- error = FSCK_CANCELED;
- }
- else
- log_notice( _("Pass5 complete
"));
- } else {
- error = FSCK_CANCELED;
- }
-
- if (!fsck_abort)
- check_statfs(sdp);
+ for (i = 0; passes[i].name; i++)
+ error = fsck_pass(passes + i, sdp);

/* Free up our system inodes */
if (!sdp->gfs1)
--
1.7.4.4
 
Old 12-15-2011, 12:42 PM
Bob Peterson
 
Default fsck.gfs2: Clean up pass calling code

----- Original Message -----
| >From 4e664f2ae4ee2d58469a83216a2e049a614b2964 Mon Sep 17 00:00:00
| >2001
| From: Steven Whitehouse <swhiteho@redhat.com>
| Date: Thu, 15 Dec 2011 11:29:45 +0000
| Subject: [PATCH 2/2] fsck.gfs2: Clean up pass calling code
|
| There was a lot of repeated code for running each pass
| of fsck. This cleans it up into a single function that
| is called once for each pass.
|
| Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

Hi,

ACK,

Regards,

Bob Peterson
Red Hat File Systems
 

Thread Tools




All times are GMT. The time now is 07:22 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org