[Ocfs2-tools-devel] [PATCH 28/39] mkfs.ocfs2: Add the cluster stack options.

Sunil Mushran Sunil.Mushran at oracle.com
Fri May 23 17:14:11 PDT 2008


Joel Becker wrote:
> This code detects the running cluster stack and cluster name as well as
> accepting them from the user.  It checks for conflicts or missing
> information.  It then writes the out to the disk, setting the
> USERSPACE_STACK feature flag when appropriate.
>
> Signed-off-by: Joel Becker <joel.becker at oracle.com>
>   

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>



> +static int pick_one(State *s, const char *what_is_it,
> +		    const char *user_value, const char *o2cb_value,
> +		    const char *disk_value, char **ret_value)
> +{
> +	int rc = -1;
> +
> +	/*
> +	 * First, compare o2cb and disk values.  If we get past this
> +	 * block (via match or override), the o2cb value takes precedence.
> +	 */
> +	if (disk_value) {
> +		if (o2cb_value) {
> +			if (strcmp(o2cb_value, disk_value)) {
> +				fprintf(stderr,
> +					"%s is configured to use %s \"%s\", but \"%s\" is currently running.\n"
> +					"%s will not be able to determine if the filesystem is in use.\n",
> +					s->device_name, what_is_it,
> +					disk_value, o2cb_value,
> +					s->progname);
> +				if (!s->force) {
> +					fprintf(stderr,
> +						"To skip this check, use --force or -F\n");
> +					goto out;
> +				}
> +				fprintf(stdout,
> +					"Overwrite of disk information forced\n");
> +			}
> +		}
> +	}
> +
> +	if (user_value) {
> +		if (o2cb_value) {
> +			if (strcmp(o2cb_value, user_value)) {
> +				fprintf(stderr, "%s \"%s\" was requested, but \"%s\" is running.\n",
> +				what_is_it, user_value, o2cb_value);
> +				if (!s->force) {
> +					fprintf(stderr,
> +						"To skip this check, use --force or -F\n");
> +					goto out;
> +				}
> +				fprintf(stdout, "%s forced\n", what_is_it);
> +			}
> +		} else if (disk_value) {
> +			if (strcmp(disk_value, user_value)) {
> +				fprintf(stderr, "%s \"%s\" was requested, but %s is configured for \"%s\".\n",
> +					what_is_it, user_value,
> +					s->device_name, disk_value);
> +				if (!s->force) {
> +					fprintf(stderr,
> +						"To skip this check, use --force or -F\n");
> +					goto out;
> +				}
> +				fprintf(stderr, "%s forced\n", what_is_it);
> +			}
> +		}
> +		*ret_value = strdup(user_value);
> +	} else if (o2cb_value)
> +		*ret_value = strdup(o2cb_value);
> +	else if (disk_value)
> +		*ret_value = strdup(disk_value);
> +
> +	rc = 0;
> +
> +out:
> +	return rc;;
> +}
>   

Wondering if we can simplify this.

> @@ -781,6 +819,16 @@ get_state(int argc, char **argv)
>  	if (mount != -1)
>  		s->mount = mount;
>  
> +	if ((stack_name || cluster_name) && (s->mount == MOUNT_LOCAL)) {
> +		com_err(progname, 0,
> +			"Local mount is incompatible with specifying a cluster stack");
> +		exit(1);
> +	}
>   

	if (stack_name || cluster_name) {
		if (!(stack_name && cluster_name)) {
			com_err(progname, 0, "Both stack name and cluster name need to be specified");
			exit(1);
		}
	}

We could be checking for the same in ocfs2_fill_cluster_information()....
not totally clear.




More information about the Ocfs2-tools-devel mailing list