All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 linux-next] gfs2: convert simple_str to kstr
@ 2015-04-30 17:30 ` Fabian Frederick
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Frederick @ 2015-04-30 17:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexey Dobriyan, Fabian Frederick, Steven Whitehouse,
	Bob Peterson, cluster-devel

-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Thanks to Alexey Dobriyan for suggesting improvements in
block_store() and wdack_store()

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/gfs2/sys.c | 69 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ae8e881..3a2de91 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-	int error;
-	int n = simple_strtol(buf, NULL, 0);
+	int error, n;
+
+	error = kstrtoint(buf, 0, &n);
+	if (error)
+		return error;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
+	int error, val;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (simple_strtol(buf, NULL, 0) != 1)
+	error = kstrtoint(buf, 0, &val);
+	if (error)
+		return error;
+
+	if (val != -1)
 		return -EINVAL;
 
 	gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 				 size_t len)
 {
+	int error, val;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (simple_strtol(buf, NULL, 0) != 1)
+	error = kstrtoint(buf, 0, &val);
+	if (error)
+		return error;
+
+	if (val != -1)
 		return -EINVAL;
 
 	gfs2_statfs_sync(sdp->sd_vfs, 0);
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
 				size_t len)
 {
+	int error, val;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (simple_strtol(buf, NULL, 0) != 1)
+	error = kstrtoint(buf, 0, &val);
+	if (error)
+		return error;
+
+	if (val != -1)
 		return -EINVAL;
 
 	gfs2_quota_sync(sdp->sd_vfs, 0);
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	id = simple_strtoul(buf, NULL, 0);
+	error = kstrtou32(buf, 0, &id);
+	if (error)
+		return error;
 
 	qid = make_kqid(current_user_ns(), USRQUOTA, id);
 	if (!qid_valid(qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	id = simple_strtoul(buf, NULL, 0);
+	error = kstrtou32(buf, 0, &id);
+	if (error)
+		return error;
 
 	qid = make_kqid(current_user_ns(), GRPQUOTA, id);
 	if (!qid_valid(qid))
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)
 static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
 	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
-	ssize_t ret = len;
-	int val;
+	int ret, val;
 
-	val = simple_strtol(buf, NULL, 0);
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
 
 	if (val == 1)
 		set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
@@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 		clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
 		smp_mb__after_atomic();
 		gfs2_glock_thaw(sdp);
-	} else {
-		ret = -EINVAL;
-	}
-	return ret;
+	} else
+		return -EINVAL;
+	return len;
 }
 
 static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
@@ -350,17 +375,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-	ssize_t ret = len;
-	int val;
+	int ret, val;
 
-	val = simple_strtol(buf, NULL, 0);
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
 
 	if ((val == 1) &&
 	    !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm"))
 		complete(&sdp->sd_wdack);
 	else
-		ret = -EINVAL;
-	return ret;
+		return -EINVAL;
+	return len;
 }
 
 static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf)
@@ -553,11 +579,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
 {
 	struct gfs2_tune *gt = &sdp->sd_tune;
 	unsigned int x;
+	int error;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	x = simple_strtoul(buf, NULL, 0);
+	error = kstrtouint(buf, 0, &x);
+	if (error)
+		return error;
 
 	if (check_zero && !x)
 		return -EINVAL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Cluster-devel] [PATCH V2 linux-next] gfs2: convert simple_str to kstr
@ 2015-04-30 17:30 ` Fabian Frederick
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Frederick @ 2015-04-30 17:30 UTC (permalink / raw)
  To: cluster-devel.redhat.com

-Remove obsolete simple_str functions.
-Return error code when kstr failed.
-This patch also calls functions corresponding to destination type.

Thanks to Alexey Dobriyan for suggesting improvements in
block_store() and wdack_store()

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/gfs2/sys.c | 69 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ae8e881..3a2de91 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-	int error;
-	int n = simple_strtol(buf, NULL, 0);
+	int error, n;
+
+	error = kstrtoint(buf, 0, &n);
+	if (error)
+		return error;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
+	int error, val;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (simple_strtol(buf, NULL, 0) != 1)
+	error = kstrtoint(buf, 0, &val);
+	if (error)
+		return error;
+
+	if (val != -1)
 		return -EINVAL;
 
 	gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
