Skip to content

Commit 6376d75

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubifs: Remove insert_dead_orphan from replaying orphan process
UBIFS will do commit at the end of mounting process(rw mode), dead orphans(added by insert_dead_orphan in replaying orphan) are deleted by ubifs_orphan_end_commit(). The only reason why dead orphans are added into orphan list is that old orpans may be lost when powercut happens in ubifs_orphan_end_commit(): ubifs_orphan_end_commit // TNC(updated by orphans) is not written yet if (c->cmt_orphans != 0) commit_orphans consolidate // traverse orphan list write_orph_nodes // rewrite all orphans by ubifs_leb_change // If dead orphans are not in list, they will be lost when powercut // happens, then TNC won't be updated by old orphans in next mounting. Luckily, the condition 'c->cmt_orphans != 0' will never be true in mounting process, there can't be new orphans added into orphan list before mounting returned, but commit will be done at the end of mounting. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 7bed61a commit 6376d75

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

fs/ubifs/orphan.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -513,51 +513,6 @@ int ubifs_clear_orphans(struct ubifs_info *c)
513513
return 0;
514514
}
515515

516-
/**
517-
* insert_dead_orphan - insert an orphan.
518-
* @c: UBIFS file-system description object
519-
* @inum: orphan inode number
520-
*
521-
* This function is a helper to the 'do_kill_orphans()' function. The orphan
522-
* must be kept until the next commit, so it is added to the rb-tree and the
523-
* deletion list.
524-
*/
525-
static int insert_dead_orphan(struct ubifs_info *c, ino_t inum)
526-
{
527-
struct ubifs_orphan *orphan, *o;
528-
struct rb_node **p, *parent = NULL;
529-
530-
orphan = kzalloc(sizeof(struct ubifs_orphan), GFP_KERNEL);
531-
if (!orphan)
532-
return -ENOMEM;
533-
orphan->inum = inum;
534-
535-
p = &c->orph_tree.rb_node;
536-
while (*p) {
537-
parent = *p;
538-
o = rb_entry(parent, struct ubifs_orphan, rb);
539-
if (inum < o->inum)
540-
p = &(*p)->rb_left;
541-
else if (inum > o->inum)
542-
p = &(*p)->rb_right;
543-
else {
544-
/* Already added - no problem */
545-
kfree(orphan);
546-
return 0;
547-
}
548-
}
549-
c->tot_orphans += 1;
550-
rb_link_node(&orphan->rb, parent, p);
551-
rb_insert_color(&orphan->rb, &c->orph_tree);
552-
list_add_tail(&orphan->list, &c->orph_list);
553-
orphan->del = 1;
554-
orphan->dnext = c->orph_dnext;
555-
c->orph_dnext = orphan;
556-
dbg_mnt("ino %lu, new %d, tot %d", (unsigned long)inum,
557-
c->new_orphans, c->tot_orphans);
558-
return 0;
559-
}
560-
561516
/**
562517
* do_kill_orphans - remove orphan inodes from the index.
563518
* @c: UBIFS file-system description object
@@ -655,10 +610,6 @@ static int do_kill_orphans(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
655610
if (err)
656611
goto out_ro;
657612
}
658-
659-
err = insert_dead_orphan(c, inum);
660-
if (err)
661-
goto out_free;
662613
}
663614

664615
*last_cmt_no = cmt_no;

0 commit comments

Comments
 (0)