From: Yongqiang Yang Subject: [PATCH 08/13] ext4: add a function which sets up a flex groups each time Date: Thu, 11 Aug 2011 11:28:23 +0800 Message-ID: <1313033308-882-9-git-send-email-xiaoqiangnk@gmail.com> References: <1313033308-882-1-git-send-email-xiaoqiangnk@gmail.com> Cc: aedilger@gmail.com, tytso@mit.edu, Yongqiang Yang To: linux-ext4@vger.kernel.org Return-path: Received: from mail-pz0-f42.google.com ([209.85.210.42]:48649 "EHLO mail-pz0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753987Ab1HKDfm (ORCPT ); Wed, 10 Aug 2011 23:35:42 -0400 Received: by mail-pz0-f42.google.com with SMTP id 37so2947235pzk.1 for ; Wed, 10 Aug 2011 20:35:42 -0700 (PDT) In-Reply-To: <1313033308-882-1-git-send-email-xiaoqiangnk@gmail.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: This patch adds a function named ext4_setup_new_descs() which sets up a flex groups each time. Signed-off-by: Yongqiang Yang --- fs/ext4/resize.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 7e91d58..5939b62 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -1114,7 +1114,8 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb, * @sb: super block */ static int ext4_setup_new_desc(handle_t *handle, struct super_block *sb, - struct ext4_new_group_data *input) + struct ext4_new_group_data *input, + __u16 bg_flags) { struct ext4_sb_info *sbi = EXT4_SB(sb); ext4_group_t group; @@ -1143,7 +1144,7 @@ static int ext4_setup_new_desc(handle_t *handle, struct super_block *sb, ext4_inode_table_set(sb, gdp, input->inode_table); /* LV FIXME */ ext4_free_blks_set(sb, gdp, input->free_blocks_count); ext4_free_inodes_set(sb, gdp, EXT4_INODES_PER_GROUP(sb)); - gdp->bg_flags = cpu_to_le16(EXT4_BG_INODE_ZEROED); + gdp->bg_flags = cpu_to_le16(bg_flags); gdp->bg_checksum = ext4_group_desc_csum(sbi, input->group, gdp); err = ext4_handle_dirty_metadata(handle, NULL, gdb_bh); @@ -1162,6 +1163,26 @@ static int ext4_setup_new_desc(handle_t *handle, struct super_block *sb, } /* + * ext4_setup_new_descs setups group descriptors of a flex groups + */ +static int ext4_setup_new_descs(handle_t *handle, struct super_block *sb, + struct ext4_new_flex_group_data *flex_gd) +{ + struct ext4_new_group_data *group_data = flex_gd->groups; + __u16 *bg_flags = flex_gd->bg_flags; + int i, err = 0; + + for (i = 0; i < flex_gd->count; i++) { + err = ext4_setup_new_desc(handle, sb, group_data + i, + bg_flags[i]); + if (err) + return err; + } + + return err; +} + +/* * ext4_update_super() updates super so that new the added group can be seen * by the filesystem. * -- 1.7.5.1