1 --- ./fs/ext3/inode.c.orig Wed Mar 12 02:44:06 2003
2 +++ ./fs/ext3/inode.c Wed Mar 12 11:55:20 2003
3 @@ -99,7 +99,35 @@ int ext3_forget(handle_t *handle, int is
9 + * Work out how many blocks we need to progress with the next chunk of a
10 + * truncate transaction.
13 +static unsigned long blocks_for_truncate(struct inode *inode)
15 + unsigned long needed;
17 + needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
19 + /* Give ourselves just enough room to cope with inodes in which
20 + * i_blocks is corrupt: we've seen disk corruptions in the past
21 + * which resulted in random data in an inode which looked enough
22 + * like a regular file for ext3 to try to delete it. Things
23 + * will go a bit crazy if that happens, but at least we should
24 + * try not to panic the whole kernel. */
28 + /* But we need to bound the transaction so we don't overflow the
30 + if (needed > EXT3_MAX_TRANS_DATA)
31 + needed = EXT3_MAX_TRANS_DATA;
33 + return EXT3_DATA_TRANS_BLOCKS + needed;
37 * Truncate transactions can be complex and absolutely huge. So we need to
38 * be able to restart the transaction at a conventient checkpoint to make
39 * sure we don't overflow the journal.
40 @@ -110,19 +138,14 @@ int ext3_forget(handle_t *handle, int is
41 * transaction in the top-level truncate loop. --sct
44 -static handle_t *start_transaction(struct inode *inode)
45 +static handle_t *start_transaction(struct inode *inode)
50 - needed = inode->i_blocks;
51 - if (needed > EXT3_MAX_TRANS_DATA)
52 - needed = EXT3_MAX_TRANS_DATA;
54 - result = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS + needed);
56 + result = ext3_journal_start(inode, blocks_for_truncate(inode));
61 ext3_std_error(inode->i_sb, PTR_ERR(result));
64 @@ -135,14 +158,9 @@ static handle_t *start_transaction(struc
66 static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
70 if (handle->h_buffer_credits > EXT3_RESERVE_TRANS_BLOCKS)
72 - needed = inode->i_blocks;
73 - if (needed > EXT3_MAX_TRANS_DATA)
74 - needed = EXT3_MAX_TRANS_DATA;
75 - if (!ext3_journal_extend(handle, EXT3_RESERVE_TRANS_BLOCKS + needed))
76 + if (!ext3_journal_extend(handle, blocks_for_truncate(inode)))
80 @@ -154,11 +172,8 @@ static int try_to_extend_transaction(han
82 static int ext3_journal_test_restart(handle_t *handle, struct inode *inode)
84 - long needed = inode->i_blocks;
85 - if (needed > EXT3_MAX_TRANS_DATA)
86 - needed = EXT3_MAX_TRANS_DATA;
87 jbd_debug(2, "restarting handle %p\n", handle);
88 - return ext3_journal_restart(handle, EXT3_DATA_TRANS_BLOCKS + needed);
89 + return ext3_journal_restart(handle, blocks_for_truncate(inode));