From patchwork Mon Jul 22 01:23:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11051331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0256613AC for ; Mon, 22 Jul 2019 01:25:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19EE26E4A for ; Mon, 22 Jul 2019 01:25:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5B53284AA; Mon, 22 Jul 2019 01:25:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83DDE26E4A for ; Mon, 22 Jul 2019 01:25:25 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 132DE21FE42; Sun, 21 Jul 2019 18:24:57 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 95C0021FCCB for ; Sun, 21 Jul 2019 18:24:04 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 0B3202232; Sun, 21 Jul 2019 21:23:56 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 0A18EBF; Sun, 21 Jul 2019 21:23:56 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown , Shaun Tancheff , Li Dongyang , Artem Blagodarenko , Yang Sheng Date: Sun, 21 Jul 2019 21:23:51 -0400 Message-Id: <1563758631-29550-23-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1563758631-29550-1-git-send-email-jsimmons@infradead.org> References: <1563758631-29550-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 22/22] ext4: export mb stream allocator variables X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: James Simmons --- fs/ext4/ext4.h | 2 ++ fs/ext4/mballoc.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ext4/sysfs.c | 4 ++++ 3 files changed, 65 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 0ee4606..46f2619 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2620,6 +2620,8 @@ extern int ext4_init_inode_table(struct super_block *sb, /* mballoc.c */ extern const struct file_operations ext4_seq_prealloc_table_fops; extern const struct seq_operations ext4_mb_seq_groups_ops; +extern const struct file_operations ext4_seq_mb_last_group_fops; +extern int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v); extern long ext4_mb_stats; extern long ext4_mb_max_to_scan; extern int ext4_mb_init(struct super_block *); diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 82398b0..8270e35 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2459,6 +2459,65 @@ static struct kmem_cache *get_groupinfo_cache(int blocksize_bits) return cachep; } +#define EXT4_MB_MAX_INPUT_STRING_SIZE 32 + +static ssize_t ext4_mb_last_group_write(struct file *file, + const char __user *buf, + size_t cnt, loff_t *pos) +{ + char dummy[EXT4_MB_MAX_INPUT_STRING_SIZE + 1]; + struct super_block *sb = PDE_DATA(file_inode(file)); + struct ext4_sb_info *sbi = EXT4_SB(sb); + unsigned long val; + char *end; + + if (cnt > EXT4_MB_MAX_INPUT_STRING_SIZE) + return -EINVAL; + if (copy_from_user(dummy, buf, cnt)) + return -EFAULT; + dummy[cnt] = '\0'; + val = simple_strtoul(dummy, &end, 0); + if (dummy == end) + return -EINVAL; + if (val >= ext4_get_groups_count(sb)) + return -ERANGE; + spin_lock(&sbi->s_md_lock); + sbi->s_mb_last_group = val; + sbi->s_mb_last_start = 0; + spin_unlock(&sbi->s_md_lock); + return cnt; +} + +static int ext4_mb_seq_last_group_seq_show(struct seq_file *m, void *v) +{ + struct ext4_sb_info *sbi = EXT4_SB(m->private); + + seq_printf(m , "%ld\n", sbi->s_mb_last_group); + return 0; +} + +static int ext4_mb_seq_last_group_open(struct inode *inode, struct file *file) +{ + return single_open(file, ext4_mb_seq_last_group_seq_show, PDE_DATA(inode)); +} + +const struct file_operations ext4_seq_mb_last_group_fops = { + .owner = THIS_MODULE, + .open = ext4_mb_seq_last_group_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + .write = ext4_mb_last_group_write, +}; + +int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v) +{ + struct ext4_sb_info *sbi = EXT4_SB(m->private); + + seq_printf(m , "%ld\n", sbi->s_mb_last_start); + return 0; +} + /* * Allocate the top-level s_group_info array for the specified number * of groups diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index 575f318..6bcb455 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -425,6 +425,10 @@ int ext4_register_sysfs(struct super_block *sb) &ext4_mb_seq_groups_ops, sb); proc_create_data("prealloc_table", S_IRUGO, sbi->s_proc, &ext4_seq_prealloc_table_fops, sb); + proc_create_data("mb_last_group", S_IRUGO, sbi->s_proc, + &ext4_seq_mb_last_group_fops, sb); + proc_create_single_data("mb_last_start", S_IRUGO, sbi->s_proc, + ext4_mb_seq_last_start_seq_show, sb); } return 0; }