diff options
| author | ngkaho1234 <ngkaho1234@gmail.com> | 2015-12-14 14:35:18 +0000 |
|---|---|---|
| committer | ngkaho1234 <ngkaho1234@gmail.com> | 2015-12-14 14:35:18 +0000 |
| commit | 07ef5d4916b1b81d98825529665fd6d6dc177c4d (patch) | |
| tree | d89b889f0dba50f91f8a5ae36be49cbb1559ee39 | |
| parent | fc4574f0955a74a7b034fa60b1df176360517271 (diff) | |
ext4: more codes on journal testing.
| -rw-r--r-- | lwext4/ext4.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lwext4/ext4.c b/lwext4/ext4.c index f09ce76..57cc00f 100644 --- a/lwext4/ext4.c +++ b/lwext4/ext4.c @@ -2540,13 +2540,35 @@ int ext4_test_journal(const char *mount_point) goto Finish; } - jbd_journal_stop(journal); + ext4_fsblk_t rand_block = rand() % 4096; + if (!rand_block) + rand_block = 1; + struct ext4_block block; + r = ext4_block_get(mp->fs.bdev, &block, rand_block); + if (r != EOK) + goto out; + + struct jbd_trans *trans = jbd_journal_new_trans(journal); + if (!trans) { + ext4_block_set(mp->fs.bdev, &block); + r = ENOMEM; + goto out; + } + r = jbd_trans_add_block(trans, &block); + if (r != EOK) { + jbd_journal_free_trans(journal, trans, true); + ext4_block_set(mp->fs.bdev, &block); + r = ENOMEM; + goto out; + } + jbd_journal_submit_trans(journal, trans); + jbd_journal_commit_one(journal); +out: jbd_put_fs(jbd_fs); free(journal); free(jbd_fs); } - Finish: EXT4_MP_UNLOCK(mp); return r; |
