diff options
| author | Kaho Ng <ngkaho1234@gmail.com> | 2016-05-24 13:37:12 +0800 |
|---|---|---|
| committer | Kaho Ng <ngkaho1234@gmail.com> | 2016-05-24 13:37:54 +0800 |
| commit | bc6e18d5bce604736a77a15ebcfca8a54b2488c0 (patch) | |
| tree | 15e80be5601f9ea18126fb40074eda8797f67d49 /src | |
| parent | 6665a61fa4be7816b22cd005a7cfb720acce8e15 (diff) | |
ext4_journal: handle trans_id wrapping around cases
Diffstat (limited to 'src')
| -rw-r--r-- | src/ext4_journal.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ext4_journal.c b/src/ext4_journal.c index 9fe984e..c68d5a1 100644 --- a/src/ext4_journal.c +++ b/src/ext4_journal.c @@ -103,6 +103,12 @@ do { \ var -= (jbd_get32((sb), maxlen) - jbd_get32((sb), first)); \ } while (0) +static inline int32_t +trans_id_diff(uint32_t x, uint32_t y) +{ + int32_t diff = x - y; + return (diff >= 0); +} static int jbd_revoke_entry_cmp(struct revoke_entry *a, struct revoke_entry *b) @@ -878,7 +884,7 @@ static void jbd_replay_block_tags(struct jbd_fs *jbd_fs, * is equal or greater than that in revoke entry.*/ revoke_entry = jbd_revoke_entry_lookup(info, block); if (revoke_entry && - arg->this_trans_id < revoke_entry->trans_id) + trans_id_diff(arg->this_trans_id, revoke_entry->trans_id) < 0) return; ext4_dbg(DEBUG_JBD, @@ -1066,7 +1072,7 @@ static int jbd_iterate_log(struct jbd_fs *jbd_fs, * we will stop when we reach the end of * the journal.*/ if (action != ACTION_SCAN) - if (this_trans_id > info->last_trans_id) { + if (trans_id_diff(this_trans_id, info->last_trans_id) > 0) { log_end = true; continue; } @@ -1176,7 +1182,7 @@ static int jbd_iterate_log(struct jbd_fs *jbd_fs, if (r == EOK && action == ACTION_SCAN) { /* We have finished scanning the journal. */ info->start_trans_id = start_trans_id; - if (this_trans_id > start_trans_id) + if (trans_id_diff(this_trans_id, start_trans_id) > 0) info->last_trans_id = this_trans_id - 1; else info->last_trans_id = this_trans_id; |
