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>
This commit is contained in:
parent
cf3e696026
commit
4804f3ac26
4 changed files with 1 additions and 41 deletions
|
@ -31,11 +31,6 @@ static inline unsigned dirent_val_u64s(unsigned len)
|
|||
sizeof(u64));
|
||||
}
|
||||
|
||||
static inline unsigned int dirent_occupied_size(const struct qstr *name)
|
||||
{
|
||||
return (BKEY_U64s + dirent_val_u64s(name->len)) * sizeof(u64);
|
||||
}
|
||||
|
||||
int bch2_dirent_read_target(struct btree_trans *, subvol_inum,
|
||||
struct bkey_s_c_dirent, subvol_inum *);
|
||||
|
||||
|
|
|
@ -152,7 +152,6 @@ int bch2_create_trans(struct btree_trans *trans,
|
|||
if (is_subdir_for_nlink(new_inode))
|
||||
dir_u->bi_nlink++;
|
||||
dir_u->bi_mtime = dir_u->bi_ctime = now;
|
||||
dir_u->bi_size += dirent_occupied_size(name);
|
||||
|
||||
ret = bch2_inode_write(trans, &dir_iter, dir_u);
|
||||
if (ret)
|
||||
|
@ -221,7 +220,6 @@ int bch2_link_trans(struct btree_trans *trans,
|
|||
}
|
||||
|
||||
dir_u->bi_mtime = dir_u->bi_ctime = now;
|
||||
dir_u->bi_size += dirent_occupied_size(name);
|
||||
|
||||
dir_hash = bch2_hash_info_init(c, dir_u);
|
||||
|
||||
|
@ -324,7 +322,6 @@ int bch2_unlink_trans(struct btree_trans *trans,
|
|||
|
||||
dir_u->bi_mtime = dir_u->bi_ctime = inode_u->bi_ctime = now;
|
||||
dir_u->bi_nlink -= is_subdir_for_nlink(inode_u);
|
||||
dir_u->bi_size -= dirent_occupied_size(name);
|
||||
|
||||
ret = bch2_hash_delete_at(trans, bch2_dirent_hash_desc,
|
||||
&dir_hash, &dirent_iter,
|
||||
|
@ -463,14 +460,6 @@ int bch2_rename_trans(struct btree_trans *trans,
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (mode == BCH_RENAME) {
|
||||
src_dir_u->bi_size -= dirent_occupied_size(src_name);
|
||||
dst_dir_u->bi_size += dirent_occupied_size(dst_name);
|
||||
}
|
||||
|
||||
if (mode == BCH_RENAME_OVERWRITE)
|
||||
src_dir_u->bi_size -= dirent_occupied_size(src_name);
|
||||
|
||||
if (src_inode_u->bi_parent_subvol)
|
||||
src_inode_u->bi_parent_subvol = dst_dir.subvol;
|
||||
|
||||
|
|
|
@ -1978,31 +1978,10 @@ fsck_err:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int check_dir_i_size_notnested(struct btree_trans *trans, struct inode_walker *w)
|
||||
{
|
||||
struct bch_fs *c = trans->c;
|
||||
int ret = 0;
|
||||
|
||||
darray_for_each(w->inodes, i)
|
||||
if (fsck_err_on(i->inode.bi_size != i->i_size,
|
||||
trans, inode_dir_wrong_nlink,
|
||||
"directory %llu:%u with wrong i_size: got %llu, should be %llu",
|
||||
w->last_pos.inode, i->snapshot, i->inode.bi_size, i->i_size)) {
|
||||
i->inode.bi_size = i->i_size;
|
||||
ret = bch2_fsck_write_inode(trans, &i->inode);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
fsck_err:
|
||||
bch_err_fn(c, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_subdir_dirents_count(struct btree_trans *trans, struct inode_walker *w)
|
||||
{
|
||||
u32 restart_count = trans->restart_count;
|
||||
return check_subdir_count_notnested(trans, w) ?:
|
||||
check_dir_i_size_notnested(trans, w) ?:
|
||||
trans_was_restarted(trans, restart_count);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,10 +90,7 @@
|
|||
BIT_ULL(BCH_RECOVERY_PASS_check_allocations), \
|
||||
BCH_FSCK_ERR_accounting_mismatch, \
|
||||
BCH_FSCK_ERR_accounting_key_replicas_nr_devs_0, \
|
||||
BCH_FSCK_ERR_accounting_key_junk_at_end) \
|
||||
x(directory_size, \
|
||||
BIT_ULL(BCH_RECOVERY_PASS_check_dirents), \
|
||||
BCH_FSCK_ERR_directory_size_mismatch) \
|
||||
BCH_FSCK_ERR_accounting_key_junk_at_end)
|
||||
|
||||
#define DOWNGRADE_TABLE() \
|
||||
x(bucket_stripe_sectors, \
|
||||
|
|
Loading…
Add table
Reference in a new issue