88 else if (inum > o->
inum)
99 rb_link_node(&orphan->
rb, parent, p);
104 dbg_gen(
"ino %lu", (
unsigned long)inum);
126 else if (inum > o->
inum)
131 dbg_gen(
"deleted twice ino %lu",
132 (
unsigned long)inum);
139 dbg_gen(
"delete later ino %lu",
140 (
unsigned long)inum);
152 dbg_gen(
"inum %lu", (
unsigned long)inum);
157 ubifs_err(
"missing orphan ino %lu", (
unsigned long)inum);
177 last = &orphan->
cnext;
201 int avail_lebs,
avail, gap;
219 static int tot_avail_orphs(
struct ubifs_info *c)
221 int avail_lebs,
avail;
239 static int do_write_orph_node(
struct ubifs_info *c,
int len,
int atomic)
270 static int write_orph_node(
struct ubifs_info *c,
int atomic)
287 ubifs_err(
"out of space in orphan area");
300 for (i = 0; i <
cnt; i++) {
303 cnext = orphan->
cnext;
317 err = do_write_orph_node(c, len, atomic);
331 static int write_orph_nodes(
struct ubifs_info *c,
int atomic)
336 err = write_orph_node(c, atomic);
345 for (lnum = c->
ohead_lnum + 1; lnum <= c->orph_last; lnum++) {
367 int tot_avail = tot_avail_orphs(c), err = 0;
370 dbg_cmt(
"there is space for %d orphans and there are %d",
382 last = &orphan->
cnext;
395 ubifs_err(
"out of space in orphan area");
409 static int commit_orphans(
struct ubifs_info *c)
414 avail = avail_orphs(c);
415 if (avail < c->cmt_orphans) {
417 err = consolidate(c);
422 err = write_orph_nodes(c, atomic);
435 static void erase_deleted(
struct ubifs_info *c)
443 dnext = orphan->
dnext;
448 dbg_gen(
"deleting orphan ino %lu", (
unsigned long)orphan->
inum);
466 err = commit_orphans(c);
471 err = dbg_check_orphans(c);
487 for (lnum = c->
orph_first; lnum <= c->orph_last; lnum++) {
522 else if (inum > o->
inum)
531 rb_link_node(&orphan->
rb, parent, p);
536 dbg_mnt(
"ino %lu, new %d, tot %d", (
unsigned long)inum,
554 unsigned long long *last_cmt_no,
int *outofdate,
559 unsigned long long cmt_no;
565 ubifs_err(
"invalid node type %d in orphan area at %d:%d",
585 if (cmt_no < *last_cmt_no && *last_flagged) {
592 ubifs_err(
"out of order commit number %llu in orphan node at %d:%d",
606 for (i = 0; i <
n; i++) {
609 (
unsigned long)inum);
613 err = insert_dead_orphan(c, inum);
620 dbg_rcvry(
"last orph node for commit %llu at %d:%d",
642 unsigned long long last_cmt_no = 0;
643 int lnum, err = 0, outofdate = 0, last_flagged = 0;
663 for (lnum = c->
orph_first; lnum <= c->orph_last; lnum++) {
677 err = do_kill_orphans(c, sleb, &last_cmt_no, &outofdate,
679 if (err || outofdate) {
715 err = kill_orphans(c);
751 else if (inum > o->
inum)
762 static int dbg_ins_check_orphan(
struct rb_root *root,
ino_t inum)
778 else if (inum > o->
inum)
785 rb_link_node(&orphan->
rb, parent, p);
790 static int dbg_find_check_orphan(
struct rb_root *root,
ino_t inum)
800 else if (inum > o->
inum)
808 static void dbg_free_check_tree(
struct rb_root *root)
840 inum = key_inum(c, &zbr->
key);
844 ubifs_err(
"found orphan node ino %lu, type %d",
845 (
unsigned long)inum, key_type(c, &zbr->
key));
850 ubifs_err(
"node read failed, error %d", err);
853 if (ci->
node->nlink == 0)
855 if (!dbg_find_check_orphan(&ci->
root, inum) &&
856 !dbg_find_orphan(c, inum)) {
858 (
unsigned long)inum);
879 for (i = 0; i <
n; i++) {
881 err = dbg_ins_check_orphan(&ci->
root, inum);
900 ubifs_err(
"cannot allocate memory to check orphans");
904 for (lnum = c->
orph_first; lnum <= c->orph_last; lnum++) {
913 err = dbg_read_orphans(ci, sleb);
923 static int dbg_check_orphans(
struct ubifs_info *c)
928 if (!dbg_is_chk_orph(c))
942 err = dbg_scan_orphans(c, &ci);
948 ubifs_err(
"cannot scan TNC, error %d", err);
963 dbg_free_check_tree(&ci.
root);