From: Kent Overstreet Date: Wed, 12 Oct 2022 20:12:27 +0000 (-0400) Subject: bcachefs: Don't allow hardlinks when inherited attrs would change X-Git-Tag: io_uring-6.7-2023-11-10~119^2~724 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=bf9cb250edf776454d0600b4341c6667974bedb8;p=linux-block.git bcachefs: Don't allow hardlinks when inherited attrs would change This is the right thing to do, and conforms with our own behaviour on rename and xfs's behaviour on hardlink. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c index 53ffc684223c..e9dd1d13ec7e 100644 --- a/fs/bcachefs/fs-common.c +++ b/fs/bcachefs/fs-common.c @@ -212,6 +212,11 @@ int bch2_link_trans(struct btree_trans *trans, if (ret) goto err; + if (bch2_reinherit_attrs(inode_u, dir_u)) { + ret = -EXDEV; + goto err; + } + dir_u->bi_mtime = dir_u->bi_ctime = now; dir_hash = bch2_hash_info_init(c, dir_u);