bcachefs: Revert directory i_size
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 27 Feb 2025 00:30:38 +0000 (19:30 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 27 Feb 2025 00:30:38 +0000 (19:30 -0500)
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>
fs/bcachefs/dirent.h
fs/bcachefs/fs-common.c
fs/bcachefs/fsck.c
fs/bcachefs/sb-downgrade.c

index a633f83c1ac787574af56094f33637ab5c52aa14..362b3b2f2f2e38f4b06e666960c51daf26c4551e 100644 (file)
@@ -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 *);
 
index d70d9f634cea9f93ef8d8d8c9ef9b1d848e3cbc5..2c3d46ac70c61353ede8988443b8a55dc5386fb6 100644 (file)
@@ -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;
 
index 9bf316e7b845d156010d9adbad7130eb97895948..0e85131d0af88b1bada3fb4139288245ab3233c4 100644 (file)
@@ -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);
 }
 
index 35e07bc8fbd3445e71773cc047e39327dc212d0a..051214fdc73521dd2ab5b05609fdcc34caa34daa 100644 (file)
          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,                                \