@@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 				 size_t len)
 {
+	int error, val;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (simple_strtol(buf, NULL, 0) != 1)
+	error = kstrtoint(buf, 0, &val);
+	if (error)
+		return error;
+
+	if (val != -1)
 		return -EINVAL;
 
 	gfs2_statfs_sync(sdp->sd_vfs, 0);
@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
 static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
 				size_t len)
 {
+	int error, val;
+
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (simple_strtol(buf, NULL, 0) != 1)
+	error = kstrtoint(buf, 0, &val);
+	if (error)
+		return error;
+
+	if (val != -1)
 		return -EINVAL;
 
 	gfs2_quota_sync(sdp->sd_vfs, 0);
@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	id = simple_strtoul(buf, NULL, 0);
+	error = kstrtou32(buf, 0, &id);
+	if (error)
+		return error;
 
 	qid = make_kqid(current_user_ns(), USRQUOTA, id);
 	if (!qid_valid(qid))
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	id = simple_strtoul(buf, NULL, 0);
+	error = kstrtou32(buf, 0, &id);
+	if (error)
+		return error;
 
 	qid = make_kqid(current_user_ns(), GRPQUOTA, id);
 	if (!qid_valid(qid))
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)
 static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
 	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
-	ssize_t ret = len;
-	int val;
+	int ret, val;
 
-	val = simple_strtol(buf, NULL, 0);
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
 
 	if (val == 1)
 		set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
@@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 		clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
 		smp_mb__after_atomic();
 		gfs2_glock_thaw(sdp);
-	} else {
-		ret = -EINVAL;
-	}
-	return ret;
+	} else
+		return -EINVAL;
+	return len;
 }
 
 static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
@@ -350,17 +375,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-	ssize_t ret = len;
-	int val;
+	int ret, val;
 
-	val = simple_strtol(buf, NULL, 0);
+	ret = kstrtoint(buf, 0, &val);
+	if (ret)
+		return ret;
 
 	if ((val == 1) &&
 	    !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm"))
 		complete(&sdp->sd_wdack);
 	else
-		ret = -EINVAL;
-	return ret;
+		return -EINVAL;
+	return len;
 }
 
 static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf)
@@ -553,11 +579,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
 {
 	struct gfs2_tune *gt = &sdp->sd_tune;
 	unsigned int x;
+	int error;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	x = simple_strtoul(buf, NULL, 0);
+	error = kstrtouint(buf, 0, &x);
+	if (error)
+		return error;
 
 	if (check_zero && !x)
 		return -EINVAL;
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 linux-next] gfs2: convert simple_str to kstr
  2015-04-30 17:30 ` [Cluster-devel] " Fabian Frederick
@ 2015-05-05 13:56   ` Bob Peterson
  -1 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2015-05-05 13:56 UTC (permalink / raw)
  To: Fabian Frederick
  Cc: linux-kernel, Alexey Dobriyan, Steven Whitehouse, cluster-devel

Hi,

Comments below.

----- Original Message -----
> -Remove obsolete simple_str functions.
> -Return error code when kstr failed.
> -This patch also calls functions corresponding to destination type.
> 
> Thanks to Alexey Dobriyan for suggesting improvements in
> block_store() and wdack_store()
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  fs/gfs2/sys.c | 69
>  ++++++++++++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 49 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> index ae8e881..3a2de91 100644
> --- a/fs/gfs2/sys.c
> +++ b/fs/gfs2/sys.c
> @@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char
> *buf)
>  
>  static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t
>  len)
>  {
> -	int error;
> -	int n = simple_strtol(buf, NULL, 0);
> +	int error, n;
> +
> +	error = kstrtoint(buf, 0, &n);
> +	if (error)
> +		return error;
>  
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
> @@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char
> *buf)
>  
>  static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t
>  len)
>  {
> +	int error, val;
> +
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	if (simple_strtol(buf, NULL, 0) != 1)
> +	error = kstrtoint(buf, 0, &val);
> +	if (error)
> +		return error;
> +
> +	if (val != -1)

Shouldn't this be != 1, not -1 ?

>  		return -EINVAL;
>  
>  	gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
> @@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp,
> const char *buf, size_t len)
>  static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
>  				 size_t len)
>  {
> +	int error, val;
> +
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	if (simple_strtol(buf, NULL, 0) != 1)
> +	error = kstrtoint(buf, 0, &val);
> +	if (error)
> +		return error;
> +
> +	if (val != -1)

Same here. Should that be 1, not -1?

>  		return -EINVAL;
>  
>  	gfs2_statfs_sync(sdp->sd_vfs, 0);
> @@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp,
> const char *buf,
>  static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
>  				size_t len)
>  {
> +	int error, val;
> +
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	if (simple_strtol(buf, NULL, 0) != 1)
> +	error = kstrtoint(buf, 0, &val);
> +	if (error)
> +		return error;
> +
> +	if (val != -1)

And again here.

>  		return -EINVAL;
>  
>  	gfs2_quota_sync(sdp->sd_vfs, 0);
> @@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd
> *sdp, const char *buf,
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	id = simple_strtoul(buf, NULL, 0);
> +	error = kstrtou32(buf, 0, &id);
> +	if (error)
> +		return error;
>  
>  	qid = make_kqid(current_user_ns(), USRQUOTA, id);
>  	if (!qid_valid(qid))
> @@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd
> *sdp, const char *buf,
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	id = simple_strtoul(buf, NULL, 0);
> +	error = kstrtou32(buf, 0, &id);
> +	if (error)
> +		return error;
>  
>  	qid = make_kqid(current_user_ns(), GRPQUOTA, id);
>  	if (!qid_valid(qid))
> @@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char
> *buf)
>  static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t
>  len)
>  {
>  	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> -	ssize_t ret = len;
> -	int val;
> +	int ret, val;
>  
> -	val = simple_strtol(buf, NULL, 0);
> +	ret = kstrtoint(buf, 0, &val);
> +	if (ret)
> +		return ret;
>  
>  	if (val == 1)
>  		set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
> @@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const
> char *buf, size_t len)
>  		clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
>  		smp_mb__after_atomic();
>  		gfs2_glock_thaw(sdp);
> -	} else {
> -		ret = -EINVAL;
> -	}
> -	return ret;
> +	} else

