diff mbox

[OpenWrt-Devel] fstools: Check FS state before writing

Message ID 1452251263-23077-1-git-send-email-Wojciech.Dubowik@neratec.com
State Rejected
Headers show

Commit Message

Wojciech Dubowik Jan. 8, 2016, 11:07 a.m. UTC
It reduces number of flash writes on systems with FS ready.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
---
 libfstools/overlay.c | 3 ++-
 mount_root.c         | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Felix Fietkau Jan. 10, 2016, 5:30 p.m. UTC | #1
On 2016-01-08 12:07, Wojciech Dubowik wrote:
> It reduces number of flash writes on systems with FS ready.
> 
> Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
fs_state_set() already has such a check.

- Felix
Felix Fietkau Jan. 10, 2016, 5:32 p.m. UTC | #2
On 2016-01-10 18:30, Felix Fietkau wrote:
> On 2016-01-08 12:07, Wojciech Dubowik wrote:
>> It reduces number of flash writes on systems with FS ready.
>> 
>> Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
> fs_state_set() already has such a check.
And I just realized that I had apparently forgotten to actually push
that change that added the check. Sorry about that ;)

- Felix
diff mbox

Patch

diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index 7f69606..b51a6ae 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -251,7 +251,8 @@  jffs2_switch(struct volume *v)
 		return ret;
 
 	sync();
-	fs_state_set("/overlay", FS_STATE_READY);
+	if (fs_state_get("/overlay") != FS_STATE_READY)
+		fs_state_set("/overlay", FS_STATE_READY);
 	return 0;
 }
 
diff --git a/mount_root.c b/mount_root.c
index bf70265..29b2758 100644
--- a/mount_root.c
+++ b/mount_root.c
@@ -106,7 +106,8 @@  done(int argc, char *argv[1])
 
 	case FS_JFFS2:
 	case FS_UBIFS:
-		fs_state_set("/overlay", FS_STATE_READY);
+		if (fs_state_get("/overlay") != FS_STATE_READY)
+			fs_state_set("/overlay", FS_STATE_READY);
 		break;
 	}