2022-10-27 03:08:27 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#ifndef BTRFS_FILE_ITEM_H
|
|
|
|
#define BTRFS_FILE_ITEM_H
|
|
|
|
|
2024-01-27 10:19:56 +08:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <uapi/linux/btrfs_tree.h>
|
2022-11-16 00:16:12 +08:00
|
|
|
#include "accessors.h"
|
|
|
|
|
2024-01-26 00:44:47 +08:00
|
|
|
struct extent_map;
|
2024-01-27 10:19:56 +08:00
|
|
|
struct btrfs_file_extent_item;
|
|
|
|
struct btrfs_fs_info;
|
|
|
|
struct btrfs_path;
|
|
|
|
struct btrfs_bio;
|
|
|
|
struct btrfs_trans_handle;
|
|
|
|
struct btrfs_root;
|
|
|
|
struct btrfs_ordered_sum;
|
|
|
|
struct btrfs_path;
|
|
|
|
struct btrfs_inode;
|
2024-01-26 00:44:47 +08:00
|
|
|
|
2022-11-16 00:16:12 +08:00
|
|
|
#define BTRFS_FILE_EXTENT_INLINE_DATA_START \
|
|
|
|
(offsetof(struct btrfs_file_extent_item, disk_bytenr))
|
|
|
|
|
|
|
|
static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info)
|
|
|
|
{
|
|
|
|
return BTRFS_MAX_ITEM_SIZE(info) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the number of bytes used by the item on disk, minus the size of any
|
|
|
|
* extent headers. If a file is compressed on disk, this is the compressed
|
|
|
|
* size.
|
|
|
|
*/
|
|
|
|
static inline u32 btrfs_file_extent_inline_item_len(
|
|
|
|
const struct extent_buffer *eb,
|
|
|
|
int nr)
|
|
|
|
{
|
|
|
|
return btrfs_item_size(eb, nr) - BTRFS_FILE_EXTENT_INLINE_DATA_START;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned long btrfs_file_extent_inline_start(
|
|
|
|
const struct btrfs_file_extent_item *e)
|
|
|
|
{
|
|
|
|
return (unsigned long)e + BTRFS_FILE_EXTENT_INLINE_DATA_START;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
|
|
|
|
{
|
|
|
|
return BTRFS_FILE_EXTENT_INLINE_DATA_START + datasize;
|
|
|
|
}
|
|
|
|
|
2022-10-27 03:08:27 +08:00
|
|
|
int btrfs_del_csums(struct btrfs_trans_handle *trans,
|
|
|
|
struct btrfs_root *root, u64 bytenr, u64 len);
|
2023-01-21 14:50:02 +08:00
|
|
|
blk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio);
|
2022-10-27 03:08:27 +08:00
|
|
|
int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans,
|
|
|
|
struct btrfs_root *root, u64 objectid, u64 pos,
|
|
|
|
u64 num_bytes);
|
|
|
|
int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
|
|
|
|
struct btrfs_root *root,
|
|
|
|
struct btrfs_path *path, u64 objectid,
|
|
|
|
u64 bytenr, int mod);
|
|
|
|
int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
|
|
|
|
struct btrfs_root *root,
|
|
|
|
struct btrfs_ordered_sum *sums);
|
2023-01-21 14:50:16 +08:00
|
|
|
blk_status_t btrfs_csum_one_bio(struct btrfs_bio *bbio);
|
2023-05-24 23:03:08 +08:00
|
|
|
blk_status_t btrfs_alloc_dummy_sum(struct btrfs_bio *bbio);
|
2023-01-21 14:50:16 +08:00
|
|
|
int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
|
|
|
|
struct list_head *list, int search_commit,
|
|
|
|
bool nowait);
|
2022-11-14 08:26:32 +08:00
|
|
|
int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
|
2024-04-12 01:26:56 +08:00
|
|
|
struct list_head *list, bool nowait);
|
2023-08-03 14:33:30 +08:00
|
|
|
int btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path,
|
|
|
|
u64 start, u64 end, u8 *csum_buf,
|
|
|
|
unsigned long *csum_bitmap);
|
2022-10-27 03:08:27 +08:00
|
|
|
void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
|
|
|
|
const struct btrfs_path *path,
|
2024-06-27 05:39:11 +08:00
|
|
|
const struct btrfs_file_extent_item *fi,
|
2022-10-27 03:08:27 +08:00
|
|
|
struct extent_map *em);
|
|
|
|
int btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start,
|
|
|
|
u64 len);
|
|
|
|
int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start, u64 len);
|
|
|
|
void btrfs_inode_safe_disk_i_size_write(struct btrfs_inode *inode, u64 new_i_size);
|
|
|
|
u64 btrfs_file_extent_end(const struct btrfs_path *path);
|
|
|
|
|
|
|
|
#endif
|