Skip to content

Commit 4d53ddd

Browse files
committed
btrfs: document existence of extent_io ops callbacks
Some of the callbacks defined in btree_extent_io_ops and btrfs_extent_io_ops do always exist so we don't need to check the existence before each call. This patch just reorders the definition and documents which are mandatory/optional. Signed-off-by: David Sterba <[email protected]>
1 parent c3988d6 commit 4d53ddd

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

fs/btrfs/disk-io.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,9 +4653,12 @@ static int btrfs_cleanup_transaction(struct btrfs_fs_info *fs_info)
46534653
}
46544654

46554655
static const struct extent_io_ops btree_extent_io_ops = {
4656-
.readpage_end_io_hook = btree_readpage_end_io_hook,
4657-
.readpage_io_failed_hook = btree_io_failed_hook,
4656+
/* mandatory callbacks */
46584657
.submit_bio_hook = btree_submit_bio_hook,
4658+
.readpage_end_io_hook = btree_readpage_end_io_hook,
46594659
/* note we're sharing with inode.c for the merge bio hook */
46604660
.merge_bio_hook = btrfs_merge_bio_hook,
4661+
4662+
/* optional callbacks */
4663+
.readpage_io_failed_hook = btree_io_failed_hook,
46614664
};

fs/btrfs/extent_io.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,27 @@ typedef int (extent_submit_bio_hook_t)(struct inode *inode, struct bio *bio,
9292
int mirror_num, unsigned long bio_flags,
9393
u64 bio_offset);
9494
struct extent_io_ops {
95-
int (*fill_delalloc)(struct inode *inode, struct page *locked_page,
96-
u64 start, u64 end, int *page_started,
97-
unsigned long *nr_written);
98-
int (*writepage_start_hook)(struct page *page, u64 start, u64 end);
95+
/*
96+
* The following callbacks must be allways defined, the function
97+
* pointer will be called unconditionally.
98+
*/
9999
extent_submit_bio_hook_t *submit_bio_hook;
100+
int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio, u64 phy_offset,
101+
struct page *page, u64 start, u64 end,
102+
int mirror);
100103
int (*merge_bio_hook)(struct page *page, unsigned long offset,
101104
size_t size, struct bio *bio,
102105
unsigned long bio_flags);
106+
107+
/*
108+
* Optional hooks, called if the pointer is not NULL
109+
*/
110+
int (*fill_delalloc)(struct inode *inode, struct page *locked_page,
111+
u64 start, u64 end, int *page_started,
112+
unsigned long *nr_written);
103113
int (*readpage_io_failed_hook)(struct page *page, int failed_mirror);
104-
int (*readpage_end_io_hook)(struct btrfs_io_bio *io_bio, u64 phy_offset,
105-
struct page *page, u64 start, u64 end,
106-
int mirror);
114+
115+
int (*writepage_start_hook)(struct page *page, u64 start, u64 end);
107116
void (*writepage_end_io_hook)(struct page *page, u64 start, u64 end,
108117
struct extent_state *state, int uptodate);
109118
void (*set_bit_hook)(struct inode *inode, struct extent_state *state,

fs/btrfs/inode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10547,10 +10547,13 @@ static const struct file_operations btrfs_dir_file_operations = {
1054710547
};
1054810548

1054910549
static const struct extent_io_ops btrfs_extent_io_ops = {
10550-
.fill_delalloc = run_delalloc_range,
10550+
/* mandatory callbacks */
1055110551
.submit_bio_hook = btrfs_submit_bio_hook,
10552-
.merge_bio_hook = btrfs_merge_bio_hook,
1055310552
.readpage_end_io_hook = btrfs_readpage_end_io_hook,
10553+
.merge_bio_hook = btrfs_merge_bio_hook,
10554+
10555+
/* optional callbacks */
10556+
.fill_delalloc = run_delalloc_range,
1055410557
.writepage_end_io_hook = btrfs_writepage_end_io_hook,
1055510558
.writepage_start_hook = btrfs_writepage_start_hook,
1055610559
.set_bit_hook = btrfs_set_bit_hook,

0 commit comments

Comments
 (0)