]>
Commit | Line | Data |
---|---|---|
3902a19b JR |
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 | |
3 | @@ -101,6 +101,34 @@ | |
4 | return err; | |
5 | } | |
6 | ||
7 | +/* | |
8 | + * Work out how many blocks we need to progress with the next chunk of a | |
9 | + * truncate transaction. | |
10 | + */ | |
11 | + | |
12 | +static unsigned long blocks_for_truncate(struct inode *inode) | |
13 | +{ | |
14 | + unsigned long needed; | |
15 | + | |
16 | + needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9); | |
17 | + | |
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. */ | |
24 | + if (needed < 2) | |
25 | + needed = 2; | |
26 | + | |
27 | + /* But we need to bound the transaction so we don't overflow the | |
28 | + * journal. */ | |
29 | + if (needed > EXT3_MAX_TRANS_DATA) | |
30 | + needed = EXT3_MAX_TRANS_DATA; | |
31 | + | |
32 | + return EXT3_DATA_TRANS_BLOCKS + needed; | |
33 | +} | |
34 | + | |
35 | /* | |
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 | |
38 | @@ -114,14 +142,9 @@ | |
39 | ||
40 | static handle_t *start_transaction(struct inode *inode) | |
41 | { | |
42 | - long needed; | |
43 | handle_t *result; | |
44 | ||
45 | - needed = inode->i_blocks; | |
46 | - if (needed > EXT3_MAX_TRANS_DATA) | |
47 | - needed = EXT3_MAX_TRANS_DATA; | |
48 | - | |
49 | - result = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS + needed); | |
50 | + result = ext3_journal_start(inode, blocks_for_truncate(inode)); | |
51 | if (!IS_ERR(result)) | |
52 | return result; | |
53 | ||
54 | @@ -137,14 +160,9 @@ | |
55 | */ | |
56 | static int try_to_extend_transaction(handle_t *handle, struct inode *inode) | |
57 | { | |
58 | - long needed; | |
59 | - | |
60 | if (handle->h_buffer_credits > EXT3_RESERVE_TRANS_BLOCKS) | |
61 | return 0; | |
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))) | |
67 | return 0; | |
68 | return 1; | |
69 | } | |
70 | @@ -156,11 +174,8 @@ | |
71 | */ | |
72 | static int ext3_journal_test_restart(handle_t *handle, struct inode *inode) | |
73 | { | |
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)); | |
80 | } | |
81 | ||
82 | /* | |
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 | |
85 | @@ -28,7 +28,7 @@ | |
86 | * indirection blocks, the group and superblock summaries, and the data | |
87 | * block to complete the transaction. */ | |
88 | ||
89 | -#define EXT3_SINGLEDATA_TRANS_BLOCKS 8 | |
90 | +#define EXT3_SINGLEDATA_TRANS_BLOCKS 8U | |
91 | ||
92 | /* Extended attributes may touch two data buffers, two bitmap buffers, | |
93 | * and two group and summaries. */ | |
94 | @@ -58,7 +58,7 @@ | |
95 | * start off at the maximum transaction size and grow the transaction | |
96 | * optimistically as we go. */ | |
97 | ||
98 | -#define EXT3_MAX_TRANS_DATA 64 | |
99 | +#define EXT3_MAX_TRANS_DATA 64U | |
100 | ||
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 | |
103 | @@ -67,7 +67,7 @@ | |
104 | * one block, plus two quota updates. Quota allocations are not | |
105 | * needed. */ | |
106 | ||
107 | -#define EXT3_RESERVE_TRANS_BLOCKS 12 | |
108 | +#define EXT3_RESERVE_TRANS_BLOCKS 12U | |
109 | ||
110 | int | |
111 | ext3_mark_iloc_dirty(handle_t *handle, |