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=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 3748AC3A5A2 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 15398233A2 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: =?us-ascii?q?A2DXAQAROl9d/3Wz0XYNWBwBAQEEAQE?= =?us-ascii?q?HBAEBgWeEM4Qgj1YBAQaBEYoRigSFOIFnCQEBAQEBAQEBATcBAYQ6AwICgwI?= =?us-ascii?q?4EwIJAQEBBAECAQEGAwGFWIYZAgEDIwRSEBgNAiYCAkcQBhOFGatQc38zGop?= =?us-ascii?q?AgQwogWOKJHiBB4FEgx2ELIMjglgEjxSGD0KVdwmCH5RYDIIlizYDEIpQLYN?= =?us-ascii?q?zo2GBeU0uCoMnkRRljFYBAQ?= X-IPAS-Result: =?us-ascii?q?A2DXAQAROl9d/3Wz0XYNWBwBAQEEAQEHBAEBgWeEM4Qgj?= =?us-ascii?q?1YBAQaBEYoRigSFOIFnCQEBAQEBAQEBATcBAYQ6AwICgwI4EwIJAQEBBAECA?= =?us-ascii?q?QEGAwGFWIYZAgEDIwRSEBgNAiYCAkcQBhOFGatQc38zGopAgQwogWOKJHiBB?= =?us-ascii?q?4FEgx2ELIMjglgEjxSGD0KVdwmCH5RYDIIlizYDEIpQLYNzo2GBeU0uCoMnk?= =?us-ascii?q?RRljFYBAQ?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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;