+/*
+ * Copyright (c) 2015 Grzegorz Kostka (kostka.grzegorz@gmail.com)
+ * Copyright (c) 2015 Kaho Ng (ngkaho1234@gmail.com)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup lwext4
+ * @{
+ */
/**
* @file ext4_journal.c
- * @brief Journalling
+ * @brief Journal handle functions
*/
#include "ext4_config.h"
#include "tree.h"
#include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
struct revoke_entry {
ext4_fsblk_t block;
if (rc != EOK) {
memset(jbd_fs, 0, sizeof(struct jbd_fs));
ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
+ return rc;
+ }
+ if (!jbd_verify_sb(&jbd_fs->sb)) {
+ memset(jbd_fs, 0, sizeof(struct jbd_fs));
+ ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
+ rc = EIO;
}
return rc;
ext4_lblk_t iblock,
ext4_fsblk_t *fblock)
{
- int rc = ext4_fs_get_inode_data_block_index(
+ int rc = ext4_fs_get_inode_dblk_idx(
&jbd_fs->inode_ref,
iblock,
fblock,
struct ext4_block journal_block, ext4_block;
struct ext4_fs *fs = jbd_fs->inode_ref.fs;
- ext4_dbg(DEBUG_JBD,
- "Replaying block in block_tag: %" PRIu64 "\n",
- block);
(*this_block)++;
revoke_entry = jbd_revoke_entry_lookup(info, block);
arg->this_trans_id < revoke_entry->trans_id)
return;
+ ext4_dbg(DEBUG_JBD,
+ "Replaying block in block_tag: %" PRIu64 "\n",
+ block);
+
r = jbd_block_get(jbd_fs, &journal_block, *this_block);
if (r != EOK)
return;
JBD_FEATURE_INCOMPAT_64BIT))
record_len = 8;
- nr_entries = (revoke_hdr->count -
+ nr_entries = (jbd_get32(revoke_hdr, count) -
sizeof(struct jbd_revoke_header)) /
record_len;
if (record_len == 8) {
uint64_t *blocks =
(uint64_t *)blocks_entry;
- jbd_add_revoke_block_tags(info, *blocks);
+ jbd_add_revoke_block_tags(info, to_be64(*blocks));
} else {
uint32_t *blocks =
(uint32_t *)blocks_entry;
- jbd_add_revoke_block_tags(info, *blocks);
+ jbd_add_revoke_block_tags(info, to_be32(*blocks));
}
blocks_entry += record_len;
}
ext4_dbg(DEBUG_JBD, "Descriptor block: %" PRIu32", "
"trans_id: %" PRIu32"\n",
this_block, this_trans_id);
- if (action == ACTION_SCAN)
- jbd_debug_descriptor_block(jbd_fs,
- header, &this_block);
- else if (action == ACTION_RECOVER) {
+ if (action == ACTION_RECOVER) {
struct replay_arg replay_arg;
replay_arg.info = info;
replay_arg.this_block = &this_block;
jbd_replay_descriptor_block(jbd_fs,
header, &replay_arg);
- }
+ } else
+ jbd_debug_descriptor_block(jbd_fs,
+ header, &this_block);
break;
case JBD_COMMIT_BLOCK:
jbd_destroy_revoke_tree(&info);
return r;
}
+
+/**
+ * @}
+ */