Browse Source

ext4_journal: fix wrong parsing of revoke blocks list.

pull/11/head
ngkaho1234 9 years ago
parent
commit
13b86cb3c2
  1. 41
      lwext4/ext4_journal.c

41
lwext4/ext4_journal.c

@ -324,12 +324,9 @@ jbd_revoke_entry_lookup(struct recover_info *info, ext4_fsblk_t block)
return RB_FIND(jbd_revoke, &info->revoke_root, &tmp); return RB_FIND(jbd_revoke, &info->revoke_root, &tmp);
} }
static void jbd_add_revoke_block_tags(struct jbd_fs *jbd_fs __unused, static void jbd_add_revoke_block_tags(struct recover_info *info,
ext4_fsblk_t block, ext4_fsblk_t block)
uint8_t *uuid __unused,
void *arg)
{ {
struct recover_info *info = arg;
struct revoke_entry *revoke_entry; struct revoke_entry *revoke_entry;
ext4_dbg(DEBUG_JBD, "Add block %" PRIu64 " to revoke tree\n", block); ext4_dbg(DEBUG_JBD, "Add block %" PRIu64 " to revoke tree\n", block);
@ -371,19 +368,36 @@ do { \
#define ACTION_RECOVER 2 #define ACTION_RECOVER 2
static void jbd_build_revoke_root(struct jbd_fs *jbd_fs, static void jbd_build_revoke_tree(struct jbd_fs *jbd_fs,
struct jbd_bhdr *header, struct jbd_bhdr *header,
struct recover_info *info) struct recover_info *info)
{ {
char *blocks_entry;
struct jbd_revoke_header *revoke_hdr = struct jbd_revoke_header *revoke_hdr =
(struct jbd_revoke_header *)header; (struct jbd_revoke_header *)header;
uint32_t i, nr_entries, record_len = 4;
if (JBD_HAS_INCOMPAT_FEATURE(&jbd_fs->sb,
JBD_FEATURE_INCOMPAT_64BIT))
record_len = 8;
jbd_iterate_block_table(jbd_fs, nr_entries = (revoke_hdr->count -
revoke_hdr + 1, sizeof(struct jbd_revoke_header)) /
jbd_get32(&jbd_fs->sb, blocksize) - record_len;
sizeof(struct jbd_revoke_header),
jbd_add_revoke_block_tags, blocks_entry = (char *)(revoke_hdr + 1);
info);
for (i = 0;i < nr_entries;i++) {
if (record_len == 8) {
uint64_t *blocks =
(uint64_t *)blocks_entry;
jbd_add_revoke_block_tags(info, *blocks);
} else {
uint32_t *blocks =
(uint32_t *)blocks_entry;
jbd_add_revoke_block_tags(info, *blocks);
}
blocks_entry += record_len;
}
} }
static void jbd_debug_descriptor_block(struct jbd_fs *jbd_fs, static void jbd_debug_descriptor_block(struct jbd_fs *jbd_fs,
@ -464,7 +478,8 @@ int jbd_iterate_log(struct jbd_fs *jbd_fs,
this_block, this_trans_id); this_block, this_trans_id);
if (action == ACTION_REVOKE) { if (action == ACTION_REVOKE) {
info->this_trans_id = this_trans_id; info->this_trans_id = this_trans_id;
jbd_build_revoke_root(jbd_fs, header, info); jbd_build_revoke_tree(jbd_fs,
header, info);
} }
break; break;
default: default:

Loading…
Cancel
Save