btrfs: switch polarity on NOxxx flags
Switch polarity on NOxxx flags to allow more common handling of flags.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 790e41b..464b083 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1319,20 +1319,21 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
/*
* Flags for mount options.
*
- * Note: don't forget to add new options to btrfs_show_options()
+ * Note: don't forget to add new options to btrfs_alloc_fs_info() and
+ * btrfs_show_options().
*/
-#define BTRFS_MOUNT_NODATASUM (1 << 0)
-#define BTRFS_MOUNT_NODATACOW (1 << 1)
-#define BTRFS_MOUNT_NOBARRIER (1 << 2)
+#define BTRFS_MOUNT_DATASUM (1 << 0)
+#define BTRFS_MOUNT_DATACOW (1 << 1)
+#define BTRFS_MOUNT_BARRIER (1 << 2)
#define BTRFS_MOUNT_SSD (1 << 3)
#define BTRFS_MOUNT_DEGRADED (1 << 4)
#define BTRFS_MOUNT_COMPRESS (1 << 5)
-#define BTRFS_MOUNT_NOTREELOG (1 << 6)
-#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
+#define BTRFS_MOUNT_TREELOG (1 << 6)
+#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
#define BTRFS_MOUNT_SSD_SPREAD (1 << 8)
#define BTRFS_MOUNT_NOSSD (1 << 9)
#define BTRFS_MOUNT_DISCARD (1 << 10)
-#define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
+#define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
#define BTRFS_MOUNT_SPACE_CACHE (1 << 12)
#define BTRFS_MOUNT_CLEAR_CACHE (1 << 13)
#define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b0ab41d..99bea5c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3491,7 +3491,7 @@ static int write_dev_supers(struct btrfs_device *device,
* to go down lazy.
*/
op_flags = REQ_SYNC | REQ_META | REQ_PRIO;
- if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER))
+ if (i == 0 && btrfs_test_opt(device->fs_info, BARRIER))
op_flags |= REQ_FUA;
ret = btrfsic_submit_bh(REQ_OP_WRITE, op_flags, bh);
if (ret)
@@ -3712,7 +3712,7 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
int total_errors = 0;
u64 flags;
- do_barriers = !btrfs_test_opt(fs_info, NOBARRIER);
+ do_barriers = btrfs_test_opt(fs_info, BARRIER);
/*
* max_mirrors == 0 indicates we're from commit_transaction,
diff --git a/fs/btrfs/fs_params.c b/fs/btrfs/fs_params.c
index 2b179ec..a09bb1f 100644
--- a/fs/btrfs/fs_params.c
+++ b/fs/btrfs/fs_params.c
@@ -189,22 +189,22 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
*/
break;
case Opt_nodatasum:
- btrfs_set_and_info(info, NODATASUM,
- "setting nodatasum");
+ btrfs_clear_and_info(info, DATASUM,
+ "setting nodatasum");
break;
case Opt_datasum:
- if (btrfs_test_opt(info, NODATASUM)) {
- if (btrfs_test_opt(info, NODATACOW))
+ if (!btrfs_test_opt(info, DATASUM)) {
+ if (!btrfs_test_opt(info, DATACOW))
btrfs_info(info,
"setting datasum, datacow enabled");
else
btrfs_info(info, "setting datasum");
}
- btrfs_clear_opt(info->mount_opt, NODATACOW);
- btrfs_clear_opt(info->mount_opt, NODATASUM);
+ btrfs_set_opt(info->mount_opt, DATACOW);
+ btrfs_set_opt(info->mount_opt, DATASUM);
break;
case Opt_nodatacow:
- if (!btrfs_test_opt(info, NODATACOW)) {
+ if (btrfs_test_opt(info, DATACOW)) {
if (!btrfs_test_opt(info, COMPRESS) ||
!btrfs_test_opt(info, FORCE_COMPRESS)) {
btrfs_info(info,
@@ -215,12 +215,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
}
btrfs_clear_opt(info->mount_opt, COMPRESS);
btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
- btrfs_set_opt(info->mount_opt, NODATACOW);
- btrfs_set_opt(info->mount_opt, NODATASUM);
+ btrfs_clear_opt(info->mount_opt, DATACOW);
+ btrfs_clear_opt(info->mount_opt, DATASUM);
break;
case Opt_datacow:
- btrfs_clear_and_info(info, NODATACOW,
- "setting datacow");
+ btrfs_set_and_info(info, DATACOW,
+ "setting datacow");
break;
case Opt_compress_force:
case Opt_compress_force_type:
@@ -250,23 +250,23 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
info->compress_level =
btrfs_compress_str2level(args[0].from);
btrfs_set_opt(info->mount_opt, COMPRESS);
- btrfs_clear_opt(info->mount_opt, NODATACOW);
- btrfs_clear_opt(info->mount_opt, NODATASUM);
+ btrfs_set_opt(info->mount_opt, DATACOW);
+ btrfs_set_opt(info->mount_opt, DATASUM);
no_compress = 0;
} else if (strncmp(args[0].from, "lzo", 3) == 0) {
compress_type = "lzo";
info->compress_type = BTRFS_COMPRESS_LZO;
btrfs_set_opt(info->mount_opt, COMPRESS);
- btrfs_clear_opt(info->mount_opt, NODATACOW);
- btrfs_clear_opt(info->mount_opt, NODATASUM);
+ btrfs_set_opt(info->mount_opt, DATACOW);
+ btrfs_set_opt(info->mount_opt, DATASUM);
btrfs_set_fs_incompat(info, COMPRESS_LZO);
no_compress = 0;
} else if (strcmp(args[0].from, "zstd") == 0) {
compress_type = "zstd";
info->compress_type = BTRFS_COMPRESS_ZSTD;
btrfs_set_opt(info->mount_opt, COMPRESS);
- btrfs_clear_opt(info->mount_opt, NODATACOW);
- btrfs_clear_opt(info->mount_opt, NODATASUM);
+ btrfs_set_opt(info->mount_opt, DATACOW);
+ btrfs_set_opt(info->mount_opt, DATASUM);
btrfs_set_fs_incompat(info, COMPRESS_ZSTD);
no_compress = 0;
} else if (strncmp(args[0].from, "no", 2) == 0) {
@@ -324,11 +324,11 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
"not using spread ssd allocation scheme");
break;
case Opt_barrier:
- btrfs_clear_and_info(info, NOBARRIER,
+ btrfs_set_and_info(info, BARRIER,
"turning on barriers");
break;
case Opt_nobarrier:
- btrfs_set_and_info(info, NOBARRIER,
+ btrfs_clear_and_info(info, BARRIER,
"turning off barriers");
break;
case Opt_thread_pool:
@@ -376,12 +376,12 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
info->sb->s_flags &= ~SB_POSIXACL;
break;
case Opt_notreelog:
- btrfs_set_and_info(info, NOTREELOG,
- "disabling tree log");
+ btrfs_clear_and_info(info, TREELOG,
+ "disabling tree log");
break;
case Opt_treelog:
- btrfs_clear_and_info(info, NOTREELOG,
- "enabling tree log");
+ btrfs_set_and_info(info, TREELOG,
+ "enabling tree log");
break;
case Opt_norecovery:
case Opt_nologreplay:
@@ -721,11 +721,11 @@ int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
if (btrfs_test_opt(info, DEGRADED))
seq_puts(seq, ",degraded");
- if (btrfs_test_opt(info, NODATASUM))
+ if (!btrfs_test_opt(info, DATASUM))
seq_puts(seq, ",nodatasum");
- if (btrfs_test_opt(info, NODATACOW))
+ if (!btrfs_test_opt(info, DATACOW))
seq_puts(seq, ",nodatacow");
- if (btrfs_test_opt(info, NOBARRIER))
+ if (!btrfs_test_opt(info, BARRIER))
seq_puts(seq, ",nobarrier");
if (info->max_inline != BTRFS_DEFAULT_MAX_INLINE)
seq_printf(seq, ",max_inline=%llu", info->max_inline);
@@ -747,7 +747,7 @@ int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
seq_puts(seq, ",ssd_spread");
else if (btrfs_test_opt(info, SSD))
seq_puts(seq, ",ssd");
- if (btrfs_test_opt(info, NOTREELOG))
+ if (!btrfs_test_opt(info, TREELOG))
seq_puts(seq, ",notreelog");
if (btrfs_test_opt(info, NOLOGREPLAY))
seq_puts(seq, ",nologreplay");
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d3df5b5..8f1487f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6296,9 +6296,9 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
btrfs_inherit_iflags(inode, dir);
if (S_ISREG(mode)) {
- if (btrfs_test_opt(fs_info, NODATASUM))
+ if (!btrfs_test_opt(fs_info, DATASUM))
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
- if (btrfs_test_opt(fs_info, NODATACOW))
+ if (!btrfs_test_opt(fs_info, DATACOW))
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW |
BTRFS_INODE_NODATASUM;
}
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f7378d5..4e4d88a 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -661,6 +661,25 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
}
/*
+ * Allocate an fsinfo record and initialise the options to appropriate
+ * defaults.
+ */
+static struct btrfs_fs_info *btrfs_alloc_fs_info(void)
+{
+ struct btrfs_fs_info *fs_info;
+
+ fs_info = kvzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL);
+ if (fs_info) {
+ btrfs_set_opt(fs_info->mount_opt, DATASUM);
+ btrfs_set_opt(fs_info->mount_opt, DATACOW);
+ btrfs_set_opt(fs_info->mount_opt, BARRIER);
+ btrfs_set_opt(fs_info->mount_opt, TREELOG);
+ }
+
+ return fs_info;
+}
+
+/*
* Find a superblock for the given device / mount point.
*
* Note: This is based on mount_bdev from fs/super.c with a few additions
@@ -693,7 +712,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
* it for searching for existing supers, so this lets us do that and
* then open_ctree will properly initialize everything later.
*/
- fs_info = kvzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL);
+ fs_info = btrfs_alloc_fs_info();
if (!fs_info) {
error = -ENOMEM;
goto error_sec_opts;
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index e07f337..bcc25c2 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -5654,7 +5654,7 @@ static int btrfs_log_inode_parent(struct btrfs_trans_handle *trans,
sb = inode->vfs_inode.i_sb;
- if (btrfs_test_opt(fs_info, NOTREELOG)) {
+ if (!btrfs_test_opt(fs_info, TREELOG)) {
ret = 1;
goto end_no_trans;
}