Just a style thing here: We never do "} else". If there's a closing bracket
we always add the following open bracket ("} else {") even when there's only
one line that follows. It's not incorrect, and I used to code it that way too,
but I was always scolded for not having the following "{".

Regards,

Bob Peterson
Red Hat File Systems

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] [PATCH V2 linux-next] gfs2: convert simple_str to kstr
@ 2015-05-05 13:56   ` Bob Peterson
  0 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2015-05-05 13:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Comments below.

----- Original Message -----
> -Remove obsolete simple_str functions.
> -Return error code when kstr failed.
> -This patch also calls functions corresponding to destination type.
> 
> Thanks to Alexey Dobriyan for suggesting improvements in
> block_store() and wdack_store()
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  fs/gfs2/sys.c | 69
>  ++++++++++++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 49 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> index ae8e881..3a2de91 100644
> --- a/fs/gfs2/sys.c
> +++ b/fs/gfs2/sys.c
> @@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char
> *buf)
>  
>  static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t
>  len)
>  {
> -	int error;
> -	int n = simple_strtol(buf, NULL, 0);
> +	int error, n;
> +
> +	error = kstrtoint(buf, 0, &n);
> +	if (error)
> +		return error;
>  
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
> @@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char
> *buf)
>  
>  static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t
>  len)
>  {
> +	int error, val;
> +
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	if (simple_strtol(buf, NULL, 0) != 1)
> +	error = kstrtoint(buf, 0, &val);
> +	if (error)
> +		return error;
> +
> +	if (val != -1)

Shouldn't this be != 1, not -1 ?

>  		return -EINVAL;
>  
>  	gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
> @@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp,
> const char *buf, size_t len)
>  static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
>  				 size_t len)
>  {
> +	int error, val;
> +
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	if (simple_strtol(buf, NULL, 0) != 1)
> +	error = kstrtoint(buf, 0, &val);
> +	if (error)
> +		return error;
> +
> +	if (val != -1)

Same here. Should that be 1, not -1?

>  		return -EINVAL;
>  
>  	gfs2_statfs_sync(sdp->sd_vfs, 0);
> @@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp,
> const char *buf,
>  static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
>  				size_t len)
>  {
> +	int error, val;
> +
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	if (simple_strtol(buf, NULL, 0) != 1)
> +	error = kstrtoint(buf, 0, &val);
> +	if (error)
> +		return error;
> +
> +	if (val != -1)

And again here.

>  		return -EINVAL;
>  
>  	gfs2_quota_sync(sdp->sd_vfs, 0);
> @@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd
> *sdp, const char *buf,
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	id = simple_strtoul(buf, NULL, 0);
> +	error = kstrtou32(buf, 0, &id);
> +	if (error)
> +		return error;
>  
>  	qid = make_kqid(current_user_ns(), USRQUOTA, id);
>  	if (!qid_valid(qid))
> @@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd
> *sdp, const char *buf,
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> -	id = simple_strtoul(buf, NULL, 0);
> +	error = kstrtou32(buf, 0, &id);
> +	if (error)
> +		return error;
>  
>  	qid = make_kqid(current_user_ns(), GRPQUOTA, id);
>  	if (!qid_valid(qid))
> @@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char
> *buf)
>  static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t
>  len)
>  {
>  	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> -	ssize_t ret = len;
> -	int val;
> +	int ret, val;
>  
> -	val = simple_strtol(buf, NULL, 0);
> +	ret = kstrtoint(buf, 0, &val);
> +	if (ret)
> +		return ret;
>  
>  	if (val == 1)
>  		set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
> @@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const
> char *buf, size_t len)
>  		clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
>  		smp_mb__after_atomic();
>  		gfs2_glock_thaw(sdp);
> -	} else {
> -		ret = -EINVAL;
> -	}
> -	return ret;
> +	} else

Just a style thing here: We never do "} else". If there's a closing bracket
we always add the following open bracket ("} else {") even when there's only
one line that follows. It's not incorrect, and I used to code it that way too,
but I was always scolded for not having the following "{".

Regards,

Bob Peterson
Red Hat File Systems



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 linux-next] gfs2: convert simple_str to kstr
  2015-05-05 13:56   ` [Cluster-devel] " Bob Peterson
