From: koraynilay <koray.fra@gmail.com>
To: clm@fb.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, koraynilay <koray.fra@gmail.com>
Subject: [PATCH 1/4] btrfs: export btrfs_match_compress_type(), move it to compression.h
Date: Sat, 8 Aug 2026 04:34:56 +0200 [thread overview]
Message-ID: <20260808023459.1494928-2-koray.fra@gmail.com> (raw)
In-Reply-To: <20260808023459.1494928-1-koray.fra@gmail.com>
Export btrfs_match_compress_type() from being a static and locally used
function in super.c and move it to compression.c, exporting it in
compression.h. This allows it to be used in the next patches as validation
for compression algorithm names.
Assisted-by: Gemini:3.1-pro antigravity-cli-1.1.5
Signed-off-by: koraynilay <koray.fra@gmail.com>
---
fs/btrfs/compression.c | 17 +++++++++++++++++
fs/btrfs/compression.h | 1 +
fs/btrfs/super.c | 8 --------
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index ffb6b52863a7..58138f300b58 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1660,3 +1660,20 @@ int btrfs_compress_str2level(unsigned int type, const char *str, int *level_ret)
*level_ret = btrfs_compress_set_level(type, level);
return 0;
}
+
+/**
+ * btrfs_match_compress_type - Check if the string matches the compression type
+ * @string: The string to check
+ * @type: The compression type string (name) to match against (e.g. "zstd")
+ * @may_have_level: If true, the string may have a level suffix (e.g., ":1")
+ *
+ * Return: %true if the string matches the type and, if %may_have_level is %true,
+ * has a level suffix, %false otherwise.
+ */
+bool btrfs_match_compress_type(const char *string, const char *type, bool may_have_level)
+{
+ const int len = strlen(type);
+
+ return (strncmp(string, type, len) == 0) &&
+ ((may_have_level && string[len] == ':') || string[len] == '\0');
+}
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 1022dc53ec51..e67ba47b4cdc 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -97,6 +97,7 @@ void btrfs_submit_compressed_write(struct btrfs_ordered_extent *ordered,
void btrfs_submit_compressed_read(struct btrfs_bio *bbio);
int btrfs_compress_str2level(unsigned int type, const char *str, int *level_ret);
+bool btrfs_match_compress_type(const char *string, const char *type, bool may_have_level);
struct folio *btrfs_alloc_compr_folio(struct btrfs_fs_info *fs_info, gfp_t gfp);
void btrfs_free_compr_folio(struct folio *folio);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f4e34898d581..7a21085c33c5 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -264,14 +264,6 @@ static const struct fs_parameter_spec btrfs_fs_parameters[] = {
{}
};
-static bool btrfs_match_compress_type(const char *string, const char *type, bool may_have_level)
-{
- const int len = strlen(type);
-
- return (strncmp(string, type, len) == 0) &&
- ((may_have_level && string[len] == ':') || string[len] == '\0');
-}
-
static int btrfs_parse_compress(struct btrfs_fs_context *ctx,
const struct fs_parameter *param, int opt)
{
--
2.55.0
next prev parent reply other threads:[~2026-08-08 2:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 2:34 [PATCH 0/4] btrfs: add per-inode compression levels in xattrs koraynilay
2026-08-08 2:34 ` koraynilay [this message]
2026-08-08 2:34 ` [PATCH 2/4] btrfs: also validate compression levels in btrfs_compress_is_valid_type() koraynilay
2026-08-08 2:34 ` [PATCH 3/4] btrfs: add per-inode compression levels in xattrs koraynilay
2026-08-08 2:34 ` [PATCH 4/4] btrfs: support inheritance for per-inode compression levels koraynilay
2026-08-09 0:17 ` [PATCH 0/4] btrfs: add per-inode compression levels in xattrs Qu Wenruo
2026-08-09 0:35 ` koraynilay
2026-08-09 1:00 ` Qu Wenruo
2026-08-09 1:32 ` koraynilay
2026-08-09 23:17 ` Zygo Blaxell
2026-08-09 23:20 ` Qu Wenruo
2026-08-10 0:28 ` Zygo Blaxell
2026-08-10 0:51 ` Qu Wenruo
2026-08-10 0:57 ` Zygo Blaxell
2026-08-10 1:05 ` koraynilay
2026-08-10 1:54 ` Qu Wenruo
2026-08-10 1:57 ` koraynilay
2026-08-10 1:57 ` Qu Wenruo
2026-08-10 2:06 ` Zygo Blaxell
2026-08-10 2:11 ` Qu Wenruo
2026-08-10 22:41 ` koraynilay
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=20260808023459.1494928-2-koray.fra@gmail.com \
--to=koray.fra@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.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