On Tue, 2019-08-27 at 08:40 -0400, Brian Foster wrote: > On Fri, Aug 23, 2019 at 08:59:33AM +0800, Ian Kent wrote: > > The mount-api doesn't have a "human unit" parse type yet so > > the options that have values like "10k" etc. still need to > > be converted by the fs. > > > > But the value comes to the fs as a string (not a substring_t > > type) so there's a need to change the conversion function to > > take a character string instead. > > > > After refactoring xfs_parseargs() and changing it to use > > xfs_parse_param() match_kstrtoint() will no longer be used > > and will be removed. > > > > Signed-off-by: Ian Kent <raven@xxxxxxxxxx> > > --- > > fs/xfs/xfs_super.c | 22 ++++++++++++++++++---- > > 1 file changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c > > index 74c88b92ce22..49c87fb921f1 100644 > > --- a/fs/xfs/xfs_super.c > > +++ b/fs/xfs/xfs_super.c > > @@ -153,13 +153,13 @@ static const struct fs_parameter_description > > xfs_fs_parameters = { > > }; > > > > STATIC int > > -suffix_kstrtoint(const substring_t *s, unsigned int base, int > > *res) > > +suffix_kstrtoint(const char *s, unsigned int base, int *res) > > { > > int last, shift_left_factor = 0, _res; > > char *value; > > int ret = 0; > > > > - value = match_strdup(s); > > + value = kstrdup(s, GFP_KERNEL); > > if (!value) > > return -ENOMEM; > > > > @@ -184,6 +184,20 @@ suffix_kstrtoint(const substring_t *s, > > unsigned int base, int *res) > > return ret; > > } > > > > +STATIC int > > +match_kstrtoint(const substring_t *s, unsigned int base, int *res) > > +{ > > + const char *value; > > + int ret; > > + > > + value = match_strdup(s); > > + if (!value) > > + return -ENOMEM; > > + ret = suffix_kstrtoint(value, base, res); > > + kfree(value); > > + return ret; > > +} > > + > > I guess the use case isn't clear to me yet and it's not critical if > this > code is going away by the end of the series, but why not refactor > into a > __suffix_kstrtoint(char *s, ...) variant that accepts an already > duplicated string so we don't have to duplicate each string twice in > the > match_kstrtoint() case? I guess, it seemed sensible to me to create the needed function (that doesn't take the substring_t returned by the existing tokenizer) and just adapt the replacement to work with that, essentially because it is going to go away fairly soon after ... Also I think your suggestion would require creating a helper that would be used by both and then would later need to be merged back into the caller, having only one caller left at that point which is, I think, unnecessary code churn. Not sure I'm terribly worried about this one myself but if it really bugs you I will change it. > > Brian > > > /* > > * This function fills in xfs_mount_t fields based on mount args. > > * Note: the superblock has _not_ yet been read in. > > @@ -255,7 +269,7 @@ xfs_parseargs( > > return -EINVAL; > > break; > > case Opt_logbsize: > > - if (suffix_kstrtoint(args, 10, &mp- > > >m_logbsize)) > > + if (match_kstrtoint(args, 10, &mp->m_logbsize)) > > return -EINVAL; > > break; > > case Opt_logdev: > > @@ -272,7 +286,7 @@ xfs_parseargs( > > break; > > case Opt_allocsize: > > case Opt_biosize: > > - if (suffix_kstrtoint(args, 10, &iosize)) > > + if (match_kstrtoint(args, 10, &iosize)) > > return -EINVAL; > > iosizelog = ffs(iosize) - 1; > > break; > >