ref: 73a57bbf40e9acd4d7200d3c9693d02b727aca9b
parent: 6a159c161b337b95932e3e6e956eec103e6d5141
author: gkostka <kostka.grzegorz@gmail.com>
date: Sat Jan 16 07:50:13 EST 2016
ext4_config: introduce CONFIG_JOURNALING_ENABLE configuration switch Disabling journaling at compile time will reduce footprint size significantly.
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -464,10 +464,11 @@
if (!strncmp(_mp[i].name, path, strlen(_mp[i].name)))
return &_mp[i];
}
- return 0;
+ return NULL;
}
-int ext4_journal_start(const char *mount_point)
+__unused
+static int __ext4_journal_start(const char *mount_point)
{
int r = EOK;
struct ext4_mountpoint *mp = ext4_get_mount(mount_point);
@@ -493,7 +494,8 @@
return r;
}
-int ext4_journal_stop(const char *mount_point)
+__unused
+static int __ext4_journal_stop(const char *mount_point)
{
int r = EOK;
struct ext4_mountpoint *mp = ext4_get_mount(mount_point);
@@ -525,7 +527,8 @@
return r;
}
-int ext4_recover(const char *mount_point)
+__unused
+static int __ext4_recover(const char *mount_point)
{
struct ext4_mountpoint *mp = ext4_get_mount(mount_point);
if (!mp)
@@ -558,7 +561,8 @@
return r;
}
-static int ext4_trans_start(struct ext4_mountpoint *mp)
+__unused
+static int __ext4_trans_start(struct ext4_mountpoint *mp)
{
int r = EOK;
if (mp->fs.jbd_journal && !mp->fs.curr_trans) {
@@ -575,7 +579,8 @@
return r;
}
-static int ext4_trans_stop(struct ext4_mountpoint *mp)
+__unused
+static int __ext4_trans_stop(struct ext4_mountpoint *mp)
{
int r = EOK;
if (mp->fs.jbd_journal && mp->fs.curr_trans) {
@@ -587,7 +592,8 @@
return r;
}
-static void ext4_trans_abort(struct ext4_mountpoint *mp)
+__unused
+static void __ext4_trans_abort(struct ext4_mountpoint *mp)
{
if (mp->fs.jbd_journal && mp->fs.curr_trans) {
struct jbd_journal *journal = mp->fs.jbd_journal;
@@ -597,6 +603,59 @@
}
}
+int ext4_journal_start(const char *mount_point __unused)
+{
+ int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
+ r = __ext4_journal_start(mount_point);
+#endif
+ return r;
+}
+
+int ext4_journal_stop(const char *mount_point __unused)
+{
+ int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
+ r = __ext4_journal_stop(mount_point);
+#endif
+ return r;
+}
+
+int ext4_recover(const char *mount_point __unused)
+{
+ int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
+ r = __ext4_recover(mount_point);
+#endif
+ return r;
+}
+
+static int ext4_trans_start(struct ext4_mountpoint *mp __unused)
+{
+ int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
+ r = __ext4_trans_start(mp);
+#endif
+ return r;
+}
+
+static int ext4_trans_stop(struct ext4_mountpoint *mp __unused)
+{
+ int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
+ r = __ext4_trans_stop(mp);
+#endif
+ return r;
+}
+
+static void ext4_trans_abort(struct ext4_mountpoint *mp __unused)
+{
+#if CONFIG_JOURNALING_ENABLE
+ __ext4_trans_abort(mp);
+#endif
+}
+
+
int ext4_mount_point_stats(const char *mount_point,
struct ext4_mount_stats *stats)
{
@@ -2827,6 +2886,7 @@
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);
@@ -2925,7 +2985,7 @@
EXT4_MP_UNLOCK(mp);
return r;
}
-
+#endif
/**
* @}
*/
--- a/lwext4/ext4_config.h
+++ b/lwext4/ext4_config.h
@@ -83,6 +83,11 @@
/*****************************************************************************/
+/**@brief Enable/disable journaling*/
+#ifndef CONFIG_JOURNALING_ENABLE
+#define CONFIG_JOURNALING_ENABLE 1
+#endif
+
/**@brief Enable directory indexing comb sort*/
#ifndef CONFIG_DIR_INDEX_COMB_SORT
#define CONFIG_DIR_INDEX_COMB_SORT 1
--- a/lwext4/ext4_trans.c
+++ b/lwext4/ext4_trans.c
@@ -31,7 +31,7 @@
* @{
*/
/**
- * @file ext4.h
+ * @file ext4_trans.c
* @brief Ext4 transaction buffer operations.
*/
@@ -39,15 +39,17 @@
#include "ext4_types.h"
#include "ext4_journal.h"
-static int ext4_trans_get_write_access(struct ext4_fs *fs,
- struct ext4_block *block)
+static int ext4_trans_get_write_access(struct ext4_fs *fs __unused,
+ struct ext4_block *block __unused)
{
int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
if (fs->jbd_journal && fs->curr_trans) {
struct jbd_journal *journal = fs->jbd_journal;
struct jbd_trans *trans = fs->curr_trans;
r = jbd_trans_get_access(journal, trans, block);
}
+#endif
return r;
}
@@ -54,6 +56,7 @@
int ext4_trans_set_block_dirty(struct ext4_buf *buf)
{
int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
struct ext4_fs *fs = buf->bc->bdev->fs;
struct ext4_block block = {
.lb_id = buf->lba,
@@ -63,10 +66,10 @@
if (fs->jbd_journal && fs->curr_trans) {
struct jbd_trans *trans = fs->curr_trans;
- r = jbd_trans_set_block_dirty(trans, &block);
- } else
- ext4_bcache_set_dirty(buf);
-
+ return jbd_trans_set_block_dirty(trans, &block);
+ }
+#endif
+ ext4_bcache_set_dirty(buf);
return r;
}
@@ -100,17 +103,19 @@
return r;
}
-int ext4_trans_try_revoke_block(struct ext4_blockdev *bdev,
- uint64_t lba)
+int ext4_trans_try_revoke_block(struct ext4_blockdev *bdev __unused,
+ uint64_t lba __unused)
{
int r = EOK;
+#if CONFIG_JOURNALING_ENABLE
struct ext4_fs *fs = bdev->fs;
if (fs->jbd_journal && fs->curr_trans) {
struct jbd_trans *trans = fs->curr_trans;
r = jbd_trans_try_revoke_block(trans, lba);
- } else if (fs->jbd_journal)
+ } else if (fs->jbd_journal) {
r = ext4_block_flush_lba(fs->bdev, lba);
-
+ }
+#endif
return r;
}