summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs-common.c
diff options
context:
space:
mode:
authorJustin Husted <sigstop@gmail.com>2019-11-11 20:14:30 -0800
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:33 -0400
commit184b1dc1a6bf4bc53a1c71bf14120498aad67ff5 (patch)
tree5411a4bcd40a99ac2533b92c28c540bbc287d77c /fs/bcachefs/fs-common.c
parentc45d473df77f41a104ecf78275be49b67f6d6295 (diff)
bcachefs: Update directory timestamps during link
Timestamp updates on the directory during a link operation were cached. This is inconsistent with other metadata operations such as rename, as well as being less efficient. Signed-off-by: Justin Husted <sigstop@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs-common.c')
-rw-r--r--fs/bcachefs/fs-common.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c
index a4497eeb1f1b..96f7bbe0a3ed 100644
--- a/fs/bcachefs/fs-common.c
+++ b/fs/bcachefs/fs-common.c
@@ -76,11 +76,10 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum,
}
int bch2_link_trans(struct btree_trans *trans, u64 dir_inum,
- u64 inum, struct bch_inode_unpacked *inode_u,
- const struct qstr *name)
+ u64 inum, struct bch_inode_unpacked *dir_u,
+ struct bch_inode_unpacked *inode_u, const struct qstr *name)
{
struct btree_iter *dir_iter, *inode_iter;
- struct bch_inode_unpacked dir_u;
struct bch_hash_info dir_hash;
u64 now = bch2_current_time(trans->c);
@@ -91,18 +90,19 @@ int bch2_link_trans(struct btree_trans *trans, u64 dir_inum,
inode_u->bi_ctime = now;
bch2_inode_nlink_inc(inode_u);
- dir_iter = bch2_inode_peek(trans, &dir_u, dir_inum, 0);
+ dir_iter = bch2_inode_peek(trans, dir_u, dir_inum, 0);
if (IS_ERR(dir_iter))
return PTR_ERR(dir_iter);
- /* XXX: shouldn't we be updating mtime/ctime on the directory? */
+ dir_u->bi_mtime = dir_u->bi_ctime = now;
- dir_hash = bch2_hash_info_init(trans->c, &dir_u);
+ dir_hash = bch2_hash_info_init(trans->c, dir_u);
bch2_trans_iter_put(trans, dir_iter);
return bch2_dirent_create(trans, dir_inum, &dir_hash,
mode_to_type(inode_u->bi_mode),
name, inum, BCH_HASH_SET_MUST_CREATE) ?:
+ bch2_inode_write(trans, dir_iter, dir_u) ?:
bch2_inode_write(trans, inode_iter, inode_u);
}