mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-03 15:55:38 +00:00
bcachefs: Check for unsupported features
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
319f9ac38e
commit
c258f28eba
6 changed files with 28 additions and 17 deletions
|
@ -1234,7 +1234,8 @@ enum bch_sb_features {
|
||||||
BCH_FEATURE_LZ4 = 0,
|
BCH_FEATURE_LZ4 = 0,
|
||||||
BCH_FEATURE_GZIP = 1,
|
BCH_FEATURE_GZIP = 1,
|
||||||
BCH_FEATURE_ZSTD = 2,
|
BCH_FEATURE_ZSTD = 2,
|
||||||
BCH_FEATURE_ATOMIC_NLINK = 3,
|
BCH_FEATURE_ATOMIC_NLINK = 3, /* should have gone under compat */
|
||||||
|
BCH_FEATURE_NR,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* options: */
|
/* options: */
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
#include "bcachefs.h"
|
#include "bcachefs.h"
|
||||||
|
#include "compress.h"
|
||||||
#include "disk_groups.h"
|
#include "disk_groups.h"
|
||||||
#include "opts.h"
|
#include "opts.h"
|
||||||
#include "super-io.h"
|
#include "super-io.h"
|
||||||
|
@ -269,6 +270,20 @@ void bch2_opt_to_text(struct printbuf *out, struct bch_fs *c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int bch2_opt_check_may_set(struct bch_fs *c, int id, u64 v)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case Opt_compression:
|
||||||
|
case Opt_background_compression:
|
||||||
|
ret = bch2_check_set_has_compressed_data(c, v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int bch2_parse_mount_opts(struct bch_opts *opts, char *options)
|
int bch2_parse_mount_opts(struct bch_opts *opts, char *options)
|
||||||
{
|
{
|
||||||
char *opt, *name, *val;
|
char *opt, *name, *val;
|
||||||
|
|
|
@ -269,6 +269,7 @@ int bch2_opt_parse(struct bch_fs *, const struct bch_option *, const char *, u64
|
||||||
void bch2_opt_to_text(struct printbuf *, struct bch_fs *,
|
void bch2_opt_to_text(struct printbuf *, struct bch_fs *,
|
||||||
const struct bch_option *, u64, unsigned);
|
const struct bch_option *, u64, unsigned);
|
||||||
|
|
||||||
|
int bch2_opt_check_may_set(struct bch_fs *, int, u64);
|
||||||
int bch2_parse_mount_opts(struct bch_opts *, char *);
|
int bch2_parse_mount_opts(struct bch_opts *, char *);
|
||||||
|
|
||||||
/* inode opts: */
|
/* inode opts: */
|
||||||
|
|
|
@ -230,6 +230,10 @@ const char *bch2_sb_validate(struct bch_sb_handle *disk_sb)
|
||||||
le16_to_cpu(sb->version) > BCH_SB_VERSION_MAX)
|
le16_to_cpu(sb->version) > BCH_SB_VERSION_MAX)
|
||||||
return "Unsupported superblock version";
|
return "Unsupported superblock version";
|
||||||
|
|
||||||
|
if (sb->features[1] ||
|
||||||
|
(le64_to_cpu(sb->features[0]) & (~0ULL << BCH_FEATURE_NR)))
|
||||||
|
return "Filesystem has incompatible features";
|
||||||
|
|
||||||
if (le16_to_cpu(sb->version) < BCH_SB_VERSION_EXTENT_MAX) {
|
if (le16_to_cpu(sb->version) < BCH_SB_VERSION_EXTENT_MAX) {
|
||||||
SET_BCH_SB_ENCODED_EXTENT_MAX_BITS(sb, 7);
|
SET_BCH_SB_ENCODED_EXTENT_MAX_BITS(sb, 7);
|
||||||
SET_BCH_SB_POSIX_ACL(sb, 1);
|
SET_BCH_SB_POSIX_ACL(sb, 1);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "bcachefs.h"
|
#include "bcachefs.h"
|
||||||
#include "alloc_background.h"
|
#include "alloc_background.h"
|
||||||
#include "compress.h"
|
|
||||||
#include "sysfs.h"
|
#include "sysfs.h"
|
||||||
#include "btree_cache.h"
|
#include "btree_cache.h"
|
||||||
#include "btree_io.h"
|
#include "btree_io.h"
|
||||||
|
@ -581,14 +580,9 @@ STORE(bch2_fs_opts_dir)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (id == Opt_compression ||
|
ret = bch2_opt_check_may_set(c, id, v);
|
||||||
id == Opt_background_compression) {
|
if (ret < 0)
|
||||||
int ret = bch2_check_set_has_compressed_data(c, v);
|
return ret;
|
||||||
if (ret) {
|
|
||||||
mutex_unlock(&c->sb_lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt->set_sb != SET_NO_SB_OPT) {
|
if (opt->set_sb != SET_NO_SB_OPT) {
|
||||||
mutex_lock(&c->sb_lock);
|
mutex_lock(&c->sb_lock);
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "bcachefs.h"
|
#include "bcachefs.h"
|
||||||
#include "bkey_methods.h"
|
#include "bkey_methods.h"
|
||||||
#include "btree_update.h"
|
#include "btree_update.h"
|
||||||
#include "compress.h"
|
|
||||||
#include "extents.h"
|
#include "extents.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "rebalance.h"
|
#include "rebalance.h"
|
||||||
|
@ -433,12 +432,9 @@ static int bch2_xattr_bcachefs_set(const struct xattr_handler *handler,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (s.id == Opt_compression ||
|
ret = bch2_opt_check_may_set(c, s.id, s.v);
|
||||||
s.id == Opt_background_compression) {
|
if (ret < 0)
|
||||||
ret = bch2_check_set_has_compressed_data(c, s.v);
|
return ret;
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.defined = true;
|
s.defined = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue