]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/fs-ioctl.c
Fixes tests which have broken since 'list' improvements
[bcachefs-tools-debian] / libbcachefs / fs-ioctl.c
index d6cb21d690732b030442788866c7caca22f33d26..031e6d931171fe4c5da4d0055a195d3ef1f383a7 100644 (file)
@@ -1,9 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
 #ifndef NO_BCACHEFS_FS
 
 #include "bcachefs.h"
 #include "chardev.h"
 #include "dirent.h"
 #include "fs.h"
+#include "fs-common.h"
 #include "fs-ioctl.h"
 #include "quota.h"
 
@@ -163,6 +165,15 @@ err:
        return ret;
 }
 
+static int bch2_reinherit_attrs_fn(struct bch_inode_info *inode,
+                                  struct bch_inode_unpacked *bi,
+                                  void *p)
+{
+       struct bch_inode_info *dir = p;
+
+       return !bch2_reinherit_attrs(bi, &dir->ei_inode);
+}
+
 static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
                                    struct file *file,
                                    struct bch_inode_info *src,
@@ -183,7 +194,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
        if (unlikely(ret < 0))
                goto err1;
 
-       qstr.hash_len   = ret;
+       qstr.len        = ret;
        qstr.name       = kname;
 
        ret = -ENOENT;
@@ -204,7 +215,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
        if (ret)
                goto err2;
 
-       bch2_lock_inodes(src, dst);
+       bch2_lock_inodes(INODE_UPDATE_LOCK, src, dst);
 
        if (inode_attr_changing(src, dst, Inode_opt_project)) {
                ret = bch2_fs_quota_transfer(c, dst,
@@ -217,7 +228,7 @@ static int bch2_ioc_reinherit_attrs(struct bch_fs *c,
 
        ret = bch2_write_inode(c, dst, bch2_reinherit_attrs_fn, src, 0);
 err3:
-       bch2_unlock_inodes(src, dst);
+       bch2_unlock_inodes(INODE_UPDATE_LOCK, src, dst);
 
        /* return true if we did work */
        if (ret >= 0)
@@ -265,8 +276,9 @@ long bch2_fs_file_ioctl(struct file *file, unsigned cmd, unsigned long arg)
                        return -EPERM;
 
                down_write(&sb->s_umount);
-               sb->s_flags |= MS_RDONLY;
-               bch2_fs_emergency_read_only(c);
+               sb->s_flags |= SB_RDONLY;
+               if (bch2_fs_emergency_read_only(c))
+                       bch_err(c, "emergency read only due to ioctl");
                up_write(&sb->s_umount);
                return 0;