bcachefs: Don't allow hardlinks when inherited attrs would change
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 12 Oct 2022 20:12:27 +0000 (16:12 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:43 +0000 (17:09 -0400)
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 <kent.overstreet@linux.dev>
fs/bcachefs/fs-common.c

index 53ffc684223cf30486693f615b6de27054de347b..e9dd1d13ec7e97d39acf2b2472092934b06508b5 100644 (file)
@@ -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);