Commit 2a5232a8 authored by David Sterba's avatar David Sterba

btrfs: simplify handling of bio_ctrl::bio_flags

The 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.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 572f3dad
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "subpage.h" #include "subpage.h"
#include "zoned.h" #include "zoned.h"
#include "block-group.h" #include "block-group.h"
#include "compression.h"
static struct kmem_cache *extent_state_cache; static struct kmem_cache *extent_state_cache;
static struct kmem_cache *extent_buffer_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 ...@@ -2561,7 +2562,6 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
logical = em->block_start + logical; logical = em->block_start + logical;
if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) { if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) {
logical = em->block_start; logical = em->block_start;
failrec->bio_flags = EXTENT_BIO_COMPRESSED;
extent_set_compress_type(&failrec->bio_flags, em->compress_type); 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, ...@@ -3273,7 +3273,7 @@ static int btrfs_bio_add_page(struct btrfs_bio_ctrl *bio_ctrl,
if (bio_ctrl->bio_flags != bio_flags) if (bio_ctrl->bio_flags != bio_flags)
return 0; 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; contig = bio->bi_iter.bi_sector == sector;
else else
contig = bio_end_sector(bio) == sector; contig = bio_end_sector(bio) == sector;
...@@ -3316,7 +3316,7 @@ static int calc_bio_boundaries(struct btrfs_bio_ctrl *bio_ctrl, ...@@ -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 * The split happens for real compressed bio, which happens in
* btrfs_submit_compressed_read/write(). * 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_oe_boundary = U32_MAX;
bio_ctrl->len_to_stripe_boundary = U32_MAX; bio_ctrl->len_to_stripe_boundary = U32_MAX;
return 0; return 0;
...@@ -3370,7 +3370,7 @@ static int alloc_new_bio(struct btrfs_inode *inode, ...@@ -3370,7 +3370,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,
* For compressed page range, its disk_bytenr is always @disk_bytenr * For compressed page range, its disk_bytenr is always @disk_bytenr
* passed in, no matter if we have added any range into previous bio. * 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; bio->bi_iter.bi_sector = disk_bytenr >> SECTOR_SHIFT;
else else
bio->bi_iter.bi_sector = (disk_bytenr + offset) >> SECTOR_SHIFT; bio->bi_iter.bi_sector = (disk_bytenr + offset) >> SECTOR_SHIFT;
...@@ -3476,7 +3476,7 @@ static int submit_extent_page(unsigned int opf, ...@@ -3476,7 +3476,7 @@ static int submit_extent_page(unsigned int opf,
* We must go through btrfs_bio_add_page() to ensure each * We must go through btrfs_bio_add_page() to ensure each
* page range won't cross various boundaries. * 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, added = btrfs_bio_add_page(bio_ctrl, page, disk_bytenr,
size - offset, pg_offset + offset, size - offset, pg_offset + offset,
bio_flags); bio_flags);
...@@ -3682,7 +3682,6 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, ...@@ -3682,7 +3682,6 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached,
BUG_ON(end < cur); BUG_ON(end < cur);
if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) { if (test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) {
this_bio_flag |= EXTENT_BIO_COMPRESSED;
extent_set_compress_type(&this_bio_flag, extent_set_compress_type(&this_bio_flag,
em->compress_type); em->compress_type);
} }
...@@ -3690,7 +3689,7 @@ static int btrfs_do_readpage(struct page *page, struct extent_map **em_cached, ...@@ -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); iosize = min(extent_map_end(em) - cur, end - cur + 1);
cur_end = min(extent_map_end(em) - 1, end); cur_end = min(extent_map_end(em) - 1, end);
iosize = ALIGN(iosize, blocksize); iosize = ALIGN(iosize, blocksize);
if (this_bio_flag & EXTENT_BIO_COMPRESSED) if (this_bio_flag != BTRFS_COMPRESS_NONE)
disk_bytenr = em->block_start; disk_bytenr = em->block_start;
else else
disk_bytenr = em->block_start + extent_offset; disk_bytenr = em->block_start + extent_offset;
......
...@@ -9,13 +9,6 @@ ...@@ -9,13 +9,6 @@
#include <linux/btrfs_tree.h> #include <linux/btrfs_tree.h>
#include "ulist.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 { enum {
EXTENT_BUFFER_UPTODATE, EXTENT_BUFFER_UPTODATE,
EXTENT_BUFFER_DIRTY, EXTENT_BUFFER_DIRTY,
...@@ -150,12 +143,12 @@ static inline void extent_changeset_free(struct extent_changeset *changeset) ...@@ -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, static inline void extent_set_compress_type(unsigned long *bio_flags,
int compress_type) 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) static inline int extent_compress_type(unsigned long bio_flags)
{ {
return bio_flags >> EXTENT_BIO_FLAG_SHIFT; return bio_flags;
} }
struct extent_map_tree; struct extent_map_tree;
......
...@@ -2602,7 +2602,7 @@ void btrfs_submit_data_bio(struct inode *inode, struct bio *bio, ...@@ -2602,7 +2602,7 @@ void btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
if (ret) if (ret)
goto out; goto out;
if (bio_flags & EXTENT_BIO_COMPRESSED) { if (bio_flags != BTRFS_COMPRESS_NONE) {
/* /*
* btrfs_submit_compressed_read will handle completing * btrfs_submit_compressed_read will handle completing
* the bio if there were any errors, so just return * the bio if there were any errors, so just return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment