Skip to content

Commit

Permalink
fs: dlm: add errno handling to check callback
Browse files Browse the repository at this point in the history
[ Upstream commit 8aa9540 ]

This allows to return individual errno values for the config attribute
check callback instead of returning invalid argument only.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Alexander Aring authored and gregkh committed May 19, 2021
1 parent 6645236 commit 2929c46
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions fs/dlm/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static ssize_t cluster_cluster_name_store(struct config_item *item,
CONFIGFS_ATTR(cluster_, cluster_name);

static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
int *info_field, bool (*check_cb)(unsigned int x),
int *info_field, int (*check_cb)(unsigned int x),
const char *buf, size_t len)
{
unsigned int x;
Expand All @@ -137,8 +137,11 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
if (rc)
return rc;

if (check_cb && check_cb(x))
return -EINVAL;
if (check_cb) {
rc = check_cb(x);
if (rc)
return rc;
}

*cl_field = x;
*info_field = x;
Expand All @@ -161,14 +164,20 @@ static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
} \
CONFIGFS_ATTR(cluster_, name);

static bool dlm_check_zero(unsigned int x)
static int dlm_check_zero(unsigned int x)
{
return !x;
if (!x)
return -EINVAL;

return 0;
}

static bool dlm_check_buffer_size(unsigned int x)
static int dlm_check_buffer_size(unsigned int x)
{
return (x < DEFAULT_BUFFER_SIZE);
if (x < DEFAULT_BUFFER_SIZE)
return -EINVAL;

return 0;
}

CLUSTER_ATTR(tcp_port, dlm_check_zero);
Expand Down

0 comments on commit 2929c46

Please sign in to comment.