summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fs.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.c
parentc45d473df77f41a104ecf78275be49b67f6d6295 (diff)
downloadlwn-184b1dc1a6bf4bc53a1c71bf14120498aad67ff5.tar.gz
lwn-184b1dc1a6bf4bc53a1c71bf14120498aad67ff5.zip
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.c')
-rw-r--r--fs/bcachefs/fs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index e8cdae3c114b..c20eaa7418c2 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -395,7 +395,7 @@ static int __bch2_link(struct bch_fs *c,
struct dentry *dentry)
{
struct btree_trans trans;
- struct bch_inode_unpacked inode_u;
+ struct bch_inode_unpacked dir_u, inode_u;
int ret;
mutex_lock(&inode->ei_update_lock);
@@ -405,7 +405,7 @@ static int __bch2_link(struct bch_fs *c,
bch2_trans_begin(&trans);
ret = bch2_link_trans(&trans,
dir->v.i_ino,
- inode->v.i_ino, &inode_u,
+ inode->v.i_ino, &dir_u, &inode_u,
&dentry->d_name) ?:
bch2_trans_commit(&trans, NULL,
&inode->ei_journal_seq,
@@ -413,8 +413,14 @@ static int __bch2_link(struct bch_fs *c,
BTREE_INSERT_NOUNLOCK);
} while (ret == -EINTR);
- if (likely(!ret))
+ if (likely(!ret)) {
+ BUG_ON(inode_u.bi_inum != inode->v.i_ino);
+
+ journal_seq_copy(inode, dir->ei_journal_seq);
+ bch2_inode_update_after_write(c, dir, &dir_u,
+ ATTR_MTIME|ATTR_CTIME);
bch2_inode_update_after_write(c, inode, &inode_u, ATTR_CTIME);
+ }
bch2_trans_exit(&trans);
mutex_unlock(&inode->ei_update_lock);