diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-08-08 19:53:30 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:09 -0400 |
commit | fc3268c13c1925df9bdc427ffe9bd5466f672b83 (patch) | |
tree | e22d60b4c38a4124ecf03c6da3a8888e630a4bc9 /fs/bcachefs/fsck.c | |
parent | 190fa7af39a41867f98166661422f0cf84812358 (diff) |
bcachefs: kill extent_insert_hook
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fsck.c')
-rw-r--r-- | fs/bcachefs/fsck.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 33fff198858a..2430833dbce8 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -73,8 +73,7 @@ static int reattach_inode(struct bch_fs *c, bch2_inode_pack(&packed, lostfound_inode); ret = bch2_btree_insert(c, BTREE_ID_INODES, &packed.inode.k_i, - NULL, NULL, NULL, - BTREE_INSERT_NOFAIL); + NULL, NULL, BTREE_INSERT_NOFAIL); if (ret) { bch_err(c, "error %i reattaching inode %llu while updating lost+found", ret, inum); @@ -202,7 +201,7 @@ retry: } ret = bch2_hash_delete_at(&trans, desc, info, iter) ?: - bch2_trans_commit(&trans, NULL, NULL, NULL, + bch2_trans_commit(&trans, NULL, NULL, BTREE_INSERT_ATOMIC| BTREE_INSERT_NOFAIL); err: @@ -290,6 +289,13 @@ fsck_err: return ret; } +static int bch2_inode_truncate(struct bch_fs *c, u64 inode_nr, u64 new_size) +{ + return bch2_btree_delete_range(c, BTREE_ID_EXTENTS, + POS(inode_nr, round_up(new_size, block_bytes(c)) >> 9), + POS(inode_nr + 1, 0), NULL); +} + /* * Walk extents: verify that extents have a corresponding S_ISREG inode, and * that i_size an i_sectors are consistent @@ -320,7 +326,7 @@ static int check_extents(struct bch_fs *c) k.k->type, k.k->p.inode, w.inode.bi_mode)) { bch2_btree_iter_unlock(&iter); - ret = bch2_inode_truncate(c, k.k->p.inode, 0, NULL, NULL); + ret = bch2_inode_truncate(c, k.k->p.inode, 0); if (ret) goto err; continue; @@ -342,10 +348,7 @@ static int check_extents(struct bch_fs *c) bch2_inode_pack(&p, &w.inode); ret = bch2_btree_insert(c, BTREE_ID_INODES, - &p.inode.k_i, - NULL, - NULL, - NULL, + &p.inode.k_i, NULL, NULL, BTREE_INSERT_NOFAIL); if (ret) { bch_err(c, "error in fs gc: error %i " @@ -366,8 +369,7 @@ static int check_extents(struct bch_fs *c) bch2_btree_iter_unlock(&iter); ret = bch2_inode_truncate(c, k.k->p.inode, - round_up(w.inode.bi_size, PAGE_SIZE) >> 9, - NULL, NULL); + w.inode.bi_size); if (ret) goto err; continue; @@ -508,7 +510,7 @@ static int check_dirents(struct bch_fs *c) bkey_reassemble(&n->k_i, d.s_c); n->v.d_type = mode_to_type(target.bi_mode); - ret = bch2_btree_insert_at(c, NULL, NULL, NULL, + ret = bch2_btree_insert_at(c, NULL, NULL, BTREE_INSERT_NOFAIL, BTREE_INSERT_ENTRY(iter, &n->k_i)); kfree(n); @@ -602,7 +604,7 @@ create_root: bch2_inode_pack(&packed, root_inode); return bch2_btree_insert(c, BTREE_ID_INODES, &packed.inode.k_i, - NULL, NULL, NULL, BTREE_INSERT_NOFAIL); + NULL, NULL, BTREE_INSERT_NOFAIL); } /* Get lost+found, create if it doesn't exist: */ @@ -646,7 +648,7 @@ create_lostfound: bch2_inode_pack(&packed, root_inode); ret = bch2_btree_insert(c, BTREE_ID_INODES, &packed.inode.k_i, - NULL, NULL, NULL, BTREE_INSERT_NOFAIL); + NULL, NULL, BTREE_INSERT_NOFAIL); if (ret) return ret; @@ -1094,9 +1096,7 @@ static int check_inode(struct bch_fs *c, * just switch units to bytes and that issue goes away */ - ret = bch2_inode_truncate(c, u.bi_inum, - round_up(u.bi_size, PAGE_SIZE) >> 9, - NULL, NULL); + ret = bch2_inode_truncate(c, u.bi_inum, u.bi_size); if (ret) { bch_err(c, "error in fs gc: error %i " "truncating inode", ret); @@ -1142,7 +1142,7 @@ static int check_inode(struct bch_fs *c, bch2_inode_pack(&p, &u); - ret = bch2_btree_insert_at(c, NULL, NULL, NULL, + ret = bch2_btree_insert_at(c, NULL, NULL, BTREE_INSERT_NOFAIL, BTREE_INSERT_ENTRY(iter, &p.inode.k_i)); if (ret && ret != -EINTR) |