[Ocfs2-devel] [PATCH 01/20] ocfs2/cluster: Add heartbeat mode configfs parameter

Wengang Wang wen.gang.wang at oracle.com
Sat Sep 25 01:11:40 PDT 2010


On 10-09-14 15:50, Sunil Mushran wrote:
> Add heartbeat mode parameter to the configfs tree. This will be used
> to set/show the heartbeat mode. The user is free to toggle the mode
> between local and global as long as there is no active heartbeat region.
> 
> Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
> ---
>  fs/ocfs2/cluster/heartbeat.c |   70 ++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 70 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
> index 41d5f1f..57cc715 100644
> --- a/fs/ocfs2/cluster/heartbeat.c
> +++ b/fs/ocfs2/cluster/heartbeat.c
> @@ -77,7 +77,19 @@ static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type);
>  
> +static
> +ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group,
> +					const char *page, size_t count)
> +{
> +	unsigned int i;
> +	int ret;
> +	size_t len;
> +
> +	len = (page[count - 1] == '\n') ? count - 1 : count;

How about adding
 
+	if (!len)
+		return -EINVAL;

In case len is 0(though userspace should take care of this), strnicmp() returns "match".
And the mode will be set to O2HB_HEARTBEAT_LOCAL unexpectedly.

regards,
wengang.
> +
> +	for (i = 0; i < O2HB_HEARTBEAT_NUM_MODES; ++i) {
> +		if (strnicmp(page, o2hb_heartbeat_mode_desc[i], len))
> +			continue;
> +
> +		ret = o2hb_global_hearbeat_mode_set(i);
> +		if (!ret)
> +			printk(KERN_NOTICE "ocfs2: Heartbeat mode set to %s\n",
> +			       o2hb_heartbeat_mode_desc[i]);
> +		return count;
> +	}
> +
> +	return -EINVAL;
> +
> +}



More information about the Ocfs2-devel mailing list