All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCHv3 dlm/next 03/20] fs: dlm: add errno handling to check callback
Date: Mon,  4 Jan 2021 16:00:07 -0500	[thread overview]
Message-ID: <20210104210024.233765-4-aahringo@redhat.com> (raw)
In-Reply-To: <20210104210024.233765-1-aahringo@redhat.com>

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>
---
 fs/dlm/config.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 49c5f9407098..73e6643903af 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -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;
@@ -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;
@@ -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);
-- 
2.26.2



  parent reply	other threads:[~2021-01-04 21:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-04 21:00 [Cluster-devel] [PATCHv3 dlm/next 00/20] fs: dlm: introduce dlm re-transmission layer Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 01/20] fs: dlm: set connected bit after accept Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 02/20] fs: dlm: set subclass for othercon sock_mutex Alexander Aring
2021-01-04 21:00 ` Alexander Aring [this message]
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 04/20] fs: dlm: add check if dlm is currently running Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 05/20] fs: dlm: change allocation limits Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 06/20] fs: dlm: public header in out utility Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 07/20] fs: dlm: use GFP_ZERO for page buffer Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 08/20] fs: dlm: simplify writequeue handling Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 09/20] fs: dlm: add more midcomms hooks Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 10/20] fs: dlm: make buffer handling per msg Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 11/20] fs: dlm: make new buffer handling softirq ready Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 12/20] fs: dlm: add functionality to re-transmit a message Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 13/20] fs: dlm: move out some hash functionality Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 14/20] fs: dlm: remove unaligned memory access handling Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 15/20] fs: dlm: add union in dlm header for lockspace id Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 16/20] fs: dlm: add per node receive flush Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 17/20] fs: dlm: add reliable connection if reconnect Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 18/20] fs: dlm: don't allow half transmitted messages Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 19/20] fs: dlm: remove obsolete code and comment Alexander Aring
2021-01-04 21:00 ` [Cluster-devel] [PATCHv3 dlm/next 20/20] fs: dlm: check for invalid namelen Alexander Aring

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=20210104210024.233765-4-aahringo@redhat.com \
    --to=aahringo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.