]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.fixes/reiserfs-commit-ids-unsigned-ints
Updated xen patches taken from suse.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.fixes / reiserfs-commit-ids-unsigned-ints
1 From: Jeff Mahoney <jeffm@suse.com>
2 Subject: [PATCH] reiserfs: audit transaction ids to always be unsigned ints
3 References: bnc#410847
4
5 This patch fixes up the reiserfs code such that transaction ids are
6 always unsigned ints. In places they can currently be signed ints or
7 unsigned longs.
8
9 The former just causes an annoying clm-2200 warning and may join a
10 transaction when it should wait.
11
12 The latter is just for correctness since the disk format uses a 32-bit
13 transaction id. There aren't any runtime problems that result from it
14 not wrapping at the correct location since the value is truncated
15 correctly even on big endian systems. The 0 value might make it to disk,
16 but the mount-time checks will bump it to 10 itself.
17
18 Signed-off-by: Jeff Mahoney <jeffm@suse.com>
19
20 ---
21 fs/reiserfs/journal.c | 46 ++++++++++++++++++++---------------------
22 fs/reiserfs/procfs.c | 4 +--
23 include/linux/reiserfs_fs.h | 2 -
24 include/linux/reiserfs_fs_i.h | 2 -
25 include/linux/reiserfs_fs_sb.h | 8 +++----
26 5 files changed, 31 insertions(+), 31 deletions(-)
27
28 --- a/fs/reiserfs/journal.c
29 +++ b/fs/reiserfs/journal.c
30 @@ -574,7 +574,7 @@ static inline void put_journal_list(stru
31 struct reiserfs_journal_list *jl)
32 {
33 if (jl->j_refcount < 1) {
34 - reiserfs_panic(s, "trans id %lu, refcount at %d",
35 + reiserfs_panic(s, "trans id %u, refcount at %d",
36 jl->j_trans_id, jl->j_refcount);
37 }
38 if (--jl->j_refcount == 0)
39 @@ -599,7 +599,7 @@ static void cleanup_freed_for_journal_li
40 }
41
42 static int journal_list_still_alive(struct super_block *s,
43 - unsigned long trans_id)
44 + unsigned int trans_id)
45 {
46 struct reiserfs_journal *journal = SB_JOURNAL(s);
47 struct list_head *entry = &journal->j_journal_list;
48 @@ -933,9 +933,9 @@ static int flush_older_commits(struct su
49 struct reiserfs_journal_list *other_jl;
50 struct reiserfs_journal_list *first_jl;
51 struct list_head *entry;
52 - unsigned long trans_id = jl->j_trans_id;
53 - unsigned long other_trans_id;
54 - unsigned long first_trans_id;
55 + unsigned int trans_id = jl->j_trans_id;
56 + unsigned int other_trans_id;
57 + unsigned int first_trans_id;
58
59 find_first:
60 /*
61 @@ -1014,7 +1014,7 @@ static int flush_commit_list(struct supe
62 int i;
63 b_blocknr_t bn;
64 struct buffer_head *tbh = NULL;
65 - unsigned long trans_id = jl->j_trans_id;
66 + unsigned int trans_id = jl->j_trans_id;
67 struct reiserfs_journal *journal = SB_JOURNAL(s);
68 int barrier = 0;
69 int retval = 0;
70 @@ -1275,7 +1275,7 @@ static void remove_all_from_journal_list
71 */
72 static int _update_journal_header_block(struct super_block *p_s_sb,
73 unsigned long offset,
74 - unsigned long trans_id)
75 + unsigned int trans_id)
76 {
77 struct reiserfs_journal_header *jh;
78 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
79 @@ -1329,7 +1329,7 @@ static int _update_journal_header_block(
80
81 static int update_journal_header_block(struct super_block *p_s_sb,
82 unsigned long offset,
83 - unsigned long trans_id)
84 + unsigned int trans_id)
85 {
86 return _update_journal_header_block(p_s_sb, offset, trans_id);
87 }
88 @@ -1344,7 +1344,7 @@ static int flush_older_journal_lists(str
89 struct list_head *entry;
90 struct reiserfs_journal_list *other_jl;
91 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
92 - unsigned long trans_id = jl->j_trans_id;
93 + unsigned int trans_id = jl->j_trans_id;
94
95 /* we know we are the only ones flushing things, no extra race
96 * protection is required.
97 @@ -1758,13 +1758,13 @@ static int dirty_one_transaction(struct
98 static int kupdate_transactions(struct super_block *s,
99 struct reiserfs_journal_list *jl,
100 struct reiserfs_journal_list **next_jl,
101 - unsigned long *next_trans_id,
102 + unsigned int *next_trans_id,
103 int num_blocks, int num_trans)
104 {
105 int ret = 0;
106 int written = 0;
107 int transactions_flushed = 0;
108 - unsigned long orig_trans_id = jl->j_trans_id;
109 + unsigned int orig_trans_id = jl->j_trans_id;
110 struct buffer_chunk chunk;
111 struct list_head *entry;
112 struct reiserfs_journal *journal = SB_JOURNAL(s);
113 @@ -1833,7 +1833,7 @@ static int flush_used_journal_lists(stru
114 int limit = 256;
115 struct reiserfs_journal_list *tjl;
116 struct reiserfs_journal_list *flush_jl;
117 - unsigned long trans_id;
118 + unsigned int trans_id;
119 struct reiserfs_journal *journal = SB_JOURNAL(s);
120
121 flush_jl = tjl = jl;
122 @@ -2023,7 +2023,7 @@ static int journal_compare_desc_commit(s
123 */
124 static int journal_transaction_is_valid(struct super_block *p_s_sb,
125 struct buffer_head *d_bh,
126 - unsigned long *oldest_invalid_trans_id,
127 + unsigned int *oldest_invalid_trans_id,
128 unsigned long *newest_mount_id)
129 {
130 struct reiserfs_journal_desc *desc;
131 @@ -2124,18 +2124,18 @@ static void brelse_array(struct buffer_h
132 static int journal_read_transaction(struct super_block *p_s_sb,
133 unsigned long cur_dblock,
134 unsigned long oldest_start,
135 - unsigned long oldest_trans_id,
136 + unsigned int oldest_trans_id,
137 unsigned long newest_mount_id)
138 {
139 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
140 struct reiserfs_journal_desc *desc;
141 struct reiserfs_journal_commit *commit;
142 - unsigned long trans_id = 0;
143 + unsigned int trans_id = 0;
144 struct buffer_head *c_bh;
145 struct buffer_head *d_bh;
146 struct buffer_head **log_blocks = NULL;
147 struct buffer_head **real_blocks = NULL;
148 - unsigned long trans_offset;
149 + unsigned int trans_offset;
150 int i;
151 int trans_half;
152
153 @@ -2356,8 +2356,8 @@ static int journal_read(struct super_blo
154 {
155 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
156 struct reiserfs_journal_desc *desc;
157 - unsigned long oldest_trans_id = 0;
158 - unsigned long oldest_invalid_trans_id = 0;
159 + unsigned int oldest_trans_id = 0;
160 + unsigned int oldest_invalid_trans_id = 0;
161 time_t start;
162 unsigned long oldest_start = 0;
163 unsigned long cur_dblock = 0;
164 @@ -2967,7 +2967,7 @@ static void wake_queued_writers(struct s
165 wake_up(&journal->j_join_wait);
166 }
167
168 -static void let_transaction_grow(struct super_block *sb, unsigned long trans_id)
169 +static void let_transaction_grow(struct super_block *sb, unsigned int trans_id)
170 {
171 struct reiserfs_journal *journal = SB_JOURNAL(sb);
172 unsigned long bcount = journal->j_bcount;
173 @@ -2998,7 +2998,7 @@ static int do_journal_begin_r(struct rei
174 int join)
175 {
176 time_t now = get_seconds();
177 - int old_trans_id;
178 + unsigned int old_trans_id;
179 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
180 struct reiserfs_transaction_handle myth;
181 int sched_count = 0;
182 @@ -3821,7 +3821,7 @@ static int __commit_trans_jl(struct inod
183
184 int reiserfs_commit_for_inode(struct inode *inode)
185 {
186 - unsigned long id = REISERFS_I(inode)->i_trans_id;
187 + unsigned int id = REISERFS_I(inode)->i_trans_id;
188 struct reiserfs_journal_list *jl = REISERFS_I(inode)->i_jl;
189
190 /* for the whole inode, assume unset id means it was
191 @@ -3935,7 +3935,7 @@ static int do_journal_end(struct reiserf
192 struct reiserfs_journal_list *jl, *temp_jl;
193 struct list_head *entry, *safe;
194 unsigned long jindex;
195 - unsigned long commit_trans_id;
196 + unsigned int commit_trans_id;
197 int trans_half;
198
199 BUG_ON(th->t_refcount > 1);
200 @@ -3943,7 +3943,7 @@ static int do_journal_end(struct reiserf
201
202 /* protect flush_older_commits from doing mistakes if the
203 transaction ID counter gets overflowed. */
204 - if (th->t_trans_id == ~0UL)
205 + if (th->t_trans_id == ~0U)
206 flags |= FLUSH_ALL | COMMIT_NOW | WAIT;
207 flush = flags & FLUSH_ALL;
208 wait_on_commit = flags & WAIT;
209 --- a/fs/reiserfs/procfs.c
210 +++ b/fs/reiserfs/procfs.c
211 @@ -323,7 +323,7 @@ static int show_journal(struct seq_file
212 /* incore fields */
213 "j_1st_reserved_block: \t%i\n"
214 "j_state: \t%li\n"
215 - "j_trans_id: \t%lu\n"
216 + "j_trans_id: \t%u\n"
217 "j_mount_id: \t%lu\n"
218 "j_start: \t%lu\n"
219 "j_len: \t%lu\n"
220 @@ -331,7 +331,7 @@ static int show_journal(struct seq_file
221 "j_wcount: \t%i\n"
222 "j_bcount: \t%lu\n"
223 "j_first_unflushed_offset: \t%lu\n"
224 - "j_last_flush_trans_id: \t%lu\n"
225 + "j_last_flush_trans_id: \t%u\n"
226 "j_trans_start_time: \t%li\n"
227 "j_list_bitmap_index: \t%i\n"
228 "j_must_wait: \t%i\n"
229 --- a/include/linux/reiserfs_fs.h
230 +++ b/include/linux/reiserfs_fs.h
231 @@ -1676,7 +1676,7 @@ struct reiserfs_transaction_handle {
232 int t_refcount;
233 int t_blocks_logged; /* number of blocks this writer has logged */
234 int t_blocks_allocated; /* number of blocks this writer allocated */
235 - unsigned long t_trans_id; /* sanity check, equals the current trans id */
236 + unsigned int t_trans_id; /* sanity check, equals the current trans id */
237 void *t_handle_save; /* save existing current->journal_info */
238 unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
239 should be displaced from others */
240 --- a/include/linux/reiserfs_fs_i.h
241 +++ b/include/linux/reiserfs_fs_i.h
242 @@ -51,7 +51,7 @@ struct reiserfs_inode_info {
243 /* we use these for fsync or O_SYNC to decide which transaction
244 ** needs to be committed in order for this inode to be properly
245 ** flushed */
246 - unsigned long i_trans_id;
247 + unsigned int i_trans_id;
248 struct reiserfs_journal_list *i_jl;
249 struct mutex i_mmap;
250 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
251 --- a/include/linux/reiserfs_fs_sb.h
252 +++ b/include/linux/reiserfs_fs_sb.h
253 @@ -156,7 +156,7 @@ struct reiserfs_journal_list {
254 atomic_t j_commit_left;
255 atomic_t j_older_commits_done; /* all commits older than this on disk */
256 struct mutex j_commit_mutex;
257 - unsigned long j_trans_id;
258 + unsigned int j_trans_id;
259 time_t j_timestamp;
260 struct reiserfs_list_bitmap *j_list_bitmap;
261 struct buffer_head *j_commit_bh; /* commit buffer head */
262 @@ -184,7 +184,7 @@ struct reiserfs_journal {
263 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
264
265 unsigned long j_state;
266 - unsigned long j_trans_id;
267 + unsigned int j_trans_id;
268 unsigned long j_mount_id;
269 unsigned long j_start; /* start of current waiting commit (index into j_ap_blocks) */
270 unsigned long j_len; /* length of current waiting commit */
271 @@ -225,10 +225,10 @@ struct reiserfs_journal {
272 int j_num_work_lists; /* number that need attention from kreiserfsd */
273
274 /* debugging to make sure things are flushed in order */
275 - int j_last_flush_id;
276 + unsigned int j_last_flush_id;
277
278 /* debugging to make sure things are committed in order */
279 - int j_last_commit_id;
280 + unsigned int j_last_commit_id;
281
282 struct list_head j_bitmap_nodes;
283 struct list_head j_dirty_buffers;