From patchwork Sat Sep 27 07:26:55 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Fujita X-Patchwork-Id: 1762 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org 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 5D847DDD0C for ; Sat, 27 Sep 2008 17:27:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbYI0H1A (ORCPT ); Sat, 27 Sep 2008 03:27:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751923AbYI0H06 (ORCPT ); Sat, 27 Sep 2008 03:26:58 -0400 Received: from TYO202.gate.nec.co.jp ([202.32.8.206]:57350 "EHLO tyo202.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751948AbYI0H05 (ORCPT ); Sat, 27 Sep 2008 03:26:57 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id m8R7QtU9004456; Sat, 27 Sep 2008 16:26:55 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id m8R7Qth20605; Sat, 27 Sep 2008 16:26:55 +0900 (JST) Received: from shoin.jp.nec.com (shoin.jp.nec.com [10.26.220.3]) by mailsv.nec.co.jp (8.13.8/8.13.4) with ESMTP id m8R7QtCF029308; Sat, 27 Sep 2008 16:26:55 +0900 (JST) Received: from [10.64.168.93] ([10.64.168.93] [10.64.168.93]) by mail.jp.nec.com with ESMTP; Sat, 27 Sep 2008 16:26:55 +0900 Message-ID: <48DDE03F.8020604@rs.jp.nec.com> Date: Sat, 27 Sep 2008 16:26:55 +0900 From: Akira Fujita User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: linux-ext4@vger.kernel.org CC: linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH 6/12]ext4: Add the EXT4_IOC_GROUP_INFO ioctl Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext4: online defrag -- Add the EXT4_IOC_GROUP_INFO ioctl. From: Akira Fujita The EXT4_IOC_GROUP_INFO ioctl gets the block group information of target inode is located in. This ioctl is used only in the force defrag (-f). The defragger will do the same thing in user space instead of implement the ioctl, so this ioctl will go away in the next version. Signed-off-by: Akira Fujita Signed-off-by: Takashi Sato --- fs/ext4/defrag.c | 11 +++++++++++ fs/ext4/ext4.h | 6 ++++++ fs/ext4/ioctl.c | 3 ++- 3 files changed, 19 insertions(+), 1 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/defrag.c b/fs/ext4/defrag.c index 49b8d49..cb7d237 100644 --- a/fs/ext4/defrag.c +++ b/fs/ext4/defrag.c @@ -114,6 +114,17 @@ int ext4_defrag_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, block = ext4_bmap(mapping, block); return put_user(block, p); + } else if (cmd == EXT4_IOC_GROUP_INFO) { + struct ext4_group_data_info grp_data; + + grp_data.s_blocks_per_group = + EXT4_BLOCKS_PER_GROUP(inode->i_sb); + grp_data.s_inodes_per_group = + EXT4_INODES_PER_GROUP(inode->i_sb); + + if (copy_to_user((struct ext4_group_data_info __user *)arg, + &grp_data, sizeof(grp_data))) + return -EFAULT; } else if (cmd == EXT4_IOC_DEFRAG) { struct ext4_ext_defrag_data defrag; struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index db4891c..a635a76 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -304,6 +304,7 @@ struct ext4_new_group_data { /* note ioctl 11 reserved for filesystem-independent FIEMAP ioctl */ #define EXT4_IOC_DEFRAG _IOW('f', 15, struct ext4_ext_defrag_data) #define EXT4_IOC_FIBMAP _IOW('f', 16, ext4_fsblk_t) +#define EXT4_IOC_GROUP_INFO _IOW('f', 17, struct ext4_group_data_info) /* * ioctl commands in 32 bit emulation @@ -327,6 +328,11 @@ struct ext4_ext_defrag_data { ext4_fsblk_t goal; /* block offset for allocation */ }; +struct ext4_group_data_info { + int s_blocks_per_group; /* blocks per group */ + int s_inodes_per_group; /* inodes per group */ +}; + #define EXT4_TRANS_META_BLOCKS 4 /* bitmap + group desc + sb + inode */ /* diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 5982f3e..c05502f 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -257,7 +257,8 @@ setversion_out: return err; } case EXT4_IOC_FIBMAP: - case EXT4_IOC_DEFRAG: { + case EXT4_IOC_DEFRAG: + case EXT4_IOC_GROUP_INFO: { return ext4_defrag_ioctl(inode, filp, cmd, arg); } case EXT4_IOC_GROUP_ADD: {