From: koraynilay <koray.fra@gmail.com>
To: David Sterba <dsterba@suse.com>
Cc: Chris Mason <mason@kernel.org>, Qu Wenruo <wqu@suse.com>,
Zygo Blaxell <ce3g8jdj@umail.furryterror.org>,
linux-btrfs@vger.kernel.org, koraynilay <koray.fra@gmail.com>
Subject: [PATCH v6 1/6] btrfs: export btrfs_match_compress_type(), move it to compression.h
Date: Fri, 11 Sep 2026 05:33:31 +0200 [thread overview]
Message-ID: <20260911033336.957102-2-koray.fra@gmail.com> (raw)
In-Reply-To: <20260911033336.957102-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 20169d028961..2880ee1f80d1 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1652,3 +1652,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 464129b1b0d4..00452ed872d3 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -261,14 +261,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-09-11 3:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 3:33 [PATCH v6 0/6] btrfs: add per-inode compression levels in xattrs koraynilay
2026-09-11 3:33 ` koraynilay [this message]
2026-09-11 3:33 ` [PATCH v6 2/6] btrfs: also validate compression levels in btrfs_compress_is_valid_type() koraynilay
2026-09-11 3:33 ` [PATCH v6 3/6] btrfs: add per-inode compression levels in xattrs koraynilay
2026-09-11 3:33 ` [PATCH v6 4/6] btrfs: support inheritance for per-inode compression levels koraynilay
2026-09-11 3:33 ` [PATCH v6 5/6] btrfs: add btrfs_compress_typelevel2str() helper koraynilay
2026-09-11 3:33 ` [PATCH v6 6/6] btrfs: preserve btrfs.compression when setting inode flags 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=20260911033336.957102-2-koray.fra@gmail.com \
--to=koray.fra@gmail.com \
--cc=ce3g8jdj@umail.furryterror.org \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=mason@kernel.org \
--cc=wqu@suse.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.