]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/inode.c
Update bcachefs sources to 0d63ed13ea3d closures: Fix race in closure_sync()
[bcachefs-tools-debian] / libbcachefs / inode.c
index bb3f443d8381cc1dd087e961a593a989146e6014..23fcd442c5145aca5fdb754b78bff2d2c67044a1 100644 (file)
@@ -6,6 +6,7 @@
 #include "bkey_methods.h"
 #include "btree_update.h"
 #include "buckets.h"
+#include "compress.h"
 #include "error.h"
 #include "extents.h"
 #include "extent_update.h"
@@ -422,9 +423,10 @@ static int __bch2_inode_invalid(struct bkey_s_c k, struct printbuf *err)
                return -BCH_ERR_invalid_bkey;
        }
 
-       if (unpacked.bi_compression >= BCH_COMPRESSION_OPT_NR + 1) {
-               prt_printf(err, "invalid data checksum type (%u >= %u)",
-                      unpacked.bi_compression, BCH_COMPRESSION_OPT_NR + 1);
+       if (unpacked.bi_compression &&
+           !bch2_compression_opt_valid(unpacked.bi_compression - 1)) {
+               prt_printf(err, "invalid compression opt %u",
+                          unpacked.bi_compression - 1);
                return -BCH_ERR_invalid_bkey;
        }
 
@@ -979,6 +981,18 @@ void bch2_inode_opts_get(struct bch_io_opts *opts, struct bch_fs *c,
                opts->compression = opts->background_compression = opts->data_checksum = opts->erasure_code = 0;
 }
 
+int bch2_inum_opts_get(struct btree_trans *trans, subvol_inum inum, struct bch_io_opts *opts)
+{
+       struct bch_inode_unpacked inode;
+       int ret = lockrestart_do(trans, bch2_inode_find_by_inum_trans(trans, inum, &inode));
+
+       if (ret)
+               return ret;
+
+       bch2_inode_opts_get(opts, trans->c, &inode);
+       return 0;
+}
+
 int bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot)
 {
        struct bch_fs *c = trans->c;