Lines Matching +full:skip +full:- +full:power +full:- +full:up
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2006-2008 Nokia Corporation
12 * This file implements functions needed to recover from unclean un-mounts.
14 * an un-mount was completed successfully. If not, the process of mounting
15 * incorporates additional checking and fixing of on-flash data structures.
16 * UBIFS always cleans away all remnants of an unclean un-mount, so that
18 * read-only, and the flash is not modified in that case.
21 * corruptions which could be caused by power cuts, but it refuses to recover
29 * writes in @c->max_write_size bytes at a time.
34 * not true, the corruption cannot be the result of a power cut, and UBIFS
43 * is_empty - determine whether a buffer is empty (contains all 0xff).
62 * first_non_ff - find offset of the first non-0xff byte.
66 * This function returns offset of the first non-0xff byte in @buf or %-1 if
77 return -1; in first_non_ff()
81 * get_master_node - get the last valid master node allowing for corruption.
82 * @c: UBIFS file-system description object
100 const int sz = c->mst_node_alsz; in get_master_node()
104 sbuf = vmalloc(c->leb_size); in get_master_node()
106 return -ENOMEM; in get_master_node()
108 err = ubifs_leb_read(c, lnum, sbuf, 0, c->leb_size, 0); in get_master_node()
109 if (err && err != -EBADMSG) in get_master_node()
115 len = c->leb_size; in get_master_node()
116 while (offs + UBIFS_MST_NODE_SZ <= c->leb_size) { in get_master_node()
119 if (le32_to_cpu(ch->magic) != UBIFS_NODE_MAGIC) in get_master_node()
123 len -= sz; in get_master_node()
129 offs -= sz; in get_master_node()
130 buf -= sz; in get_master_node()
135 offs -= sz; in get_master_node()
136 buf -= sz; in get_master_node()
150 if (ch->node_type != UBIFS_MST_NODE) in get_master_node()
156 len -= sz; in get_master_node()
160 if (offs < c->leb_size) { in get_master_node()
167 len -= sz; in get_master_node()
170 if (offs < c->leb_size) in get_master_node()
177 err = -EINVAL; in get_master_node()
186 * write_rcvrd_mst_node - write recovered master node.
187 * @c: UBIFS file-system description object
195 int err = 0, lnum = UBIFS_MST_LNUM, sz = c->mst_node_alsz; in write_rcvrd_mst_node()
200 save_flags = mst->flags; in write_rcvrd_mst_node()
201 mst->flags |= cpu_to_le32(UBIFS_MST_RCVRY); in write_rcvrd_mst_node()
214 mst->flags = save_flags; in write_rcvrd_mst_node()
219 * ubifs_recover_master_node - recover the master node.
220 * @c: UBIFS file-system description object
231 const int sz = c->mst_node_alsz; in ubifs_recover_master_node()
245 offs1 = (void *)mst1 - buf1; in ubifs_recover_master_node()
246 if ((le32_to_cpu(mst1->flags) & UBIFS_MST_RCVRY) && in ubifs_recover_master_node()
255 offs2 = (void *)mst2 - buf2; in ubifs_recover_master_node()
267 c->leb_size - offs2 - sz < sz) { in ubifs_recover_master_node()
291 offs2 = (void *)mst2 - buf2; in ubifs_recover_master_node()
292 if (offs2 + sz + sz <= c->leb_size) in ubifs_recover_master_node()
300 memcpy(c->mst_node, mst, UBIFS_MST_NODE_SZ); in ubifs_recover_master_node()
302 if (c->ro_mount) { in ubifs_recover_master_node()
303 /* Read-only mode. Keep a copy for switching to rw mode */ in ubifs_recover_master_node()
304 c->rcvrd_mst_node = kmalloc(sz, GFP_KERNEL); in ubifs_recover_master_node()
305 if (!c->rcvrd_mst_node) { in ubifs_recover_master_node()
306 err = -ENOMEM; in ubifs_recover_master_node()
309 memcpy(c->rcvrd_mst_node, c->mst_node, UBIFS_MST_NODE_SZ); in ubifs_recover_master_node()
319 * node in the first (%UBIFS_MST_LNUM). A power cut happens, in ubifs_recover_master_node()
320 * so this LEB ends up with some amount of garbage at the in ubifs_recover_master_node()
327 * 4. However, this master node (@c->mst_node) is marked as in ubifs_recover_master_node()
330 * node when it is re-mounter R/W later. in ubifs_recover_master_node()
335 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); in ubifs_recover_master_node()
338 c->max_sqnum = le64_to_cpu(mst->ch.sqnum) - 1; in ubifs_recover_master_node()
339 err = write_rcvrd_mst_node(c, c->mst_node); in ubifs_recover_master_node()
350 err = -EINVAL; in ubifs_recover_master_node()
355 ubifs_dump_node(c, mst1, c->leb_size - ((void *)mst1 - buf1)); in ubifs_recover_master_node()
359 ubifs_dump_node(c, mst2, c->leb_size - ((void *)mst2 - buf2)); in ubifs_recover_master_node()
367 * ubifs_write_rcvrd_mst_node - write the recovered master node.
368 * @c: UBIFS file-system description object
371 * read-only mode and must now be written because we are remounting rw.
379 if (!c->rcvrd_mst_node) in ubifs_write_rcvrd_mst_node()
381 c->rcvrd_mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); in ubifs_write_rcvrd_mst_node()
382 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY); in ubifs_write_rcvrd_mst_node()
383 err = write_rcvrd_mst_node(c, c->rcvrd_mst_node); in ubifs_write_rcvrd_mst_node()
386 kfree(c->rcvrd_mst_node); in ubifs_write_rcvrd_mst_node()
387 c->rcvrd_mst_node = NULL; in ubifs_write_rcvrd_mst_node()
392 * is_last_write - determine if an offset was in the last write to a LEB.
393 * @c: UBIFS file-system description object
399 * for subsequent empty space starting from the next @c->max_write_size
408 * Round up to the next @c->max_write_size boundary i.e. @offs is in in is_last_write()
411 empty_offs = ALIGN(offs + 1, c->max_write_size); in is_last_write()
412 check_len = c->leb_size - empty_offs; in is_last_write()
413 p = buf + empty_offs - offs; in is_last_write()
418 * clean_buf - clean the data from an LEB sitting in a buffer.
419 * @c: UBIFS file-system description object
425 * This function pads up to the next min_io_size boundary (if there is one) and
427 * @c->min_io_size boundary.
437 empty_offs = ALIGN(*offs, c->min_io_size); in clean_buf()
438 pad_len = empty_offs - *offs; in clean_buf()
442 *len -= pad_len; in clean_buf()
443 memset(*buf, 0xff, c->leb_size - empty_offs); in clean_buf()
447 * no_more_nodes - determine if there are no more nodes in a buffer.
448 * @c: UBIFS file-system description object
462 int skip, dlen = le32_to_cpu(ch->len); in no_more_nodes() local
465 skip = ALIGN(offs + UBIFS_CH_SZ, c->max_write_size) - offs; in no_more_nodes()
466 if (is_empty(buf + skip, len - skip)) in no_more_nodes()
472 if (ubifs_check_node(c, buf, len, lnum, offs, 1, 0) != -EUCLEAN) { in no_more_nodes()
476 /* Now we know the corrupt node's length we can skip over it */ in no_more_nodes()
477 skip = ALIGN(offs + dlen, c->max_write_size) - offs; in no_more_nodes()
479 if (is_empty(buf + skip, len - skip)) in no_more_nodes()
481 dbg_rcvry("unexpected data at %d:%d", lnum, offs + skip); in no_more_nodes()
486 * fix_unclean_leb - fix an unclean LEB.
487 * @c: UBIFS file-system description object
494 int lnum = sleb->lnum, endpt = start; in fix_unclean_leb()
497 if (!list_empty(&sleb->nodes)) { in fix_unclean_leb()
500 snod = list_entry(sleb->nodes.prev, in fix_unclean_leb()
502 endpt = snod->offs + snod->len; in fix_unclean_leb()
505 if (c->ro_mount && !c->remounting_rw) { in fix_unclean_leb()
510 lnum, start, sleb->endpt); in fix_unclean_leb()
513 return -ENOMEM; in fix_unclean_leb()
514 ucleb->lnum = lnum; in fix_unclean_leb()
515 ucleb->endpt = endpt; in fix_unclean_leb()
516 list_add_tail(&ucleb->list, &c->unclean_leb_list); in fix_unclean_leb()
522 lnum, start, sleb->endpt); in fix_unclean_leb()
528 int len = ALIGN(endpt, c->min_io_size); in fix_unclean_leb()
531 err = ubifs_leb_read(c, lnum, sleb->buf, 0, in fix_unclean_leb()
538 int pad_len = len - ALIGN(endpt, 8); in fix_unclean_leb()
541 void *buf = sleb->buf + len - pad_len; in fix_unclean_leb()
546 err = ubifs_leb_change(c, lnum, sleb->buf, len); in fix_unclean_leb()
555 * drop_last_group - drop the last group of nodes.
564 while (!list_empty(&sleb->nodes)) { in drop_last_group()
568 snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node, in drop_last_group()
570 ch = snod->node; in drop_last_group()
571 if (ch->group_type != UBIFS_IN_NODE_GROUP) in drop_last_group()
575 sleb->lnum, snod->offs); in drop_last_group()
576 *offs = snod->offs; in drop_last_group()
577 list_del(&snod->list); in drop_last_group()
579 sleb->nodes_cnt -= 1; in drop_last_group()
584 * drop_last_node - drop the last node.
595 if (!list_empty(&sleb->nodes)) { in drop_last_node()
596 snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node, in drop_last_node()
600 sleb->lnum, snod->offs); in drop_last_node()
601 *offs = snod->offs; in drop_last_node()
602 list_del(&snod->list); in drop_last_node()
604 sleb->nodes_cnt -= 1; in drop_last_node()
609 * ubifs_recover_leb - scan and recover a LEB.
610 * @c: UBIFS file-system description object
613 * @sbuf: LEB-sized buffer to use
614 * @jhead: journal head number this LEB belongs to (%-1 if the LEB does not
625 int ret = 0, err, len = c->leb_size - offs, start = offs, min_io_unit; in ubifs_recover_leb()
626 int grouped = jhead == -1 ? 0 : c->jheads[jhead].grouped; in ubifs_recover_leb()
656 node_len = ALIGN(le32_to_cpu(ch->len), 8); in ubifs_recover_leb()
659 len -= node_len; in ubifs_recover_leb()
664 len -= ret; in ubifs_recover_leb()
674 err = -EINVAL; in ubifs_recover_leb()
695 /* Make sure we dump interesting non-0xFF data */ in ubifs_recover_leb()
702 min_io_unit = round_down(offs, c->min_io_size); in ubifs_recover_leb()
723 * means that UBIFS had been writing to B just before the power in ubifs_recover_leb()
730 * can't we just clean-up the second half of B by putting a in ubifs_recover_leb()
732 * exception which was reproduced with power cut emulation in ubifs_recover_leb()
735 * Imagine the file-system is full, we run GC which starts in ubifs_recover_leb()
737 * the current GC head LEB). The @c->gc_lnum is -1, which means in ubifs_recover_leb()
743 * And a power cut happens when nodes are moved from LEB X to in ubifs_recover_leb()
746 * Then we clean-up LEB Y by padding min. I/O unit. And later in ubifs_recover_leb()
752 * user-visible effect of this which I once observed and in ubifs_recover_leb()
753 * analysed is that we cannot mount the file-system with in ubifs_recover_leb()
754 * -ENOSPC error. in ubifs_recover_leb()
766 len = c->leb_size - offs; in ubifs_recover_leb()
778 /* Re-scan the corrupted data with verbose messages */ in ubifs_recover_leb()
783 err = -EUCLEAN; in ubifs_recover_leb()
791 * get_cs_sqnum - get commit start sequence number.
792 * @c: UBIFS file-system description object
808 return -ENOMEM; in get_cs_sqnum()
809 if (c->leb_size - offs < UBIFS_CS_NODE_SZ) in get_cs_sqnum()
813 if (err && err != -EBADMSG) in get_cs_sqnum()
820 if (cs_node->ch.node_type != UBIFS_CS_NODE) { in get_cs_sqnum()
821 ubifs_err(c, "Not a CS node, type is %d", cs_node->ch.node_type); in get_cs_sqnum()
824 if (le64_to_cpu(cs_node->cmt_no) != c->cmt_no) { in get_cs_sqnum()
826 (unsigned long long)le64_to_cpu(cs_node->cmt_no), in get_cs_sqnum()
827 c->cmt_no); in get_cs_sqnum()
830 *cs_sqnum = le64_to_cpu(cs_node->ch.sqnum); in get_cs_sqnum()
836 err = -EINVAL; in get_cs_sqnum()
844 * ubifs_recover_log_leb - scan and recover a log LEB.
845 * @c: UBIFS file-system description object
848 * @sbuf: LEB-sized buffer to use
864 if (next_lnum >= UBIFS_LOG_LNUM + c->log_lebs) in ubifs_recover_log_leb()
866 if (next_lnum != c->ltail_lnum) { in ubifs_recover_log_leb()
874 if (sleb->nodes_cnt) { in ubifs_recover_log_leb()
876 unsigned long long cs_sqnum = c->cs_sqnum; in ubifs_recover_log_leb()
878 snod = list_entry(sleb->nodes.next, in ubifs_recover_log_leb()
889 if (snod->sqnum > cs_sqnum) { in ubifs_recover_log_leb()
893 return ERR_PTR(-EUCLEAN); in ubifs_recover_log_leb()
898 return ubifs_recover_leb(c, lnum, offs, sbuf, -1); in ubifs_recover_log_leb()
902 * recover_head - recover a head.
903 * @c: UBIFS file-system description object
906 * @sbuf: LEB-sized buffer to use
914 int len = c->max_write_size, err; in recover_head()
916 if (offs + len > c->leb_size) in recover_head()
917 len = c->leb_size - offs; in recover_head()
938 * ubifs_recover_inl_heads - recover index and LPT heads.
939 * @c: UBIFS file-system description object
940 * @sbuf: LEB-sized buffer to use
945 * This deals with the recovery of a half-completed journal commit. UBIFS is
947 * the index and LPT are wandering trees, data from a half-completed commit will
958 ubifs_assert(c, !c->ro_mount || c->remounting_rw); in ubifs_recover_inl_heads()
960 dbg_rcvry("checking index head at %d:%d", c->ihead_lnum, c->ihead_offs); in ubifs_recover_inl_heads()
961 err = recover_head(c, c->ihead_lnum, c->ihead_offs, sbuf); in ubifs_recover_inl_heads()
965 dbg_rcvry("checking LPT head at %d:%d", c->nhead_lnum, c->nhead_offs); in ubifs_recover_inl_heads()
967 return recover_head(c, c->nhead_lnum, c->nhead_offs, sbuf); in ubifs_recover_inl_heads()
971 * clean_an_unclean_leb - read and write a LEB to remove corruption.
972 * @c: UBIFS file-system description object
974 * @sbuf: LEB-sized buffer to use
976 * This function reads a LEB up to a point pre-determined by the mount recovery,
978 * off any following corruption, or non-fatal ECC errors.
985 int err, lnum = ucleb->lnum, offs = 0, len = ucleb->endpt, quiet = 1; in clean_an_unclean_leb()
996 if (err && err != -EBADMSG) in clean_an_unclean_leb()
1012 node_len = ALIGN(le32_to_cpu(ch->len), 8); in clean_an_unclean_leb()
1015 len -= node_len; in clean_an_unclean_leb()
1023 len -= ret; in clean_an_unclean_leb()
1030 return -EUCLEAN; in clean_an_unclean_leb()
1040 return -EUCLEAN; in clean_an_unclean_leb()
1044 len = ALIGN(ucleb->endpt, c->min_io_size); in clean_an_unclean_leb()
1045 if (len > ucleb->endpt) { in clean_an_unclean_leb()
1046 int pad_len = len - ALIGN(ucleb->endpt, 8); in clean_an_unclean_leb()
1049 buf = c->sbuf + len - pad_len; in clean_an_unclean_leb()
1065 * ubifs_clean_lebs - clean LEBs recovered during read-only mount.
1066 * @c: UBIFS file-system description object
1067 * @sbuf: LEB-sized buffer to use
1070 * written but was not because UBIFS was mounted read-only. This happens when
1071 * remounting to read-write mode.
1078 while (!list_empty(&c->unclean_leb_list)) { in ubifs_clean_lebs()
1082 ucleb = list_entry(c->unclean_leb_list.next, in ubifs_clean_lebs()
1087 list_del(&ucleb->list); in ubifs_clean_lebs()
1094 * grab_empty_leb - grab an empty LEB to use as GC LEB and run commit.
1095 * @c: UBIFS file-system description object
1098 * LEB to be used as GC LEB (@c->gc_lnum), and then runs the commit. Returns
1107 * run the commit, not vice-versa. The reason is that there might be in grab_empty_leb()
1109 * @c->gc_lnum just before the power cut happened. During the regular in grab_empty_leb()
1110 * UBIFS operation (not now) @c->gc_lnum is marked as "taken", so no in grab_empty_leb()
1112 * not marked as taken, so if we run commit - what happens? Right, the in grab_empty_leb()
1124 ubifs_dump_budg(c, &c->bi); in grab_empty_leb()
1134 c->gc_lnum = lnum; in grab_empty_leb()
1141 * ubifs_rcvry_gc_commit - recover the GC LEB number and run the commit.
1142 * @c: UBIFS file-system description object
1144 * Out-of-place garbage collection requires always one empty LEB with which to
1145 * start garbage collection. The LEB number is recorded in c->gc_lnum and is
1153 * size-recovery and orphans to be written to the flash. That is important to
1160 struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf; in ubifs_rcvry_gc_commit()
1164 dbg_rcvry("GC head LEB %d, offs %d", wbuf->lnum, wbuf->offs); in ubifs_rcvry_gc_commit()
1166 c->gc_lnum = -1; in ubifs_rcvry_gc_commit()
1167 if (wbuf->lnum == -1 || wbuf->offs == c->leb_size) in ubifs_rcvry_gc_commit()
1170 err = ubifs_find_dirty_leb(c, &lp, wbuf->offs, 2); in ubifs_rcvry_gc_commit()
1172 if (err != -ENOSPC) in ubifs_rcvry_gc_commit()
1180 ubifs_assert(c, lp.free + lp.dirty >= wbuf->offs); in ubifs_rcvry_gc_commit()
1192 mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead); in ubifs_rcvry_gc_commit()
1200 mutex_unlock(&wbuf->io_mutex); in ubifs_rcvry_gc_commit()
1203 if (err == -EAGAIN) in ubifs_rcvry_gc_commit()
1204 err = -EINVAL; in ubifs_rcvry_gc_commit()
1210 return -EINVAL; in ubifs_rcvry_gc_commit()
1212 err = ubifs_leb_unmap(c, c->gc_lnum); in ubifs_rcvry_gc_commit()
1221 * struct size_entry - inode size information for recovery.
1222 * @rb: link in the RB-tree of sizes
1239 * add_ino - add an entry to the size tree.
1240 * @c: UBIFS file-system description object
1249 struct rb_node **p = &c->size_tree.rb_node, *parent = NULL; in add_ino()
1255 if (inum < e->inum) in add_ino()
1256 p = &(*p)->rb_left; in add_ino()
1258 p = &(*p)->rb_right; in add_ino()
1263 return -ENOMEM; in add_ino()
1265 e->inum = inum; in add_ino()
1266 e->i_size = i_size; in add_ino()
1267 e->d_size = d_size; in add_ino()
1268 e->exists = exists; in add_ino()
1270 rb_link_node(&e->rb, parent, p); in add_ino()
1271 rb_insert_color(&e->rb, &c->size_tree); in add_ino()
1277 * find_ino - find an entry on the size tree.
1278 * @c: UBIFS file-system description object
1283 struct rb_node *p = c->size_tree.rb_node; in find_ino()
1288 if (inum < e->inum) in find_ino()
1289 p = p->rb_left; in find_ino()
1290 else if (inum > e->inum) in find_ino()
1291 p = p->rb_right; in find_ino()
1299 * remove_ino - remove an entry from the size tree.
1300 * @c: UBIFS file-system description object
1309 rb_erase(&e->rb, &c->size_tree); in remove_ino()
1314 * ubifs_destroy_size_tree - free resources related to the size tree.
1315 * @c: UBIFS file-system description object
1321 rbtree_postorder_for_each_entry_safe(e, n, &c->size_tree, rb) { in ubifs_destroy_size_tree()
1322 iput(e->inode); in ubifs_destroy_size_tree()
1326 c->size_tree = RB_ROOT; in ubifs_destroy_size_tree()
1330 * ubifs_recover_size_accum - accumulate inode sizes for recovery.
1331 * @c: UBIFS file-system description object
1339 * To accomplish those purposes, a rb-tree is constructed containing an entry
1368 e->i_size = new_size; in ubifs_recover_size_accum()
1369 e->exists = 1; in ubifs_recover_size_accum()
1380 if (new_size > e->d_size) in ubifs_recover_size_accum()
1381 e->d_size = new_size; in ubifs_recover_size_accum()
1391 e->d_size = new_size; in ubifs_recover_size_accum()
1398 * fix_size_in_place - fix inode size in place on flash.
1399 * @c: UBIFS file-system description object
1404 struct ubifs_ino_node *ino = c->sbuf; in fix_size_in_place()
1412 ino_key_init(c, &key, e->inum); in fix_size_in_place()
1420 i_size = le64_to_cpu(ino->size); in fix_size_in_place()
1421 if (i_size >= e->d_size) in fix_size_in_place()
1424 err = ubifs_leb_read(c, lnum, c->sbuf, 0, c->leb_size, 1); in fix_size_in_place()
1428 ino = c->sbuf + offs; in fix_size_in_place()
1429 ino->size = cpu_to_le64(e->d_size); in fix_size_in_place()
1430 len = le32_to_cpu(ino->ch.len); in fix_size_in_place()
1431 crc = crc32(UBIFS_CRC32_INIT, (void *)ino + 8, len - 8); in fix_size_in_place()
1432 ino->ch.crc = cpu_to_le32(crc); in fix_size_in_place()
1434 p = c->sbuf; in fix_size_in_place()
1435 len = c->leb_size - 1; in fix_size_in_place()
1437 len -= 1; in fix_size_in_place()
1438 len = ALIGN(len + 1, c->min_io_size); in fix_size_in_place()
1440 err = ubifs_leb_change(c, lnum, c->sbuf, len); in fix_size_in_place()
1443 dbg_rcvry("inode %lu at %d:%d size %lld -> %lld", in fix_size_in_place()
1444 (unsigned long)e->inum, lnum, offs, i_size, e->d_size); in fix_size_in_place()
1448 ubifs_warn(c, "inode %lu failed to fix size %lld -> %lld error %d", in fix_size_in_place()
1449 (unsigned long)e->inum, e->i_size, e->d_size, err); in fix_size_in_place()
1454 * inode_fix_size - fix inode size
1455 * @c: UBIFS file-system description object
1464 if (c->ro_mount) in inode_fix_size()
1465 ubifs_assert(c, !e->inode); in inode_fix_size()
1467 if (e->inode) { in inode_fix_size()
1468 /* Remounting rw, pick up inode we stored earlier */ in inode_fix_size()
1469 inode = e->inode; in inode_fix_size()
1471 inode = ubifs_iget(c->vfs_sb, e->inum); in inode_fix_size()
1475 if (inode->i_size >= e->d_size) { in inode_fix_size()
1484 dbg_rcvry("ino %lu size %lld -> %lld", in inode_fix_size()
1485 (unsigned long)e->inum, in inode_fix_size()
1486 inode->i_size, e->d_size); in inode_fix_size()
1490 inode->i_size = e->d_size; in inode_fix_size()
1491 ui->ui_size = e->d_size; in inode_fix_size()
1492 ui->synced_i_size = e->d_size; in inode_fix_size()
1494 e->inode = inode; in inode_fix_size()
1502 if (c->ro_mount) in inode_fix_size()
1512 rb_erase(&e->rb, &c->size_tree); in inode_fix_size()
1519 * ubifs_recover_size - recover inode size.
1520 * @c: UBIFS file-system description object
1521 * @in_place: If true, do a in-place size fixup
1530 struct rb_node *this = rb_first(&c->size_tree); in ubifs_recover_size()
1540 if (!e->exists) { in ubifs_recover_size()
1543 ino_key_init(c, &key, e->inum); in ubifs_recover_size()
1544 err = ubifs_tnc_lookup(c, &key, c->sbuf); in ubifs_recover_size()
1545 if (err && err != -ENOENT) in ubifs_recover_size()
1547 if (err == -ENOENT) { in ubifs_recover_size()
1550 (unsigned long)e->inum); in ubifs_recover_size()
1551 err = ubifs_tnc_remove_ino(c, e->inum); in ubifs_recover_size()
1555 struct ubifs_ino_node *ino = c->sbuf; in ubifs_recover_size()
1557 e->exists = 1; in ubifs_recover_size()
1558 e->i_size = le64_to_cpu(ino->size); in ubifs_recover_size()
1562 if (e->exists && e->i_size < e->d_size) { in ubifs_recover_size()
1563 ubifs_assert(c, !(c->ro_mount && in_place)); in ubifs_recover_size()
1574 iput(e->inode); in ubifs_recover_size()
1583 rb_erase(&e->rb, &c->size_tree); in ubifs_recover_size()