Lines Matching refs:offs
108 int err, offs, len;
122 offs = 0;
125 while (offs + UBIFS_MST_NODE_SZ <= c->leb_size) {
131 offs += sz;
136 if (offs) {
139 offs -= sz;
142 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
143 if (ret != SCANNED_A_NODE && offs) {
145 offs -= sz;
148 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
164 dbg_rcvry("found a master node at %d:%d", lnum, offs);
166 offs += sz;
172 if (offs < c->leb_size) {
175 dbg_rcvry("found corruption at %d:%d", lnum, offs);
177 offs += sz;
182 if (offs < c->leb_size) {
419 * @offs: offset to check
421 * This function returns %1 if @offs was in the last write to the LEB whose data
426 static int is_last_write(const struct ubifs_info *c, void *buf, int offs)
432 * Round up to the next @c->max_write_size boundary i.e. @offs is in
435 empty_offs = ALIGN(offs + 1, c->max_write_size);
437 p = buf + empty_offs - offs;
446 * @offs: offset from which to clean
450 * sets empty space to all 0xff. @buf, @offs and @len are updated to the next
453 static void clean_buf(const struct ubifs_info *c, void **buf, int lnum, int *offs, int *len)
457 dbg_rcvry("cleaning corruption at %d:%d", lnum, *offs);
459 ubifs_assert(c, !(*offs & RECOVERY_SEVEN));
460 empty_offs = ALIGN(*offs, c->min_io_size);
461 pad_len = empty_offs - *offs;
463 *offs += pad_len;
475 * @offs: offset from which @buf was read
477 * This function ensures that the corrupted node at @offs is the last thing
481 static int no_more_nodes(const struct ubifs_info *c, void *buf, int len, int lnum, int offs)
487 skip = ALIGN(offs + UBIFS_CH_SZ, c->max_write_size) - offs;
495 if (ubifs_check_node(c, buf, len, lnum, offs, 1, 0) != -EUCLEAN) {
496 dbg_rcvry("unexpected bad common header at %d:%d", lnum, offs);
500 skip = ALIGN(offs + dlen, c->max_write_size) - offs;
505 dbg_rcvry("unexpected data at %d:%d", lnum, offs + skip);
524 endpt = snod->offs + snod->len;
579 * @offs: offset of dropped nodes is returned here
584 static void drop_last_group(struct ubifs_scan_leb *sleb, int *offs)
596 dbg_rcvry("dropping grouped node at %d:%d", sleb->lnum, snod->offs);
597 *offs = snod->offs;
607 * @offs: offset of dropped nodes is returned here
612 static void drop_last_node(struct ubifs_scan_leb *sleb, int *offs)
619 dbg_rcvry("dropping last node at %d:%d", sleb->lnum, snod->offs);
620 *offs = snod->offs;
631 * @offs: offset
641 struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum, int offs, void *sbuf, int jhead)
643 int ret = 0, err, len = c->leb_size - offs, start = offs, min_io_unit;
646 void *buf = sbuf + offs;
648 dbg_rcvry("%d:%d, jhead %d, grouped %d", lnum, offs, jhead, grouped);
650 sleb = ubifs_start_scan(c, lnum, offs, sbuf);
657 dbg_scan("look at LEB %d:%d (%d bytes left)", lnum, offs, len);
665 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
671 err = ubifs_add_snod(c, sleb, buf, offs);
676 offs += node_len;
681 offs += ret;
685 dbg_rcvry("found corruption (%d) at %d:%d", ret, lnum, offs);
686 if (ubifs_check_node(c, buf, len, lnum, offs, 1, 1) == -EUCLEAN &&
687 !no_more_nodes(c, buf, len, lnum, offs)) {
698 skip = ALIGN(offs + le32_to_cpu(ch->len), c->max_write_size) - offs;
704 dbg_rcvry("found corruption (%d) at %d:%d", ret, lnum, offs);
705 if (!is_empty(buf, len) && !is_last_write(c, buf, offs)) {
718 dbg_rcvry("found corruption (%d) at %d:%d", ret, lnum, offs);
728 if (!is_last_write(c, buf, offs)) {
732 if (!no_more_nodes(c, buf, len, lnum, offs)) {
736 if (!is_last_write(c, buf, offs)) {
743 ubifs_err(c, "corrupt empty space LEB %d:%d, corruption starts at %d", lnum, offs, corruption);
745 offs += corruption;
751 min_io_unit = round_down(offs, c->min_io_size);
757 drop_last_group(sleb, &offs);
811 while (offs > min_io_unit) {
812 drop_last_node(sleb, &offs);
816 buf = sbuf + offs;
817 len = c->leb_size - offs;
819 clean_buf(c, &buf, lnum, &offs, &len);
820 ubifs_end_scan(c, sleb, lnum, offs);
832 ubifs_scan_a_node(c, buf, len, lnum, offs, 0);
834 ubifs_scanned_corruption(c, lnum, offs, buf);
846 * @offs: offset of commit start node
851 static int get_cs_sqnum(struct ubifs_info *c, int lnum, int offs, unsigned long long *cs_sqnum)
856 dbg_rcvry("at %d:%d", lnum, offs);
861 if (c->leb_size - offs < UBIFS_CS_NODE_SZ) {
864 err = ubifs_leb_read(c, lnum, (void *)cs_node, offs, UBIFS_CS_NODE_SZ, 0);
868 ret = ubifs_scan_a_node(c, cs_node, UBIFS_CS_NODE_SZ, lnum, offs, 0);
899 * @offs: offset
908 struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum, int offs, void *sbuf)
935 err = get_cs_sqnum(c, lnum, offs, &cs_sqnum);
949 return ubifs_recover_leb(c, lnum, offs, sbuf, -1);
956 * @offs: offset of head to recover
963 static int recover_head(struct ubifs_info *c, int lnum, int offs, void *sbuf)
967 if (offs + len > c->leb_size) {
968 len = c->leb_size - offs;
976 err = ubifs_leb_read(c, lnum, sbuf, offs, len, 1);
978 dbg_rcvry("cleaning head at %d:%d", lnum, offs);
979 if (offs == 0) {
982 err = ubifs_leb_read(c, lnum, sbuf, 0, offs, 1);
986 return ubifs_leb_change(c, lnum, sbuf, offs);
1040 int err, lnum = ucleb->lnum, offs = 0, len = ucleb->endpt, quiet = 1;
1050 err = ubifs_leb_read(c, lnum, buf, offs, len, 0);
1061 ret = ubifs_scan_a_node(c, buf, len, lnum, offs, quiet);
1068 offs += node_len;
1076 offs += ret;
1083 ubifs_err(c, "unexpected empty space at %d:%d", lnum, offs);
1093 ubifs_scanned_corruption(c, lnum, offs, buf);
1218 dbg_rcvry("GC head LEB %d, offs %d", wbuf->lnum, wbuf->offs);
1221 if (wbuf->lnum == -1 || wbuf->offs == c->leb_size) {
1225 err = ubifs_find_dirty_leb(c, &lp, wbuf->offs, RECOVERY_TWO);
1236 ubifs_assert(c, lp.free + lp.dirty >= wbuf->offs);
1476 int err, lnum, offs, len;
1482 err = ubifs_tnc_locate(c, &key, ino, &lnum, &offs);
1500 ino = c->sbuf + offs;
1517 dbg_rcvry("inode %lu at %d:%d size %lld -> %lld", (unsigned long)e->inum, lnum, offs, i_size, e->d_size);