diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-05-05 14:23:22 -0400 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2015-05-05 14:23:22 -0400 |
commit | e50ead480fac63ede9e0b656cd29c1820f7af9de (patch) | |
tree | 72d1be78c76b181985a5b4a141b7162798d76972 | |
parent | 01e64ee40ad741037352d1d6202eaa432f833eb4 (diff) |
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: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
-rw-r--r-- | fs/gfs2/sys.c | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index ae8e8811f0e8..c9ff1cf7d4f3 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) | |||
101 | 101 | ||
102 | static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | 102 | static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len) |
103 | { | 103 | { |
104 | int error; | 104 | int error, n; |
105 | int n = simple_strtol(buf, NULL, 0); | 105 | |
106 | error = kstrtoint(buf, 0, &n); | ||
107 | if (error) | ||
108 | return error; | ||
106 | 109 | ||
107 | if (!capable(CAP_SYS_ADMIN)) | 110 | if (!capable(CAP_SYS_ADMIN)) |
108 | return -EPERM; | 111 | return -EPERM; |
@@ -134,10 +137,16 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf) | |||
134 | 137 | ||
135 | static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | 138 | static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len) |
136 | { | 139 | { |
140 | int error, val; | ||
141 | |||
137 | if (!capable(CAP_SYS_ADMIN)) | 142 | if (!capable(CAP_SYS_ADMIN)) |
138 | return -EPERM; | 143 | return -EPERM; |
139 | 144 | ||
140 | if (simple_strtol(buf, NULL, 0) != 1) | 145 | error = kstrtoint(buf, 0, &val); |
146 | if (error) | ||
147 | return error; | ||
148 | |||
149 | if (val != 1) | ||
141 | return -EINVAL; | 150 | return -EINVAL; |
142 | 151 | ||
143 | gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n"); | 152 | 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 | static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, | 157 | static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, |
149 | size_t len) | 158 | size_t len) |
150 | { | 159 | { |
160 | int error, val; | ||
161 | |||
151 | if (!capable(CAP_SYS_ADMIN)) | 162 | if (!capable(CAP_SYS_ADMIN)) |
152 | return -EPERM; | 163 | return -EPERM; |
153 | 164 | ||
154 | if (simple_strtol(buf, NULL, 0) != 1) | 165 | error = kstrtoint(buf, 0, &val); |
166 | if (error) | ||
167 | return error; | ||
168 | |||
169 | if (val != 1) | ||
155 | return -EINVAL; | 170 | return -EINVAL; |
156 | 171 | ||
157 | gfs2_statfs_sync(sdp->sd_vfs, 0); | 172 | 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 | static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, | 176 | static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, |
162 | size_t len) | 177 | size_t len) |
163 | { | 178 | { |
179 | int error, val; | ||
180 | |||
164 | if (!capable(CAP_SYS_ADMIN)) | 181 | if (!capable(CAP_SYS_ADMIN)) |
165 | return -EPERM; | 182 | return -EPERM; |
166 | 183 | ||
167 | if (simple_strtol(buf, NULL, 0) != 1) | 184 | error = kstrtoint(buf, 0, &val); |
185 | if (error) | ||
186 | return error; | ||
187 | |||
188 | if (val != 1) | ||
168 | return -EINVAL; | 189 | return -EINVAL; |
169 | 190 | ||
170 | gfs2_quota_sync(sdp->sd_vfs, 0); | 191 | 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 | if (!capable(CAP_SYS_ADMIN)) | 202 | if (!capable(CAP_SYS_ADMIN)) |
182 | return -EPERM; | 203 | return -EPERM; |
183 | 204 | ||
184 | id = simple_strtoul(buf, NULL, 0); | 205 | error = kstrtou32(buf, 0, &id); |
206 | if (error) | ||
207 | return error; | ||
185 | 208 | ||
186 | qid = make_kqid(current_user_ns(), USRQUOTA, id); | 209 | qid = make_kqid(current_user_ns(), USRQUOTA, id); |
187 | if (!qid_valid(qid)) | 210 | if (!qid_valid(qid)) |
@@ -201,7 +224,9 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf, | |||
201 | if (!capable(CAP_SYS_ADMIN)) | 224 | if (!capable(CAP_SYS_ADMIN)) |
202 | return -EPERM; | 225 | return -EPERM; |
203 | 226 | ||
204 | id = simple_strtoul(buf, NULL, 0); | 227 | error = kstrtou32(buf, 0, &id); |
228 | if (error) | ||
229 | return error; | ||
205 | 230 | ||
206 | qid = make_kqid(current_user_ns(), GRPQUOTA, id); | 231 | qid = make_kqid(current_user_ns(), GRPQUOTA, id); |
207 | if (!qid_valid(qid)) | 232 | if (!qid_valid(qid)) |
@@ -324,10 +349,11 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf) | |||
324 | static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | 349 | static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) |
325 | { | 350 | { |
326 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | 351 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; |
327 | ssize_t ret = len; | 352 | int ret, val; |
328 | int val; | ||
329 | 353 | ||
330 | val = simple_strtol(buf, NULL, 0); | 354 | ret = kstrtoint(buf, 0, &val); |
355 | if (ret) | ||
356 | return ret; | ||
331 | 357 | ||
332 | if (val == 1) | 358 | if (val == 1) |
333 | set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); | 359 | 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 | smp_mb__after_atomic(); | 362 | smp_mb__after_atomic(); |
337 | gfs2_glock_thaw(sdp); | 363 | gfs2_glock_thaw(sdp); |
338 | } else { | 364 | } else { |
339 | ret = -EINVAL; | 365 | return -EINVAL; |
340 | } | 366 | } |
341 | return ret; | 367 | return len; |
342 | } | 368 | } |
343 | 369 | ||
344 | static ssize_t wdack_show(struct gfs2_sbd *sdp, char *buf) | 370 | 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 | 376 | ||
351 | static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | 377 | static ssize_t wdack_store(struct gfs2_sbd *sdp, const char *buf, size_t len) |
352 | { | 378 | { |
353 | ssize_t ret = len; | 379 | int ret, val; |
354 | int val; | ||
355 | 380 | ||
356 | val = simple_strtol(buf, NULL, 0); | 381 | ret = kstrtoint(buf, 0, &val); |
382 | if (ret) | ||
383 | return ret; | ||
357 | 384 | ||
358 | if ((val == 1) && | 385 | if ((val == 1) && |
359 | !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm")) | 386 | !strcmp(sdp->sd_lockstruct.ls_ops->lm_proto_name, "lock_dlm")) |
360 | complete(&sdp->sd_wdack); | 387 | complete(&sdp->sd_wdack); |
361 | else | 388 | else |
362 | ret = -EINVAL; | 389 | return -EINVAL; |
363 | return ret; | 390 | return len; |
364 | } | 391 | } |
365 | 392 | ||
366 | static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf) | 393 | 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 | { | 580 | { |
554 | struct gfs2_tune *gt = &sdp->sd_tune; | 581 | struct gfs2_tune *gt = &sdp->sd_tune; |
555 | unsigned int x; | 582 | unsigned int x; |
583 | int error; | ||
556 | 584 | ||
557 | if (!capable(CAP_SYS_ADMIN)) | 585 | if (!capable(CAP_SYS_ADMIN)) |
558 | return -EPERM; | 586 | return -EPERM; |
559 | 587 | ||
560 | x = simple_strtoul(buf, NULL, 0); | 588 | error = kstrtouint(buf, 0, &x); |
589 | if (error) | ||
590 | return error; | ||
561 | 591 | ||
562 | if (check_zero && !x) | 592 | if (check_zero && !x) |
563 | return -EINVAL; | 593 | return -EINVAL; |