From patchwork Tue Jun 23 08:26:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Fujita X-Patchwork-Id: 29038 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id CC59EB7117 for ; Tue, 23 Jun 2009 18:28:07 +1000 (EST) Received: by ozlabs.org (Postfix) id BF4C2DDDE2; Tue, 23 Jun 2009 18:28:07 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 4D67FDDDE5 for ; Tue, 23 Jun 2009 18:28:07 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757886AbZFWI1v (ORCPT ); Tue, 23 Jun 2009 04:27:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757524AbZFWI1v (ORCPT ); Tue, 23 Jun 2009 04:27:51 -0400 Received: from TYO201.gate.nec.co.jp ([202.32.8.193]:38705 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757458AbZFWI1t (ORCPT ); Tue, 23 Jun 2009 04:27:49 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.192]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id n5N8RnfL005482; Tue, 23 Jun 2009 17:27:49 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id n5N8RnI26637; Tue, 23 Jun 2009 17:27:49 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id n5N8RmBS014451; Tue, 23 Jun 2009 17:27:48 +0900 (JST) Received: from matabe.jp.nec.com ([10.26.220.20] [10.26.220.20]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-38358; Tue, 23 Jun 2009 17:26:06 +0900 Received: from [10.64.168.93] ([10.64.168.93] [10.64.168.93]) by mail.jp.nec.com with ESMTP; Tue, 23 Jun 2009 17:26:06 +0900 Message-ID: <4A40919D.6000905@rs.jp.nec.com> Date: Tue, 23 Jun 2009 17:26:05 +0900 From: Akira Fujita User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: Theodore Tso , linux-ext4@vger.kernel.org CC: linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH 6/7]ext4: Add EXT4_IOC_PRINT_GLOBAL_ARULE for debug block allocation restriction Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext4: Add EXT4_IOC_PRINT_GLOBAL_ARULE for debug block allocation restriction From: Akira Fujita This is a debug ioctl for block allocation restriction EXT4_IOC_PRINT_GLOBAL_ARULE prints the information of block allocation restriction to syslog. #define EXT4_IOC_PRINT_GLOBAL_ARULE _IO('f', 19) This information consists of following three entries. - start physical offset - end physical offset - flag (0: mandatory, 1:advisory) e.g. ARULE: start=10000 end=13999 flag=1 The above means ext4 FS where target fd located in is set block allocation restriction from 10000 to 13999 with advisory. Block allocator use blocks from 10000 to 13999 with precedence, if it can not use them, then block allocator tries to use blocks from other range. Signed-off-by: Akira Fujita Signed-off-by: Kazuya Mio --- fs/ext4/ext4.h | 2 ++ fs/ext4/ioctl.c | 5 +++++ fs/ext4/mballoc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b6469d5..4ed4b27 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -362,6 +362,7 @@ struct ext4_new_group_data { #define EXT4_IOC_ADD_GLOBAL_ALLOC_RULE _IOW('f', 16, struct ext4_alloc_rule) #define EXT4_IOC_CLR_GLOBAL_ALLOC_RULE _IOW('f', 17, struct ext4_alloc_rule) #define EXT4_IOC_ADD_INODE_ALLOC_RULE _IOW('f', 18, struct ext4_alloc_rule) +#define EXT4_IOC_PRINT_GLOBAL_ARULE _IO('f', 19) /* * ioctl commands in 32 bit emulation @@ -1404,6 +1405,7 @@ extern int ext4_mb_add_inode_arule(struct inode *inode, struct ext4_alloc_rule *arule); extern void ext4_mb_del_inode_arule(struct inode *inode); extern void ext4_mb_dec_inode_arule(struct inode *inode, unsigned int len); +extern void ext4_mb_print_global_arule(struct inode *inode); /* inode.c */ int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index b009132..323e3d2 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -318,6 +318,11 @@ setversion_out: return err; } + case EXT4_IOC_PRINT_GLOBAL_ARULE: { + ext4_mb_print_global_arule(inode); + return 0; + } + case EXT4_IOC_GROUP_ADD: { struct ext4_new_group_data input; struct super_block *sb = inode->i_sb; diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index ff79189..cd5b833 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5814,3 +5814,48 @@ void ext4_mb_dec_inode_arule(struct inode *inode, unsigned int len) ext4_mb_del_inode_arule(inode); } } + +void ext4_mb_print_global_arule(struct inode *inode) +{ + struct super_block *sb = inode->i_sb; + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_bg_alloc_rule_list *bg_arule_list, *tmp_arule_list; + struct ext4_bg_alloc_rule *bg_arule, *tmp_arule; + + if (list_empty(&sbi->s_bg_arule_list)) { + printk(KERN_ERR "ARULE: s_bg_arule_list is empty\n"); + return; + } + + list_for_each_entry_safe(bg_arule_list, tmp_arule_list, + &sbi->s_bg_arule_list, bg_arule_list) { + ext4_group_t bg; + ext4_fsblk_t bg_first_block_no; + if (list_empty(&bg_arule_list->arule_list)) { + printk(KERN_ERR "ARULE: bg_arule_list[bgnum=%u] " + "is empty\n", bg_arule_list->bg_num); + continue; + } + + printk(KERN_ERR "bgnum %u: bg_arule_list mand %d adv %d\n", + bg_arule_list->bg_num, + bg_arule_list->mand_restricted_blks, + bg_arule_list->adv_restricted_blks); + + bg = bg_arule_list->bg_num; + bg_first_block_no = ext4_group_first_block_no(sb, bg); + list_for_each_entry_safe(bg_arule, tmp_arule, + &bg_arule_list->arule_list, arule_list) { + ext4_grpblk_t g_start = bg_arule->start; + ext4_grpblk_t g_end = bg_arule->end; + ext4_fsblk_t fs_start, fs_end; + + fs_start = bg_first_block_no + g_start; + fs_end = bg_first_block_no + g_end; + printk(KERN_ERR "ARULE: start=%llu end=%llu flag=%d\n", + fs_start, fs_end, bg_arule->alloc_flag); + } + } + + return; +}