]> git.hungrycats.org Git - linux/commitdiff
btrfs: export btrfs_match_compress_type(), move it to compression.h
authorkoraynilay <koray.fra@gmail.com>
Tue, 3 Nov 2026 19:47:29 +0000 (20:47 +0100)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 3 Nov 2026 23:39:27 +0000 (18:39 -0500)
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>
Link: https://lore.kernel.org/r/20261103194734.598182-2-koray.fra@gmail.com
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/super.c

index b12b7f1b31fdfa7860a6852a9394ab8f49747517..9f0e42424e865ca4eaa4b27287a485e273ccebe7 100644 (file)
@@ -1646,3 +1646,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');
+}
index 1022dc53ec51ea498e97352e9765d46a35bb064b..e67ba47b4cdc5e85cba69a2e016234f11fcc3022 100644 (file)
@@ -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);
index b424cc836bd4a366b0c6264524b2d4d6000a3a41..372d4e75bfb6091190688d9698037b60d98ca17a 100644 (file)
@@ -270,14 +270,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)
 {