FAILED: patch "[PATCH] ubifs: Only check replay with inode type to judge if inode" failed to apply to 4.14-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3e903315790baf4a966436e7f32e9c97864570ac Mon Sep 17 00:00:00 2001
From: Guochun Mao <[email protected]>
Date: Tue, 16 Mar 2021 16:52:14 +0800
Subject: [PATCH] ubifs: Only check replay with inode type to judge if inode
linked
Conside the following case, it just write a big file into flash, when complete writing, delete the file, and then power off promptly. Next time power on, we'll get a replay list like:
...
LEB 1105:211344 len 4144 deletion 0 sqnum 428783 key type 1 inode 80 LEB 15:233544 len 160 deletion 1 sqnum 428785 key type 0 inode 80 LEB 1105:215488 len 4144 deletion 0 sqnum 428787 key type 1 inode 80
...
In the replay list, data nodes' deletion are 0, and the inode node's deletion is 1. In current logic, the file's dentry will be removed, but inode and the flash space it occupied will be reserved. User will see that much free space been disappeared.
We only need to check the deletion value of the following inode type node of the replay entry.
fs/ubifs/replay.c +2 -1
@@ -223,7 +223,8 @@ static bool inode_still_linked(struct ubifs_info *c, struct replay_entry *rino)*/ list_for_each_entry_reverse (r, &c->replay_list, list) {ubifs_assert (c, r->sqnum >= rino->sqnum); -if (key_inum (c, &r->key) ==key_inum (c, &rino->key)) +if (key_inum (c, &r->key) ==key_inum (c, &rino->key) && +key_type (c, &r->key) ==UBIFS_INO_KEY )return r->deletion ==0 ; }