diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-05-20 14:06:24 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-05-20 14:08:05 -0400 |
commit | 250f972d85effad5b6e10da4bbd877e6a4b503b6 (patch) | |
tree | 007393a6fc6439af7e0121dd99a6f9f9fb8405bc /fs/hpfs/dnode.c | |
parent | 7372b0b122af0f6675f3ab65bfd91c8a438e0480 (diff) | |
parent | bbe7b8bef48c567f5ff3f6041c1fb011292e8f12 (diff) |
Merge branch 'timers/urgent' into timers/core
Reason: Get upstream fixes and kfree_rcu which is necessary for a
follow up patch.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/hpfs/dnode.c')
-rw-r--r-- | fs/hpfs/dnode.c | 174 |
1 files changed, 84 insertions, 90 deletions
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 9b2ffadfc8c4..1e0e2ac30fd3 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -14,11 +14,11 @@ static loff_t get_pos(struct dnode *d, struct hpfs_dirent *fde) | |||
14 | struct hpfs_dirent *de_end = dnode_end_de(d); | 14 | struct hpfs_dirent *de_end = dnode_end_de(d); |
15 | int i = 1; | 15 | int i = 1; |
16 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { | 16 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { |
17 | if (de == fde) return ((loff_t) d->self << 4) | (loff_t)i; | 17 | if (de == fde) return ((loff_t) le32_to_cpu(d->self) << 4) | (loff_t)i; |
18 | i++; | 18 | i++; |
19 | } | 19 | } |
20 | printk("HPFS: get_pos: not_found\n"); | 20 | printk("HPFS: get_pos: not_found\n"); |
21 | return ((loff_t)d->self << 4) | (loff_t)1; | 21 | return ((loff_t)le32_to_cpu(d->self) << 4) | (loff_t)1; |
22 | } | 22 | } |
23 | 23 | ||
24 | void hpfs_add_pos(struct inode *inode, loff_t *pos) | 24 | void hpfs_add_pos(struct inode *inode, loff_t *pos) |
@@ -130,29 +130,30 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno | |||
130 | { | 130 | { |
131 | struct hpfs_dirent *de; | 131 | struct hpfs_dirent *de; |
132 | if (!(de = dnode_last_de(d))) { | 132 | if (!(de = dnode_last_de(d))) { |
133 | hpfs_error(s, "set_last_pointer: empty dnode %08x", d->self); | 133 | hpfs_error(s, "set_last_pointer: empty dnode %08x", le32_to_cpu(d->self)); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | if (hpfs_sb(s)->sb_chk) { | 136 | if (hpfs_sb(s)->sb_chk) { |
137 | if (de->down) { | 137 | if (de->down) { |
138 | hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x", | 138 | hpfs_error(s, "set_last_pointer: dnode %08x has already last pointer %08x", |
139 | d->self, de_down_pointer(de)); | 139 | le32_to_cpu(d->self), de_down_pointer(de)); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | if (de->length != 32) { | 142 | if (le16_to_cpu(de->length) != 32) { |
143 | hpfs_error(s, "set_last_pointer: bad last dirent in dnode %08x", d->self); | 143 | hpfs_error(s, "set_last_pointer: bad last dirent in dnode %08x", le32_to_cpu(d->self)); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | if (ptr) { | 147 | if (ptr) { |
148 | if ((d->first_free += 4) > 2048) { | 148 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4); |
149 | hpfs_error(s,"set_last_pointer: too long dnode %08x", d->self); | 149 | if (le32_to_cpu(d->first_free) > 2048) { |
150 | d->first_free -= 4; | 150 | hpfs_error(s, "set_last_pointer: too long dnode %08x", le32_to_cpu(d->self)); |
151 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - 4); | ||
151 | return; | 152 | return; |
152 | } | 153 | } |
153 | de->length = 36; | 154 | de->length = cpu_to_le16(36); |
154 | de->down = 1; | 155 | de->down = 1; |
155 | *(dnode_secno *)((char *)de + 32) = ptr; | 156 | *(dnode_secno *)((char *)de + 32) = cpu_to_le32(ptr); |
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
@@ -168,7 +169,7 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
168 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { | 169 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) { |
169 | int c = hpfs_compare_names(s, name, namelen, de->name, de->namelen, de->last); | 170 | int c = hpfs_compare_names(s, name, namelen, de->name, de->namelen, de->last); |
170 | if (!c) { | 171 | if (!c) { |
171 | hpfs_error(s, "name (%c,%d) already exists in dnode %08x", *name, namelen, d->self); | 172 | hpfs_error(s, "name (%c,%d) already exists in dnode %08x", *name, namelen, le32_to_cpu(d->self)); |
172 | return NULL; | 173 | return NULL; |
173 | } | 174 | } |
174 | if (c < 0) break; | 175 | if (c < 0) break; |
@@ -176,15 +177,14 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
176 | memmove((char *)de + d_size, de, (char *)de_end - (char *)de); | 177 | memmove((char *)de + d_size, de, (char *)de_end - (char *)de); |
177 | memset(de, 0, d_size); | 178 | memset(de, 0, d_size); |
178 | if (down_ptr) { | 179 | if (down_ptr) { |
179 | *(int *)((char *)de + d_size - 4) = down_ptr; | 180 | *(dnode_secno *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr); |
180 | de->down = 1; | 181 | de->down = 1; |
181 | } | 182 | } |
182 | de->length = d_size; | 183 | de->length = cpu_to_le16(d_size); |
183 | if (down_ptr) de->down = 1; | ||
184 | de->not_8x3 = hpfs_is_name_long(name, namelen); | 184 | de->not_8x3 = hpfs_is_name_long(name, namelen); |
185 | de->namelen = namelen; | 185 | de->namelen = namelen; |
186 | memcpy(de->name, name, namelen); | 186 | memcpy(de->name, name, namelen); |
187 | d->first_free += d_size; | 187 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + d_size); |
188 | return de; | 188 | return de; |
189 | } | 189 | } |
190 | 190 | ||
@@ -194,25 +194,25 @@ static void hpfs_delete_de(struct super_block *s, struct dnode *d, | |||
194 | struct hpfs_dirent *de) | 194 | struct hpfs_dirent *de) |
195 | { | 195 | { |
196 | if (de->last) { | 196 | if (de->last) { |
197 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); | 197 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", le32_to_cpu(d->self)); |
198 | return; | 198 | return; |
199 | } | 199 | } |
200 | d->first_free -= de->length; | 200 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - le16_to_cpu(de->length)); |
201 | memmove(de, de_next_de(de), d->first_free + (char *)d - (char *)de); | 201 | memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de); |
202 | } | 202 | } |
203 | 203 | ||
204 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) | 204 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) |
205 | { | 205 | { |
206 | struct hpfs_dirent *de; | 206 | struct hpfs_dirent *de; |
207 | struct hpfs_dirent *de_end = dnode_end_de(d); | 207 | struct hpfs_dirent *de_end = dnode_end_de(d); |
208 | dnode_secno dno = d->self; | 208 | dnode_secno dno = le32_to_cpu(d->self); |
209 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) | 209 | for (de = dnode_first_de(d); de < de_end; de = de_next_de(de)) |
210 | if (de->down) { | 210 | if (de->down) { |
211 | struct quad_buffer_head qbh; | 211 | struct quad_buffer_head qbh; |
212 | struct dnode *dd; | 212 | struct dnode *dd; |
213 | if ((dd = hpfs_map_dnode(s, de_down_pointer(de), &qbh))) { | 213 | if ((dd = hpfs_map_dnode(s, de_down_pointer(de), &qbh))) { |
214 | if (dd->up != dno || dd->root_dnode) { | 214 | if (le32_to_cpu(dd->up) != dno || dd->root_dnode) { |
215 | dd->up = dno; | 215 | dd->up = cpu_to_le32(dno); |
216 | dd->root_dnode = 0; | 216 | dd->root_dnode = 0; |
217 | hpfs_mark_4buffers_dirty(&qbh); | 217 | hpfs_mark_4buffers_dirty(&qbh); |
218 | } | 218 | } |
@@ -262,7 +262,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
262 | kfree(nname); | 262 | kfree(nname); |
263 | return 1; | 263 | return 1; |
264 | } | 264 | } |
265 | if (d->first_free + de_size(namelen, down_ptr) <= 2048) { | 265 | if (le32_to_cpu(d->first_free) + de_size(namelen, down_ptr) <= 2048) { |
266 | loff_t t; | 266 | loff_t t; |
267 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); | 267 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); |
268 | t = get_pos(d, de); | 268 | t = get_pos(d, de); |
@@ -286,11 +286,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
286 | kfree(nname); | 286 | kfree(nname); |
287 | return 1; | 287 | return 1; |
288 | } | 288 | } |
289 | memcpy(nd, d, d->first_free); | 289 | memcpy(nd, d, le32_to_cpu(d->first_free)); |
290 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); | 290 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); |
291 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); | 291 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); |
292 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; | 292 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; |
293 | if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1, 0))) { | 293 | if (!(ad = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &adno, &qbh1))) { |
294 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 294 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
295 | hpfs_brelse4(&qbh); | 295 | hpfs_brelse4(&qbh); |
296 | kfree(nd); | 296 | kfree(nd); |
@@ -313,20 +313,21 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
313 | down_ptr = adno; | 313 | down_ptr = adno; |
314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); | 314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); |
315 | de = de_next_de(de); | 315 | de = de_next_de(de); |
316 | memmove((char *)nd + 20, de, nd->first_free + (char *)nd - (char *)de); | 316 | memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de); |
317 | nd->first_free -= (char *)de - (char *)nd - 20; | 317 | nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - ((char *)de - (char *)nd - 20)); |
318 | memcpy(d, nd, nd->first_free); | 318 | memcpy(d, nd, le32_to_cpu(nd->first_free)); |
319 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); | 319 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); |
320 | fix_up_ptrs(i->i_sb, ad); | 320 | fix_up_ptrs(i->i_sb, ad); |
321 | if (!d->root_dnode) { | 321 | if (!d->root_dnode) { |
322 | dno = ad->up = d->up; | 322 | ad->up = d->up; |
323 | dno = le32_to_cpu(ad->up); | ||
323 | hpfs_mark_4buffers_dirty(&qbh); | 324 | hpfs_mark_4buffers_dirty(&qbh); |
324 | hpfs_brelse4(&qbh); | 325 | hpfs_brelse4(&qbh); |
325 | hpfs_mark_4buffers_dirty(&qbh1); | 326 | hpfs_mark_4buffers_dirty(&qbh1); |
326 | hpfs_brelse4(&qbh1); | 327 | hpfs_brelse4(&qbh1); |
327 | goto go_up; | 328 | goto go_up; |
328 | } | 329 | } |
329 | if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2, 0))) { | 330 | if (!(rd = hpfs_alloc_dnode(i->i_sb, le32_to_cpu(d->up), &rdno, &qbh2))) { |
330 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 331 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
331 | hpfs_brelse4(&qbh); | 332 | hpfs_brelse4(&qbh); |
332 | hpfs_brelse4(&qbh1); | 333 | hpfs_brelse4(&qbh1); |
@@ -338,7 +339,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
338 | i->i_blocks += 4; | 339 | i->i_blocks += 4; |
339 | rd->root_dnode = 1; | 340 | rd->root_dnode = 1; |
340 | rd->up = d->up; | 341 | rd->up = d->up; |
341 | if (!(fnode = hpfs_map_fnode(i->i_sb, d->up, &bh))) { | 342 | if (!(fnode = hpfs_map_fnode(i->i_sb, le32_to_cpu(d->up), &bh))) { |
342 | hpfs_free_dnode(i->i_sb, rdno); | 343 | hpfs_free_dnode(i->i_sb, rdno); |
343 | hpfs_brelse4(&qbh); | 344 | hpfs_brelse4(&qbh); |
344 | hpfs_brelse4(&qbh1); | 345 | hpfs_brelse4(&qbh1); |
@@ -347,10 +348,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
347 | kfree(nname); | 348 | kfree(nname); |
348 | return 1; | 349 | return 1; |
349 | } | 350 | } |
350 | fnode->u.external[0].disk_secno = rdno; | 351 | fnode->u.external[0].disk_secno = cpu_to_le32(rdno); |
351 | mark_buffer_dirty(bh); | 352 | mark_buffer_dirty(bh); |
352 | brelse(bh); | 353 | brelse(bh); |
353 | d->up = ad->up = hpfs_i(i)->i_dno = rdno; | 354 | hpfs_i(i)->i_dno = rdno; |
355 | d->up = ad->up = cpu_to_le32(rdno); | ||
354 | d->root_dnode = ad->root_dnode = 0; | 356 | d->root_dnode = ad->root_dnode = 0; |
355 | hpfs_mark_4buffers_dirty(&qbh); | 357 | hpfs_mark_4buffers_dirty(&qbh); |
356 | hpfs_brelse4(&qbh); | 358 | hpfs_brelse4(&qbh); |
@@ -373,7 +375,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
373 | 375 | ||
374 | int hpfs_add_dirent(struct inode *i, | 376 | int hpfs_add_dirent(struct inode *i, |
375 | const unsigned char *name, unsigned namelen, | 377 | const unsigned char *name, unsigned namelen, |
376 | struct hpfs_dirent *new_de, int cdepth) | 378 | struct hpfs_dirent *new_de) |
377 | { | 379 | { |
378 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 380 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
379 | struct dnode *d; | 381 | struct dnode *d; |
@@ -403,7 +405,6 @@ int hpfs_add_dirent(struct inode *i, | |||
403 | } | 405 | } |
404 | } | 406 | } |
405 | hpfs_brelse4(&qbh); | 407 | hpfs_brelse4(&qbh); |
406 | if (!cdepth) hpfs_lock_creation(i->i_sb); | ||
407 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { | 408 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { |
408 | c = 1; | 409 | c = 1; |
409 | goto ret; | 410 | goto ret; |
@@ -411,7 +412,6 @@ int hpfs_add_dirent(struct inode *i, | |||
411 | i->i_version++; | 412 | i->i_version++; |
412 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); | 413 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); |
413 | ret: | 414 | ret: |
414 | if (!cdepth) hpfs_unlock_creation(i->i_sb); | ||
415 | return c; | 415 | return c; |
416 | } | 416 | } |
417 | 417 | ||
@@ -437,9 +437,9 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
437 | return 0; | 437 | return 0; |
438 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0; | 438 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return 0; |
439 | if (hpfs_sb(i->i_sb)->sb_chk) { | 439 | if (hpfs_sb(i->i_sb)->sb_chk) { |
440 | if (dnode->up != chk_up) { | 440 | if (le32_to_cpu(dnode->up) != chk_up) { |
441 | hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x", | 441 | hpfs_error(i->i_sb, "move_to_top: up pointer from %08x should be %08x, is %08x", |
442 | dno, chk_up, dnode->up); | 442 | dno, chk_up, le32_to_cpu(dnode->up)); |
443 | hpfs_brelse4(&qbh); | 443 | hpfs_brelse4(&qbh); |
444 | return 0; | 444 | return 0; |
445 | } | 445 | } |
@@ -455,7 +455,7 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
455 | hpfs_brelse4(&qbh); | 455 | hpfs_brelse4(&qbh); |
456 | } | 456 | } |
457 | while (!(de = dnode_pre_last_de(dnode))) { | 457 | while (!(de = dnode_pre_last_de(dnode))) { |
458 | dnode_secno up = dnode->up; | 458 | dnode_secno up = le32_to_cpu(dnode->up); |
459 | hpfs_brelse4(&qbh); | 459 | hpfs_brelse4(&qbh); |
460 | hpfs_free_dnode(i->i_sb, dno); | 460 | hpfs_free_dnode(i->i_sb, dno); |
461 | i->i_size -= 2048; | 461 | i->i_size -= 2048; |
@@ -474,8 +474,8 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
474 | hpfs_brelse4(&qbh); | 474 | hpfs_brelse4(&qbh); |
475 | return 0; | 475 | return 0; |
476 | } | 476 | } |
477 | dnode->first_free -= 4; | 477 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
478 | de->length -= 4; | 478 | de->length = cpu_to_le16(le16_to_cpu(de->length) - 4); |
479 | de->down = 0; | 479 | de->down = 0; |
480 | hpfs_mark_4buffers_dirty(&qbh); | 480 | hpfs_mark_4buffers_dirty(&qbh); |
481 | dno = up; | 481 | dno = up; |
@@ -483,12 +483,12 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
483 | t = get_pos(dnode, de); | 483 | t = get_pos(dnode, de); |
484 | for_all_poss(i, hpfs_pos_subst, t, 4); | 484 | for_all_poss(i, hpfs_pos_subst, t, 4); |
485 | for_all_poss(i, hpfs_pos_subst, t + 1, 5); | 485 | for_all_poss(i, hpfs_pos_subst, t + 1, 5); |
486 | if (!(nde = kmalloc(de->length, GFP_NOFS))) { | 486 | if (!(nde = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) { |
487 | hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted"); | 487 | hpfs_error(i->i_sb, "out of memory for dirent - directory will be corrupted"); |
488 | hpfs_brelse4(&qbh); | 488 | hpfs_brelse4(&qbh); |
489 | return 0; | 489 | return 0; |
490 | } | 490 | } |
491 | memcpy(nde, de, de->length); | 491 | memcpy(nde, de, le16_to_cpu(de->length)); |
492 | ddno = de->down ? de_down_pointer(de) : 0; | 492 | ddno = de->down ? de_down_pointer(de) : 0; |
493 | hpfs_delete_de(i->i_sb, dnode, de); | 493 | hpfs_delete_de(i->i_sb, dnode, de); |
494 | set_last_pointer(i->i_sb, dnode, ddno); | 494 | set_last_pointer(i->i_sb, dnode, ddno); |
@@ -517,11 +517,11 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
517 | try_it_again: | 517 | try_it_again: |
518 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; | 518 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; |
519 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; | 519 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; |
520 | if (dnode->first_free > 56) goto end; | 520 | if (le32_to_cpu(dnode->first_free) > 56) goto end; |
521 | if (dnode->first_free == 52 || dnode->first_free == 56) { | 521 | if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) { |
522 | struct hpfs_dirent *de_end; | 522 | struct hpfs_dirent *de_end; |
523 | int root = dnode->root_dnode; | 523 | int root = dnode->root_dnode; |
524 | up = dnode->up; | 524 | up = le32_to_cpu(dnode->up); |
525 | de = dnode_first_de(dnode); | 525 | de = dnode_first_de(dnode); |
526 | down = de->down ? de_down_pointer(de) : 0; | 526 | down = de->down ? de_down_pointer(de) : 0; |
527 | if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) { | 527 | if (hpfs_sb(i->i_sb)->sb_chk) if (root && !down) { |
@@ -545,13 +545,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
545 | return; | 545 | return; |
546 | } | 546 | } |
547 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { | 547 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { |
548 | d1->up = up; | 548 | d1->up = cpu_to_le32(up); |
549 | d1->root_dnode = 1; | 549 | d1->root_dnode = 1; |
550 | hpfs_mark_4buffers_dirty(&qbh1); | 550 | hpfs_mark_4buffers_dirty(&qbh1); |
551 | hpfs_brelse4(&qbh1); | 551 | hpfs_brelse4(&qbh1); |
552 | } | 552 | } |
553 | if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) { | 553 | if ((fnode = hpfs_map_fnode(i->i_sb, up, &bh))) { |
554 | fnode->u.external[0].disk_secno = down; | 554 | fnode->u.external[0].disk_secno = cpu_to_le32(down); |
555 | mark_buffer_dirty(bh); | 555 | mark_buffer_dirty(bh); |
556 | brelse(bh); | 556 | brelse(bh); |
557 | } | 557 | } |
@@ -570,22 +570,22 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
570 | for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p); | 570 | for_all_poss(i, hpfs_pos_subst, ((loff_t)dno << 4) | 1, ((loff_t)up << 4) | p); |
571 | if (!down) { | 571 | if (!down) { |
572 | de->down = 0; | 572 | de->down = 0; |
573 | de->length -= 4; | 573 | de->length = cpu_to_le16(le16_to_cpu(de->length) - 4); |
574 | dnode->first_free -= 4; | 574 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
575 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, | 575 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, |
576 | (char *)dnode + dnode->first_free - (char *)de_next_de(de)); | 576 | (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de)); |
577 | } else { | 577 | } else { |
578 | struct dnode *d1; | 578 | struct dnode *d1; |
579 | struct quad_buffer_head qbh1; | 579 | struct quad_buffer_head qbh1; |
580 | *(dnode_secno *) ((void *) de + de->length - 4) = down; | 580 | *(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4) = down; |
581 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { | 581 | if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { |
582 | d1->up = up; | 582 | d1->up = cpu_to_le32(up); |
583 | hpfs_mark_4buffers_dirty(&qbh1); | 583 | hpfs_mark_4buffers_dirty(&qbh1); |
584 | hpfs_brelse4(&qbh1); | 584 | hpfs_brelse4(&qbh1); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | } else { | 587 | } else { |
588 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, dnode->first_free); | 588 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, le32_to_cpu(dnode->first_free)); |
589 | goto end; | 589 | goto end; |
590 | } | 590 | } |
591 | 591 | ||
@@ -596,18 +596,18 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
596 | struct quad_buffer_head qbh1; | 596 | struct quad_buffer_head qbh1; |
597 | if (!de_next->down) goto endm; | 597 | if (!de_next->down) goto endm; |
598 | ndown = de_down_pointer(de_next); | 598 | ndown = de_down_pointer(de_next); |
599 | if (!(de_cp = kmalloc(de->length, GFP_NOFS))) { | 599 | if (!(de_cp = kmalloc(le16_to_cpu(de->length), GFP_NOFS))) { |
600 | printk("HPFS: out of memory for dtree balancing\n"); | 600 | printk("HPFS: out of memory for dtree balancing\n"); |
601 | goto endm; | 601 | goto endm; |
602 | } | 602 | } |
603 | memcpy(de_cp, de, de->length); | 603 | memcpy(de_cp, de, le16_to_cpu(de->length)); |
604 | hpfs_delete_de(i->i_sb, dnode, de); | 604 | hpfs_delete_de(i->i_sb, dnode, de); |
605 | hpfs_mark_4buffers_dirty(&qbh); | 605 | hpfs_mark_4buffers_dirty(&qbh); |
606 | hpfs_brelse4(&qbh); | 606 | hpfs_brelse4(&qbh); |
607 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4); | 607 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, 4); |
608 | for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1); | 608 | for_all_poss(i, hpfs_pos_del, ((loff_t)up << 4) | p, 1); |
609 | if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) { | 609 | if (de_cp->down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de_cp), &qbh1))) { |
610 | d1->up = ndown; | 610 | d1->up = cpu_to_le32(ndown); |
611 | hpfs_mark_4buffers_dirty(&qbh1); | 611 | hpfs_mark_4buffers_dirty(&qbh1); |
612 | hpfs_brelse4(&qbh1); | 612 | hpfs_brelse4(&qbh1); |
613 | } | 613 | } |
@@ -635,7 +635,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
635 | struct hpfs_dirent *del = dnode_last_de(d1); | 635 | struct hpfs_dirent *del = dnode_last_de(d1); |
636 | dlp = del->down ? de_down_pointer(del) : 0; | 636 | dlp = del->down ? de_down_pointer(del) : 0; |
637 | if (!dlp && down) { | 637 | if (!dlp && down) { |
638 | if (d1->first_free > 2044) { | 638 | if (le32_to_cpu(d1->first_free) > 2044) { |
639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { | 639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { |
640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
641 | printk("HPFS: warning: terminating balancing operation\n"); | 641 | printk("HPFS: warning: terminating balancing operation\n"); |
@@ -647,38 +647,38 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
647 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 647 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
648 | printk("HPFS: warning: goin'on\n"); | 648 | printk("HPFS: warning: goin'on\n"); |
649 | } | 649 | } |
650 | del->length += 4; | 650 | del->length = cpu_to_le16(le16_to_cpu(del->length) + 4); |
651 | del->down = 1; | 651 | del->down = 1; |
652 | d1->first_free += 4; | 652 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4); |
653 | } | 653 | } |
654 | if (dlp && !down) { | 654 | if (dlp && !down) { |
655 | del->length -= 4; | 655 | del->length = cpu_to_le16(le16_to_cpu(del->length) - 4); |
656 | del->down = 0; | 656 | del->down = 0; |
657 | d1->first_free -= 4; | 657 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); |
658 | } else if (down) | 658 | } else if (down) |
659 | *(dnode_secno *) ((void *) del + del->length - 4) = down; | 659 | *(dnode_secno *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); |
660 | } else goto endm; | 660 | } else goto endm; |
661 | if (!(de_cp = kmalloc(de_prev->length, GFP_NOFS))) { | 661 | if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { |
662 | printk("HPFS: out of memory for dtree balancing\n"); | 662 | printk("HPFS: out of memory for dtree balancing\n"); |
663 | hpfs_brelse4(&qbh1); | 663 | hpfs_brelse4(&qbh1); |
664 | goto endm; | 664 | goto endm; |
665 | } | 665 | } |
666 | hpfs_mark_4buffers_dirty(&qbh1); | 666 | hpfs_mark_4buffers_dirty(&qbh1); |
667 | hpfs_brelse4(&qbh1); | 667 | hpfs_brelse4(&qbh1); |
668 | memcpy(de_cp, de_prev, de_prev->length); | 668 | memcpy(de_cp, de_prev, le16_to_cpu(de_prev->length)); |
669 | hpfs_delete_de(i->i_sb, dnode, de_prev); | 669 | hpfs_delete_de(i->i_sb, dnode, de_prev); |
670 | if (!de_prev->down) { | 670 | if (!de_prev->down) { |
671 | de_prev->length += 4; | 671 | de_prev->length = cpu_to_le16(le16_to_cpu(de_prev->length) + 4); |
672 | de_prev->down = 1; | 672 | de_prev->down = 1; |
673 | dnode->first_free += 4; | 673 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); |
674 | } | 674 | } |
675 | *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; | 675 | *(dnode_secno *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown); |
676 | hpfs_mark_4buffers_dirty(&qbh); | 676 | hpfs_mark_4buffers_dirty(&qbh); |
677 | hpfs_brelse4(&qbh); | 677 | hpfs_brelse4(&qbh); |
678 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); | 678 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); |
679 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1)); | 679 | for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | p, ((loff_t)up << 4) | (p - 1)); |
680 | if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) { | 680 | if (down) if ((d1 = hpfs_map_dnode(i->i_sb, de_down_pointer(de), &qbh1))) { |
681 | d1->up = ndown; | 681 | d1->up = cpu_to_le32(ndown); |
682 | hpfs_mark_4buffers_dirty(&qbh1); | 682 | hpfs_mark_4buffers_dirty(&qbh1); |
683 | hpfs_brelse4(&qbh1); | 683 | hpfs_brelse4(&qbh1); |
684 | } | 684 | } |
@@ -701,7 +701,6 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
701 | { | 701 | { |
702 | struct dnode *dnode = qbh->data; | 702 | struct dnode *dnode = qbh->data; |
703 | dnode_secno down = 0; | 703 | dnode_secno down = 0; |
704 | int lock = 0; | ||
705 | loff_t t; | 704 | loff_t t; |
706 | if (de->first || de->last) { | 705 | if (de->first || de->last) { |
707 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); | 706 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); |
@@ -710,11 +709,8 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
710 | } | 709 | } |
711 | if (de->down) down = de_down_pointer(de); | 710 | if (de->down) down = de_down_pointer(de); |
712 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { | 711 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { |
713 | lock = 1; | ||
714 | hpfs_lock_creation(i->i_sb); | ||
715 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { | 712 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { |
716 | hpfs_brelse4(qbh); | 713 | hpfs_brelse4(qbh); |
717 | hpfs_unlock_creation(i->i_sb); | ||
718 | return 2; | 714 | return 2; |
719 | } | 715 | } |
720 | } | 716 | } |
@@ -727,11 +723,9 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
727 | dnode_secno a = move_to_top(i, down, dno); | 723 | dnode_secno a = move_to_top(i, down, dno); |
728 | for_all_poss(i, hpfs_pos_subst, 5, t); | 724 | for_all_poss(i, hpfs_pos_subst, 5, t); |
729 | if (a) delete_empty_dnode(i, a); | 725 | if (a) delete_empty_dnode(i, a); |
730 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
731 | return !a; | 726 | return !a; |
732 | } | 727 | } |
733 | delete_empty_dnode(i, dno); | 728 | delete_empty_dnode(i, dno); |
734 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
735 | return 0; | 729 | return 0; |
736 | } | 730 | } |
737 | 731 | ||
@@ -751,8 +745,8 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes, | |||
751 | ptr = 0; | 745 | ptr = 0; |
752 | go_up: | 746 | go_up: |
753 | if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return; | 747 | if (!(dnode = hpfs_map_dnode(s, dno, &qbh))) return; |
754 | if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && dnode->up != odno) | 748 | if (hpfs_sb(s)->sb_chk) if (odno && odno != -1 && le32_to_cpu(dnode->up) != odno) |
755 | hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, dnode->up); | 749 | hpfs_error(s, "hpfs_count_dnodes: bad up pointer; dnode %08x, down %08x points to %08x", odno, dno, le32_to_cpu(dnode->up)); |
756 | de = dnode_first_de(dnode); | 750 | de = dnode_first_de(dnode); |
757 | if (ptr) while(1) { | 751 | if (ptr) while(1) { |
758 | if (de->down) if (de_down_pointer(de) == ptr) goto process_de; | 752 | if (de->down) if (de_down_pointer(de) == ptr) goto process_de; |
@@ -776,7 +770,7 @@ void hpfs_count_dnodes(struct super_block *s, dnode_secno dno, int *n_dnodes, | |||
776 | if (!de->first && !de->last && n_items) (*n_items)++; | 770 | if (!de->first && !de->last && n_items) (*n_items)++; |
777 | if ((de = de_next_de(de)) < dnode_end_de(dnode)) goto next_de; | 771 | if ((de = de_next_de(de)) < dnode_end_de(dnode)) goto next_de; |
778 | ptr = dno; | 772 | ptr = dno; |
779 | dno = dnode->up; | 773 | dno = le32_to_cpu(dnode->up); |
780 | if (dnode->root_dnode) { | 774 | if (dnode->root_dnode) { |
781 | hpfs_brelse4(&qbh); | 775 | hpfs_brelse4(&qbh); |
782 | return; | 776 | return; |
@@ -824,8 +818,8 @@ dnode_secno hpfs_de_as_down_as_possible(struct super_block *s, dnode_secno dno) | |||
824 | return d; | 818 | return d; |
825 | if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno; | 819 | if (!(de = map_nth_dirent(s, d, 1, &qbh, NULL))) return dno; |
826 | if (hpfs_sb(s)->sb_chk) | 820 | if (hpfs_sb(s)->sb_chk) |
827 | if (up && ((struct dnode *)qbh.data)->up != up) | 821 | if (up && le32_to_cpu(((struct dnode *)qbh.data)->up) != up) |
828 | hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, ((struct dnode *)qbh.data)->up); | 822 | hpfs_error(s, "hpfs_de_as_down_as_possible: bad up pointer; dnode %08x, down %08x points to %08x", up, d, le32_to_cpu(((struct dnode *)qbh.data)->up)); |
829 | if (!de->down) { | 823 | if (!de->down) { |
830 | hpfs_brelse4(&qbh); | 824 | hpfs_brelse4(&qbh); |
831 | return d; | 825 | return d; |
@@ -874,7 +868,7 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp, | |||
874 | /* Going up */ | 868 | /* Going up */ |
875 | if (dnode->root_dnode) goto bail; | 869 | if (dnode->root_dnode) goto bail; |
876 | 870 | ||
877 | if (!(up_dnode = hpfs_map_dnode(inode->i_sb, dnode->up, &qbh0))) | 871 | if (!(up_dnode = hpfs_map_dnode(inode->i_sb, le32_to_cpu(dnode->up), &qbh0))) |
878 | goto bail; | 872 | goto bail; |
879 | 873 | ||
880 | end_up_de = dnode_end_de(up_dnode); | 874 | end_up_de = dnode_end_de(up_dnode); |
@@ -882,16 +876,16 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp, | |||
882 | for (up_de = dnode_first_de(up_dnode); up_de < end_up_de; | 876 | for (up_de = dnode_first_de(up_dnode); up_de < end_up_de; |
883 | up_de = de_next_de(up_de)) { | 877 | up_de = de_next_de(up_de)) { |
884 | if (!(++c & 077)) hpfs_error(inode->i_sb, | 878 | if (!(++c & 077)) hpfs_error(inode->i_sb, |
885 | "map_pos_dirent: pos crossed dnode boundary; dnode = %08x", dnode->up); | 879 | "map_pos_dirent: pos crossed dnode boundary; dnode = %08x", le32_to_cpu(dnode->up)); |
886 | if (up_de->down && de_down_pointer(up_de) == dno) { | 880 | if (up_de->down && de_down_pointer(up_de) == dno) { |
887 | *posp = ((loff_t) dnode->up << 4) + c; | 881 | *posp = ((loff_t) le32_to_cpu(dnode->up) << 4) + c; |
888 | hpfs_brelse4(&qbh0); | 882 | hpfs_brelse4(&qbh0); |
889 | return de; | 883 | return de; |
890 | } | 884 | } |
891 | } | 885 | } |
892 | 886 | ||
893 | hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x", | 887 | hpfs_error(inode->i_sb, "map_pos_dirent: pointer to dnode %08x not found in parent dnode %08x", |
894 | dno, dnode->up); | 888 | dno, le32_to_cpu(dnode->up)); |
895 | hpfs_brelse4(&qbh0); | 889 | hpfs_brelse4(&qbh0); |
896 | 890 | ||
897 | bail: | 891 | bail: |
@@ -1017,17 +1011,17 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1017 | /*name2[15] = 0xff;*/ | 1011 | /*name2[15] = 0xff;*/ |
1018 | name1len = 15; name2len = 256; | 1012 | name1len = 15; name2len = 256; |
1019 | } | 1013 | } |
1020 | if (!(upf = hpfs_map_fnode(s, f->up, &bh))) { | 1014 | if (!(upf = hpfs_map_fnode(s, le32_to_cpu(f->up), &bh))) { |
1021 | kfree(name2); | 1015 | kfree(name2); |
1022 | return NULL; | 1016 | return NULL; |
1023 | } | 1017 | } |
1024 | if (!upf->dirflag) { | 1018 | if (!upf->dirflag) { |
1025 | brelse(bh); | 1019 | brelse(bh); |
1026 | hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, f->up); | 1020 | hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); |
1027 | kfree(name2); | 1021 | kfree(name2); |
1028 | return NULL; | 1022 | return NULL; |
1029 | } | 1023 | } |
1030 | dno = upf->u.external[0].disk_secno; | 1024 | dno = le32_to_cpu(upf->u.external[0].disk_secno); |
1031 | brelse(bh); | 1025 | brelse(bh); |
1032 | go_down: | 1026 | go_down: |
1033 | downd = 0; | 1027 | downd = 0; |
@@ -1049,7 +1043,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1049 | return NULL; | 1043 | return NULL; |
1050 | } | 1044 | } |
1051 | next_de: | 1045 | next_de: |
1052 | if (de->fnode == fno) { | 1046 | if (le32_to_cpu(de->fnode) == fno) { |
1053 | kfree(name2); | 1047 | kfree(name2); |
1054 | return de; | 1048 | return de; |
1055 | } | 1049 | } |
@@ -1065,7 +1059,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1065 | goto go_down; | 1059 | goto go_down; |
1066 | } | 1060 | } |
1067 | f: | 1061 | f: |
1068 | if (de->fnode == fno) { | 1062 | if (le32_to_cpu(de->fnode) == fno) { |
1069 | kfree(name2); | 1063 | kfree(name2); |
1070 | return de; | 1064 | return de; |
1071 | } | 1065 | } |
@@ -1074,7 +1068,7 @@ struct hpfs_dirent *map_fnode_dirent(struct super_block *s, fnode_secno fno, | |||
1074 | if ((de = de_next_de(de)) < de_end) goto next_de; | 1068 | if ((de = de_next_de(de)) < de_end) goto next_de; |
1075 | if (d->root_dnode) goto not_found; | 1069 | if (d->root_dnode) goto not_found; |
1076 | downd = dno; | 1070 | downd = dno; |
1077 | dno = d->up; | 1071 | dno = le32_to_cpu(d->up); |
1078 | hpfs_brelse4(qbh); | 1072 | hpfs_brelse4(qbh); |
1079 | if (hpfs_sb(s)->sb_chk) | 1073 | if (hpfs_sb(s)->sb_chk) |
1080 | if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) { | 1074 | if (hpfs_stop_cycles(s, downd, &d1, &d2, "map_fnode_dirent #2")) { |