ubifs: Fix ubifs_tnc_lookup() usage in do_kill_orphans()
authorRichard Weinberger <richard@nod.at>
Sun, 19 Jan 2020 21:52:33 +0000 (22:52 +0100)
committerRichard Weinberger <richard@nod.at>
Mon, 30 Mar 2020 20:59:23 +0000 (22:59 +0200)
Orphans are allowed to point to deleted inodes.
So -ENOENT is not a fatal error.

Reported-by: Кочетков Максим <fido_max@inbox.ru>
Reported-and-tested-by: "Christian Berger" <Christian.Berger@de.bosch.com>
Tested-by: Karl Olsen <karl@micro-technic.com>
Tested-by: Jef Driesen <jef.driesen@niko.eu>
Fixes: ee1438ce5dc4 ("ubifs: Check link count of inodes when killing orphans.")
Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/orphan.c

index edf43ddd7dce47797bad711f197e8b857a362c7f..7dd740e3692daf0a6db5c8014c67bd6d984781ac 100644 (file)
@@ -688,14 +688,14 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
 
                        ino_key_init(c, &key1, inum);
                        err = ubifs_tnc_lookup(c, &key1, ino);
-                       if (err)
+                       if (err && err != -ENOENT)
                                goto out_free;
 
                        /*
                         * Check whether an inode can really get deleted.
                         * linkat() with O_TMPFILE allows rebirth of an inode.
                         */
-                       if (ino->nlink == 0) {
+                       if (err == 0 && ino->nlink == 0) {
                                dbg_rcvry("deleting orphaned inode %lu",
                                          (unsigned long)inum);