Lines Matching defs:inode

13 #include "inode.h"
69 *inum = le64_to_cpu(s.inode);
74 struct bch_inode_unpacked *inode)
93 ret = bch2_inode_unpack(k, inode);
95 bch_err_msg(trans->c, ret, "fetching inode %llu", inode_nr);
101 struct bch_inode_unpacked *inode,
115 ? bch2_inode_unpack(k, inode)
151 ret = lookup_first_inode(trans, pos.inode, &dir_inode);
196 if (!subvol.inode) {
205 subvol->v.inode = cpu_to_le64(reattaching_inum);
209 root_inum.inum = le64_to_cpu(subvol.inode);
215 bch_err_msg(c, ret, "looking up root inode %llu for subvol %u",
241 bch_err_msg(c, ret, "looking up lost+found %llu:%u in (root inode %llu, snapshot root %u)",
287 struct bch_inode_unpacked *inode,
298 if (inode->bi_subvol) {
299 inode->bi_parent_subvol = BCACHEFS_ROOT_SUBVOL;
302 ret = subvol_lookup(trans, inode->bi_parent_subvol,
307 snprintf(name_buf, sizeof(name_buf), "subvol-%u", inode->bi_subvol);
309 snprintf(name_buf, sizeof(name_buf), "%llu", inode->bi_inum);
312 ret = lookup_lostfound(trans, dirent_snapshot, &lostfound, inode->bi_inum);
316 if (S_ISDIR(inode->bi_mode)) {
329 inode->bi_parent_subvol, lostfound.bi_inum,
332 inode_d_type(inode),
334 inode->bi_subvol ?: inode->bi_inum,
340 inode->bi_dir = lostfound.bi_inum;
341 inode->bi_dir_offset = dir_offset;
343 return __bch2_fsck_write_inode(trans, inode, inode_snapshot);
347 struct bch_inode_unpacked *inode)
354 POS(inode->bi_dir, inode->bi_dir_offset), 0,
366 struct bch_inode_unpacked inode;
368 (subvol_inum) { s.k->p.offset, le64_to_cpu(s.v->inode) },
369 &inode);
373 ret = remove_backpointer(trans, &inode);
378 ret = reattach_inode(trans, &inode, le32_to_cpu(s.v->snapshot));
379 bch_err_msg(c, ret, "reattaching inode %llu", inode.bi_inum);
417 bch_info(c, "reconstructing subvol %u with root inode %llu", subvolid, inum);
427 new_subvol->v.inode = cpu_to_le64(inum);
558 pos.inode, pos.offset,
662 struct bch_inode_unpacked inode;
687 struct bkey_s_c inode)
691 BUG_ON(bch2_inode_unpack(inode, &u));
694 .inode = u,
695 .snapshot = bch2_snapshot_equiv(c, inode.k->p.snapshot),
751 bch_info(c, "have key for inode %llu:%u but have inode in ancestor snapshot %u\n"
752 "unexpected because we should always update the inode when we update a key in that inode\n"
754 w->last_pos.inode, snapshot, i->snapshot, buf.buf);
775 if (w->last_pos.inode != k.k->p.inode) {
776 int ret = get_inodes_all_snapshots(trans, w, k.k->p.inode);
862 (subvol_inum) { 0, k.k->p.inode },
893 SPOS(hash_k.k->p.inode, hash, hash_k.k->p.snapshot),
920 "hash table key at wrong offset: btree %s inode %llu offset %llu, hashed to %llu\n%s",
921 bch2_btree_id_str(desc.btree_id), hash_k.k->p.inode, hash_k.k->p.offset, hash,
943 struct bch_inode_unpacked *inode,
946 if (inode->bi_subvol) {
948 int ret = subvol_lookup(trans, inode->bi_parent_subvol, snapshot, &inum);
953 return dirent_get_by_pos(trans, iter, SPOS(inode->bi_dir, inode->bi_dir_offset, *snapshot));
956 static bool inode_points_to_dirent(struct bch_inode_unpacked *inode,
959 return inode->bi_dir == d.k->p.inode &&
960 inode->bi_dir_offset == d.k->p.offset;
964 struct bch_inode_unpacked *inode)
967 ? le32_to_cpu(d.v->d_child_subvol) == inode->bi_subvol
968 : le64_to_cpu(d.v->d_inum) == inode->bi_inum;
981 struct bch_inode_unpacked *inode,
988 struct bkey_s_c_dirent d = inode_get_dirent(trans, &dirent_iter, inode, &inode_snapshot);
995 "inode points to missing dirent\n%s",
997 fsck_err_on(!ret && !dirent_points_to_inode(d, inode),
999 "inode points to dirent that does not point back:\n%s",
1005 * dirent that points to this inode in check_dirents(), we'll
1009 inode->bi_dir = 0;
1010 inode->bi_dir_offset = 0;
1011 inode->bi_flags &= ~BCH_INODE_backptr_untrusted;
1079 bch_err_msg(c, ret, "in fsck updating inode");
1094 "inode %llu:%u unlinked, but not on deleted list",
1102 "filesystem marked clean, but inode %llu unlinked",
1105 bch_err_msg(c, ret, "in fsck deleting inode");
1112 "filesystem marked clean, but inode %llu has i_size dirty",
1114 bch_verbose(c, "truncating inode %llu", u.bi_inum);
1125 bch_err_msg(c, ret, "in fsck truncating inode");
1142 "filesystem marked clean, but inode %llu has i_sectors dirty",
1146 bch_verbose(c, "recounting sectors for inode %llu",
1151 bch_err_msg(c, sectors, "in fsck recounting inode sectors");
1177 "inode %llu:%u has subvol %u but nonzero parent subvol %u",
1197 "inode %llu:%u bi_subvol points to missing subvolume %u",
1199 fsck_err_on(le64_to_cpu(s.inode) != u.bi_inum ||
1203 "inode %llu:%u points to subvol %u, but subvol points to %llu:%u",
1205 le64_to_cpu(s.inode),
1215 bch_err_msg(c, ret, "in fsck updating inode");
1252 if (i->inode.bi_sectors == i->count)
1255 count2 = bch2_count_inode_sectors(trans, w->last_pos.inode, i->snapshot);
1261 bch_err_ratelimited(c, "fsck counted i_sectors wrong for inode %llu:%u: got %llu should be %llu",
1262 w->last_pos.inode, i->snapshot, i->count, count2);
1266 if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_sectors_dirty),
1268 "inode %llu:%u has incorrect i_sectors: got %llu, should be %llu",
1269 w->last_pos.inode, i->snapshot,
1270 i->inode.bi_sectors, i->count)) {
1271 i->inode.bi_sectors = i->count;
1272 ret = bch2_fsck_write_inode(trans, &i->inode, i->snapshot);
1367 k1 = bch2_btree_iter_peek_upto(&iter1, POS(pos1.inode, U64_MAX));
1392 k2 = bch2_btree_iter_peek_upto(&iter2, POS(pos1.inode, U64_MAX));
1480 if (extent_ends->last_pos.inode != k.k->p.inode)
1493 SPOS(iter->pos.inode,
1531 struct inode_walker *inode,
1549 if (inode->last_pos.inode != k.k->p.inode) {
1550 ret = check_i_sectors(trans, inode);
1555 i = walk_inode(trans, inode, k);
1566 ret = reconstruct_reg_inode(trans, k.k->p.snapshot, k.k->p.inode) ?:
1571 inode->last_pos.inode--;
1577 "extent in missing inode:\n %s",
1583 !S_ISREG(i->inode.bi_mode) &&
1584 !S_ISLNK(i->inode.bi_mode),
1586 "extent in non regular inode mode %o:\n %s",
1587 i->inode.bi_mode,
1594 &inode->recalculate_sums);
1601 * starting from the inode that matches this extent's snapshot. If we
1605 i = inode->inodes.data + inode->inodes.nr - 1;
1608 inode->inodes.data && i >= inode->inodes.data;
1615 if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_size_dirty) &&
1616 k.k->p.offset > round_up(i->inode.bi_size, block_bytes(c)) >> 9 &&
1619 "extent type past end of inode %llu:%u, i_size %llu\n %s",
1620 i->inode.bi_inum, i->snapshot, i->inode.bi_size,
1660 * Walk extents: verify that extents have a corresponding S_ISREG inode, and
1720 if (i->inode.bi_nlink == i->count)
1723 count2 = bch2_count_subdirs(trans, w->last_pos.inode, i->snapshot);
1729 w->last_pos.inode, i->snapshot, i->count, count2);
1731 if (i->inode.bi_nlink == i->count)
1735 if (fsck_err_on(i->inode.bi_nlink != i->count,
1738 w->last_pos.inode, i->snapshot, i->inode.bi_nlink, i->count)) {
1739 i->inode.bi_nlink = i->count;
1740 ret = bch2_fsck_write_inode(trans, &i->inode, i->snapshot);
1772 target->bi_dir = d.k->p.inode;
1789 "inode %llu:%u has wrong backpointer:\n"
1795 d.k->p.inode,
1797 target->bi_dir = d.k->p.inode;
1826 "inode %llu:%u type %s has multiple links but i_nlink 0\n%s",
2008 u64 target_inum = le64_to_cpu(s.v->inode);
2016 bch_err(c, "subvol %u points to missing inode root %llu", target_subvol, target_inum);
2074 if (dir->last_pos.inode != k.k->p.inode) {
2088 *hash_info = bch2_hash_info_init(c, &dir->inodes.data[0].inode);
2092 ret = reconstruct_inode(trans, k.k->p.snapshot, k.k->p.inode, 0, S_IFDIR) ?:
2097 dir->last_pos.inode--;
2114 if (fsck_err_on(!S_ISDIR(i->inode.bi_mode),
2116 "dirent in non directory inode type %s:\n%s",
2117 bch2_d_type_str(inode_d_type(&i->inode)),
2149 "dirent points to missing inode: (equiv %u)\n%s",
2161 &i->inode, i->snapshot);
2179 * Walk dirents: verify that they all have a corresponding S_ISDIR inode,
2211 struct inode_walker *inode)
2223 i = walk_inode(trans, inode, k);
2228 if (inode->first_this_inode && inode->inodes.nr)
2229 *hash_info = bch2_hash_info_init(c, &inode->inodes.data[0].inode);
2230 inode->first_this_inode = false;
2233 "xattr for missing inode %llu",
2234 k.k->p.inode))
2247 * Walk xattrs: verify that they all have a corresponding inode
2251 struct inode_walker inode = inode_walker_init();
2262 check_xattr(trans, &iter, k, &hash_info, &inode)));
2294 root_subvol->v.inode = cpu_to_le64(inum);
2309 "root inode not a directory")) {
2315 bch_err_msg(c, ret, "writing root inode");
2342 * We've checked that inode backpointers point to valid dirents; here, it's
2347 struct bch_inode_unpacked inode;
2349 (subvol_inum) { s.k->p.offset, le64_to_cpu(s.v->inode) },
2350 &inode);
2354 return inode.bi_dir != 0;
2449 * Check that a given inode is reachable from its subvolume root - we already
2458 struct bch_inode_unpacked inode;
2465 BUG_ON(bch2_inode_unpack(inode_k, &inode));
2467 while (!inode.bi_subvol) {
2472 d = inode_get_dirent(trans, &dirent_iter, &inode, &parent_snapshot);
2477 if (!ret && !dirent_points_to_inode(d, &inode)) {
2485 "unreachable inode\n%s",
2489 ret = reattach_inode(trans, &inode, snapshot);
2495 if (!S_ISDIR(inode.bi_mode))
2499 .inum = inode.bi_inum,
2509 SPOS(0, inode.bi_dir, snapshot), 0);
2512 : bch2_inode_unpack(inode_k, &inode);
2522 if (path_is_dup(p, inode.bi_inum, snapshot)) {
2528 pr_err("%llu:%u", inode.bi_inum, snapshot);
2531 ret = remove_backpointer(trans, &inode);
2536 ret = reattach_inode(trans, &inode, snapshot);
2537 bch_err_msg(c, ret, "reattaching inode %llu", inode.bi_inum);
2552 * After bch2_check_dirents(), if an inode backpointer doesn't exist that means it's
2764 "inode %llu type %s has wrong i_nlink (%u, should be %u)",