Commit e50ead48 authored by Fabian Frederick's avatar Fabian Frederick Committed by Bob Peterson

gfs2: convert simple_str to kstr

-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: default avatarFabian Frederick <fabf@skynet.be>
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 01e64ee4
...@@ -101,8 +101,11 @@ static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) ...@@ -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) static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
{ {
int error; int error, n;
int n = simple_strtol(buf, NULL, 0);
error = kstrtoint(buf, 0, &n);
if (error)
return error;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
...@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf) ...@@ -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) static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
{ {
int error, val;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
if (simple_strtol(buf, NULL, 0) != 1) error = kstrtoint(buf, 0, &val);
if (error)
return error;
if (val != 1)
return -EINVAL; return -EINVAL;
gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n"); 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) ...@@ -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, static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len) size_t len)
{ {
int error, val;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
if (simple_strtol(buf, NULL, 0) != 1) error = kstrtoint(buf, 0, &val);
if (error)
return error;
if (val != 1)
return -EINVAL; return -EINVAL;
gfs2_statfs_sync(sdp->sd_vfs, 0); gfs2_statfs_sync(sdp->sd_vfs, 0);
...@@ -161,10 +176,16 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, ...@@ -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, static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
size_t len) size_t len)
{ {
int error, val;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
if (simple_strtol(buf, NULL, 0) != 1) error = kstrtoint(buf, 0, &val);
if (error)
return error;
if (val != 1)
return -EINVAL; return -EINVAL;
gfs2_quota_sync(sdp->sd_vfs, 0); 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, ...@@ -181,7 +202,9 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; 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); qid = make_kqid(current_user_ns(), USRQUOTA, id);
if (!qid_valid(qid)) if (!qid_valid(qid))
...@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf, ...@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; 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); qid = make_kqid(current_user_ns(), GRPQUOTA, id);
if (!qid_valid(qid)) if (!qid_valid(qid))
...@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf) ...@@ -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) static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
{ {
struct lm_lockstruct *ls = &sdp->sd_lockstruct; struct lm_lockstruct *ls = &sdp->sd_lockstruct;
ssize_t ret = len; int ret, val;
int val;
val = simple_strtol(buf, NULL, 0); ret = kstrtoint(buf, 0, &val);
if (ret)
return ret;
if (val == 1) if (val == 1)
set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags);
...@@ -336,9 +362,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) ...@@ -336,9 +362,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
smp_mb__after_atomic(); smp_mb__after_atomic();
gfs2_glock_thaw(sdp); gfs2_glock_thaw(sdp);
} else { } else {
ret = -EINVAL; return -EINVAL;
} }
return ret; return len;
} }
static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf) static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf)
...@@ -350,17 +376,18 @@ static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf) ...@@ -350,17 +376,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) static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
{ {
ssize_t ret = len; int ret, val;
int val;
val = simple_strtol(buf, NULL, 0); ret = kstrtoint(buf, 0, &val);
if (ret)
return ret;
if ((val == 1) && if ((val == 1) &&
!strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm")) !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm"))
complete(&sdp->sd_wdack); complete(&sdp->sd_wdack);
else else
ret = -EINVAL; return -EINVAL;
return ret; return len;
} }
static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf) static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf)
...@@ -553,11 +580,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field, ...@@ -553,11 +580,14 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,
{ {
struct gfs2_tune *gt = &sdp->sd_tune; struct gfs2_tune *gt = &sdp->sd_tune;
unsigned int x; unsigned int x;
int error;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
x = simple_strtoul(buf, NULL, 0); error = kstrtouint(buf, 0, &x);
if (error)
return error;
if (check_zero && !x) if (check_zero && !x)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment