diff mbox

[RESEND] ubifs: do not write master node if need recovery

Message ID 1425465976-11116-1-git-send-email-shengyong1@huawei.com
State Accepted
Headers show

Commit Message

shengyong March 4, 2015, 10:46 a.m. UTC
The commits 781c571 ("UBIFS: intialize LPT earlier") and 0980119 ("UBIFS:
fix-up free space earlier") move some initialization before marking the
master node dirty. But the modification changes the conditions of writing
master. 

If unclean umount happens, ubifs may fail when mounting. But trying to
mount it will write new master nodes on the flash. This is useless but
increasing sqnum. So check need_recovery before writing master node, and
don't create new master node if filesystem needs recovery.

The behavour of the bug shows at:
http://lists.infradead.org/pipermail/linux-mtd/2015-February/057712.html

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

Comments

Artem Bityutskiy March 12, 2015, 11:10 a.m. UTC | #1
On Wed, 2015-03-04 at 10:46 +0000, Sheng Yong wrote:
> The commits 781c571 ("UBIFS: intialize LPT earlier") and 0980119 ("UBIFS:
> fix-up free space earlier") move some initialization before marking the
> master node dirty. But the modification changes the conditions of writing
> master. 
> 
> If unclean umount happens, ubifs may fail when mounting. But trying to
> mount it will write new master nodes on the flash. This is useless but
> increasing sqnum. So check need_recovery before writing master node, and
> don't create new master node if filesystem needs recovery.
> 
> The behavour of the bug shows at:
> http://lists.infradead.org/pipermail/linux-mtd/2015-February/057712.html
> 
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>

Pushed to linux-ubifs.git/master, thank you!

Artem.
diff mbox

Patch

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 93e9465..0b7378a 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1284,7 +1284,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.