From patchwork Fri Aug 23 00:59:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 11110339 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 2DE1914DB for ; Fri, 23 Aug 2019 01:08:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 153F323402 for ; Fri, 23 Aug 2019 01:08:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732535AbfHWBIq (ORCPT ); Thu, 22 Aug 2019 21:08:46 -0400 Received: from icp-osb-irony-out2.external.iinet.net.au ([203.59.1.155]:5498 "EHLO icp-osb-irony-out2.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387606AbfHWBIq (ORCPT ); Thu, 22 Aug 2019 21:08:46 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DXAQAROl9d/3Wz0XYNWBwBAQEEAQEHBAEBgWeEM4Qgj1YBAQaBEYoRigSFOIFnCQEBAQEBAQEBATcBAYQ6AwICgwI4EwIJAQEBBAECAQEGAwGFWIYZAgEDIwRSEBgNAiYCAkcQBhOFGatQc38zGopAgQwogWOKJHiBB4FEgx2ELIMjglgEjxSGD0KVdwmCH5RYDIIlizYDEIpQLYNzo2GBeU0uCoMnkRRljFYBAQ X-IPAS-Result: A2DXAQAROl9d/3Wz0XYNWBwBAQEEAQEHBAEBgWeEM4Qgj1YBAQaBEYoRigSFOIFnCQEBAQEBAQEBATcBAYQ6AwICgwI4EwIJAQEBBAECAQEGAwGFWIYZAgEDIwRSEBgNAiYCAkcQBhOFGatQc38zGopAgQwogWOKJHiBB4FEgx2ELIMjglgEjxSGD0KVdwmCH5RYDIIlizYDEIpQLYNzo2GBeU0uCoMnkRRljFYBAQ X-IronPort-AV: E=Sophos;i="5.64,419,1559491200"; d="scan'208";a="231796664" Received: from unknown (HELO [192.168.1.222]) ([118.209.179.117]) by icp-osb-irony-out2.iinet.net.au with ESMTP; 23 Aug 2019 08:59:33 +0800 Subject: [PATCH v2 03/15] xfs: mount-api - refactor suffix_kstrtoint() From: Ian Kent To: linux-xfs Cc: Dave Chinner , David Howells , Al Viro , Eric Sandeen Date: Fri, 23 Aug 2019 08:59:33 +0800 Message-ID: <156652197305.2607.14039510188924939054.stgit@fedora-28> In-Reply-To: <156652158924.2607.14608448087216437699.stgit@fedora-28> References: <156652158924.2607.14608448087216437699.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 --- 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; +} + /* * 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;