1 --- linux-2.4.20/fs/ext3/inode.c.=K0000=.orig 2003-02-04 13:46:03.000000000 +0000
2 +++ linux-2.4.20/fs/ext3/inode.c 2003-02-04 13:46:03.000000000 +0000
8 + * Work out how many blocks we need to progress with the next chunk of a
9 + * truncate transaction.
12 +static unsigned long blocks_for_truncate(struct inode *inode)
14 + unsigned long needed;
16 + needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
18 + /* Give ourselves just enough room to cope with inodes in which
19 + * i_blocks is corrupt: we've seen disk corruptions in the past
20 + * which resulted in random data in an inode which looked enough
21 + * like a regular file for ext3 to try to delete it. Things
22 + * will go a bit crazy if that happens, but at least we should
23 + * try not to panic the whole kernel. */
27 + /* But we need to bound the transaction so we don't overflow the
29 + if (needed > EXT3_MAX_TRANS_DATA)
30 + needed = EXT3_MAX_TRANS_DATA;
32 + return EXT3_DATA_TRANS_BLOCKS + needed;
36 * Truncate transactions can be complex and absolutely huge. So we need to
37 * be able to restart the transaction at a conventient checkpoint to make
40 static handle_t *start_transaction(struct inode *inode)
45 - needed = inode->i_blocks;
46 - if (needed > EXT3_MAX_TRANS_DATA)
47 - needed = EXT3_MAX_TRANS_DATA;
49 - result = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS + needed);
50 + result = ext3_journal_start(inode, blocks_for_truncate(inode));
56 static int try_to_extend_transaction(handle_t *handle, struct inode *inode)
60 if (handle->h_buffer_credits > EXT3_RESERVE_TRANS_BLOCKS)
62 - needed = inode->i_blocks;
63 - if (needed > EXT3_MAX_TRANS_DATA)
64 - needed = EXT3_MAX_TRANS_DATA;
65 - if (!ext3_journal_extend(handle, EXT3_RESERVE_TRANS_BLOCKS + needed))
66 + if (!ext3_journal_extend(handle, blocks_for_truncate(inode)))
72 static int ext3_journal_test_restart(handle_t *handle, struct inode *inode)
74 - long needed = inode->i_blocks;
75 - if (needed > EXT3_MAX_TRANS_DATA)
76 - needed = EXT3_MAX_TRANS_DATA;
77 jbd_debug(2, "restarting handle %p\n", handle);
78 - return ext3_journal_restart(handle, EXT3_DATA_TRANS_BLOCKS + needed);
79 + return ext3_journal_restart(handle, blocks_for_truncate(inode));
83 --- linux-2.4.20/include/linux/ext3_jbd.h.=K0000=.orig 2003-02-04 13:46:03.000000000 +0000
84 +++ linux-2.4.20/include/linux/ext3_jbd.h 2003-02-04 13:46:03.000000000 +0000
86 * indirection blocks, the group and superblock summaries, and the data
87 * block to complete the transaction. */
89 -#define EXT3_SINGLEDATA_TRANS_BLOCKS 8
90 +#define EXT3_SINGLEDATA_TRANS_BLOCKS 8U
92 /* Extended attributes may touch two data buffers, two bitmap buffers,
93 * and two group and summaries. */
95 * start off at the maximum transaction size and grow the transaction
96 * optimistically as we go. */
98 -#define EXT3_MAX_TRANS_DATA 64
99 +#define EXT3_MAX_TRANS_DATA 64U
101 /* We break up a large truncate or write transaction once the handle's
102 * buffer credits gets this low, we need either to extend the
104 * one block, plus two quota updates. Quota allocations are not
107 -#define EXT3_RESERVE_TRANS_BLOCKS 12
108 +#define EXT3_RESERVE_TRANS_BLOCKS 12U
111 ext3_mark_iloc_dirty(handle_t *handle,