--- linux-2.5.3-pre4/fs/reiserfs/bitmap.c.orig Thu Jan 24 12:21:23 2002 +++ linux-2.5.3-pre4/fs/reiserfs/bitmap.c Thu Jan 24 12:48:40 2002 @@ -84,7 +84,7 @@ to free a list of blocks at once. -Hans */ /* I wonder if it would be less modest now that we use journaling. -Hans */ -void reiserfs_free_block (struct reiserfs_transaction_handle *th, unsigned long block) +static void _reiserfs_free_block (struct reiserfs_transaction_handle *th, unsigned long block) { struct super_block * s = th->t_super; struct reiserfs_super_block * rs; @@ -92,9 +92,6 @@ struct buffer_head ** apbh; int nr, offset; - RFALSE(!s, "vs-4060: trying to free block on nonexistent device"); - RFALSE(is_reusable (s, block, 1) == 0, "vs-4070: can not free such block"); - PROC_INFO_INC( s, free_block ); rs = SB_DISK_SUPER_BLOCK (s); @@ -110,9 +107,6 @@ return; } - /* mark it before we clear it, just in case */ - journal_mark_freed(th, s, block) ; - reiserfs_prepare_for_journal(s, apbh[nr], 1 ) ; /* clear bit for the given block in bit map */ @@ -131,7 +125,26 @@ s->s_dirt = 1; } +void reiserfs_free_block (struct reiserfs_transaction_handle *th, + unsigned long block) { + struct super_block * s = th->t_super; + + RFALSE(!s, "vs-4061: trying to free block on nonexistent device"); + RFALSE(is_reusable (s, block, 1) == 0, "vs-4071: can not free such block"); + /* mark it before we clear it, just in case */ + journal_mark_freed(th, s, block) ; + _reiserfs_free_block(th, block) ; +} + +/* preallocated blocks don't need to be run through journal_mark_freed */ +void reiserfs_free_prealloc_block (struct reiserfs_transaction_handle *th, + unsigned long block) { + struct super_block * s = th->t_super; + RFALSE(!s, "vs-4060: trying to free block on nonexistent device"); + RFALSE(is_reusable (s, block, 1) == 0, "vs-4070: can not free such block"); + _reiserfs_free_block(th, block) ; +} /* beginning from offset-th bit in bmap_nr-th bitmap block, find_forward finds the closest zero bit. It returns 1 and zero @@ -664,11 +677,13 @@ static void __discard_prealloc (struct reiserfs_transaction_handle * th, struct reiserfs_inode_info *ei) { + unsigned long save = ei->i_prealloc_block ; while (ei->i_prealloc_count > 0) { - reiserfs_free_block(th,ei->i_prealloc_block); + reiserfs_free_prealloc_block(th,ei->i_prealloc_block); ei->i_prealloc_block++; ei->i_prealloc_count --; } + ei->i_prealloc_block = save; list_del_init(&(ei->i_prealloc_list)); } .