diff mbox

[RFC] ubifs: do not write master node if recovery needed

Message ID 1423130080-79705-2-git-send-email-shengyong1@huawei.com
State Superseded
Headers show

Commit Message

shengyong Feb. 5, 2015, 9:54 a.m. UTC
If unclean umount happens, ubifs may fail when mounting. Trying to mount
it will write new master nodes on the flash. This is useless but wasting
space and increasing sqnum. So check need_recovery before writing master
node, and don't create new master node if filesystem needs recovery.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
 fs/ubifs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Artem Bityutskiy Feb. 6, 2015, 5:29 p.m. UTC | #1
On Thu, 2015-02-05 at 09:54 +0000, Sheng Yong wrote:
> If unclean umount happens, ubifs may fail when mounting. Trying to mount
> it will write new master nodes on the flash. This is useless but wasting
> space and increasing sqnum. So check need_recovery before writing master
> node, and don't create new master node if filesystem needs recovery.

Looks like you caught a bug, thanks, but I need to check the code a bit
more carefully. So when will the master not be updated then, if you do
not mark it dirty now?

Artem.
shengyong Feb. 7, 2015, 1:53 a.m. UTC | #2
在 2015/2/7 1:29, Artem Bityutskiy 写道:
> On Thu, 2015-02-05 at 09:54 +0000, Sheng Yong wrote:
>> If unclean umount happens, ubifs may fail when mounting. Trying to mount
>> it will write new master nodes on the flash. This is useless but wasting
>> space and increasing sqnum. So check need_recovery before writing master
>> node, and don't create new master node if filesystem needs recovery.
> 
> Looks like you caught a bug, thanks, but I need to check the code a bit
> more carefully. So when will the master not be updated then, if you do
> not mark it dirty now?
AFAIK, if the need_recovery is set after reading master and before writing
master, the master is always marked dirty by last mount (if unclean umount
happend), and each committing will update master later, with dirty flag set.
This is same as normal mount procedure. So I don't think we need to mark it
dirty here, and only if the recovery fails, the master will not be updated.

thanks,
Sheng
> 
> Artem.
> 
> 
>
diff mbox

Patch

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index e642067..17e3016 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1287,7 +1287,7 @@  static int mount_ubifs(struct ubifs_info *c)
 			goto out_lpt;
 	}
 
-	if (!c->ro_mount) {
+	if (!c->ro_mount && !c->need_recovery) {
 		/*
 		 * Set the "dirty" flag so that if we reboot uncleanly we
 		 * will notice this immediately on the next mount.