lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGBYx2Yd4_V0hnFSA=DRE2gtmAuWn96AdoJXvFa+yg-vZoUibA@mail.gmail.com>
Date:	Thu, 21 Jul 2011 09:37:17 +0800
From:	Yongqiang Yang <xiaoqiangnk@...il.com>
To:	Andreas Dilger <aedilger@...il.com>
Cc:	"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
	"tytso@....edu" <tytso@....edu>
Subject: Re: [PATCH 2/2] ext4: remove ext4_free_blocks_after_init()

On Wed, Jul 20, 2011 at 11:41 PM, Andreas Dilger <aedilger@...il.com> wrote:
> On 2011-07-20, at 7:32 AM, Yongqiang Yang <xiaoqiangnk@...il.com> wrote:
>> This patch removes ext4_free_blocks_after_init() and simplifies
>> ext4_init_block_bitmap() a lot.
>
> Why not use the ext4_set_bits() function, exported in another patch, to set multiple bits?
That patch has not been merged.  After it is merged, I will post
another patch doing this, this can easy Ted's work.  That patch is a
part of resize, but this patch has nothing to do with it logically.


Thank you,

Yongqiang.
>
>> Signed-off-by: Yongqiang Yang <xiaoqiangnk@...il.com>
>> ---
>> fs/ext4/balloc.c |  122 ++++++++++++++++++-----------------------------------
>> fs/ext4/ext4.h   |    4 +-
>> 2 files changed, 43 insertions(+), 83 deletions(-)
>>
>> diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
>> index f8224ad..2dd9820 100644
>> --- a/fs/ext4/balloc.c
>> +++ b/fs/ext4/balloc.c
>> @@ -55,60 +55,31 @@ static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block,
>>    return 0;
>> }
>>
>> -static int ext4_group_used_meta_blocks(struct super_block *sb,
>> -                       ext4_group_t block_group,
>> -                       struct ext4_group_desc *gdp)
>> -{
>> -    ext4_fsblk_t tmp;
>> -    struct ext4_sb_info *sbi = EXT4_SB(sb);
>> -    /* block bitmap, inode bitmap, and inode table blocks */
>> -    int used_blocks = sbi->s_itb_per_group + 2;
>> -
>> -    if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
>> -        if (!ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp),
>> -                    block_group))
>> -            used_blocks--;
>> -
>> -        if (!ext4_block_in_group(sb, ext4_inode_bitmap(sb, gdp),
>> -                    block_group))
>> -            used_blocks--;
>> -
>> -        tmp = ext4_inode_table(sb, gdp);
>> -        for (; tmp < ext4_inode_table(sb, gdp) +
>> -                sbi->s_itb_per_group; tmp++) {
>> -            if (!ext4_block_in_group(sb, tmp, block_group))
>> -                used_blocks -= 1;
>> -        }
>> -    }
>> -    return used_blocks;
>> -}
>> -
>> -/* Initializes an uninitialized block bitmap if given, and returns the
>> - * number of blocks free in the group. */
>> -unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
>> +/* Initializes an uninitialized block bitmap */
>> +void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
>>         ext4_group_t block_group, struct ext4_group_desc *gdp)
>> {
>> +    ext4_fsblk_t start, tmp;
>>    int bit, bit_max;
>>    ext4_group_t ngroups = ext4_get_groups_count(sb);
>> -    unsigned free_blocks, group_blocks;
>> +    unsigned group_blocks;
>>    struct ext4_sb_info *sbi = EXT4_SB(sb);
>> -
>> -    if (bh) {
>> -        J_ASSERT_BH(bh, buffer_locked(bh));
>> -
>> -        /* If checksum is bad mark all blocks used to prevent allocation
>> -         * essentially implementing a per-group read-only flag. */
>> -        if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
>> -            ext4_error(sb, "Checksum bad for group %u",
>> -                    block_group);
>> -            ext4_free_blks_set(sb, gdp, 0);
>> -            ext4_free_inodes_set(sb, gdp, 0);
>> -            ext4_itable_unused_set(sb, gdp, 0);
>> -            memset(bh->b_data, 0xff, sb->s_blocksize);
>> -            return 0;
>> -        }
>> -        memset(bh->b_data, 0, sb->s_blocksize);
>> +    int flex_bg = 0;
>> +
>> +    J_ASSERT_BH(bh, bh && buffer_locked(bh));
>> +
>> +    /* If checksum is bad mark all blocks used to prevent allocation
>> +     * essentially implementing a per-group read-only flag. */
>> +    if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
>> +        ext4_error(sb, "Checksum bad for group %u",
>> +                block_group);
>> +        ext4_free_blks_set(sb, gdp, 0);
>> +        ext4_free_inodes_set(sb, gdp, 0);
>> +        ext4_itable_unused_set(sb, gdp, 0);
>> +        memset(bh->b_data, 0xff, sb->s_blocksize);
>> +        return;
>>    }
>> +    memset(bh->b_data, 0, sb->s_blocksize);
>>
>>    /* Check for superblock and gdt backups in this group */
>>    bit_max = ext4_bg_has_super(sb, block_group);
>> @@ -137,46 +108,37 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
>>        group_blocks = EXT4_BLOCKS_PER_GROUP(sb);
>>    }
>>
>> -    free_blocks = group_blocks - bit_max;
>>
>> -    if (bh) {
>> -        ext4_fsblk_t start, tmp;
>> -        int flex_bg = 0;
>> +    for (bit = 0; bit < bit_max; bit++)
>> +        ext4_set_bit(bit, bh->b_data);
>>
>> -        for (bit = 0; bit < bit_max; bit++)
>> -            ext4_set_bit(bit, bh->b_data);
>> +    start = ext4_group_first_block_no(sb, block_group);
>>
>> -        start = ext4_group_first_block_no(sb, block_group);
>> +    flex_bg = EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG);
>>
>> -        if (EXT4_HAS_INCOMPAT_FEATURE(sb,
>> -                          EXT4_FEATURE_INCOMPAT_FLEX_BG))
>> -            flex_bg = 1;
>> +    /* Set bits for block and inode bitmaps, and inode table */
>> +    tmp = ext4_block_bitmap(sb, gdp);
>> +    if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
>> +        ext4_set_bit(tmp - start, bh->b_data);
>>
>> -        /* Set bits for block and inode bitmaps, and inode table */
>> -        tmp = ext4_block_bitmap(sb, gdp);
>> -        if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
>> -            ext4_set_bit(tmp - start, bh->b_data);
>> +    tmp = ext4_inode_bitmap(sb, gdp);
>> +    if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
>> +        ext4_set_bit(tmp - start, bh->b_data);
>>
>> -        tmp = ext4_inode_bitmap(sb, gdp);
>> -        if (!flex_bg || ext4_block_in_group(sb, tmp, block_group))
>> +    tmp = ext4_inode_table(sb, gdp);
>> +    for (; tmp < ext4_inode_table(sb, gdp) +
>> +            sbi->s_itb_per_group; tmp++) {
>> +        if (!flex_bg ||
>> +            ext4_block_in_group(sb, tmp, block_group))
>>            ext4_set_bit(tmp - start, bh->b_data);
>> -
>> -        tmp = ext4_inode_table(sb, gdp);
>> -        for (; tmp < ext4_inode_table(sb, gdp) +
>> -                sbi->s_itb_per_group; tmp++) {
>> -            if (!flex_bg ||
>> -                ext4_block_in_group(sb, tmp, block_group))
>> -                ext4_set_bit(tmp - start, bh->b_data);
>> -        }
>> -        /*
>> -         * Also if the number of blocks within the group is
>> -         * less than the blocksize * 8 ( which is the size
>> -         * of bitmap ), set rest of the block bitmap to 1
>> -         */
>> -        ext4_mark_bitmap_end(group_blocks, sb->s_blocksize * 8,
>> -                     bh->b_data);
>>    }
>> -    return free_blocks - ext4_group_used_meta_blocks(sb, block_group, gdp);
>> +    /*
>> +     * Also if the number of blocks within the group is
>> +     * less than the blocksize * 8 ( which is the size
>> +     * of bitmap ), set rest of the block bitmap to 1
>> +     */
>> +    ext4_mark_bitmap_end(group_blocks, sb->s_blocksize * 8,
>> +                 bh->b_data);
>> }
>>
>>
>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
>> index 62cee2b..eacaad2 100644
>> --- a/fs/ext4/ext4.h
>> +++ b/fs/ext4/ext4.h
>> @@ -1741,12 +1741,10 @@ extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
>> extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
>> struct buffer_head *ext4_read_block_bitmap(struct super_block *sb,
>>                      ext4_group_t block_group);
>> -extern unsigned ext4_init_block_bitmap(struct super_block *sb,
>> +extern void ext4_init_block_bitmap(struct super_block *sb,
>>                       struct buffer_head *bh,
>>                       ext4_group_t group,
>>                       struct ext4_group_desc *desc);
>> -#define ext4_free_blocks_after_init(sb, group, desc)            \
>> -        ext4_init_block_bitmap(sb, NULL, group, desc)
>> ext4_fsblk_t ext4_inode_to_goal_block(struct inode *);
>>
>> /* dir.c */
>> --
>> 1.7.5.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>> the body of a message to majordomo@...r.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Best Wishes
Yongqiang Yang
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