cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] fsck.gfs2: Don't rely on cluster.conf when rebuilding sb
Date: Wed, 17 Jul 2013 12:52:23 +0100	[thread overview]
Message-ID: <1374061943.2707.52.camel@menhir> (raw)
In-Reply-To: <1374061917-19335-1-git-send-email-anprice@redhat.com>

Hi,

I think that looks like a good solution. Seems to be a bit smaller
code-wise too,

Steve.

On Wed, 2013-07-17 at 12:51 +0100, Andrew Price wrote:
> As cluster.conf no longer exists we can't sniff the locking options from
> it when rebuilding the superblock and in any case we shouldn't assume
> that fsck.gfs2 is running on the cluster the volume belongs to.
> 
> This patch removes the get_lockproto_table function and instead sets the
> lock table name to a placeholder ("unknown") and sets lockproto to
> "lock_dlm".  It warns the user at the end of the run that the locktable
> will need to be set before mounting.
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  gfs2/fsck/initialize.c | 57 ++++----------------------------------------------
>  gfs2/fsck/main.c       |  4 ++++
>  2 files changed, 8 insertions(+), 53 deletions(-)
> 
> diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
> index b01b240..869d2de 100644
> --- a/gfs2/fsck/initialize.c
> +++ b/gfs2/fsck/initialize.c
> @@ -33,6 +33,7 @@ static int was_mounted_ro = 0;
>  static uint64_t possible_root = HIGHEST_BLOCK;
>  static struct master_dir fix_md;
>  static unsigned long long blks_2free = 0;
> +extern int sb_fixed;
>  
>  /**
>   * block_mounters
> @@ -828,58 +829,6 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
>  	return -1;
>  }
>  
> -static int get_lockproto_table(struct gfs2_sbd *sdp)
> -{
> -	FILE *fp;
> -	char line[PATH_MAX];
> -	char *cluname, *end;
> -	const char *fsname, *cfgfile = "/etc/cluster/cluster.conf";
> -
> -	memset(sdp->lockproto, 0, sizeof(sdp->lockproto));
> -	memset(sdp->locktable, 0, sizeof(sdp->locktable));
> -	fp = fopen(cfgfile, "rt");
> -	if (!fp) {
> -		/* no cluster.conf; must be a stand-alone file system */
> -		strcpy(sdp->lockproto, "lock_nolock");
> -		log_warn(_("Lock protocol determined to be: lock_nolock\n"));
> -		log_warn(_("Stand-alone file system: No need for a lock "
> -			   "table.\n"));
> -		return 0;
> -	}
> -	/* We found a cluster.conf so assume it's a clustered file system */
> -	log_warn(_("Lock protocol assumed to be: " GFS2_DEFAULT_LOCKPROTO
> -		   "\n"));
> -	strcpy(sdp->lockproto, GFS2_DEFAULT_LOCKPROTO);
> -
> -	while (fgets(line, sizeof(line) - 1, fp)) {
> -		cluname = strstr(line,"<cluster name=");
> -		if (cluname) {
> -			cluname += 15;
> -			end = strchr(cluname,'"');
> -			if (end)
> -				*end = '\0';
> -			break;
> -		}
> -	}
> -	if (cluname == NULL || end == NULL || end - cluname < 1) {
> -		log_err(_("Error: Unable to determine cluster name from %s\n"),
> -		                                                      cfgfile);
> -	} else {
> -		fsname = strrchr(opts.device, '/');
> -		if (fsname)
> -			fsname++;
> -		else
> -			fsname = "repaired";
> -		snprintf(sdp->locktable, sizeof(sdp->locktable), "%.*s:%.16s",
> -		         (int)(sizeof(sdp->locktable) - strlen(fsname) - 2),
> -		         cluname, fsname);
> -		log_warn(_("Lock table determined to be: %s\n"),
> -			 sdp->locktable);
> -	}
> -	fclose(fp);
> -	return 0;
> -}
> -
>  /**
>   * is_journal_copy - Is this a "real" dinode or a copy inside a journal?
>   * A real dinode will be located at the block number in its no_addr.
> @@ -1256,7 +1205,8 @@ static int sb_repair(struct gfs2_sbd *sdp)
>  		}
>  	}
>  	/* Step 3 - Rebuild the lock protocol and file system table name */
> -	get_lockproto_table(sdp);
> +	strcpy(sdp->lockproto, GFS2_DEFAULT_LOCKPROTO);
> +	strcpy(sdp->locktable, "unknown");
>  	if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
>  		log_info(_("Found system master directory at: 0x%llx\n"),
>  			 sdp->sd_sb.sb_master_dir.no_addr);
> @@ -1280,6 +1230,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
>  		build_sb(sdp, uuid);
>  		inode_put(&sdp->md.rooti);
>  		inode_put(&sdp->master_dir);
> +		sb_fixed = 1;
>  	} else {
>  		log_crit(_("GFS2 superblock not fixed; fsck cannot proceed "
>  			   "without a valid superblock.\n"));
> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
> index 9c3b06d..f9e7166 100644
> --- a/gfs2/fsck/main.c
> +++ b/gfs2/fsck/main.c
> @@ -36,6 +36,7 @@ struct osi_root dirtree = (struct osi_root) { NULL, };
>  struct osi_root inodetree = (struct osi_root) { NULL, };
>  int dups_found = 0, dups_found_first = 0;
>  struct gfs_sb *sbd1 = NULL;
> +int sb_fixed = 0;
>  
>  /* This function is for libgfs2's sake.                                      */
>  void print_it(const char *label, const char *fmt, const char *fmt2, ...)
> @@ -315,6 +316,9 @@ int main(int argc, char **argv)
>  		log_notice( _("Writing changes to disk\n"));
>  	fsync(sdp->device_fd);
>  	destroy(sdp);
> +	if (sb_fixed)
> +		log_warn(_("Superblock was reset. Use tunegfs2 to manually "
> +		           "set lock table before mounting.\n"));
>  	log_notice( _("gfs2_fsck complete\n"));
>  
>  	if (!error) {




  reply	other threads:[~2013-07-17 11:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16 12:56 [Cluster-devel] [gfs2-utils PATCH 1/7] fsck.gfs2: Fix reference to uninitialized variable Bob Peterson
2013-07-16 12:56 ` [Cluster-devel] [gfs2-utils PATCH 2/7] fsck.gfs2: fix some log messages Bob Peterson
2013-07-16 12:56 ` [Cluster-devel] [gfs2-utils PATCH 3/7] fsck.gfs2: Fix directory link on relocated directory dirents Bob Peterson
2013-07-16 12:56 ` [Cluster-devel] [gfs2-utils PATCH 4/7] fsck.gfs2: Fix infinite loop in pass1b caused by duplicates in hash table Bob Peterson
2013-07-16 12:56 ` [Cluster-devel] [gfs2-utils PATCH 5/7] fsck.gfs2: don't check newly created lost+found in pass2 Bob Peterson
2013-07-16 16:52   ` Andrew Price
2013-07-16 17:14     ` Bob Peterson
2013-07-16 12:56 ` [Cluster-devel] [gfs2-utils PATCH 6/7] fsck.gfs2: avoid negative number in leaf depth Bob Peterson
2013-07-16 12:56 ` [Cluster-devel] [gfs2-utils PATCH 7/7] fsck.gfs2: Detect and fix duplicate references in hash tables Bob Peterson
2013-07-16 16:52   ` Andrew Price
2013-07-16 17:16     ` Bob Peterson
2013-07-17  5:30 ` [Cluster-devel] [gfs2-utils PATCH 1/7] fsck.gfs2: Fix reference to uninitialized variable Fabio M. Di Nitto
2013-07-17  7:53   ` Steven Whitehouse
2013-07-17 11:51     ` [Cluster-devel] [PATCH] fsck.gfs2: Don't rely on cluster.conf when rebuilding sb Andrew Price
2013-07-17 11:52       ` Steven Whitehouse [this message]
2013-07-17 12:27       ` Bob Peterson
2013-07-17 18:13       ` Fabio M. Di Nitto
2013-07-17 18:26         ` Bob Peterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374061943.2707.52.camel@menhir \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).