[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Cluster-devel] [PATCH] fsck.gfs2: Don't rely on cluster.conf when rebuilding sb



----- Original Message -----
| 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) {
| --
| 1.8.1.4

Hi,

ACK. I'll pull patch1 of my set based on this. Thanks, Andy.

Regards,

Bob Peterson
Red Hat File Systems


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]