From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52871C3A5A3 for ; Tue, 27 Aug 2019 12:40:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D6EE20828 for ; Tue, 27 Aug 2019 12:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbfH0MkF (ORCPT ); Tue, 27 Aug 2019 08:40:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58734 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbfH0MkF (ORCPT ); Tue, 27 Aug 2019 08:40:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65CD67F74B; Tue, 27 Aug 2019 12:40:05 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3688D414A; Tue, 27 Aug 2019 12:40:02 +0000 (UTC) Date: Tue, 27 Aug 2019 08:40:00 -0400 From: Brian Foster To: Ian Kent Cc: linux-xfs , Dave Chinner , David Howells , Al Viro , Eric Sandeen Subject: Re: [PATCH v2 03/15] xfs: mount-api - refactor suffix_kstrtoint() Message-ID: <20190827124000.GB10636@bfoster> References: <156652158924.2607.14608448087216437699.stgit@fedora-28> <156652197305.2607.14039510188924939054.stgit@fedora-28> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <156652197305.2607.14039510188924939054.stgit@fedora-28> User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Tue, 27 Aug 2019 12:40:05 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 > --- > 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? 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; >