btrfs: rename exported extent map compression functions
authorFilipe Manana <fdmanana@suse.com>
Tue, 8 Apr 2025 15:41:15 +0000 (16:41 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:45 +0000 (14:30 +0200)
These functions are exported and don't have a 'btrfs_' prefix in their
names, which goes against coding style conventions. Rename them to have
such prefix, making it clear they are from btrfs and avoiding potential
collisions in the future with functions defined elsewhere outside btrfs.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/defrag.c
fs/btrfs/direct-io.c
fs/btrfs/extent_io.c
fs/btrfs/extent_map.c
fs/btrfs/extent_map.h
fs/btrfs/file-item.c
fs/btrfs/inode.c
fs/btrfs/tests/inode-tests.c
fs/btrfs/tree-log.c

index 8f3771451faa4809acdb4fb8dacb944cdfdc5a4c..28259e6b73585b732164ce4fabedb7f060e71d25 100644 (file)
@@ -588,7 +588,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio)
                goto out;
        }
 
-       ASSERT(extent_map_is_compressed(em));
+       ASSERT(btrfs_extent_map_is_compressed(em));
        compressed_len = em->disk_num_bytes;
 
        cb = alloc_compressed_bio(inode, file_offset, REQ_OP_READ,
@@ -600,7 +600,7 @@ void btrfs_submit_compressed_read(struct btrfs_bio *bbio)
 
        cb->len = bbio->bio.bi_iter.bi_size;
        cb->compressed_len = compressed_len;
-       cb->compress_type = extent_map_compression(em);
+       cb->compress_type = btrfs_extent_map_compression(em);
        cb->orig_bbio = bbio;
 
        free_extent_map(em);
index d56815a685beb1d079dee2343e4836bd975744e8..5909740b2ce93fc4e73f2f1ebbb8ccf451c45681 100644 (file)
@@ -791,7 +791,7 @@ static struct extent_map *defrag_lookup_extent(struct inode *inode, u64 start,
 static u32 get_extent_max_capacity(const struct btrfs_fs_info *fs_info,
                                   const struct extent_map *em)
 {
-       if (extent_map_is_compressed(em))
+       if (btrfs_extent_map_is_compressed(em))
                return BTRFS_MAX_COMPRESSED;
        return fs_info->max_extent_size;
 }
index ddfa867ff1e5fa0c4172564386454bef53091a00..045497c8118a0a9e8c94f5b4c3738fc340d963dd 100644 (file)
@@ -474,7 +474,7 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
         * to buffered IO.  Don't blame me, this is the price we pay for using
         * the generic code.
         */
-       if (extent_map_is_compressed(em) || em->disk_bytenr == EXTENT_MAP_INLINE) {
+       if (btrfs_extent_map_is_compressed(em) || em->disk_bytenr == EXTENT_MAP_INLINE) {
                free_extent_map(em);
                /*
                 * If we are in a NOWAIT context, return -EAGAIN in order to
index 95904a7beaa03d7b42933a18b31537516b455293..eca4c6b68e5c69ae655c3acf912d30bff8119c8e 100644 (file)
@@ -972,7 +972,7 @@ static int btrfs_do_readpage(struct folio *folio, struct extent_map **em_cached,
                BUG_ON(extent_map_end(em) <= cur);
                BUG_ON(end < cur);
 
-               compress_type = extent_map_compression(em);
+               compress_type = btrfs_extent_map_compression(em);
 
                if (compress_type != BTRFS_COMPRESS_NONE)
                        disk_bytenr = em->disk_bytenr;
@@ -1547,7 +1547,7 @@ static int submit_one_sector(struct btrfs_inode *inode,
        block_start = extent_map_block_start(em);
        disk_bytenr = extent_map_block_start(em) + extent_offset;
 
-       ASSERT(!extent_map_is_compressed(em));
+       ASSERT(!btrfs_extent_map_is_compressed(em));
        ASSERT(block_start != EXTENT_MAP_HOLE);
        ASSERT(block_start != EXTENT_MAP_INLINE);
 
index 67c724a576eee60a96bdc4b25dadcfc5f96d5191..ccf69308ffb24c0db635f8b2e6e61b1cc9937112 100644 (file)
@@ -188,7 +188,7 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
 
 static inline u64 extent_map_block_len(const struct extent_map *em)
 {
-       if (extent_map_is_compressed(em))
+       if (btrfs_extent_map_is_compressed(em))
                return em->disk_num_bytes;
        return em->len;
 }
@@ -210,7 +210,7 @@ static bool can_merge_extent_map(const struct extent_map *em)
                return false;
 
        /* Don't merge compressed extents, we need to know their actual size. */
-       if (extent_map_is_compressed(em))
+       if (btrfs_extent_map_is_compressed(em))
                return false;
 
        if (em->flags & EXTENT_FLAG_LOGGING)
@@ -270,8 +270,8 @@ static void merge_ondisk_extents(const struct extent_map *prev, const struct ext
        u64 new_offset;
 
        /* @prev and @next should not be compressed. */
-       ASSERT(!extent_map_is_compressed(prev));
-       ASSERT(!extent_map_is_compressed(next));
+       ASSERT(!btrfs_extent_map_is_compressed(prev));
+       ASSERT(!btrfs_extent_map_is_compressed(next));
 
        /*
         * There are two different cases where @prev and @next can be merged.
@@ -327,9 +327,9 @@ static void validate_extent_map(struct btrfs_fs_info *fs_info, struct extent_map
                if (em->offset + em->len > em->ram_bytes)
                        dump_extent_map(fs_info, "ram_bytes too small", em);
                if (em->offset + em->len > em->disk_num_bytes &&
-                   !extent_map_is_compressed(em))
+                   !btrfs_extent_map_is_compressed(em))
                        dump_extent_map(fs_info, "disk_num_bytes too small", em);
-               if (!extent_map_is_compressed(em) &&
+               if (!btrfs_extent_map_is_compressed(em) &&
                    em->ram_bytes != em->disk_num_bytes)
                        dump_extent_map(fs_info,
                "ram_bytes mismatch with disk_num_bytes for non-compressed em",
@@ -1064,7 +1064,7 @@ int split_extent_map(struct btrfs_inode *inode, u64 start, u64 len, u64 pre,
        }
 
        ASSERT(em->len == len);
-       ASSERT(!extent_map_is_compressed(em));
+       ASSERT(!btrfs_extent_map_is_compressed(em));
        ASSERT(em->disk_bytenr < EXTENT_MAP_LAST_BYTE);
        ASSERT(em->flags & EXTENT_FLAG_PINNED);
        ASSERT(!(em->flags & EXTENT_FLAG_LOGGING));
index cd123b266b641611188530ca27f53861a38c417c..6aecb132c874646bc1b61ce06ad3c6380f2c45f2 100644 (file)
@@ -108,8 +108,8 @@ struct extent_map_tree {
 
 struct btrfs_inode;
 
-static inline void extent_map_set_compression(struct extent_map *em,
-                                             enum btrfs_compression_type type)
+static inline void btrfs_extent_map_set_compression(struct extent_map *em,
+                                                   enum btrfs_compression_type type)
 {
        if (type == BTRFS_COMPRESS_ZLIB)
                em->flags |= EXTENT_FLAG_COMPRESS_ZLIB;
@@ -119,7 +119,8 @@ static inline void extent_map_set_compression(struct extent_map *em,
                em->flags |= EXTENT_FLAG_COMPRESS_ZSTD;
 }
 
-static inline enum btrfs_compression_type extent_map_compression(const struct extent_map *em)
+static inline enum btrfs_compression_type btrfs_extent_map_compression(
+                                                      const struct extent_map *em)
 {
        if (em->flags & EXTENT_FLAG_COMPRESS_ZLIB)
                return BTRFS_COMPRESS_ZLIB;
@@ -137,7 +138,7 @@ static inline enum btrfs_compression_type extent_map_compression(const struct ex
  * More efficient way to determine if extent is compressed, instead of using
  * 'extent_map_compression() != BTRFS_COMPRESS_NONE'.
  */
-static inline bool extent_map_is_compressed(const struct extent_map *em)
+static inline bool btrfs_extent_map_is_compressed(const struct extent_map *em)
 {
        return (em->flags & (EXTENT_FLAG_COMPRESS_ZLIB |
                             EXTENT_FLAG_COMPRESS_LZO |
@@ -152,7 +153,7 @@ static inline int extent_map_in_tree(const struct extent_map *em)
 static inline u64 extent_map_block_start(const struct extent_map *em)
 {
        if (em->disk_bytenr < EXTENT_MAP_LAST_BYTE) {
-               if (extent_map_is_compressed(em))
+               if (btrfs_extent_map_is_compressed(em))
                        return em->disk_bytenr;
                return em->disk_bytenr + em->offset;
        }
index c5fb4b357100d2bc94e007e9de2c2fe04863d116..827d156a7bd7a81d8a8137993d80955122b651ed 100644 (file)
@@ -1296,7 +1296,7 @@ void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
                em->disk_num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi);
                em->offset = btrfs_file_extent_offset(leaf, fi);
                if (compress_type != BTRFS_COMPRESS_NONE) {
-                       extent_map_set_compression(em, compress_type);
+                       btrfs_extent_map_set_compression(em, compress_type);
                } else {
                        /*
                         * Older kernels can create regular non-hole data
@@ -1316,7 +1316,7 @@ void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
                em->start = 0;
                em->len = fs_info->sectorsize;
                em->offset = 0;
-               extent_map_set_compression(em, compress_type);
+               btrfs_extent_map_set_compression(em, compress_type);
        } else {
                btrfs_err(fs_info,
                          "unknown file extent item type %d, inode %llu, offset %llu, "
index c9788d633b8ac2ccdce022719457b781832eee6f..faa8f66ee6626322627c8ba77889fc52e9b66c2d 100644 (file)
@@ -7227,7 +7227,7 @@ struct extent_map *btrfs_create_io_em(struct btrfs_inode *inode, u64 start,
        em->offset = file_extent->offset;
        em->flags |= EXTENT_FLAG_PINNED;
        if (type == BTRFS_ORDERED_COMPRESSED)
-               extent_map_set_compression(em, file_extent->compression);
+               btrfs_extent_map_set_compression(em, file_extent->compression);
 
        ret = btrfs_replace_extent_map_range(inode, em, true);
        if (ret) {
@@ -9432,7 +9432,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
                count = min_t(u64, count, encoded->len);
                encoded->len = count;
                encoded->unencoded_len = count;
-       } else if (extent_map_is_compressed(em)) {
+       } else if (btrfs_extent_map_is_compressed(em)) {
                *disk_bytenr = em->disk_bytenr;
                /*
                 * Bail if the buffer isn't large enough to return the whole
@@ -9447,7 +9447,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
                encoded->unencoded_len = em->ram_bytes;
                encoded->unencoded_offset = iocb->ki_pos - (em->start - em->offset);
                ret = btrfs_encoded_io_compression_from_extent(fs_info,
-                                                              extent_map_compression(em));
+                                              btrfs_extent_map_compression(em));
                if (ret < 0)
                        goto out_em;
                encoded->compression = ret;
index 37b285896af07b438f922f6f983423b850152d0c..6aa0f92f8c020abf68b03b7cc687daacd99b21fd 100644 (file)
@@ -597,9 +597,9 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
                test_err("wrong offset, want 0, have %llu", em->offset);
                goto out;
        }
-       if (extent_map_compression(em) != BTRFS_COMPRESS_ZLIB) {
+       if (btrfs_extent_map_compression(em) != BTRFS_COMPRESS_ZLIB) {
                test_err("unexpected compress type, wanted %d, got %d",
-                        BTRFS_COMPRESS_ZLIB, extent_map_compression(em));
+                        BTRFS_COMPRESS_ZLIB, btrfs_extent_map_compression(em));
                goto out;
        }
        offset = em->start + em->len;
@@ -630,9 +630,9 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
                test_err("wrong offset, want 0, have %llu", em->offset);
                goto out;
        }
-       if (extent_map_compression(em) != BTRFS_COMPRESS_ZLIB) {
+       if (btrfs_extent_map_compression(em) != BTRFS_COMPRESS_ZLIB) {
                test_err("unexpected compress type, wanted %d, got %d",
-                        BTRFS_COMPRESS_ZLIB, extent_map_compression(em));
+                        BTRFS_COMPRESS_ZLIB, btrfs_extent_map_compression(em));
                goto out;
        }
        disk_bytenr = extent_map_block_start(em);
@@ -692,9 +692,9 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
                         em->start, em->offset, orig_start);
                goto out;
        }
-       if (extent_map_compression(em) != BTRFS_COMPRESS_ZLIB) {
+       if (btrfs_extent_map_compression(em) != BTRFS_COMPRESS_ZLIB) {
                test_err("unexpected compress type, wanted %d, got %d",
-                        BTRFS_COMPRESS_ZLIB, extent_map_compression(em));
+                        BTRFS_COMPRESS_ZLIB, btrfs_extent_map_compression(em));
                goto out;
        }
        offset = em->start + em->len;
index 856ec4431ce28354c0fd6b3fdff83f0264d8db66..d5e95ab2c9fdfbd2d9b41edccfc79c8f038c98b6 100644 (file)
@@ -4648,7 +4648,7 @@ static int log_extent_csums(struct btrfs_trans_handle *trans,
                return 0;
 
        /* If we're compressed we have to save the entire range of csums. */
-       if (extent_map_is_compressed(em)) {
+       if (btrfs_extent_map_is_compressed(em)) {
                csum_offset = 0;
                csum_len = em->disk_num_bytes;
        } else {
@@ -4703,7 +4703,7 @@ static int log_one_extent(struct btrfs_trans_handle *trans,
                btrfs_set_stack_file_extent_type(&fi, BTRFS_FILE_EXTENT_REG);
 
        block_len = em->disk_num_bytes;
-       compress_type = extent_map_compression(em);
+       compress_type = btrfs_extent_map_compression(em);
        if (compress_type != BTRFS_COMPRESS_NONE) {
                btrfs_set_stack_file_extent_disk_bytenr(&fi, block_start);
                btrfs_set_stack_file_extent_disk_num_bytes(&fi, block_len);