diff options
author | Zach Brown <zach.brown@oracle.com> | 2006-10-11 04:21:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-11 14:14:16 -0400 |
commit | b517bea1c74e4773482b3f41b3f493522a8c8e30 (patch) | |
tree | 1e98110151f1a35cde84ce1a2cb6f0cb871e9551 /fs/jbd2/recovery.c | |
parent | d0d856e8bd6e697cb44b2b4dd038f3bec576a70e (diff) |
[PATCH] 64-bit jbd2 core
Here is the patch to JBD to handle 64 bit block numbers, originally from Zach
Brown. This patch is useful only after adding support for 64-bit block
numbers in the filesystem.
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
Signed-off-by: Zach Brown <zach.brown@oracle.com>
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/jbd2/recovery.c')
-rw-r--r-- | fs/jbd2/recovery.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index b2012d112432..2486843adda0 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c | |||
@@ -178,19 +178,20 @@ static int jread(struct buffer_head **bhp, journal_t *journal, | |||
178 | * Count the number of in-use tags in a journal descriptor block. | 178 | * Count the number of in-use tags in a journal descriptor block. |
179 | */ | 179 | */ |
180 | 180 | ||
181 | static int count_tags(struct buffer_head *bh, int size) | 181 | static int count_tags(journal_t *journal, struct buffer_head *bh) |
182 | { | 182 | { |
183 | char * tagp; | 183 | char * tagp; |
184 | journal_block_tag_t * tag; | 184 | journal_block_tag_t * tag; |
185 | int nr = 0; | 185 | int nr = 0, size = journal->j_blocksize; |
186 | int tag_bytes = journal_tag_bytes(journal); | ||
186 | 187 | ||
187 | tagp = &bh->b_data[sizeof(journal_header_t)]; | 188 | tagp = &bh->b_data[sizeof(journal_header_t)]; |
188 | 189 | ||
189 | while ((tagp - bh->b_data + sizeof(journal_block_tag_t)) <= size) { | 190 | while ((tagp - bh->b_data + tag_bytes) <= size) { |
190 | tag = (journal_block_tag_t *) tagp; | 191 | tag = (journal_block_tag_t *) tagp; |
191 | 192 | ||
192 | nr++; | 193 | nr++; |
193 | tagp += sizeof(journal_block_tag_t); | 194 | tagp += tag_bytes; |
194 | if (!(tag->t_flags & cpu_to_be32(JBD2_FLAG_SAME_UUID))) | 195 | if (!(tag->t_flags & cpu_to_be32(JBD2_FLAG_SAME_UUID))) |
195 | tagp += 16; | 196 | tagp += 16; |
196 | 197 | ||
@@ -307,6 +308,14 @@ int jbd2_journal_skip_recovery(journal_t *journal) | |||
307 | return err; | 308 | return err; |
308 | } | 309 | } |
309 | 310 | ||
311 | static inline sector_t read_tag_block(int tag_bytes, journal_block_tag_t *tag) | ||
312 | { | ||
313 | sector_t block = be32_to_cpu(tag->t_blocknr); | ||
314 | if (tag_bytes > JBD_TAG_SIZE32) | ||
315 | block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32; | ||
316 | return block; | ||
317 | } | ||
318 | |||
310 | static int do_one_pass(journal_t *journal, | 319 | static int do_one_pass(journal_t *journal, |
311 | struct recovery_info *info, enum passtype pass) | 320 | struct recovery_info *info, enum passtype pass) |
312 | { | 321 | { |
@@ -318,11 +327,12 @@ static int do_one_pass(journal_t *journal, | |||
318 | struct buffer_head * bh; | 327 | struct buffer_head * bh; |
319 | unsigned int sequence; | 328 | unsigned int sequence; |
320 | int blocktype; | 329 | int blocktype; |
330 | int tag_bytes = journal_tag_bytes(journal); | ||
321 | 331 | ||
322 | /* Precompute the maximum metadata descriptors in a descriptor block */ | 332 | /* Precompute the maximum metadata descriptors in a descriptor block */ |
323 | int MAX_BLOCKS_PER_DESC; | 333 | int MAX_BLOCKS_PER_DESC; |
324 | MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t)) | 334 | MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t)) |
325 | / sizeof(journal_block_tag_t)); | 335 | / tag_bytes); |
326 | 336 | ||
327 | /* | 337 | /* |
328 | * First thing is to establish what we expect to find in the log | 338 | * First thing is to establish what we expect to find in the log |
@@ -412,8 +422,7 @@ static int do_one_pass(journal_t *journal, | |||
412 | * in pass REPLAY; otherwise, just skip over the | 422 | * in pass REPLAY; otherwise, just skip over the |
413 | * blocks it describes. */ | 423 | * blocks it describes. */ |
414 | if (pass != PASS_REPLAY) { | 424 | if (pass != PASS_REPLAY) { |
415 | next_log_block += | 425 | next_log_block += count_tags(journal, bh); |
416 | count_tags(bh, journal->j_blocksize); | ||
417 | wrap(journal, next_log_block); | 426 | wrap(journal, next_log_block); |
418 | brelse(bh); | 427 | brelse(bh); |
419 | continue; | 428 | continue; |
@@ -424,7 +433,7 @@ static int do_one_pass(journal_t *journal, | |||
424 | * getting done here! */ | 433 | * getting done here! */ |
425 | 434 | ||
426 | tagp = &bh->b_data[sizeof(journal_header_t)]; | 435 | tagp = &bh->b_data[sizeof(journal_header_t)]; |
427 | while ((tagp - bh->b_data +sizeof(journal_block_tag_t)) | 436 | while ((tagp - bh->b_data + tag_bytes) |
428 | <= journal->j_blocksize) { | 437 | <= journal->j_blocksize) { |
429 | unsigned long io_block; | 438 | unsigned long io_block; |
430 | 439 | ||
@@ -446,7 +455,8 @@ static int do_one_pass(journal_t *journal, | |||
446 | unsigned long blocknr; | 455 | unsigned long blocknr; |
447 | 456 | ||
448 | J_ASSERT(obh != NULL); | 457 | J_ASSERT(obh != NULL); |
449 | blocknr = be32_to_cpu(tag->t_blocknr); | 458 | blocknr = read_tag_block(tag_bytes, |
459 | tag); | ||
450 | 460 | ||
451 | /* If the block has been | 461 | /* If the block has been |
452 | * revoked, then we're all done | 462 | * revoked, then we're all done |
@@ -494,7 +504,7 @@ static int do_one_pass(journal_t *journal, | |||
494 | } | 504 | } |
495 | 505 | ||
496 | skip_write: | 506 | skip_write: |
497 | tagp += sizeof(journal_block_tag_t); | 507 | tagp += tag_bytes; |
498 | if (!(flags & JBD2_FLAG_SAME_UUID)) | 508 | if (!(flags & JBD2_FLAG_SAME_UUID)) |
499 | tagp += 16; | 509 | tagp += 16; |
500 | 510 | ||
@@ -572,17 +582,24 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, | |||
572 | { | 582 | { |
573 | jbd2_journal_revoke_header_t *header; | 583 | jbd2_journal_revoke_header_t *header; |
574 | int offset, max; | 584 | int offset, max; |
585 | int record_len = 4; | ||
575 | 586 | ||
576 | header = (jbd2_journal_revoke_header_t *) bh->b_data; | 587 | header = (jbd2_journal_revoke_header_t *) bh->b_data; |
577 | offset = sizeof(jbd2_journal_revoke_header_t); | 588 | offset = sizeof(jbd2_journal_revoke_header_t); |
578 | max = be32_to_cpu(header->r_count); | 589 | max = be32_to_cpu(header->r_count); |
579 | 590 | ||
580 | while (offset < max) { | 591 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) |
592 | record_len = 8; | ||
593 | |||
594 | while (offset + record_len <= max) { | ||
581 | unsigned long blocknr; | 595 | unsigned long blocknr; |
582 | int err; | 596 | int err; |
583 | 597 | ||
584 | blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset))); | 598 | if (record_len == 4) |
585 | offset += 4; | 599 | blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset))); |
600 | else | ||
601 | blocknr = be64_to_cpu(* ((__be64 *) (bh->b_data+offset))); | ||
602 | offset += record_len; | ||
586 | err = jbd2_journal_set_revoke(journal, blocknr, sequence); | 603 | err = jbd2_journal_set_revoke(journal, blocknr, sequence); |
587 | if (err) | 604 | if (err) |
588 | return err; | 605 | return err; |