Structre and parameter cleanups
David Sterba
maintainercover Structre and parameter cleanups
Simplify some argument passing, remove too-trivial helpers or unused structure members.
David Sterba (9):
btrfs: sink parameter is_data to btrfs_set_disk_extent_flags
btrfs: remove btrfs_delayed_extent_op::is_data
btrfs: remove unused parameter bio_flags from btrfs_wq_submit_bio
btrfs: remove trivial helper update_nr_written
btrfs: simplify handling of bio_ctrl::bio_flags
btrfs: open code extent_set_compress_type helpers
btrfs: rename io_failure_record::bio_flags to compress_type
btrfs: rename bio_flags in parameters and switch type
btrfs: rename bio_ctrl::bio_flags to compress_type
fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 5 ++- fs/btrfs/delayed-ref.c | 4 +-- fs/btrfs/delayed-ref.h | 1 - fs/btrfs/disk-io.c | 5 ++- fs/btrfs/disk-io.h | 3 +- fs/btrfs/extent-tree.c | 10 +++--- fs/btrfs/extent_io.c | 73 ++++++++++++++++++------------------------ fs/btrfs/extent_io.h | 22 ++----------- fs/btrfs/inode.c | 10 +++--- 10 files changed, 50 insertions(+), 85 deletions(-)
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 1/9 btrfs: sink parameter is_data to btrfs_set_disk_extent_flags
The parameter has been added in 2009 in the infamous monster commit 5d4f98a28c7d ("Btrfs: Mixed back reference (FORWARD ROLLING FORMAT CHANGE)") but not used ever since. We can sink it and allow further simplifications.
--- fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 3 +-- fs/btrfs/extent-tree.c | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-)
fs/btrfs/ctree.c +1 -1
@@ -343,7 +343,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,int level =btrfs_header_level (buf); ret =btrfs_set_disk_extent_flags (trans, buf, - new_flags, level,0 ); + new_flags, level);if (ret)return ret; }
fs/btrfs/ctree.h +1 -2
@@ -2810,8 +2810,7 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,int btrfs_dec_ref (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct extent_buffer *buf,int full_backref);int btrfs_set_disk_extent_flags (struct btrfs_trans_handle *trans, -struct extent_buffer *eb,u64 flags, -int level,int is_data); +struct extent_buffer *eb,u64 flags,int level);int btrfs_free_extent (struct btrfs_trans_handle *trans,struct btrfs_ref *ref); int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
fs/btrfs/extent-tree.c +3 -3
@@ -2180,7 +2180,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,int btrfs_set_disk_extent_flags (struct btrfs_trans_handle *trans,struct extent_buffer *eb,u64 flags, -int level,int is_data) +int level) {struct btrfs_delayed_extent_op *extent_op;int ret;
@@ -2192,7 +2192,7 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, extent_op->flags_to_set = flags; extent_op->update_flags = true; extent_op->update_key = false; - extent_op->is_data = is_data ? true : false; + extent_op->is_data = false; extent_op->level = level; ret =btrfs_add_delayed_extent_op (trans, eb->start, eb->len, extent_op);
@@ -5136,7 +5136,7 @@ static noinline int walk_down_proc(struct btrfs_trans_handle *trans, ret =btrfs_dec_ref (trans, root, eb,0 );BUG_ON (ret);/* -ENOMEM */ ret =btrfs_set_disk_extent_flags (trans, eb, flag, -btrfs_header_level (eb),0 ); +btrfs_header_level (eb));BUG_ON (ret);/* -ENOMEM */ wc->flags[level] |= flag; }
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 2/9 btrfs: remove btrfs_delayed_extent_op::is_data
In reply to David SterbaThe value of btrfs_delayed_extent_op::is_data is always false, we can cascade the change and simplify code that depends on it, removing the structure member eventually.
--- fs/btrfs/delayed-ref.c | 4 +--- fs/btrfs/delayed-ref.h | 1 - fs/btrfs/extent-tree.c | 6 ++---- 3 files changed, 3 insertions(+), 8 deletions(-)
fs/btrfs/delayed-ref.c +1 -3
@@ -930,7 +930,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, is_system = (generic_ref->tree_ref.owning_root ==BTRFS_CHUNK_TREE_OBJECTID );ASSERT (generic_ref->type ==BTRFS_REF_METADATA && generic_ref->action); -BUG_ON (extent_op && extent_op->is_data); ref =kmem_cache_alloc (btrfs_delayed_tree_ref_cachep,GFP_NOFS );if (!ref)return -ENOMEM ;
@@ -1103,8 +1102,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans,return -ENOMEM ;init_delayed_ref_head (head_ref,NULL , bytenr, num_bytes,0 ,0 , -BTRFS_UPDATE_DELAYED_HEAD , extent_op->is_data, - false); +BTRFS_UPDATE_DELAYED_HEAD , false, false); head_ref->extent_op = extent_op; delayed_refs = &trans->transaction->delayed_refs;
fs/btrfs/delayed-ref.h +0 -1
@@ -58,7 +58,6 @@ struct btrfs_delayed_extent_op {u8 level;bool update_key;bool update_flags; -bool is_data;u64 flags_to_set; };
fs/btrfs/extent-tree.c +2 -4
@@ -1577,12 +1577,12 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,u32 item_size;int ret;int err =0 ; -int metadata = !extent_op->is_data; +int metadata =1 ;if (TRANS_ABORTED (trans))return 0 ; -if (metadata && !btrfs_fs_incompat (fs_info,SKINNY_METADATA )) +if (!btrfs_fs_incompat (fs_info,SKINNY_METADATA )) metadata =0 ; path =btrfs_alloc_path ();
@@ -2192,7 +2192,6 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, extent_op->flags_to_set = flags; extent_op->update_flags = true; extent_op->update_key = false; - extent_op->is_data = false; extent_op->level = level; ret =btrfs_add_delayed_extent_op (trans, eb->start, eb->len, extent_op);
@@ -4951,7 +4950,6 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, extent_op->flags_to_set = flags; extent_op->update_key = skinny_metadata ? false : true; extent_op->update_flags = true; - extent_op->is_data = false; extent_op->level = level; btrfs_init_generic_ref(&generic_ref, BTRFS_ADD_DELAYED_EXTENT,
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 3/9 btrfs: remove unused parameter bio_flags from btrfs_wq_submit_bio
In reply to David Sterba--- fs/btrfs/disk-io.c | 5 ++--- fs/btrfs/disk-io.h | 3 +-- fs/btrfs/inode.c | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-)
fs/btrfs/disk-io.c +2 -3
@@ -849,8 +849,7 @@ static void run_one_async_free(struct btrfs_work *work) }blk_status_t btrfs_wq_submit_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 dio_file_offset, +int mirror_num,u64 dio_file_offset,extent_submit_bio_start_t *submit_bio_start) {struct btrfs_fs_info *fs_info =BTRFS_I (inode)->root->fs_info;
@@ -943,7 +942,7 @@ void btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio, int mirror_* checksumming can happen in parallel across all CPUs */ ret =btrfs_wq_submit_bio (inode, bio, mirror_num,0 , -0 , btree_submit_bio_start); + btree_submit_bio_start); }if (ret) {
fs/btrfs/disk-io.h +1 -2
@@ -124,8 +124,7 @@ int btrfs_read_extent_buffer(struct extent_buffer *buf, u64 parent_transid,blk_status_t btrfs_bio_wq_end_io (struct btrfs_fs_info *info,struct bio *bio,enum btrfs_wq_endio_type metadata);blk_status_t btrfs_wq_submit_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags, -u64 dio_file_offset, +int mirror_num,u64 dio_file_offset,extent_submit_bio_start_t *submit_bio_start);blk_status_t btrfs_submit_bio_done (void *private_data,struct bio *bio,int mirror_num);
fs/btrfs/inode.c +2 -2
@@ -2624,7 +2624,7 @@ void btrfs_submit_data_bio(struct inode *inode, struct bio *bio,if (btrfs_is_data_reloc_root (root)) goto mapit;/* we're doing a write, do the async checksumming */ - ret =btrfs_wq_submit_bio (inode, bio, mirror_num, bio_flags, + ret =btrfs_wq_submit_bio (inode, bio, mirror_num,0 , btrfs_submit_bio_start); goto out; }else if (!skip_sum) {
@@ -7913,7 +7913,7 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio, goto map;if (write && async_submit) { - ret =btrfs_wq_submit_bio (inode, bio,0 ,0 , file_offset, + ret =btrfs_wq_submit_bio (inode, bio,0 , file_offset, btrfs_submit_bio_start_direct_io); goto err; }else if (write) {
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 4/9 btrfs: remove trivial helper update_nr_written
In reply to David SterbaThe helper used to do more with the wbc state but now it's just one subtraction, no need to have a special helper.
It became trivial in a91326679f2a ("Btrfs: make mapping->writeback_index point to the last written page").
--- fs/btrfs/extent_io.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
fs/btrfs/extent_io.c +3 -9
@@ -3839,12 +3839,6 @@ static inline void contiguous_readpages(struct page *pages[], int nr_pages, } } -static void update_nr_written (struct writeback_control *wbc, -unsigned long nr_written) -{ - wbc->nr_to_write -= nr_written; -} -/* * helper for __extent_writepage, doing all of the delayed allocation setup. *
@@ -4007,7 +4001,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,* we don't want to touch the inode after unlocking the page, * so we update the mapping writeback index now */ -update_nr_written (wbc,1 ); + wbc->nr_to_write--;while (cur <= end) {u64 disk_bytenr;
@@ -4620,7 +4614,7 @@ static int write_one_subpage_eb(struct extent_buffer *eb,* dirty anymore, we have submitted a page. Update nr_written in wbc. */ if (no_dirty_ebs) -update_nr_written (wbc,1 ); + wbc->nr_to_write--;return ret; }
@@ -4656,7 +4650,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,break ; } disk_bytenr +=PAGE_SIZE ; -update_nr_written (wbc,1 ); + wbc->nr_to_write--;unlock_page (p); }
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 5/9 btrfs: simplify handling of bio_ctrl::bio_flags
In reply to David SterbaThe bio_flags are used only to encode the compression and there are no other EXTENT_BIO_* flags, so the compress type can be stored directly. The struct member name is left unchanged and will be cleaned in later patches.
--- fs/btrfs/extent_io.c | 13 ++++++------- fs/btrfs/extent_io.h | 11 ++--------- fs/btrfs/inode.c | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-)
fs/btrfs/extent_io.c +6 -7
@@ -29,6 +29,7 @@#include "subpage.h" #include "zoned.h" #include "block-group.h" +#include "compression.h" static struct kmem_cache *extent_state_cache;static struct kmem_cache *extent_buffer_cache;
@@ -2561,7 +2562,6 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode logical = em->block_start + logical;if (test_bit (EXTENT_FLAG_COMPRESSED , &em->flags)) { logical = em->block_start; - failrec->bio_flags =EXTENT_BIO_COMPRESSED ;extent_set_compress_type (&failrec->bio_flags, em->compress_type); }
@@ -3273,7 +3273,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,if (bio_ctrl->bio_flags != bio_flags)return 0 ; -if (bio_ctrl->bio_flags &EXTENT_BIO_COMPRESSED ) +if (bio_ctrl->bio_flags !=BTRFS_COMPRESS_NONE ) contig = bio->bi_iter.bi_sector == sector;else contig =bio_end_sector (bio) == sector;
@@ -3316,7 +3316,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,* The split happens for real compressed bio, which happens in * btrfs_submit_compressed_read/write(). */ -if (bio_ctrl->bio_flags &EXTENT_BIO_COMPRESSED ) { +if (bio_ctrl->bio_flags !=BTRFS_COMPRESS_NONE ) { bio_ctrl->len_to_oe_boundary =U32_MAX ; bio_ctrl->len_to_stripe_boundary =U32_MAX ;return 0 ;
@@ -3370,7 +3370,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,* For compressed page range, its disk_bytenr is always @disk_bytenr * passed in, no matter if we have added any range into previous bio. */ -if (bio_flags &EXTENT_BIO_COMPRESSED ) +if (bio_flags !=BTRFS_COMPRESS_NONE ) bio->bi_iter.bi_sector = disk_bytenr >>SECTOR_SHIFT ;else bio->bi_iter.bi_sector = (disk_bytenr + offset) >>SECTOR_SHIFT ;
@@ -3476,7 +3476,7 @@ static int submit_extent_page(unsigned int opf,* We must go through btrfs_bio_add_page() to ensure each * page range won't cross various boundaries. */ -if (bio_flags &EXTENT_BIO_COMPRESSED ) +if (bio_flags !=BTRFS_COMPRESS_NONE ) added =btrfs_bio_add_page (bio_ctrl, page, disk_bytenr, size - offset, pg_offset + offset, bio_flags);
@@ -3682,7 +3682,6 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,BUG_ON (end < cur);if (test_bit (EXTENT_FLAG_COMPRESSED , &em->flags)) { - this_bio_flag |=EXTENT_BIO_COMPRESSED ;extent_set_compress_type (&this_bio_flag, em->compress_type); }
@@ -3690,7 +3689,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, iosize =min (extent_map_end (em) - cur, end - cur +1 ); cur_end =min (extent_map_end (em) -1 , end); iosize =ALIGN (iosize, blocksize); -if (this_bio_flag &EXTENT_BIO_COMPRESSED ) +if (this_bio_flag !=BTRFS_COMPRESS_NONE ) disk_bytenr = em->block_start;else disk_bytenr = em->block_start + extent_offset;
fs/btrfs/extent_io.h +2 -9
@@ -9,13 +9,6 @@#include <linux/btrfs_tree.h> #include "ulist.h" -/* -* flags for bio submission. The high bits indicate the compression -* type for this bio -*/ -#define EXTENT_BIO_COMPRESSED 1 -#define EXTENT_BIO_FLAG_SHIFT 16 -enum {EXTENT_BUFFER_UPTODATE ,EXTENT_BUFFER_DIRTY ,
@@ -150,12 +143,12 @@ static inline void extent_changeset_free(struct extent_changeset *changeset)static inline void extent_set_compress_type (unsigned long *bio_flags,int compress_type) { - *bio_flags |= compress_type <<EXTENT_BIO_FLAG_SHIFT ; + *bio_flags = compress_type; }static inline int extent_compress_type (unsigned long bio_flags) { -return bio_flags >>EXTENT_BIO_FLAG_SHIFT ; +return bio_flags; }struct extent_map_tree ;
fs/btrfs/inode.c +1 -1
@@ -2600,7 +2600,7 @@ void btrfs_submit_data_bio(struct inode *inode, struct bio *bio,if (ret) goto out; -if (bio_flags &EXTENT_BIO_COMPRESSED ) { +if (bio_flags !=BTRFS_COMPRESS_NONE ) {/* * btrfs_submit_compressed_read will handle completing * the bio if there were any errors, so just return
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 6/9 btrfs: open code extent_set_compress_type helpers
In reply to David SterbaThe helpers extent_set_compress_type and extent_compress_type have become trivial after previous cleanups and can be removed.
--- fs/btrfs/extent_io.c | 8 +++----- fs/btrfs/extent_io.h | 11 ----------- 2 files changed, 3 insertions(+), 16 deletions(-)
fs/btrfs/extent_io.c +3 -5
@@ -2562,7 +2562,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode logical = em->block_start + logical;if (test_bit (EXTENT_FLAG_COMPRESSED , &em->flags)) { logical = em->block_start; -extent_set_compress_type (&failrec->bio_flags, em->compress_type); + failrec->bio_flags = em->compress_type; } btrfs_debug(fs_info,
@@ -3681,10 +3681,8 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,BUG_ON (extent_map_end (em) <= cur);BUG_ON (end < cur); -if (test_bit (EXTENT_FLAG_COMPRESSED , &em->flags)) { -extent_set_compress_type (&this_bio_flag, - em->compress_type); - } +if (test_bit (EXTENT_FLAG_COMPRESSED , &em->flags)) + this_bio_flag = em->compress_type; iosize =min (extent_map_end (em) - cur, end - cur +1 ); cur_end =min (extent_map_end (em) -1 , end);
fs/btrfs/extent_io.h +0 -11
@@ -140,17 +140,6 @@ static inline void extent_changeset_free(struct extent_changeset *changeset)kfree (changeset); } -static inline void extent_set_compress_type (unsigned long *bio_flags, -int compress_type) -{ - *bio_flags = compress_type; -} - -static inline int extent_compress_type (unsigned long bio_flags) -{ -return bio_flags; -} -struct extent_map_tree ; typedef struct extent_map *(get_extent_t)(struct btrfs_inode *inode,
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 7/9 btrfs: rename io_failure_record::bio_flags to compress_type
In reply to David SterbaThe bio_flags is now used to store unchanged compress type, so unify that.
--- fs/btrfs/extent_io.c | 6 +++--- fs/btrfs/extent_io.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/extent_io.c +3 -3
@@ -2538,7 +2538,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode failrec->start = start; failrec->len = sectorsize; failrec->this_mirror =0 ; - failrec->bio_flags =0 ; + failrec->compress_type =BTRFS_COMPRESS_NONE ;read_lock (&em_tree->lock); em =lookup_extent_mapping (em_tree, start, failrec->len);
@@ -2562,7 +2562,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode logical = em->block_start + logical;if (test_bit (EXTENT_FLAG_COMPRESSED , &em->flags)) { logical = em->block_start; - failrec->bio_flags = em->compress_type; + failrec->compress_type = em->compress_type; } btrfs_debug(fs_info,
@@ -2694,7 +2694,7 @@ int btrfs_repair_one_sector(struct inode *inode,* will be handled by the endio on the repair_bio, so we can't return an * error here. */ -submit_bio_hook (inode, repair_bio, failrec->this_mirror, failrec->bio_flags); +submit_bio_hook (inode, repair_bio, failrec->this_mirror, failrec->compress_type);return BLK_STS_OK ; }
fs/btrfs/extent_io.h +1 -1
@@ -266,7 +266,7 @@ struct io_failure_record {u64 start;u64 len;u64 logical; -unsigned long bio_flags; +unsigned int compress_type;int this_mirror;int failed_mirror; };
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 8/9 btrfs: rename bio_flags in parameters and switch type
In reply to David SterbaSeveral functions take parameter bio_flags that was simplified to just compress type, unify it and change the type accordingly.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/extent_io.c | 28 ++++++++++++++-------------- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -3252,7 +3252,7 @@ u64 btrfs_file_extent_end(const struct btrfs_path *path);/* inode.c */ void btrfs_submit_data_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags); +int mirror_num,unsigned int compress_type);unsigned int btrfs_verify_data_csum (struct btrfs_bio *bbio,u32 bio_offset,struct page *page,u64 start,u64 end);
fs/btrfs/extent_io.c +14 -14
@@ -178,7 +178,7 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,return ret; } -static void submit_one_bio (struct bio *bio,int mirror_num,unsigned long bio_flags) +static void submit_one_bio (struct bio *bio,int mirror_num,unsigned int compress_type) {struct extent_io_tree *tree = bio->bi_private;
@@ -189,7 +189,7 @@ static void submit_one_bio(struct bio *bio, int mirror_num, unsigned long bio_flif (is_data_inode (tree->private_data))btrfs_submit_data_bio (tree->private_data, bio, mirror_num, - bio_flags); + compress_type);else btrfs_submit_metadata_bio (tree->private_data, bio, mirror_num);/*
@@ -3246,7 +3246,7 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size)* a contiguous page to the previous one * @size: portion of page that we want to write * @pg_offset: starting offset in the page -* @bio_flags: flags of the current bio to see if we can merge them +* @compress_type: compression type of the current bio to see if we can merge them * * Attempt to add a page to bio considering stripe alignment etc. *
@@ -3258,7 +3258,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,struct page *page, u64 disk_bytenr, unsigned int size, unsigned int pg_offset, - unsigned long bio_flags) + unsigned int compress_type) { struct bio *bio = bio_ctrl->bio;u32 bio_size = bio->bi_iter.bi_size;
@@ -3270,7 +3270,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,ASSERT (bio);/* The limit should be calculated when bio_ctrl->bio is allocated */ ASSERT (bio_ctrl->len_to_oe_boundary && bio_ctrl->len_to_stripe_boundary); -if (bio_ctrl->bio_flags != bio_flags) +if (bio_ctrl->bio_flags != compress_type)return 0 ;if (bio_ctrl->bio_flags !=BTRFS_COMPRESS_NONE )
@@ -3359,7 +3359,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,unsigned int opf, bio_end_io_t end_io_func, u64 disk_bytenr, u32 offset, u64 file_offset, - unsigned long bio_flags) + unsigned long compress_type) { struct btrfs_fs_info *fs_info = inode->root->fs_info;struct bio *bio;
@@ -3370,12 +3370,12 @@ static int alloc_new_bio(struct btrfs_inode *inode,* For compressed page range, its disk_bytenr is always @disk_bytenr * passed in, no matter if we have added any range into previous bio. */ -if (bio_flags !=BTRFS_COMPRESS_NONE ) +if (compress_type !=BTRFS_COMPRESS_NONE ) bio->bi_iter.bi_sector = disk_bytenr >>SECTOR_SHIFT ;else bio->bi_iter.bi_sector = (disk_bytenr + offset) >>SECTOR_SHIFT ; bio_ctrl->bio = bio; - bio_ctrl->bio_flags = bio_flags; + bio_ctrl->bio_flags = compress_type; bio->bi_end_io = end_io_func; bio->bi_private = &inode->io_tree; bio->bi_opf = opf;
@@ -3434,7 +3434,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,* @end_io_func: end_io callback for new bio * @mirror_num: desired mirror to read/write * @prev_bio_flags: flags of previous bio to see if we can merge the current one -* @bio_flags: flags of the current bio to see if we can merge them +* @compress_type: compress type for current bio */ static int submit_extent_page(unsigned int opf, struct writeback_control *wbc,
@@ -3443,7 +3443,7 @@ static int submit_extent_page(unsigned int opf, size_t size, unsigned long pg_offset, bio_end_io_t end_io_func, int mirror_num, - unsigned long bio_flags, + unsigned int compress_type, bool force_bio_submit) { int ret = 0;
@@ -3468,7 +3468,7 @@ static int submit_extent_page(unsigned int opf, ret =alloc_new_bio (inode, bio_ctrl, wbc, opf, end_io_func, disk_bytenr, offset,page_offset (page) + cur, - bio_flags); + compress_type);if (ret <0 )return ret; }
@@ -3476,14 +3476,14 @@ static int submit_extent_page(unsigned int opf,* We must go through btrfs_bio_add_page() to ensure each * page range won't cross various boundaries. */ -if (bio_flags !=BTRFS_COMPRESS_NONE ) +if (compress_type !=BTRFS_COMPRESS_NONE ) added =btrfs_bio_add_page (bio_ctrl, page, disk_bytenr, size - offset, pg_offset + offset, - bio_flags); + compress_type);else added =btrfs_bio_add_page (bio_ctrl, page, disk_bytenr + offset, size - offset, - pg_offset + offset, bio_flags); + pg_offset + offset, compress_type);/* Metadata page range should never be split */ if (!is_data_inode (&inode->vfs_inode))
fs/btrfs/extent_io.h +1 -1
@@ -66,7 +66,7 @@ struct extent_io_tree;typedef void (submit_bio_hook_t )(struct inode *inode,struct bio *bio,int mirror_num, -unsigned long bio_flags); +unsigned int compress_type);typedef blk_status_t (extent_submit_bio_start_t )(struct inode *inode,struct bio *bio,u64 dio_file_offset);
fs/btrfs/inode.c +3 -3
@@ -2571,7 +2571,7 @@ static blk_status_t extract_ordered_extent(struct btrfs_inode *inode,* c-3) otherwise: async submit */ void btrfs_submit_data_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) +int mirror_num,unsigned int compress_type) {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);struct btrfs_root *root =BTRFS_I (inode)->root;
@@ -2600,7 +2600,7 @@ void btrfs_submit_data_bio(struct inode *inode, struct bio *bio,if (ret) goto out; -if (bio_flags !=BTRFS_COMPRESS_NONE ) { +if (compress_type !=BTRFS_COMPRESS_NONE ) {/* * btrfs_submit_compressed_read will handle completing * the bio if there were any errors, so just return
@@ -7786,7 +7786,7 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip) }static void submit_dio_repair_bio (struct inode *inode,struct bio *bio, -int mirror_num,unsigned long bio_flags) +int mirror_num,unsigned int compress_type) {struct btrfs_dio_private *dip = bio->bi_private;struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);
Signature · 1 line
2.34.1
David Sterba
maintainerPATCH 9/9 btrfs: rename bio_ctrl::bio_flags to compress_type
In reply to David SterbaThe bio_ctrl is the last use of bio_flags that has been converted to compress type everywhere else.
--- fs/btrfs/extent_io.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
fs/btrfs/extent_io.c +10 -10
@@ -144,7 +144,7 @@ struct tree_entry {*/ struct btrfs_bio_ctrl {struct bio *bio; -unsigned long bio_flags; +unsigned int compress_type;u32 len_to_stripe_boundary;u32 len_to_oe_boundary; };
@@ -3270,10 +3270,10 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,ASSERT (bio);/* The limit should be calculated when bio_ctrl->bio is allocated */ ASSERT (bio_ctrl->len_to_oe_boundary && bio_ctrl->len_to_stripe_boundary); -if (bio_ctrl->bio_flags != compress_type) +if (bio_ctrl->compress_type != compress_type)return 0 ; -if (bio_ctrl->bio_flags !=BTRFS_COMPRESS_NONE ) +if (bio_ctrl->compress_type !=BTRFS_COMPRESS_NONE ) contig = bio->bi_iter.bi_sector == sector;else contig =bio_end_sector (bio) == sector;
@@ -3316,7 +3316,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl,* The split happens for real compressed bio, which happens in * btrfs_submit_compressed_read/write(). */ -if (bio_ctrl->bio_flags !=BTRFS_COMPRESS_NONE ) { +if (bio_ctrl->compress_type !=BTRFS_COMPRESS_NONE ) { bio_ctrl->len_to_oe_boundary =U32_MAX ; bio_ctrl->len_to_stripe_boundary =U32_MAX ;return 0 ;
@@ -3375,7 +3375,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,else bio->bi_iter.bi_sector = (disk_bytenr + offset) >>SECTOR_SHIFT ; bio_ctrl->bio = bio; - bio_ctrl->bio_flags = compress_type; + bio_ctrl->compress_type = compress_type; bio->bi_end_io = end_io_func; bio->bi_private = &inode->io_tree; bio->bi_opf = opf;
@@ -3455,7 +3455,7 @@ static int submit_extent_page(unsigned int opf,ASSERT (pg_offset <PAGE_SIZE && size <=PAGE_SIZE && pg_offset + size <=PAGE_SIZE );if (force_bio_submit && bio_ctrl->bio) { -submit_one_bio (bio_ctrl->bio, mirror_num, bio_ctrl->bio_flags); +submit_one_bio (bio_ctrl->bio, mirror_num, bio_ctrl->compress_type); bio_ctrl->bio =NULL ; }
@@ -3497,7 +3497,7 @@ static int submit_extent_page(unsigned int opf,if (added < size - offset) {/* The bio should contain some page(s) */ ASSERT (bio_ctrl->bio->bi_iter.bi_size); -submit_one_bio (bio_ctrl->bio, mirror_num, bio_ctrl->bio_flags); +submit_one_bio (bio_ctrl->bio, mirror_num, bio_ctrl->compress_type); bio_ctrl->bio =NULL ; } cur += added;
@@ -3814,7 +3814,7 @@ int btrfs_readpage(struct file *file, struct page *page)* bio to do the cleanup. */ if (bio_ctrl.bio) -submit_one_bio (bio_ctrl.bio,0 , bio_ctrl.bio_flags); +submit_one_bio (bio_ctrl.bio,0 , bio_ctrl.compress_type);return ret; }
@@ -5273,7 +5273,7 @@ void extent_readahead(struct readahead_control *rac)free_extent_map (em_cached);if (bio_ctrl.bio) -submit_one_bio (bio_ctrl.bio,0 , bio_ctrl.bio_flags); +submit_one_bio (bio_ctrl.bio,0 , bio_ctrl.compress_type); }/*
@@ -6760,7 +6760,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num) }if (bio_ctrl.bio) { -submit_one_bio (bio_ctrl.bio, mirror_num, bio_ctrl.bio_flags); +submit_one_bio (bio_ctrl.bio, mirror_num, bio_ctrl.compress_type); bio_ctrl.bio =NULL ; }
Signature · 1 line
2.34.1
Re: [PATCH 7/9] btrfs: rename io_failure_record::bio_flags to compress_type
In reply to David Sterbafs/btrfs/extent_io.h struct io_failure_record { · line 272
Quoted 13 lines · David Sterba
fs/btrfs/extent_io.h +1
-1@@ -266,7 +266,7 @@ struct io_failure_record {u64 start;u64 len;u64 logical; -unsigned long bio_flags; +unsigned int compress_type;int this_mirror;int failed_mirror; };
Why 'unsigned int' and not 'enum btrfs_compression_type'?
Re: [PATCH 1/9] btrfs: sink parameter is_data to btrfs_set_disk_extent_flags
In reply to David SterbaLooks good,
Re: [PATCH 2/9] btrfs: remove btrfs_delayed_extent_op::is_data
In reply to David SterbaLooks good,
Re: [PATCH 3/9] btrfs: remove unused parameter bio_flags from btrfs_wq_submit_bio
In reply to David SterbaLooks good,
Re: [PATCH 4/9] btrfs: remove trivial helper update_nr_written
In reply to David SterbaLooks good,
Re: [PATCH 5/9] btrfs: simplify handling of bio_ctrl::bio_flags
In reply to David SterbaLooks good,
Re: [PATCH 6/9] btrfs: open code extent_set_compress_type helpers
In reply to David SterbaLooks good,
Re: [PATCH 7/9] btrfs: rename io_failure_record::bio_flags to compress_type
In reply to Johannes ThumshirnQuoted 17 lines · Johannes Thumshirn
fs/btrfs/extent_io.h struct io_failure_record { · line 272
Quoted 13 lines · David Sterba
fs/btrfs/extent_io.h +1
-1@@ -266,7 +266,7 @@ struct io_failure_record {u64 start;u64 len;u64 logical; -unsigned long bio_flags; +unsigned int compress_type;int this_mirror;int failed_mirror; };Why 'unsigned int' and not 'enum
btrfs_compression_type'?
Good point I'll change it, though it's not used almost anywhere else.
Re: [PATCH 7/9] btrfs: rename io_failure_record::bio_flags to compress_type
Quoted 19 lines · David Sterba
Quoted 17 lines · Johannes Thumshirn
fs/btrfs/extent_io.h struct io_failure_record { · line 272
Quoted 13 lines · David Sterba
fs/btrfs/extent_io.h +1
-1@@ -266,7 +266,7 @@ struct io_failure_record {u64 start;u64 len;u64 logical; -unsigned long bio_flags; +unsigned int compress_type;int this_mirror;int failed_mirror; };Why 'unsigned int' and not 'enum
btrfs_compression_type'?
Quoted 1 line
Good point I'll change it, though it's not used almost anywhere else.
I'll fix up the 2 following patches as well, the type switch in parameters.
Re: [PATCH 7/9] btrfs: rename io_failure_record::bio_flags to compress_type
Quoted 20 lines · David Sterba
Quoted 19 lines · David Sterba
Quoted 17 lines · Johannes Thumshirn
fs/btrfs/extent_io.h struct io_failure_record { · line 272
Quoted 13 lines · David Sterba
fs/btrfs/extent_io.h +1
-1@@ -266,7 +266,7 @@ struct io_failure_record {u64 start;u64 len;u64 logical; -unsigned long bio_flags; +unsigned int compress_type;int this_mirror;int failed_mirror; };Why 'unsigned int' and not 'enum
btrfs_compression_type'?
Quoted 4 lines
Quoted 1 line
Good point I'll change it, though it's not used almost anywhere else.
I'll fix up the 2 following patches as well, the type switch in parameters.
Cool thanks, I was about to ask.
Quoted 14 lines · David Sterba
Simplify some argument passing, remove too-trivial helpers or unused structure members.
David Sterba (9):
btrfs: sink parameteris_datatobtrfs_set_disk_extent_flags
btrfs: removebtrfs_delayed_extent_op::is_data
btrfs: remove unused parameterbio_flagsfrombtrfs_wq_submit_bio
btrfs: remove trivial helperupdate_nr_written
btrfs: simplify handling ofbio_ctrl::bio_flags
btrfs: open codeextent_set_compress_typehelpers
btrfs: renameio_failure_record::bio_flagstocompress_type
btrfs: renamebio_flagsin parameters and switch type
btrfs: renamebio_ctrl::bio_flagstocompress_type
Quoted 12 lines
fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 5 ++- fs/btrfs/delayed-ref.c | 4 +-- fs/btrfs/delayed-ref.h | 1 - fs/btrfs/disk-io.c | 5 ++- fs/btrfs/disk-io.h | 3 +- fs/btrfs/extent-tree.c | 10 +++--- fs/btrfs/extent_io.c | 73 ++++++++++++++++++------------------------ fs/btrfs/extent_io.h | 22 ++----------- fs/btrfs/inode.c | 10 +++--- 10 files changed, 50 insertions(+), 85 deletions(-)
FWIW:
(I did look at the patches that have been merged into misc-next with the compression type fixed up) .
Quoted 31 lines · Nikolay Borisov
Quoted 14 lines · David Sterba
Simplify some argument passing, remove too-trivial helpers or unused structure members.
David Sterba (9):
btrfs: sink parameteris_datatobtrfs_set_disk_extent_flags
btrfs: removebtrfs_delayed_extent_op::is_data
btrfs: remove unused parameterbio_flagsfrombtrfs_wq_submit_bio
btrfs: remove trivial helperupdate_nr_written
btrfs: simplify handling ofbio_ctrl::bio_flags
btrfs: open codeextent_set_compress_typehelpers
btrfs: renameio_failure_record::bio_flagstocompress_type
btrfs: renamebio_flagsin parameters and switch type
btrfs: renamebio_ctrl::bio_flagstocompress_typeQuoted 12 lines
fs/btrfs/ctree.c | 2 +- fs/btrfs/ctree.h | 5 ++- fs/btrfs/delayed-ref.c | 4 +-- fs/btrfs/delayed-ref.h | 1 - fs/btrfs/disk-io.c | 5 ++- fs/btrfs/disk-io.h | 3 +- fs/btrfs/extent-tree.c | 10 +++--- fs/btrfs/extent_io.c | 73 ++++++++++++++++++------------------------ fs/btrfs/extent_io.h | 22 ++----------- fs/btrfs/inode.c | 10 +++--- 10 files changed, 50 insertions(+), 85 deletions(-)
Quoted 6 lines
FWIW:
Reviewed-by Nikolay Borisov <[email protected]>(I did look at the patches that have been merged into misc-next with the compression type fixed up) .
Thanks, commits updated.