@ 2015-05-05 17:14     ` Fabian Frederick
  -1 siblings, 0 replies; 6+ messages in thread
From: Fabian Frederick @ 2015-05-05 17:14 UTC (permalink / raw)
  To: Bob Peterson
  Cc: Alexey Dobriyan, linux-kernel, Steven Whitehouse, cluster-devel



> On 05 May 2015 at 15:56 Bob Peterson <rpeterso@redhat.com> wrote:
>
>
> Hi,
>
> Comments below.
>
> ----- Original Message -----
> > -Remove obsolete simple_str functions.
> > -Return error code when kstr failed.
> > -This patch also calls functions corresponding to destination type.
> >
> > Thanks to Alexey Dobriyan for suggesting improvements in
> > block_store() and wdack_store()
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > ---
> >  fs/gfs2/sys.c | 69
> >  ++++++++++++++++++++++++++++++++++++++++++-----------------
> >  1 file changed, 49 insertions(+), 20 deletions(-)
> >
> > diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> > index ae8e881..3a2de91 100644
> > --- a/fs/gfs2/sys.c
> > +++ b/fs/gfs2/sys.c
> > @@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char
> > *buf)
> > 
> >  static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t
> >  len)
> >  {
> > -   int error;
> > -   int n = simple_strtol(buf, NULL, 0);
> > +   int error, n;
> > +
> > +   error = kstrtoint(buf, 0, &n);
> > +   if (error)
> > +           return error;
> > 
> >     if (!capable(CAP_SYS_ADMIN))
> >             return -EPERM;
> > @@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp,
> > char
> > *buf)
> > 
> >  static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t
> >  len)
> >  {
> > +   int error, val;
> > +
> >     if (!capable(CAP_SYS_ADMIN))
> >             return -EPERM;
> > 
> > -   if (simple_strtol(buf, NULL, 0) != 1)
> > +   error = kstrtoint(buf, 0, &val);
> > +   if (error)
> > +           return error;
> > +
> > +   if (val != -1)
>
> Shouldn't this be != 1, not -1 ?

Hi Bob,

   You're absolutely right, thanks a lot ; I send a new version with {} fix as
well.

Regards,
Fabian
>
> >             return -EINVAL;
> > 
> >     gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
> > @@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp,
> > const char *buf, size_t len)
> >  static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
> >                              size_t len)
> >  {
> > +   int error, val;
> > +
> >     if (!capable(CAP_SYS_ADMIN))
> >             return -EPERM;
> > 
> > -   if (simple_strtol(buf, NULL, 0) != 1)
> > +   error = kstrtoint(buf, 0, &val);
> > +   if (error)
> > +           return error;
> > +
> > +   if (val != -1)
>
> Same here. Should that be 1, not -1?
>
> >             return -EINVAL;
> > 
> >     gfs2_statfs_sync(sdp->sd_vfs, 0);
> > @@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp,
> > const char *buf,
> >  static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
> >                             size_t len)
> >  {
> > +   int error, val;
> > +
> >     if (!capable(CAP_SYS_ADMIN))
> >             return -EPERM;
> > 
> > -   if (simple_strtol(buf, NULL, 0) != 1)
> > +   error = kstrtoint(buf, 0, &val);
> > +   if (error)
> > +           return error;
> > +
> > +   if (val != -1)
>
> And again here.
>
> >             return -EINVAL;
> > 
> >     gfs2_quota_sync(sdp->sd_vfs, 0);
> > @@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd
> > *sdp, const char *buf,
> >     if (!capable(CAP_SYS_ADMIN))
> >             return -EPERM;
> > 
> > -   id = simple_strtoul(buf, NULL, 0);
> > +   error = kstrtou32(buf, 0, &id);
> > +   if (error)
> > +           return error;
> > 
> >     qid = make_kqid(current_user_ns(), USRQUOTA, id);
> >     if (!qid_valid(qid))
> > @@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd
> > *sdp, const char *buf,
> >     if (!capable(CAP_SYS_ADMIN))
> >             return -EPERM;
> > 
> > -   id = simple_strtoul(buf, NULL, 0);
> > +   error = kstrtou32(buf, 0, &id);
> > +   if (error)
> > +           return error;
> > 
> >     qid = make_kqid(current_user_ns(), GRPQUOTA, id);
> >     if (!qid_valid(qid))
> > @@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char
> > *buf)
> >  static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t
> >  len)
> >  {
> >     struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> > -   ssize_t ret = len;
> > -   int val;
> > +   int ret, val;
> > 
> > -   val = simple_strtol(buf, NULL, 0);
> > +   ret = kstrtoint(buf, 0, &val);
> > +   if (ret)
> > +           return ret;
> > 
> >     if (val == 1)
> >             set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
> > @@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const
> > char *buf, size_t len)
> >             clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
> >             smp_mb__after_atomic();
> >             gfs2_glock_thaw(sdp);
> > -   } else {
> > -           ret = -EINVAL;
> > -   }
> > -   return ret;
> > +   } else
>
> Just a style thing here: We never do "} else". If there's a closing bracket
> we always add the following open bracket ("} else {") even when there's only
> one line that follows. It's not incorrect, and I used to code it that way too,
> but I was always scolded for not having the following "{".
>
> Regards,
>
> Bob Peterson
> Red Hat File Systems

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Cluster-devel] [PATCH V2 linux-next] gfs2: convert simple_str to kstr
@ 2015-05-05 17:14     ` Fabian Frederick
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Frederick @ 2015-05-05 17:14 UTC (permalink / raw)
  To: cluster-devel.redhat.com



