Skip to content

Commit cba31b7

Browse files
author
Kent Overstreet
committed
bcachefs: Delete vestigal check_inode() checks
BCH_INODE_i_size_dirty dates from before we had logged operations for truncate (as well as finsert) - it hasn't been needed since before bcachefs was mainlined. BCH_INODE_i_sectors_dirty hasn't been needed since we started always updating i_sectors transactionally - it's been unused for even longer. BCH_INODE_backptr_untrusted also hasn't been used since prior to mainlining; when unlinking a hardling, we zero out the backpointer fields if they're for the dirent being removed. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 12f2860 commit cba31b7

File tree

1 file changed

+5
-75
lines changed

1 file changed

+5
-75
lines changed

fs/bcachefs/fsck.c

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,6 @@ static int check_inode_dirent_inode(struct btree_trans *trans,
10851085
*/
10861086
inode->bi_dir = 0;
10871087
inode->bi_dir_offset = 0;
1088-
inode->bi_flags &= ~BCH_INODE_backptr_untrusted;
10891088
*write_inode = true;
10901089
}
10911090

@@ -1117,8 +1116,7 @@ static int check_inode(struct btree_trans *trans,
11171116
struct btree_iter *iter,
11181117
struct bkey_s_c k,
11191118
struct bch_inode_unpacked *prev,
1120-
struct snapshots_seen *s,
1121-
bool full)
1119+
struct snapshots_seen *s)
11221120
{
11231121
struct bch_fs *c = trans->c;
11241122
struct printbuf buf = PRINTBUF;
@@ -1141,12 +1139,6 @@ static int check_inode(struct btree_trans *trans,
11411139

11421140
BUG_ON(bch2_inode_unpack(k, &u));
11431141

1144-
if (!full &&
1145-
!(u.bi_flags & (BCH_INODE_i_size_dirty|
1146-
BCH_INODE_i_sectors_dirty|
1147-
BCH_INODE_unlinked)))
1148-
return 0;
1149-
11501142
if (prev->bi_inum != u.bi_inum)
11511143
*prev = u;
11521144

@@ -1192,15 +1184,15 @@ static int check_inode(struct btree_trans *trans,
11921184
ret = 0;
11931185
}
11941186

1195-
if ((u.bi_flags & (BCH_INODE_i_size_dirty|BCH_INODE_unlinked)) &&
1187+
if ((u.bi_flags & BCH_INODE_unlinked) &&
11961188
bch2_key_has_snapshot_overwrites(trans, BTREE_ID_inodes, k.k->p)) {
11971189
struct bpos new_min_pos;
11981190

11991191
ret = bch2_propagate_key_to_snapshot_leaves(trans, iter->btree_id, k, &new_min_pos);
12001192
if (ret)
12011193
goto err;
12021194

1203-
u.bi_flags &= ~BCH_INODE_i_size_dirty|BCH_INODE_unlinked;
1195+
u.bi_flags &= ~BCH_INODE_unlinked;
12041196

12051197
ret = __bch2_fsck_write_inode(trans, &u);
12061198

@@ -1249,66 +1241,6 @@ static int check_inode(struct btree_trans *trans,
12491241
}
12501242
}
12511243

1252-
/* i_size_dirty is vestigal, since we now have logged ops for truncate * */
1253-
if (u.bi_flags & BCH_INODE_i_size_dirty &&
1254-
(!test_bit(BCH_FS_clean_recovery, &c->flags) ||
1255-
fsck_err(trans, inode_i_size_dirty_but_clean,
1256-
"filesystem marked clean, but inode %llu has i_size dirty",
1257-
u.bi_inum))) {
1258-
bch_verbose(c, "truncating inode %llu", u.bi_inum);
1259-
1260-
/*
1261-
* XXX: need to truncate partial blocks too here - or ideally
1262-
* just switch units to bytes and that issue goes away
1263-
*/
1264-
ret = bch2_btree_delete_range_trans(trans, BTREE_ID_extents,
1265-
SPOS(u.bi_inum, round_up(u.bi_size, block_bytes(c)) >> 9,
1266-
iter->pos.snapshot),
1267-
POS(u.bi_inum, U64_MAX),
1268-
0, NULL);
1269-
bch_err_msg(c, ret, "in fsck truncating inode");
1270-
if (ret)
1271-
return ret;
1272-
1273-
/*
1274-
* We truncated without our normal sector accounting hook, just
1275-
* make sure we recalculate it:
1276-
*/
1277-
u.bi_flags |= BCH_INODE_i_sectors_dirty;
1278-
1279-
u.bi_flags &= ~BCH_INODE_i_size_dirty;
1280-
do_update = true;
1281-
}
1282-
1283-
/* i_sectors_dirty is vestigal, i_sectors is always updated transactionally */
1284-
if (u.bi_flags & BCH_INODE_i_sectors_dirty &&
1285-
(!test_bit(BCH_FS_clean_recovery, &c->flags) ||
1286-
fsck_err(trans, inode_i_sectors_dirty_but_clean,
1287-
"filesystem marked clean, but inode %llu has i_sectors dirty",
1288-
u.bi_inum))) {
1289-
s64 sectors;
1290-
1291-
bch_verbose(c, "recounting sectors for inode %llu",
1292-
u.bi_inum);
1293-
1294-
sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot);
1295-
if (sectors < 0) {
1296-
bch_err_msg(c, sectors, "in fsck recounting inode sectors");
1297-
return sectors;
1298-
}
1299-
1300-
u.bi_sectors = sectors;
1301-
u.bi_flags &= ~BCH_INODE_i_sectors_dirty;
1302-
do_update = true;
1303-
}
1304-
1305-
if (u.bi_flags & BCH_INODE_backptr_untrusted) {
1306-
u.bi_dir = 0;
1307-
u.bi_dir_offset = 0;
1308-
u.bi_flags &= ~BCH_INODE_backptr_untrusted;
1309-
do_update = true;
1310-
}
1311-
13121244
if (fsck_err_on(u.bi_parent_subvol &&
13131245
(u.bi_subvol == 0 ||
13141246
u.bi_subvol == BCACHEFS_ROOT_SUBVOL),
@@ -1365,7 +1297,6 @@ static int check_inode(struct btree_trans *trans,
13651297

13661298
int bch2_check_inodes(struct bch_fs *c)
13671299
{
1368-
bool full = c->opts.fsck;
13691300
struct bch_inode_unpacked prev = { 0 };
13701301
struct snapshots_seen s;
13711302

@@ -1376,7 +1307,7 @@ int bch2_check_inodes(struct bch_fs *c)
13761307
POS_MIN,
13771308
BTREE_ITER_prefetch|BTREE_ITER_all_snapshots, k,
13781309
NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
1379-
check_inode(trans, &iter, k, &prev, &s, full)));
1310+
check_inode(trans, &iter, k, &prev, &s)));
13801311

13811312
snapshots_seen_exit(&s);
13821313
bch_err_fn(c, ret);
@@ -1876,8 +1807,7 @@ static int check_extent(struct btree_trans *trans, struct btree_iter *iter,
18761807
!key_visible_in_snapshot(c, s, i->snapshot, k.k->p.snapshot))
18771808
continue;
18781809

1879-
if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_size_dirty) &&
1880-
k.k->p.offset > round_up(i->inode.bi_size, block_bytes(c)) >> 9 &&
1810+
if (fsck_err_on(k.k->p.offset > round_up(i->inode.bi_size, block_bytes(c)) >> 9 &&
18811811
!bkey_extent_is_reservation(k),
18821812
trans, extent_past_end_of_inode,
18831813
"extent type past end of inode %llu:%u, i_size %llu\n %s",

0 commit comments

Comments
 (0)