From patchwork Sun Feb 28 10:59:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 82792 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1SB0NgB012872 for ; Sun, 28 Feb 2010 11:00:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031829Ab0B1K7y (ORCPT ); Sun, 28 Feb 2010 05:59:54 -0500 Received: from mail-iw0-f182.google.com ([209.85.223.182]:43670 "EHLO mail-iw0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031823Ab0B1K7u (ORCPT ); Sun, 28 Feb 2010 05:59:50 -0500 Received: by iwn12 with SMTP id 12so1590014iwn.21 for ; Sun, 28 Feb 2010 02:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=StJK5cGvX615hvbAXe/xKBGF7k+VbxphGJAFPwj4ZVw=; b=nufgfRN1Go/v9f4GMexds/bKIMTV4MUeILvvMlB8aBzIxgmLXL/vsAHNxJkiBp73pV DAeF7qvE1T3MPwRapFl3YT6V/dbomP4nBg7cChjdtDI+pLE79ZxS43nfrlnKI8MfR0kk KncX6CavOQPnHCki0SEYi2vHP7LZ6K9Z/Vm30= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=ln26hdFiMkbju9FRx8FJmKCgc6RaGDubsddwmLswu3de0SNsxfTRVaw4twqho9c4wD 1ho7VPwj+6drNG+mBVAw36yXWzJhTpBwhOrr7rmex31kkyFHRZauRyoutt2THuX8V2g6 ZSbCPtjMBIqsCWf/7nG+k+2QIMzOvLwAM4yuM= Received: by 10.231.150.2 with SMTP id w2mr1599624ibv.90.1267354790060; Sun, 28 Feb 2010 02:59:50 -0800 (PST) Received: from localhost (p12140-adsao01yokonib1-acca.kanagawa.ocn.ne.jp [61.199.6.140]) by mx.google.com with ESMTPS id 23sm1965403iwn.2.2010.02.28.02.59.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 28 Feb 2010 02:59:49 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org Cc: Akinobu Mita , Chris Mason , linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: use memparse Date: Sun, 28 Feb 2010 19:59:11 +0900 Message-Id: <1267354751-6502-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.6.0.6 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 28 Feb 2010 11:00:24 +0000 (UTC) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2aa8ec6..52af317 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2386,7 +2386,6 @@ void btrfs_sysfs_del_super(struct btrfs_fs_info *root); ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); /* super.c */ -u64 btrfs_parse_size(char *str); int btrfs_parse_options(struct btrfs_root *root, char *options); int btrfs_sync_fs(struct super_block *sb, int wait); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 645a179..c359efd 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -608,7 +608,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root, mod = 1; sizestr++; } - new_size = btrfs_parse_size(sizestr); + new_size = memparse(sizestr, NULL); if (new_size == 0) { ret = -EINVAL; goto out_unlock; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 8a1ea6e..aa48c6b 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -95,31 +95,6 @@ static match_table_t tokens = { {Opt_err, NULL}, }; -u64 btrfs_parse_size(char *str) -{ - u64 res; - int mult = 1; - char *end; - char last; - - res = simple_strtoul(str, &end, 10); - - last = end[0]; - if (isalpha(last)) { - last = tolower(last); - switch (last) { - case 'g': - mult *= 1024; - case 'm': - mult *= 1024; - case 'k': - mult *= 1024; - } - res = res * mult; - } - return res; -} - /* * Regular mount options parser. Everything that is needed only when * reading in a new superblock is parsed here. @@ -213,7 +188,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_max_extent: num = match_strdup(&args[0]); if (num) { - info->max_extent = btrfs_parse_size(num); + info->max_extent = memparse(num, NULL); kfree(num); info->max_extent = max_t(u64, @@ -225,7 +200,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_max_inline: num = match_strdup(&args[0]); if (num) { - info->max_inline = btrfs_parse_size(num); + info->max_inline = memparse(num, NULL); kfree(num); if (info->max_inline) { @@ -240,7 +215,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) case Opt_alloc_start: num = match_strdup(&args[0]); if (num) { - info->alloc_start = btrfs_parse_size(num); + info->alloc_start = memparse(num, NULL); kfree(num); printk(KERN_INFO "btrfs: allocations start at %llu\n",