Re: [PATCH V2 linux-next] gfs2: convert simple_str to kstr

From: Fabian Frederick
Date: Tue May 05 2015 - 13:14:59 EST




> On 05 May 2015 at 15:56 Bob Peterson <rpeterso@xxxxxxxxxx> 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@xxxxxxxxx>
> > ---
> >Â 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/