From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 07/16] btrfs: move BTRFS_FS_STATE* defs and helpers to fs.h
Date: Wed, 14 Sep 2022 13:18:12 -0400 [thread overview]
Message-ID: <5118fc3da0a134f1ebfc68825fb65e38b16f98e4.1663175597.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1663175597.git.josef@toxicpanda.com>
We're going to use fs.h to hold fs wide related helpers and definitions,
move the FS_STATE enum and related helpers to fs.h, and then update all
files that need these definitions to include fs.h.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/compression.c | 1 +
fs/btrfs/ctree.c | 1 +
fs/btrfs/ctree.h | 46 ---------------------------------
fs/btrfs/delalloc-space.c | 1 +
fs/btrfs/dev-replace.c | 1 +
fs/btrfs/extent_io.c | 1 +
fs/btrfs/fs.h | 50 ++++++++++++++++++++++++++++++++++++
fs/btrfs/sysfs.c | 1 +
fs/btrfs/tests/btrfs-tests.c | 1 +
9 files changed, 57 insertions(+), 46 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 54caa00a2245..d456c85f94dd 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -31,6 +31,7 @@
#include "extent_map.h"
#include "subpage.h"
#include "zoned.h"
+#include "fs.h"
static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" };
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index c4a0228322fe..a5fd4e2369f1 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -18,6 +18,7 @@
#include "qgroup.h"
#include "tree-mod-log.h"
#include "tree-checker.h"
+#include "fs.h"
static struct kmem_cache *btrfs_path_cachep;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 52efb662fdf9..2f4a29a36d08 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -54,37 +54,6 @@ struct btrfs_ioctl_encoded_io_args;
#define BTRFS_MAX_EXTENT_SIZE SZ_128M
-/*
- * Runtime (in-memory) states of filesystem
- */
-enum {
- /* Global indicator of serious filesystem errors */
- BTRFS_FS_STATE_ERROR,
- /*
- * Filesystem is being remounted, allow to skip some operations, like
- * defrag
- */
- BTRFS_FS_STATE_REMOUNTING,
- /* Filesystem in RO mode */
- BTRFS_FS_STATE_RO,
- /* Track if a transaction abort has been reported on this filesystem */
- BTRFS_FS_STATE_TRANS_ABORTED,
- /*
- * Bio operations should be blocked on this filesystem because a source
- * or target device is being destroyed as part of a device replace
- */
- BTRFS_FS_STATE_DEV_REPLACING,
- /* The btrfs_fs_info created for self-tests */
- BTRFS_FS_STATE_DUMMY_FS_INFO,
-
- BTRFS_FS_STATE_NO_CSUMS,
-
- /* Indicates there was an error cleaning up a log tree. */
- BTRFS_FS_STATE_LOG_CLEANUP_ERROR,
-
- BTRFS_FS_STATE_COUNT
-};
-
#define BTRFS_SUPER_INFO_OFFSET SZ_64K
#define BTRFS_SUPER_INFO_SIZE 4096
static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
@@ -3244,12 +3213,6 @@ static inline unsigned long get_eb_page_index(unsigned long offset)
#define EXPORT_FOR_TESTS
#endif
-#define BTRFS_FS_ERROR(fs_info) (unlikely(test_bit(BTRFS_FS_STATE_ERROR, \
- &(fs_info)->fs_state)))
-#define BTRFS_FS_LOG_CLEANUP_ERROR(fs_info) \
- (unlikely(test_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR, \
- &(fs_info)->fs_state)))
-
/* acl.c */
#ifdef CONFIG_BTRFS_FS_POSIX_ACL
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
@@ -3349,15 +3312,6 @@ static inline int btrfs_get_verity_descriptor(struct inode *inode, void *buf,
/* Sanity test specific functions */
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
void btrfs_test_destroy_inode(struct inode *inode);
-static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
-{
- return test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
-}
-#else
-static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
-{
- return 0;
-}
#endif
static inline bool btrfs_is_zoned(const struct btrfs_fs_info *fs_info)
diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
index 006b12ee12af..7d561911f9ba 100644
--- a/fs/btrfs/delalloc-space.c
+++ b/fs/btrfs/delalloc-space.c
@@ -9,6 +9,7 @@
#include "transaction.h"
#include "qgroup.h"
#include "block-group.h"
+#include "fs.h"
/*
* HOW DOES THIS WORK
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 61e58066b5fd..348aef453e69 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -23,6 +23,7 @@
#include "sysfs.h"
#include "zoned.h"
#include "block-group.h"
+#include "fs.h"
/*
* Device replace overview
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index a426f0e6c145..c11c05ea099d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -30,6 +30,7 @@
#include "zoned.h"
#include "block-group.h"
#include "compression.h"
+#include "fs.h"
static struct kmem_cache *extent_buffer_cache;
diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
index 36ad05b329ce..43fd78a9f46c 100644
--- a/fs/btrfs/fs.h
+++ b/fs/btrfs/fs.h
@@ -3,6 +3,37 @@
#ifndef BTRFS_FS_H
#define BTRFS_FS_H
+/*
+ * Runtime (in-memory) states of filesystem
+ */
+enum {
+ /* Global indicator of serious filesystem errors */
+ BTRFS_FS_STATE_ERROR,
+ /*
+ * Filesystem is being remounted, allow to skip some operations, like
+ * defrag
+ */
+ BTRFS_FS_STATE_REMOUNTING,
+ /* Filesystem in RO mode */
+ BTRFS_FS_STATE_RO,
+ /* Track if a transaction abort has been reported on this filesystem */
+ BTRFS_FS_STATE_TRANS_ABORTED,
+ /*
+ * Bio operations should be blocked on this filesystem because a source
+ * or target device is being destroyed as part of a device replace
+ */
+ BTRFS_FS_STATE_DEV_REPLACING,
+ /* The btrfs_fs_info created for self-tests */
+ BTRFS_FS_STATE_DUMMY_FS_INFO,
+
+ BTRFS_FS_STATE_NO_CSUMS,
+
+ /* Indicates there was an error cleaning up a log tree. */
+ BTRFS_FS_STATE_LOG_CLEANUP_ERROR,
+
+ BTRFS_FS_STATE_COUNT
+};
+
/* compatibility and incompatibility defines */
void __btrfs_clear_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
const char *name);
@@ -89,4 +120,23 @@ static inline void btrfs_clear_sb_rdonly(struct super_block *sb)
sb->s_flags &= ~SB_RDONLY;
clear_bit(BTRFS_FS_STATE_RO, &btrfs_sb(sb)->fs_state);
}
+
+#define BTRFS_FS_ERROR(fs_info) (unlikely(test_bit(BTRFS_FS_STATE_ERROR, \
+ &(fs_info)->fs_state)))
+#define BTRFS_FS_LOG_CLEANUP_ERROR(fs_info) \
+ (unlikely(test_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR, \
+ &(fs_info)->fs_state)))
+
+#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
+{
+ return test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
+}
+#else
+static inline int btrfs_is_testing(struct btrfs_fs_info *fs_info)
+{
+ return 0;
+}
+#endif
+
#endif /* BTRFS_FS_H */
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 24079df977ff..4acff123fe66 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -23,6 +23,7 @@
#include "block-group.h"
#include "qgroup.h"
#include "misc.h"
+#include "fs.h"
/*
* Structure name Path
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index 9c478fa256f6..1538c65f2b17 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -16,6 +16,7 @@
#include "../disk-io.h"
#include "../qgroup.h"
#include "../block-group.h"
+#include "../fs.h"
static struct vfsmount *test_mnt = NULL;
--
2.26.3
next prev parent reply other threads:[~2022-09-14 17:18 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 17:18 [PATCH 00/16] btrfs: split out larger chunks of ctree.h Josef Bacik
2022-09-14 17:18 ` [PATCH 01/16] btrfs: move fs wide helpers out " Josef Bacik
2022-09-16 10:34 ` Anand Jain
2022-09-14 17:18 ` [PATCH 02/16] btrfs: move larger compat flag helpers to their own c file Josef Bacik
2022-09-16 11:11 ` Anand Jain
2022-09-16 11:30 ` Anand Jain
2022-10-11 9:46 ` David Sterba
2022-09-14 17:18 ` [PATCH 03/16] btrfs: move the printk helpers out of ctree.h Josef Bacik
2022-09-16 12:13 ` Anand Jain
2022-09-14 17:18 ` [PATCH 04/16] btrfs: push extra checks into __btrfs_abort_transaction Josef Bacik
2022-09-16 12:28 ` Anand Jain
2022-10-11 9:55 ` David Sterba
2022-09-14 17:18 ` [PATCH 05/16] btrfs: move assert and error helpers out of btrfs-printk.h Josef Bacik
2022-09-16 13:21 ` Anand Jain
2022-09-14 17:18 ` [PATCH 06/16] btrfs: push printk index code into their respective helpers Josef Bacik
2022-09-19 12:24 ` Anand Jain
2022-09-14 17:18 ` Josef Bacik [this message]
2022-09-19 12:25 ` [PATCH 07/16] btrfs: move BTRFS_FS_STATE* defs and helpers to fs.h Anand Jain
2022-09-14 17:18 ` [PATCH 08/16] btrfs: move incompat and compat flag helpers to fs.c Josef Bacik
2022-09-19 12:26 ` Anand Jain
2022-10-11 10:33 ` David Sterba
2022-10-11 12:01 ` David Sterba
2022-09-14 17:18 ` [PATCH 09/16] btrfs: move mount option definitions to fs.h Josef Bacik
2022-09-19 12:26 ` Anand Jain
2022-09-14 17:18 ` [PATCH 10/16] btrfs: move fs_info->flags enum " Josef Bacik
2022-09-19 12:27 ` Anand Jain
2022-09-14 17:18 ` [PATCH 11/16] btrfs: add a BTRFS_FS_NEED_TRANS_COMMIT flag Josef Bacik
2022-09-19 12:30 ` Anand Jain
2022-09-19 12:33 ` Anand Jain
2022-09-14 17:18 ` [PATCH 12/16] btrfs: remove fs_info::pending_changes and related code Josef Bacik
2022-09-19 12:41 ` Anand Jain
2022-10-11 10:20 ` David Sterba
2022-09-14 17:18 ` [PATCH 13/16] btrfs: move the compat/incompat flag masks to fs.h Josef Bacik
2022-09-19 12:44 ` Anand Jain
2022-09-14 17:18 ` [PATCH 14/16] btrfs: rename struct-funcs.c -> item-accessors.c Josef Bacik
2022-09-19 12:46 ` Anand Jain
2022-09-14 17:18 ` [PATCH 15/16] btrfs: move btrfs_map_token to item-accessors Josef Bacik
2022-09-19 12:53 ` Anand Jain
2022-10-11 10:39 ` David Sterba
2022-10-11 11:37 ` David Sterba
2022-09-14 17:18 ` [PATCH 16/16] btrfs: move accessor helpers into item-accessors.h Josef Bacik
2022-09-15 8:27 ` Anand Jain
2022-09-15 9:51 ` [PATCH 00/16] btrfs: split out larger chunks of ctree.h Qu Wenruo
2022-10-11 10:48 ` David Sterba
2022-10-10 20:28 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5118fc3da0a134f1ebfc68825fb65e38b16f98e4.1663175597.git.josef@toxicpanda.com \
--to=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox