Skip to content

Commit 36a2fdf

Browse files
author
Kent Overstreet
committed
bcachefs: Repair code for directory i_size
We had a bug due due to an incomplete revert of the patch implementing directory i_size (summing up the size of the dirents), leading to completely screwy i_size values that underflow. Most userspace programs don't seem to care (e.g. du ignores it), but it turns out this broke sshfs, so needs to be repaired. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 95fafc0 commit 36a2fdf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fs/bcachefs/fsck.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,14 @@ static int check_inode(struct btree_trans *trans,
11671167
ret = 0;
11681168
}
11691169

1170+
if (fsck_err_on(S_ISDIR(u.bi_mode) && u.bi_size,
1171+
trans, inode_dir_has_nonzero_i_size,
1172+
"directory %llu:%u with nonzero i_size %lli",
1173+
u.bi_inum, u.bi_snapshot, u.bi_size)) {
1174+
u.bi_size = 0;
1175+
do_update = true;
1176+
}
1177+
11701178
ret = bch2_inode_has_child_snapshots(trans, k.k->p);
11711179
if (ret < 0)
11721180
goto err;

fs/bcachefs/sb-errors_format.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ enum bch_fsck_flags {
232232
x(inode_dir_multiple_links, 206, FSCK_AUTOFIX) \
233233
x(inode_dir_missing_backpointer, 284, FSCK_AUTOFIX) \
234234
x(inode_dir_unlinked_but_not_empty, 286, FSCK_AUTOFIX) \
235+
x(inode_dir_has_nonzero_i_size, 319, FSCK_AUTOFIX) \
235236
x(inode_multiple_links_but_nlink_0, 207, FSCK_AUTOFIX) \
236237
x(inode_wrong_backpointer, 208, FSCK_AUTOFIX) \
237238
x(inode_wrong_nlink, 209, FSCK_AUTOFIX) \
@@ -328,7 +329,7 @@ enum bch_fsck_flags {
328329
x(dirent_stray_data_after_cf_name, 305, 0) \
329330
x(rebalance_work_incorrectly_set, 309, FSCK_AUTOFIX) \
330331
x(rebalance_work_incorrectly_unset, 310, FSCK_AUTOFIX) \
331-
x(MAX, 319, 0)
332+
x(MAX, 320, 0)
332333

333334
enum bch_sb_error_id {
334335
#define x(t, n, ...) BCH_FSCK_ERR_##t = n,

0 commit comments

Comments
 (0)