> On 05 May 2015 at 15:56 Bob Peterson <rpeterso@redhat.com> wrote:
>
>
> Hi,
>
> Comments below.
>
> ----- Original Message -----
> > -Remove obsolete simple_str functions.
> > -Return error code when kstr failed.
> > -This patch also calls functions corresponding to destination type.
> >
> > Thanks to Alexey Dobriyan for suggesting improvements in
> > block_store() and wdack_store()
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > ---
> >? fs/gfs2/sys.c | 69
> >? ++++++++++++++++++++++++++++++++++++++++++-----------------
> >? 1 file changed, 49 insertions(+), 20 deletions(-)
> >
> > diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> > index ae8e881..3a2de91 100644
> > --- a/fs/gfs2/sys.c
> > +++ b/fs/gfs2/sys.c
> > @@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char
> > *buf)
> >?
> >? static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t
> >? len)
> >? {
> > -? ?int error;
> > -? ?int n = simple_strtol(buf, NULL, 0);
> > +? ?int error, n;
> > +
> > +? ?error = kstrtoint(buf, 0, &n);
> > +? ?if (error)
> > +? ? ? ? ? ?return error;
> >?
> >? ? ?if (!capable(CAP_SYS_ADMIN))
> >? ? ? ? ? ? ?return -EPERM;
> > @@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp,
> > char
> > *buf)
> >?
> >? static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t
> >? len)
> >? {
> > +? ?int error, val;
> > +
> >? ? ?if (!capable(CAP_SYS_ADMIN))
> >? ? ? ? ? ? ?return -EPERM;
> >?
> > -? ?if (simple_strtol(buf, NULL, 0) != 1)
> > +? ?error = kstrtoint(buf, 0, &val);
> > +? ?if (error)
> > +? ? ? ? ? ?return error;
> > +
> > +? ?if (val != -1)
>
> Shouldn't this be != 1, not -1 ?

Hi Bob,

? ?You're absolutely right, thanks a lot ; I send a new version with {} fix as
well.

Regards,
Fabian
>
> >? ? ? ? ? ? ?return -EINVAL;
> >?
> >? ? ?gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n");
> > @@ -148,10 +157,16 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp,
> > const char *buf, size_t len)
> >? static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
> >? ? ? ? ? ? ? ? ? ? ? ? ? ? ? size_t len)
> >? {
> > +? ?int error, val;
> > +
> >? ? ?if (!capable(CAP_SYS_ADMIN))
> >? ? ? ? ? ? ?return -EPERM;
> >?
> > -? ?if (simple_strtol(buf, NULL, 0) != 1)
> > +? ?error = kstrtoint(buf, 0, &val);
> > +? ?if (error)
> > +? ? ? ? ? ?return error;
> > +
> > +? ?if (val != -1)
>
> Same here. Should that be 1, not -1?
>
> >? ? ? ? ? ? ?return -EINVAL;
> >?
> >? ? ?gfs2_statfs_sync(sdp->sd_vfs, 0);
> > @@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp,
> > const char *buf,
> >? static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
> >? ? ? ? ? ? ? ? ? ? ? ? ? ? ?size_t len)
> >? {
> > +? ?int error, val;
> > +
> >? ? ?if (!capable(CAP_SYS_ADMIN))
> >? ? ? ? ? ? ?return -EPERM;
> >?
> > -? ?if (simple_strtol(buf, NULL, 0) != 1)
> > +? ?error = kstrtoint(buf, 0, &val);
> > +? ?if (error)
> > +? ? ? ? ? ?return error;
> > +
> > +? ?if (val != -1)
>
> And again here.
>
> >? ? ? ? ? ? ?return -EINVAL;
> >?
> >? ? ?gfs2_quota_sync(sdp->sd_vfs, 0);
> > @@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd
> > *sdp, const char *buf,
> >? ? ?if (!capable(CAP_SYS_ADMIN))
> >? ? ? ? ? ? ?return -EPERM;
> >?
> > -? ?id = simple_strtoul(buf, NULL, 0);
> > +? ?error = kstrtou32(buf, 0, &id);
> > +? ?if (error)
> > +? ? ? ? ? ?return error;
> >?
> >? ? ?qid = make_kqid(current_user_ns(), USRQUOTA, id);
> >? ? ?if (!qid_valid(qid))
> > @@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd
> > *sdp, const char *buf,
> >? ? ?if (!capable(CAP_SYS_ADMIN))
> >? ? ? ? ? ? ?return -EPERM;
> >?
> > -? ?id = simple_strtoul(buf, NULL, 0);
> > +? ?error = kstrtou32(buf, 0, &id);
> > +? ?if (error)
> > +? ? ? ? ? ?return error;
> >?
> >? ? ?qid = make_kqid(current_user_ns(), GRPQUOTA, id);
> >? ? ?if (!qid_valid(qid))
> > @@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char
> > *buf)
> >? static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t
> >? len)
> >? {
> >? ? ?struct lm_lockstruct *ls = &sdp->sd_lockstruct;
> > -? ?ssize_t ret = len;
> > -? ?int val;
> > +? ?int ret, val;
> >?
> > -? ?val = simple_strtol(buf, NULL, 0);
> > +? ?ret = kstrtoint(buf, 0, &val);
> > +? ?if (ret)
> > +? ? ? ? ? ?return ret;
> >?
> >? ? ?if (val == 1)
> >? ? ? ? ? ? ?set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
> > @@ -335,10 +361,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const
> > char *buf, size_t len)
> >? ? ? ? ? ? ?clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
> >? ? ? ? ? ? ?smp_mb__after_atomic();
> >? ? ? ? ? ? ?gfs2_glock_thaw(sdp);
> > -? ?} else {
> > -? ? ? ? ? ?ret = -EINVAL;
> > -? ?}
> > -? ?return ret;
> > +? ?} else
>
> Just a style thing here: We never do "} else". If there's a closing bracket
> we always add the following open bracket ("} else {") even when there's only
> one line that follows. It's not incorrect, and I used to code it that way too,
> but I was always scolded for not having the following "{".
>
> Regards,
>
> Bob Peterson
> Red Hat File Systems



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-05 17:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-30 17:30 [PATCH V2 linux-next] gfs2: convert simple_str to kstr Fabian Frederick
2015-04-30 17:30 ` [Cluster-devel] " Fabian Frederick
2015-05-05 13:56 ` Bob Peterson
2015-05-05 13:56   ` [Cluster-devel] " Bob Peterson
2015-05-05 17:14   ` Fabian Frederick
2015-05-05 17:14     ` [Cluster-devel] " Fabian Frederick

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.