Skip to content

Commit 4804f3a

Browse files
author
Kent Overstreet
committed
bcachefs: Revert directory i_size
This turned out to have several bugs, which were missed because the fsck code wasn't properly reporting errors - whoops. Kicking it out for now, hopefully it can make 6.15. Cc: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent cf3e696 commit 4804f3a

File tree

4 files changed

+1
-41
lines changed

4 files changed

+1
-41
lines changed

fs/bcachefs/dirent.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ static inline unsigned dirent_val_u64s(unsigned len)
3131
sizeof(u64));
3232
}
3333

34-
static inline unsigned int dirent_occupied_size(const struct qstr *name)
35-
{
36-
return (BKEY_U64s + dirent_val_u64s(name->len)) * sizeof(u64);
37-
}
38-
3934
int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
4035
struct bkey_s_c_dirent, subvol_inum *);
4136

fs/bcachefs/fs-common.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ int bch2_create_trans(struct btree_trans *trans,
152152
if (is_subdir_for_nlink(new_inode))
153153
dir_u->bi_nlink++;
154154
dir_u->bi_mtime = dir_u->bi_ctime = now;
155-
dir_u->bi_size += dirent_occupied_size(name);
156155

157156
ret = bch2_inode_write(trans, &dir_iter, dir_u);
158157
if (ret)
@@ -221,7 +220,6 @@ int bch2_link_trans(struct btree_trans *trans,
221220
}
222221

223222
dir_u->bi_mtime = dir_u->bi_ctime = now;
224-
dir_u->bi_size += dirent_occupied_size(name);
225223

226224
dir_hash = bch2_hash_info_init(c, dir_u);
227225

@@ -324,7 +322,6 @@ int bch2_unlink_trans(struct btree_trans *trans,
324322

325323
dir_u->bi_mtime = dir_u->bi_ctime = inode_u->bi_ctime = now;
326324
dir_u->bi_nlink -= is_subdir_for_nlink(inode_u);
327-
dir_u->bi_size -= dirent_occupied_size(name);
328325

329326
ret = bch2_hash_delete_at(trans, bch2_dirent_hash_desc,
330327
&dir_hash, &dirent_iter,
@@ -463,14 +460,6 @@ int bch2_rename_trans(struct btree_trans *trans,
463460
goto err;
464461
}
465462

466-
if (mode == BCH_RENAME) {
467-
src_dir_u->bi_size -= dirent_occupied_size(src_name);
468-
dst_dir_u->bi_size += dirent_occupied_size(dst_name);
469-
}
470-
471-
if (mode == BCH_RENAME_OVERWRITE)
472-
src_dir_u->bi_size -= dirent_occupied_size(src_name);
473-
474463
if (src_inode_u->bi_parent_subvol)
475464
src_inode_u->bi_parent_subvol = dst_dir.subvol;
476465

fs/bcachefs/fsck.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,31 +1978,10 @@ static int check_subdir_count_notnested(struct btree_trans *trans, struct inode_
19781978
return ret;
19791979
}
19801980

1981-
static int check_dir_i_size_notnested(struct btree_trans *trans, struct inode_walker *w)
1982-
{
1983-
struct bch_fs *c = trans->c;
1984-
int ret = 0;
1985-
1986-
darray_for_each(w->inodes, i)
1987-
if (fsck_err_on(i->inode.bi_size != i->i_size,
1988-
trans, inode_dir_wrong_nlink,
1989-
"directory %llu:%u with wrong i_size: got %llu, should be %llu",
1990-
w->last_pos.inode, i->snapshot, i->inode.bi_size, i->i_size)) {
1991-
i->inode.bi_size = i->i_size;
1992-
ret = bch2_fsck_write_inode(trans, &i->inode);
1993-
if (ret)
1994-
break;
1995-
}
1996-
fsck_err:
1997-
bch_err_fn(c, ret);
1998-
return ret;
1999-
}
2000-
20011981
static int check_subdir_dirents_count(struct btree_trans *trans, struct inode_walker *w)
20021982
{
20031983
u32 restart_count = trans->restart_count;
20041984
return check_subdir_count_notnested(trans, w) ?:
2005-
check_dir_i_size_notnested(trans, w) ?:
20061985
trans_was_restarted(trans, restart_count);
20071986
}
20081987

fs/bcachefs/sb-downgrade.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@
9090
BIT_ULL(BCH_RECOVERY_PASS_check_allocations), \
9191
BCH_FSCK_ERR_accounting_mismatch, \
9292
BCH_FSCK_ERR_accounting_key_replicas_nr_devs_0, \
93-
BCH_FSCK_ERR_accounting_key_junk_at_end) \
94-
x(directory_size, \
95-
BIT_ULL(BCH_RECOVERY_PASS_check_dirents), \
96-
BCH_FSCK_ERR_directory_size_mismatch) \
93+
BCH_FSCK_ERR_accounting_key_junk_at_end)
9794

9895
#define DOWNGRADE_TABLE() \
9996
x(bucket_stripe_sectors, \

0 commit comments

Comments
 (0)