ref: 97a67fc9edb25b48a12ce7306d4defbb2135a8b9
parent: f346efe5f222d05b6b6f2c65af89cddf76e83fcf
author: gkostka <kostka.grzegorz@gmail.com>
date: Sat Jan 16 15:31:10 EST 2016
ext4: remove ext4_test_journal function This function should not be in standard lwext4 API
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -2926,106 +2926,6 @@
d->next_off = 0;
}
-#if CONFIG_JOURNALING_ENABLE
-int ext4_test_journal(const char *mount_point)
-{
- struct ext4_mountpoint *mp = ext4_get_mount(mount_point);
- if (!mp)
- return ENOENT;
-
- int r = ENOTSUP;
- EXT4_MP_LOCK(mp);
- ext4_block_cache_write_back(mp->fs.bdev, 1);
- if (ext4_sb_feature_com(&mp->fs.sb, EXT4_FCOM_HAS_JOURNAL)) {
- struct jbd_fs *jbd_fs = calloc(1, sizeof(struct jbd_fs));
- struct jbd_journal *journal;
- if (!jbd_fs) {
- r = ENOMEM;
- goto Finish;
- }
- journal = calloc(1, sizeof(struct jbd_journal));
- if (!journal) {
- free(jbd_fs);
- r = ENOMEM;
- goto Finish;
- }
-
- r = jbd_get_fs(&mp->fs, jbd_fs);
- if (r != EOK) {
- free(jbd_fs);
- goto Finish;
- }
- r = jbd_journal_start(jbd_fs, journal);
- if (r != EOK) {
- jbd_put_fs(jbd_fs);
- free(journal);
- free(jbd_fs);
- goto Finish;
- }
-
- int i;
- for (i = 0;i < 50;i++) {
- 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 *t = jbd_journal_new_trans(journal);
- if (!t) {
- ext4_block_set(mp->fs.bdev, &block);
- r = ENOMEM;
- goto out;
- }
-
- switch (rand() % 2) {
- case 0:
- r = jbd_trans_get_access(journal, t, &block);
- if (r != EOK) {
- jbd_journal_free_trans(journal, t,
- true);
- ext4_block_set(mp->fs.bdev, &block);
- r = ENOMEM;
- goto out;
- }
- r = jbd_trans_set_block_dirty(t, &block);
- if (r != EOK) {
- jbd_journal_free_trans(journal, t,
- true);
- ext4_block_set(mp->fs.bdev, &block);
- r = ENOMEM;
- goto out;
- }
- break;
- case 1:
- r = jbd_trans_try_revoke_block(t, rand_block);
- if (r != EOK) {
- jbd_journal_free_trans(journal, t,
- true);
- ext4_block_set(mp->fs.bdev, &block);
- r = ENOMEM;
- goto out;
- }
- }
- ext4_block_set(mp->fs.bdev, &block);
- jbd_journal_submit_trans(journal, t);
- jbd_journal_commit_one(journal);
- }
-out:
- jbd_journal_stop(journal);
- jbd_put_fs(jbd_fs);
- free(journal);
- free(jbd_fs);
- }
-
-Finish:
- ext4_block_cache_write_back(mp->fs.bdev, 0);
- EXT4_MP_UNLOCK(mp);
- return r;
-}
-#endif
/**
* @}
*/
--- a/lwext4/ext4.h
+++ b/lwext4/ext4.h
@@ -498,14 +498,6 @@
* @param d directory handle*/
void ext4_dir_entry_rewind(ext4_dir *d);
-/**@brief Test journal functionality
- * @param mount_point mount point, for example
- * - /
- * - /my_partition/
- * - /my_second_partition/
- *
- * @return standard error code */
-int ext4_test_journal(const char *mount_point);
#ifdef __cplusplus
}