Skip to content

Commit 4ec50b1

Browse files
committed
btrfs-progs: kernel-shared: sync with 6.17-rc1
Partial sync. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 0fb0189 commit 4ec50b1

File tree

15 files changed

+212
-180
lines changed

15 files changed

+212
-180
lines changed

kernel-shared/accessors.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
5656
const void *ptr, unsigned long off) \
5757
{ \
5858
const unsigned long member_offset = (unsigned long)ptr + off; \
59-
const int size = sizeof(u##bits); \
60-
ASSERT(check_setget_bounds(eb, ptr, off, size)); \
59+
ASSERT(check_setget_bounds(eb, ptr, off, sizeof(u##bits))); \
6160
return get_unaligned_le##bits(eb->data + member_offset); \
6261
} \
6362
void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
6463
unsigned long off, u##bits val) \
6564
{ \
6665
unsigned long member_offset = (unsigned long)ptr + off; \
67-
const int size = sizeof(u##bits); \
68-
ASSERT(check_setget_bounds(eb, ptr, off, size)); \
66+
ASSERT(check_setget_bounds(eb, ptr, off, sizeof(u##bits))); \
6967
put_unaligned_le##bits(val, (void *)eb->data + member_offset); \
7068
}
7169

kernel-shared/accessors.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,9 @@ static inline void btrfs_dir_item_key_to_cpu(const struct extent_buffer *eb,
633633
static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
634634
const struct btrfs_disk_key *disk)
635635
{
636-
cpu->objectid = le64_to_cpu(disk->objectid);
637-
cpu->type = disk->type;
638636
cpu->offset = le64_to_cpu(disk->offset);
637+
cpu->type = disk->type;
638+
cpu->objectid = le64_to_cpu(disk->objectid);
639639
}
640640

641641
static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk,

kernel-shared/compression.h

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
#include "kerncompat.h"
1010
#include "kernel-lib/sizes.h"
1111

12-
struct btrfs_inode;
13-
struct btrfs_ordered_extent;
1412
struct address_space;
13+
struct folio;
14+
struct page;
1515
struct inode;
16+
struct btrfs_inode;
17+
struct btrfs_ordered_extent;
1618
struct bio;
1719
/* Stub for kernel-user parity. */
1820
struct btrfs_bio { };
@@ -37,14 +39,12 @@ _static_assert((BTRFS_MAX_COMPRESSED % PAGE_SIZE) == 0);
3739

3840
#define BTRFS_ZLIB_DEFAULT_LEVEL 3
3941

40-
struct page;
41-
4242
struct compressed_bio {
43-
/* Number of compressed pages in the array */
44-
unsigned int nr_pages;
43+
/* Number of compressed folios in the array. */
44+
unsigned int nr_folios;
4545

46-
/* the pages with the compressed data on them */
47-
struct page **compressed_pages;
46+
/* The folios with the compressed data on them. */
47+
struct folio **compressed_folios;
4848

4949
/* starting offset in the inode for our pages */
5050
u64 start;
@@ -84,34 +84,34 @@ static inline unsigned int btrfs_compress_level(unsigned int type_level)
8484
int __init btrfs_init_compress(void);
8585
void __cold btrfs_exit_compress(void);
8686

87-
int btrfs_compress_pages(unsigned int type_level, struct address_space *mapping,
88-
u64 start, struct page **pages,
89-
unsigned long *out_pages,
90-
unsigned long *total_in,
91-
unsigned long *total_out);
92-
int btrfs_decompress(int type, const u8 *data_in, struct page *dest_page,
87+
bool btrfs_compress_level_valid(unsigned int type, int level);
88+
int btrfs_compress_folios(unsigned int type, int level, struct address_space *mapping,
89+
u64 start, struct folio **folios, unsigned long *out_folios,
90+
unsigned long *total_in, unsigned long *total_out);
91+
int btrfs_decompress(int type, const u8 *data_in, struct folio *dest_folio,
9392
unsigned long start_byte, size_t srclen, size_t destlen);
9493
int btrfs_decompress_buf2page(const char *buf, u32 buf_len,
9594
struct compressed_bio *cb, u32 decompressed);
9695

9796
void btrfs_submit_compressed_write(struct btrfs_ordered_extent *ordered,
98-
struct page **compressed_pages,
99-
unsigned int nr_pages,
100-
blk_opf_t write_flags,
101-
bool writeback);
97+
struct folio **compressed_folios,
98+
unsigned int nr_folios, blk_opf_t write_flags,
99+
bool writeback);
102100
void btrfs_submit_compressed_read(struct btrfs_bio *bbio);
103101

104-
unsigned int btrfs_compress_str2level(unsigned int type, const char *str);
102+
int btrfs_compress_str2level(unsigned int type, const char *str);
105103

106-
struct page *btrfs_alloc_compr_page(void);
107-
void btrfs_free_compr_page(struct page *page);
104+
struct folio *btrfs_alloc_compr_folio(void);
105+
void btrfs_free_compr_folio(struct folio *folio);
108106

109107
enum btrfs_compression_type {
110108
BTRFS_COMPRESS_NONE = 0,
111109
BTRFS_COMPRESS_ZLIB = 1,
112110
BTRFS_COMPRESS_LZO = 2,
113111
BTRFS_COMPRESS_ZSTD = 3,
114112
BTRFS_NR_COMPRESS_TYPES = 4,
113+
114+
BTRFS_DEFRAG_DONT_COMPRESS,
115115
};
116116

117117
struct workspace_manager {
@@ -125,14 +125,15 @@ struct workspace_manager {
125125
wait_queue_head_t ws_wait;
126126
};
127127

128-
struct list_head *btrfs_get_workspace(int type, unsigned int level);
128+
struct list_head *btrfs_get_workspace(int type, int level);
129129
void btrfs_put_workspace(int type, struct list_head *ws);
130130

131131
struct btrfs_compress_op {
132132
struct workspace_manager *workspace_manager;
133133
/* Maximum level supported by the compression algorithm */
134-
unsigned int max_level;
135-
unsigned int default_level;
134+
int min_level;
135+
int max_level;
136+
int default_level;
136137
};
137138

138139
/* The heuristic workspaces are managed via the 0th workspace manager */
@@ -146,41 +147,44 @@ extern const struct btrfs_compress_op btrfs_zstd_compress;
146147
const char* btrfs_compress_type2str(enum btrfs_compression_type type);
147148
bool btrfs_compress_is_valid_type(const char *str, size_t len);
148149

149-
int btrfs_compress_heuristic(struct inode *inode, u64 start, u64 end);
150+
int btrfs_compress_heuristic(struct btrfs_inode *inode, u64 start, u64 end);
151+
152+
int btrfs_compress_filemap_get_folio(struct address_space *mapping, u64 start,
153+
struct folio **in_folio_ret);
150154

151-
int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
152-
u64 start, struct page **pages, unsigned long *out_pages,
155+
int zlib_compress_folios(struct list_head *ws, struct address_space *mapping,
156+
u64 start, struct folio **folios, unsigned long *out_folios,
153157
unsigned long *total_in, unsigned long *total_out);
154158
int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
155159
int zlib_decompress(struct list_head *ws, const u8 *data_in,
156-
struct page *dest_page, unsigned long dest_pgoff, size_t srclen,
160+
struct folio *dest_folio, unsigned long dest_pgoff, size_t srclen,
157161
size_t destlen);
158162
struct list_head *zlib_alloc_workspace(unsigned int level);
159163
void zlib_free_workspace(struct list_head *ws);
160164
struct list_head *zlib_get_workspace(unsigned int level);
161165

162-
int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
163-
u64 start, struct page **pages, unsigned long *out_pages,
166+
int lzo_compress_folios(struct list_head *ws, struct address_space *mapping,
167+
u64 start, struct folio **folios, unsigned long *out_folios,
164168
unsigned long *total_in, unsigned long *total_out);
165169
int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
166170
int lzo_decompress(struct list_head *ws, const u8 *data_in,
167-
struct page *dest_page, unsigned long dest_pgoff, size_t srclen,
171+
struct folio *dest_folio, unsigned long dest_pgoff, size_t srclen,
168172
size_t destlen);
169-
struct list_head *lzo_alloc_workspace(unsigned int level);
173+
struct list_head *lzo_alloc_workspace(void);
170174
void lzo_free_workspace(struct list_head *ws);
171175

172-
int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
173-
u64 start, struct page **pages, unsigned long *out_pages,
176+
int zstd_compress_folios(struct list_head *ws, struct address_space *mapping,
177+
u64 start, struct folio **folios, unsigned long *out_folios,
174178
unsigned long *total_in, unsigned long *total_out);
175179
int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
176180
int zstd_decompress(struct list_head *ws, const u8 *data_in,
177-
struct page *dest_page, unsigned long start_byte, size_t srclen,
181+
struct folio *dest_folio, unsigned long dest_pgoff, size_t srclen,
178182
size_t destlen);
179183
void zstd_init_workspace_manager(void);
180184
void zstd_cleanup_workspace_manager(void);
181-
struct list_head *zstd_alloc_workspace(unsigned int level);
185+
struct list_head *zstd_alloc_workspace(int level);
182186
void zstd_free_workspace(struct list_head *ws);
183-
struct list_head *zstd_get_workspace(unsigned int level);
187+
struct list_head *zstd_get_workspace(int level);
184188
void zstd_put_workspace(struct list_head *ws);
185189

186190
#endif

kernel-shared/disk-io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
#include "kernel-lib/sizes.h"
2525
#include "kernel-shared/ctree.h"
2626

27-
struct btrfs_tree_parent_check;
2827
struct btrfs_fs_devices;
2928
struct btrfs_key;
3029
struct btrfs_super_block;
3130
struct btrfs_trans_handle;
31+
struct btrfs_tree_parent_check;
3232
struct extent_buffer;
3333
struct rb_node;
3434

kernel-shared/extent-io-tree.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ enum {
3535
* that is left for the ordered extent completion.
3636
*/
3737
ENUM_BIT(EXTENT_DELALLOC_NEW),
38+
/*
39+
* Mark that a range is being locked for finishing an ordered extent.
40+
* Used together with EXTENT_LOCKED.
41+
*/
42+
ENUM_BIT(EXTENT_FINISHING_ORDERED),
3843
/*
3944
* When an ordered extent successfully completes for a region marked as
4045
* a new delalloc range, use this flag when clearing a new delalloc
@@ -48,6 +53,15 @@ enum {
4853
* want the extent states to go away.
4954
*/
5055
ENUM_BIT(EXTENT_CLEAR_ALL_BITS),
56+
57+
/*
58+
* This must be last.
59+
*
60+
* Bit not representing a state but a request for NOWAIT semantics,
61+
* e.g. when allocating memory, and must be masked out from the other
62+
* bits.
63+
*/
64+
ENUM_BIT(EXTENT_NOWAIT)
5165
};
5266

5367
#define EXTENT_DO_ACCOUNTING (EXTENT_CLEAR_META_RESV | \
@@ -56,6 +70,8 @@ enum {
5670
EXTENT_ADD_INODE_BYTES | \
5771
EXTENT_CLEAR_ALL_BITS)
5872

73+
#define EXTENT_LOCK_BITS (EXTENT_LOCKED | EXTENT_DIO_LOCKED)
74+
5975
/*
6076
* Redefined bits above which are used only in the device allocation tree,
6177
* shouldn't be using EXTENT_LOCKED / EXTENT_BOUNDARY / EXTENT_CLEAR_META_RESV

kernel-shared/file-item.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include "kernel-shared/accessors.h"
1212
#include "kernel-shared/compression.h"
1313

14+
struct extent_map;
1415
struct bio;
1516
struct inode;
17+
struct btrfs_trans_handle;
1618
struct btrfs_ordered_sum;
1719
struct btrfs_inode;
18-
struct btrfs_trans_handle;
19-
struct extent_map;
2020
struct extent_buffer;
2121
struct list_head;
2222

@@ -53,7 +53,7 @@ static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize)
5353

5454
int btrfs_del_csums(struct btrfs_trans_handle *trans,
5555
struct btrfs_root *root, u64 bytenr, u64 len);
56-
blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u8 *dst);
56+
int btrfs_lookup_bio_sums(struct btrfs_bio *bbio);
5757
int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans,
5858
struct btrfs_root *root, u64 objectid, u64 pos,
5959
u64 num_bytes);
@@ -64,14 +64,19 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
6464
int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
6565
struct btrfs_root *root,
6666
struct btrfs_ordered_sum *sums);
67-
blk_status_t btrfs_csum_one_bio(struct btrfs_inode *inode, struct bio *bio,
68-
u64 offset, bool one_ordered);
67+
int btrfs_csum_one_bio(struct btrfs_bio *bbio);
68+
int btrfs_alloc_dummy_sum(struct btrfs_bio *bbio);
6969
int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
7070
struct list_head *list, int search_commit,
7171
bool nowait);
72+
int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
73+
struct list_head *list, bool nowait);
74+
int btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path,
75+
u64 start, u64 end, u8 *csum_buf,
76+
unsigned long *csum_bitmap);
7277
void btrfs_extent_item_to_extent_map(struct btrfs_inode *inode,
7378
const struct btrfs_path *path,
74-
struct btrfs_file_extent_item *fi,
79+
const struct btrfs_file_extent_item *fi,
7580
struct extent_map *em);
7681
int btrfs_inode_clear_file_extent_range(struct btrfs_inode *inode, u64 start,
7782
u64 len);

kernel-shared/locking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw)
211211

212212
struct btrfs_drew_lock {
213213
atomic_t readers;
214-
struct percpu_counter writers;
214+
atomic_t writers;
215215
wait_queue_head_t pending_writers;
216216
wait_queue_head_t pending_readers;
217217
};

kernel-shared/messages.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#ifdef CONFIG_PRINTK
1010

11-
#define STATE_STRING_PREFACE ": state "
11+
#define STATE_STRING_PREFACE " state "
1212
#define STATE_STRING_BUF_LEN (sizeof(STATE_STRING_PREFACE) + BTRFS_FS_STATE_COUNT + 1)
1313

1414
/*
@@ -21,7 +21,8 @@ static const char fs_state_chars[] = {
2121
[BTRFS_FS_STATE_TRANS_ABORTED] = 'A',
2222
[BTRFS_FS_STATE_DEV_REPLACING] = 'R',
2323
[BTRFS_FS_STATE_DUMMY_FS_INFO] = 0,
24-
[BTRFS_FS_STATE_NO_CSUMS] = 'C',
24+
[BTRFS_FS_STATE_NO_DATA_CSUMS] = 'C',
25+
[BTRFS_FS_STATE_SKIP_META_CSUMS] = 'S',
2526
[BTRFS_FS_STATE_LOG_CLEANUP_ERROR] = 'L',
2627
};
2728

@@ -260,14 +261,6 @@ void __cold _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt,
260261
}
261262
#endif
262263

263-
#ifdef CONFIG_BTRFS_ASSERT
264-
void __cold btrfs_assertfail(const char *expr, const char *file, int line)
265-
{
266-
pr_err("assertion failed: %s, in %s:%d\n", expr, file, line);
267-
BUG();
268-
}
269-
#endif
270-
271264
#if BITS_PER_LONG == 32 && defined(__KERNEL__)
272265
void __cold btrfs_warn_32bit_limit(struct btrfs_fs_info *fs_info)
273266
{
@@ -295,8 +288,8 @@ void __cold btrfs_err_32bit_limit(struct btrfs_fs_info *fs_info)
295288
#endif
296289

297290
/*
298-
* __btrfs_panic decodes unexpected, fatal errors from the caller, issues an
299-
* alert, and either panics or BUGs, depending on mount options.
291+
* Decode unexpected, fatal errors from the caller, issue an alert, and either
292+
* panic or BUGs, depending on mount options.
300293
*
301294
* MODIFIED:
302295
* - We don't have btrfs_test_opt() yet, kill that and s_id.

0 commit comments

Comments
 (0)