From patchwork Wed Oct 9 11:30:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 11181025 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F74D912 for ; Wed, 9 Oct 2019 11:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0AB9C21835 for ; Wed, 9 Oct 2019 11:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725848AbfJILbB (ORCPT ); Wed, 9 Oct 2019 07:31:01 -0400 Received: from icp-osb-irony-out3.external.iinet.net.au ([203.59.1.153]:33473 "EHLO icp-osb-irony-out3.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfJILbB (ORCPT ); Wed, 9 Oct 2019 07:31:01 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BZAQBxxJ1d/0e30XYNWRwBAQEBAQcBAREBBAQBAYF7hDqEI48oAQEBAwaBEYodhR+EbIU8gWcJAQEBAQEBAQEBNwEBhDsDAgKCcjgTAgwBAQEEAQEBAQEFAwGFWIYaAgEDIwRSEBgNAiYCAkcQBhOFGa9vdX8zGoosgQwogWWKQXiBB4FEgx2ELIMmglgEjzQ3hjxDllmCLJU0DIIui2cDEIsMLYQKpT2Bek0uCoMnUJBGZ5EUAQE X-IPAS-Result: A2BZAQBxxJ1d/0e30XYNWRwBAQEBAQcBAREBBAQBAYF7hDqEI48oAQEBAwaBEYodhR+EbIU8gWcJAQEBAQEBAQEBNwEBhDsDAgKCcjgTAgwBAQEEAQEBAQEFAwGFWIYaAgEDIwRSEBgNAiYCAkcQBhOFGa9vdX8zGoosgQwogWWKQXiBB4FEgx2ELIMmglgEjzQ3hjxDllmCLJU0DIIui2cDEIsMLYQKpT2Bek0uCoMnUJBGZ5EUAQE X-IronPort-AV: E=Sophos;i="5.67,273,1566835200"; d="scan'208";a="216229011" Received: from unknown (HELO [192.168.1.222]) ([118.209.183.71]) by icp-osb-irony-out3.iinet.net.au with ESMTP; 09 Oct 2019 19:30:36 +0800 Subject: [PATCH v5 05/17] xfs: mount-api - refactor suffix_kstrtoint() From: Ian Kent To: linux-xfs Cc: Brian Foster , Eric Sandeen , David Howells , Dave Chinner , Al Viro Date: Wed, 09 Oct 2019 19:30:36 +0800 Message-ID: <157062063684.32346.12253005903079702405.stgit@fedora-28> In-Reply-To: <157062043952.32346.977737248061083292.stgit@fedora-28> References: <157062043952.32346.977737248061083292.stgit@fedora-28> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 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 Reviewed-by: Brian Foster --- 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 9c1ce3d70c08..6a16750b1314 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -160,13 +160,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; @@ -191,6 +191,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; +} + /* * This function fills in xfs_mount_t fields based on mount args. * Note: the superblock has _not_ yet been read in. @@ -262,7 +276,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: @@ -278,7 +292,7 @@ xfs_parseargs( return -ENOMEM; break; case Opt_allocsize: - if (suffix_kstrtoint(args, 10, &iosize)) + if (match_kstrtoint(args, 10, &iosize)) return -EINVAL; iosizelog = ffs(iosize) - 1; break;