From patchwork Wed Sep 24 12:38:42 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBCb2jDqQ==?= X-Patchwork-Id: 1279 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 4C068DDF27 for ; Wed, 24 Sep 2008 22:38:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751538AbYIXMiN (ORCPT ); Wed, 24 Sep 2008 08:38:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751517AbYIXMiN (ORCPT ); Wed, 24 Sep 2008 08:38:13 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:37831 "EHLO ecfrec.frec.bull.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbYIXMiM (ORCPT ); Wed, 24 Sep 2008 08:38:12 -0400 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id ACC541A18F4; Wed, 24 Sep 2008 14:38:05 +0200 (CEST) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30959-08; Wed, 24 Sep 2008 14:38:02 +0200 (CEST) Received: from cyclope.frec.bull.fr (cyclope.frec.bull.fr [129.183.4.9]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 735161A194B; Wed, 24 Sep 2008 14:37:10 +0200 (CEST) Received: from [129.183.101.223] (dhcp129183101223.frec.bull.fr [129.183.101.223]) by cyclope.frec.bull.fr (Postfix) with ESMTP id 7190E2728D; Wed, 24 Sep 2008 14:37:07 +0200 (CEST) Subject: Re: [PATCH v2] ext4: fix initialization of UNINIT bitmap blocks From: =?ISO-8859-1?Q?Fr=E9d=E9ric_Boh=E9?= To: "Aneesh Kumar K.V" , Theodore Tso Cc: "linux-ext4@vger.kernel.org" In-Reply-To: <1222075960.3581.33.camel@frecb007923.frec.bull.fr> References: <1221478895.6733.26.camel@frecb007923.frec.bull.fr> <1221481007.6733.32.camel@frecb007923.frec.bull.fr> <20080915133604.GA6548@skywalker> <1221489026.6733.36.camel@frecb007923.frec.bull.fr> <1221745514.3550.83.camel@frecb007923.frec.bull.fr> <20080921004451.GA15402@mit.edu> <1222070998.3581.25.camel@frecb007923.frec.bull.fr> <20080922084721.GA6691@skywalker> <1222075960.3581.33.camel@frecb007923.frec.bull.fr> Organization: Bull Date: Wed, 24 Sep 2008 14:38:42 +0200 Message-Id: <1222259922.3511.6.camel@frecb007923.frec.bull.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Virus-Scanned: by amavisd-new at frec.bull.fr Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Le lundi 22 septembre 2008 à 11:32 +0200, Frédéric Bohé a écrit : > Le lundi 22 septembre 2008 à 14:17 +0530, Aneesh Kumar K.V a écrit : > > What you can do is make ext4_group_info generic for both mballoc and > > oldalloc. We can then add bg_flag to the in memory ext4_group_info > > that would indicate whether the group is initialized or not. Here > > initialized for an UNINIT_GROUP indicate we have done > > ext4_init_block_bitmap on the buffer_head. Then > > instead of depending on the buffer_head uptodate flag we can check > > for the ext4_group_info bg_flags and decided whether the block/inode > > bitmap need to be initialized. > > > > That makes sense ! I agree with you, we need an additional in-memory > flag to know whether buffers are initialized or not. Anyway, making > ext4_group_info generic will lead to unneeded memory consumption for > oldalloc. Maybe a simple independent bits array could do the trick. Is > there any advantage to re-use ext4_group_info ? > This is an implementation of what I was talking about. Please let me know your comments. --- 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 Index: linux-2.6.27-rc6+patch_queue/fs/ext4/balloc.c =================================================================== --- linux-2.6.27-rc6+patch_queue.orig/fs/ext4/balloc.c 2008-09-23 15:04:39.000000000 +0200 +++ linux-2.6.27-rc6+patch_queue/fs/ext4/balloc.c 2008-09-23 15:39:38.000000000 +0200 @@ -175,6 +175,8 @@ unsigned ext4_init_block_bitmap(struct s */ mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data); } + + ext4_set_bit(block_group, sbi->s_block_bitmap_buffer_state); return free_blocks - ext4_group_used_meta_blocks(sb, block_group); } @@ -318,9 +320,13 @@ ext4_read_block_bitmap(struct super_bloc block_group, bitmap_blk); return NULL; } - if (bh_uptodate_or_lock(bh)) + + if (buffer_uptodate(bh) && ext4_test_bit(block_group, + EXT4_SB(sb)->s_block_bitmap_buffer_state)) return bh; + lock_buffer(bh); + spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group)); if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { ext4_init_block_bitmap(sb, bh, block_group, desc); @@ -328,7 +334,9 @@ ext4_read_block_bitmap(struct super_bloc unlock_buffer(bh); spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); return bh; - } + } else + ext4_set_bit(block_group, + EXT4_SB(sb)->s_block_bitmap_buffer_state); spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); if (bh_submit_read(bh) < 0) { put_bh(bh); Index: linux-2.6.27-rc6+patch_queue/fs/ext4/ext4_sb.h =================================================================== --- linux-2.6.27-rc6+patch_queue.orig/fs/ext4/ext4_sb.h 2008-09-23 15:07:28.000000000 +0200 +++ linux-2.6.27-rc6+patch_queue/fs/ext4/ext4_sb.h 2008-09-23 15:40:57.000000000 +0200 @@ -147,6 +147,14 @@ struct ext4_sb_info { unsigned int s_log_groups_per_flex; struct flex_groups *s_flex_groups; + + /* + * Flag for the state of the bitmaps buffers + * 0 = unknown or uninitialized + * 1 = initialized + */ + char *s_block_bitmap_buffer_state; + char *s_inode_bitmap_buffer_state; }; #endif /* _EXT4_SB */ Index: linux-2.6.27-rc6+patch_queue/fs/ext4/ialloc.c =================================================================== --- linux-2.6.27-rc6+patch_queue.orig/fs/ext4/ialloc.c 2008-09-23 15:09:15.000000000 +0200 +++ linux-2.6.27-rc6+patch_queue/fs/ext4/ialloc.c 2008-09-23 15:41:24.000000000 +0200 @@ -86,6 +86,7 @@ unsigned ext4_init_inode_bitmap(struct s memset(bh->b_data, 0, (EXT4_INODES_PER_GROUP(sb) + 7) / 8); mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), EXT4_BLOCKS_PER_GROUP(sb), bh->b_data); + ext4_set_bit(block_group, sbi->s_inode_bitmap_buffer_state); return EXT4_INODES_PER_GROUP(sb); } @@ -115,9 +116,12 @@ ext4_read_inode_bitmap(struct super_bloc block_group, bitmap_blk); return NULL; } - if (bh_uptodate_or_lock(bh)) + + if (buffer_uptodate(bh) && ext4_test_bit(block_group, + EXT4_SB(sb)->s_inode_bitmap_buffer_state)) return bh; + lock_buffer(bh); spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group)); if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) { ext4_init_inode_bitmap(sb, bh, block_group, desc); @@ -125,7 +129,9 @@ ext4_read_inode_bitmap(struct super_bloc unlock_buffer(bh); spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); return bh; - } + } else + ext4_set_bit(block_group, + EXT4_SB(sb)->s_inode_bitmap_buffer_state); spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); if (bh_submit_read(bh) < 0) { put_bh(bh); Index: linux-2.6.27-rc6+patch_queue/fs/ext4/mballoc.c =================================================================== --- linux-2.6.27-rc6+patch_queue.orig/fs/ext4/mballoc.c 2008-09-23 15:11:48.000000000 +0200 +++ linux-2.6.27-rc6+patch_queue/fs/ext4/mballoc.c 2008-09-24 14:27:55.000000000 +0200 @@ -785,9 +785,12 @@ static int ext4_mb_init_cache(struct pag if (bh[i] == NULL) goto out; - if (bh_uptodate_or_lock(bh[i])) + if (buffer_uptodate(bh[i]) && ext4_test_bit(first_group + i, + EXT4_SB(sb)->s_block_bitmap_buffer_state)) continue; + lock_buffer(bh[i]); + spin_lock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { ext4_init_block_bitmap(sb, bh[i], @@ -796,7 +799,9 @@ static int ext4_mb_init_cache(struct pag unlock_buffer(bh[i]); spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); continue; - } + } else + ext4_set_bit(first_group + i, + EXT4_SB(sb)->s_block_bitmap_buffer_state); spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); get_bh(bh[i]); bh[i]->b_end_io = end_buffer_read_sync; Index: linux-2.6.27-rc6+patch_queue/fs/ext4/super.c =================================================================== --- linux-2.6.27-rc6+patch_queue.orig/fs/ext4/super.c 2008-09-23 15:16:15.000000000 +0200 +++ linux-2.6.27-rc6+patch_queue/fs/ext4/super.c 2008-09-24 14:28:42.000000000 +0200 @@ -2219,6 +2219,20 @@ static int ext4_fill_super(struct super_ printk(KERN_ERR "EXT4-fs: not enough memory\n"); goto failed_mount; } + sbi->s_block_bitmap_buffer_state = kzalloc((sbi->s_groups_count + + le16_to_cpu(es->s_reserved_gdt_blocks) + + 7) / 8, GFP_KERNEL); + if (sbi->s_block_bitmap_buffer_state == NULL) { + printk(KERN_ERR "EXT4-fs: not enough memory\n"); + goto failed_mount; + } + sbi->s_inode_bitmap_buffer_state = kzalloc((sbi->s_groups_count + + le16_to_cpu(es->s_reserved_gdt_blocks) + + 7) / 8, GFP_KERNEL); + if (sbi->s_inode_bitmap_buffer_state == NULL) { + printk(KERN_ERR "EXT4-fs: not enough memory\n"); + goto failed_mount; + } bgl_lock_init(&sbi->s_blockgroup_lock);