]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Kill dirent_occupied_size() in create path
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 20 Feb 2025 18:15:50 +0000 (13:15 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 15 Mar 2025 01:02:15 +0000 (21:02 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/dirent.c
fs/bcachefs/dirent.h
fs/bcachefs/fs-common.c

index 17b767799cffa6282565def3736453162d87dc66..27737aaa03a64f299864a8a1f3b5bce51106d26d 100644 (file)
@@ -233,6 +233,7 @@ int bch2_dirent_create(struct btree_trans *trans, subvol_inum dir,
                       const struct bch_hash_info *hash_info,
                       u8 type, const struct qstr *name, u64 dst_inum,
                       u64 *dir_offset,
+                      u64 *i_size,
                       enum btree_iter_update_trigger_flags flags)
 {
        struct bkey_i_dirent *dirent;
@@ -243,6 +244,8 @@ int bch2_dirent_create(struct btree_trans *trans, subvol_inum dir,
        if (ret)
                return ret;
 
+       *i_size += bkey_bytes(&dirent->k);
+
        ret = bch2_hash_set(trans, bch2_dirent_hash_desc, hash_info,
                            dir, &dirent->k_i, flags);
        *dir_offset = dirent->k.p.offset;
index ec0ff2ea62751b880c1f722aa86fa660d87cff3e..37f01c1a3f7fee668cea53e7c73d9c285140fa4b 100644 (file)
@@ -47,7 +47,7 @@ int bch2_dirent_create_snapshot(struct btree_trans *, u32, u64, u32,
                        enum btree_iter_update_trigger_flags);
 int bch2_dirent_create(struct btree_trans *, subvol_inum,
                       const struct bch_hash_info *, u8,
-                      const struct qstr *, u64, u64 *,
+                      const struct qstr *, u64, u64 *, u64 *,
                       enum btree_iter_update_trigger_flags);
 
 static inline unsigned vfs_d_type(unsigned type)
index 47e521e642295256b2e55135070e660b4096aa13..1d454333afa2203a566076d8ab630bfca973664d 100644 (file)
@@ -153,16 +153,14 @@ int bch2_create_trans(struct btree_trans *trans,
                        dir_u->bi_nlink++;
                dir_u->bi_mtime = dir_u->bi_ctime = now;
 
-               ret = bch2_inode_write(trans, &dir_iter, dir_u);
-               if (ret)
-                       goto err;
-
-               ret = bch2_dirent_create(trans, dir, &dir_hash,
-                                        dir_type,
-                                        name,
-                                        dir_target,
-                                        &dir_offset,
-                                        STR_HASH_must_create|BTREE_ITER_with_updates);
+               ret =   bch2_dirent_create(trans, dir, &dir_hash,
+                                          dir_type,
+                                          name,
+                                          dir_target,
+                                          &dir_offset,
+                                          &dir_u->bi_size,
+                                          STR_HASH_must_create|BTREE_ITER_with_updates) ?:
+                       bch2_inode_write(trans, &dir_iter, dir_u);
                if (ret)
                        goto err;
 
@@ -225,7 +223,9 @@ int bch2_link_trans(struct btree_trans *trans,
 
        ret = bch2_dirent_create(trans, dir, &dir_hash,
                                 mode_to_type(inode_u->bi_mode),
-                                name, inum.inum, &dir_offset,
+                                name, inum.inum,
+                                &dir_offset,
+                                &dir_u->bi_size,
                                 STR_HASH_must_create);
        if (ret)
                goto err;