Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: move fsck_write_inode() to inode.c

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+44 -40
+13 -40
fs/bcachefs/fsck.c
··· 142 142 return 0; 143 143 } 144 144 145 - static int __write_inode(struct btree_trans *trans, 146 - struct bch_inode_unpacked *inode, 147 - u32 snapshot) 148 - { 149 - struct bkey_inode_buf *inode_p = 150 - bch2_trans_kmalloc(trans, sizeof(*inode_p)); 151 - 152 - if (IS_ERR(inode_p)) 153 - return PTR_ERR(inode_p); 154 - 155 - bch2_inode_pack(inode_p, inode); 156 - inode_p->inode.k.p.snapshot = snapshot; 157 - 158 - return bch2_btree_insert_nonextent(trans, BTREE_ID_inodes, 159 - &inode_p->inode.k_i, 160 - BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE); 161 - } 162 - 163 - static int fsck_write_inode(struct btree_trans *trans, 164 - struct bch_inode_unpacked *inode, 165 - u32 snapshot) 166 - { 167 - int ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc, 168 - __write_inode(trans, inode, snapshot)); 169 - bch_err_fn(trans->c, ret); 170 - return ret; 171 - } 172 - 173 145 static int __remove_dirent(struct btree_trans *trans, struct bpos pos) 174 146 { 175 147 struct bch_fs *c = trans->c; ··· 284 312 if (S_ISDIR(inode->bi_mode)) { 285 313 lostfound.bi_nlink++; 286 314 287 - ret = __write_inode(trans, &lostfound, U32_MAX); 315 + ret = __bch2_fsck_write_inode(trans, &lostfound, U32_MAX); 288 316 if (ret) 289 317 return ret; 290 318 } ··· 306 334 inode->bi_dir = lostfound.bi_inum; 307 335 inode->bi_dir_offset = dir_offset; 308 336 309 - return __write_inode(trans, inode, inode_snapshot); 337 + return __bch2_fsck_write_inode(trans, inode, inode_snapshot); 310 338 } 311 339 312 340 static int remove_backpointer(struct btree_trans *trans, ··· 830 858 831 859 u.bi_flags &= ~BCH_INODE_i_size_dirty|BCH_INODE_unlinked; 832 860 833 - ret = __write_inode(trans, &u, iter->pos.snapshot); 861 + ret = __bch2_fsck_write_inode(trans, &u, iter->pos.snapshot); 862 + 834 863 bch_err_msg(c, ret, "in fsck updating inode"); 835 864 if (ret) 836 865 return ret; ··· 921 948 } 922 949 923 950 if (do_update) { 924 - ret = __write_inode(trans, &u, iter->pos.snapshot); 951 + ret = __bch2_fsck_write_inode(trans, &u, iter->pos.snapshot); 925 952 bch_err_msg(c, ret, "in fsck updating inode"); 926 953 if (ret) 927 954 return ret; ··· 1002 1029 w->last_pos.inode, i->snapshot, 1003 1030 i->inode.bi_sectors, i->count)) { 1004 1031 i->inode.bi_sectors = i->count; 1005 - ret = fsck_write_inode(trans, &i->inode, i->snapshot); 1032 + ret = bch2_fsck_write_inode(trans, &i->inode, i->snapshot); 1006 1033 if (ret) 1007 1034 break; 1008 1035 } ··· 1451 1478 "directory %llu:%u with wrong i_nlink: got %u, should be %llu", 1452 1479 w->last_pos.inode, i->snapshot, i->inode.bi_nlink, i->count)) { 1453 1480 i->inode.bi_nlink = i->count; 1454 - ret = fsck_write_inode(trans, &i->inode, i->snapshot); 1481 + ret = bch2_fsck_write_inode(trans, &i->inode, i->snapshot); 1455 1482 if (ret) 1456 1483 break; 1457 1484 } ··· 1478 1505 target->bi_dir = d.k->p.inode; 1479 1506 target->bi_dir_offset = d.k->p.offset; 1480 1507 1481 - ret = __write_inode(trans, target, target_snapshot); 1508 + ret = __bch2_fsck_write_inode(trans, target, target_snapshot); 1482 1509 if (ret) 1483 1510 goto err; 1484 1511 } ··· 1518 1545 target->bi_nlink++; 1519 1546 target->bi_flags &= ~BCH_INODE_unlinked; 1520 1547 1521 - ret = __write_inode(trans, target, target_snapshot); 1548 + ret = __bch2_fsck_write_inode(trans, target, target_snapshot); 1522 1549 if (ret) 1523 1550 goto err; 1524 1551 } ··· 1536 1563 target->bi_dir = d.k->p.inode; 1537 1564 target->bi_dir_offset = d.k->p.offset; 1538 1565 1539 - ret = __write_inode(trans, target, target_snapshot); 1566 + ret = __bch2_fsck_write_inode(trans, target, target_snapshot); 1540 1567 if (ret) 1541 1568 goto err; 1542 1569 } ··· 1714 1741 target_inum, 1715 1742 subvol_root.bi_subvol, target_subvol)) { 1716 1743 subvol_root.bi_subvol = target_subvol; 1717 - ret = __write_inode(trans, &subvol_root, target_snapshot); 1744 + ret = __bch2_fsck_write_inode(trans, &subvol_root, target_snapshot); 1718 1745 if (ret) 1719 1746 goto err; 1720 1747 } ··· 1888 1915 0, NULL); 1889 1916 root_inode.bi_inum = inum; 1890 1917 1891 - ret = __write_inode(trans, &root_inode, snapshot); 1918 + ret = __bch2_fsck_write_inode(trans, &root_inode, snapshot); 1892 1919 bch_err_msg(c, ret, "writing root inode"); 1893 1920 } 1894 1921 err: ··· 2260 2287 u.bi_inum, bch2_d_types[mode_to_type(u.bi_mode)], 2261 2288 bch2_inode_nlink_get(&u), link->count)) { 2262 2289 bch2_inode_nlink_set(&u, link->count); 2263 - ret = __write_inode(trans, &u, k.k->p.snapshot); 2290 + ret = __bch2_fsck_write_inode(trans, &u, k.k->p.snapshot); 2264 2291 } 2265 2292 fsck_err: 2266 2293 return ret;
+28
fs/bcachefs/inode.c
··· 384 384 return bch2_trans_update(trans, iter, &inode_p->inode.k_i, flags); 385 385 } 386 386 387 + int __bch2_fsck_write_inode(struct btree_trans *trans, 388 + struct bch_inode_unpacked *inode, 389 + u32 snapshot) 390 + { 391 + struct bkey_inode_buf *inode_p = 392 + bch2_trans_kmalloc(trans, sizeof(*inode_p)); 393 + 394 + if (IS_ERR(inode_p)) 395 + return PTR_ERR(inode_p); 396 + 397 + bch2_inode_pack(inode_p, inode); 398 + inode_p->inode.k.p.snapshot = snapshot; 399 + 400 + return bch2_btree_insert_nonextent(trans, BTREE_ID_inodes, 401 + &inode_p->inode.k_i, 402 + BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE); 403 + } 404 + 405 + int bch2_fsck_write_inode(struct btree_trans *trans, 406 + struct bch_inode_unpacked *inode, 407 + u32 snapshot) 408 + { 409 + int ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc, 410 + __bch2_fsck_write_inode(trans, inode, snapshot)); 411 + bch_err_fn(trans->c, ret); 412 + return ret; 413 + } 414 + 387 415 struct bkey_i *bch2_inode_to_v3(struct btree_trans *trans, struct bkey_i *k) 388 416 { 389 417 struct bch_inode_unpacked u;
+3
fs/bcachefs/inode.h
··· 108 108 return bch2_inode_write_flags(trans, iter, inode, 0); 109 109 } 110 110 111 + int __bch2_fsck_write_inode(struct btree_trans *, struct bch_inode_unpacked *, u32); 112 + int bch2_fsck_write_inode(struct btree_trans *, struct bch_inode_unpacked *, u32); 113 + 111 114 void bch2_inode_init_early(struct bch_fs *, 112 115 struct bch_inode_unpacked *); 113 116 void bch2_inode_init_late(struct bch_inode_unpacked *, u64,