* cleanup btrfs bio handling, part 1 v2
@ 2022-04-08 5:08 Christoph Hellwig
2022-04-08 5:08 ` [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio Christoph Hellwig
` (12 more replies)
0 siblings, 13 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Hi all,
this series moves btrfs to use the new as of 5.18 bio interface and
cleans up a few close by areas. Larger cleanups focussed around
the btrfs_bio will follow as a next step.
Changes since v1:
- rebased to btrfs/misc-next
- improve a commit log
Diffstat:
check-integrity.c | 165 +++++++++++++++++++++++++-----------------------------
check-integrity.h | 8 +-
disk-io.c | 6 +
extent_io.c | 55 ++++++++----------
extent_io.h | 2
raid56.c | 46 ++++++---------
scrub.c | 92 ++++++++++++------------------
volumes.c | 12 ++-
8 files changed, 179 insertions(+), 207 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 7:22 ` Qu Wenruo
2022-04-08 5:08 ` [PATCH 02/12] btrfs: split submit_bio from btrfsic checking Christoph Hellwig
` (11 subsequent siblings)
12 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Split out two helpers to mak __btrfsic_submit_bio more readable.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/check-integrity.c | 150 +++++++++++++++++++------------------
1 file changed, 78 insertions(+), 72 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index b8f9dfa326207..ec8a73ff82717 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2633,6 +2633,74 @@ static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev)
&btrfsic_dev_state_hashtable);
}
+static void btrfsic_check_write_bio(struct bio *bio,
+ struct btrfsic_dev_state *dev_state)
+{
+ unsigned int segs = bio_segments(bio);
+ u64 dev_bytenr = 512 * bio->bi_iter.bi_sector;
+ u64 cur_bytenr = dev_bytenr;
+ struct bvec_iter iter;
+ struct bio_vec bvec;
+ char **mapped_datav;
+ int bio_is_patched = 0;
+ int i = 0;
+
+ if (dev_state->state->print_mask & BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
+ pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
+ bio_op(bio), bio->bi_opf, segs,
+ bio->bi_iter.bi_sector, dev_bytenr, bio->bi_bdev);
+
+ mapped_datav = kmalloc_array(segs, sizeof(*mapped_datav), GFP_NOFS);
+ if (!mapped_datav)
+ return;
+
+ bio_for_each_segment(bvec, bio, iter) {
+ BUG_ON(bvec.bv_len != PAGE_SIZE);
+ mapped_datav[i] = page_address(bvec.bv_page);
+ i++;
+
+ if (dev_state->state->print_mask &
+ BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE)
+ pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n",
+ i, cur_bytenr, bvec.bv_len, bvec.bv_offset);
+ cur_bytenr += bvec.bv_len;
+ }
+
+ btrfsic_process_written_block(dev_state, dev_bytenr, mapped_datav, segs,
+ bio, &bio_is_patched, bio->bi_opf);
+ kfree(mapped_datav);
+}
+
+static void btrfsic_check_flush_bio(struct bio *bio,
+ struct btrfsic_dev_state *dev_state)
+{
+ if (dev_state->state->print_mask & BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
+ pr_info("submit_bio(rw=%d,0x%x FLUSH, bdev=%p)\n",
+ bio_op(bio), bio->bi_opf, bio->bi_bdev);
+
+ if (dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
+ struct btrfsic_block *const block =
+ &dev_state->dummy_block_for_bio_bh_flush;
+
+ block->is_iodone = 0;
+ block->never_written = 0;
+ block->iodone_w_error = 0;
+ block->flush_gen = dev_state->last_flush_gen + 1;
+ block->submit_bio_bh_rw = bio->bi_opf;
+ block->orig_bio_private = bio->bi_private;
+ block->orig_bio_end_io = bio->bi_end_io;
+ block->next_in_same_bio = NULL;
+ bio->bi_private = block;
+ bio->bi_end_io = btrfsic_bio_end_io;
+ } else if ((dev_state->state->print_mask &
+ (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
+ BTRFSIC_PRINT_MASK_VERBOSE))) {
+ pr_info(
+"btrfsic_submit_bio(%pg) with FLUSH but dummy block already in use (ignored)!\n",
+ dev_state->bdev);
+ }
+}
+
static void __btrfsic_submit_bio(struct bio *bio)
{
struct btrfsic_dev_state *dev_state;
@@ -2640,80 +2708,18 @@ static void __btrfsic_submit_bio(struct bio *bio)
if (!btrfsic_is_initialized)
return;
- mutex_lock(&btrfsic_mutex);
- /* since btrfsic_submit_bio() is also called before
- * btrfsic_mount(), this might return NULL */
+ /*
+ * We can be called before btrfsic_mount, so there might not be a
+ * dev_state.
+ */
dev_state = btrfsic_dev_state_lookup(bio->bi_bdev->bd_dev);
- if (NULL != dev_state &&
- (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
- int i = 0;
- u64 dev_bytenr;
- u64 cur_bytenr;
- struct bio_vec bvec;
- struct bvec_iter iter;
- int bio_is_patched;
- char **mapped_datav;
- unsigned int segs = bio_segments(bio);
-
- dev_bytenr = 512 * bio->bi_iter.bi_sector;
- bio_is_patched = 0;
- if (dev_state->state->print_mask &
- BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
- pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
- bio_op(bio), bio->bi_opf, segs,
- bio->bi_iter.bi_sector, dev_bytenr, bio->bi_bdev);
-
- mapped_datav = kmalloc_array(segs,
- sizeof(*mapped_datav), GFP_NOFS);
- if (!mapped_datav)
- goto leave;
- cur_bytenr = dev_bytenr;
-
- bio_for_each_segment(bvec, bio, iter) {
- BUG_ON(bvec.bv_len != PAGE_SIZE);
- mapped_datav[i] = page_address(bvec.bv_page);
- i++;
-
- if (dev_state->state->print_mask &
- BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE)
- pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n",
- i, cur_bytenr, bvec.bv_len, bvec.bv_offset);
- cur_bytenr += bvec.bv_len;
- }
- btrfsic_process_written_block(dev_state, dev_bytenr,
- mapped_datav, segs,
- bio, &bio_is_patched,
- bio->bi_opf);
- kfree(mapped_datav);
- } else if (NULL != dev_state && (bio->bi_opf & REQ_PREFLUSH)) {
- if (dev_state->state->print_mask &
- BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
- pr_info("submit_bio(rw=%d,0x%x FLUSH, bdev=%p)\n",
- bio_op(bio), bio->bi_opf, bio->bi_bdev);
- if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
- if ((dev_state->state->print_mask &
- (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
- BTRFSIC_PRINT_MASK_VERBOSE)))
- pr_info(
-"btrfsic_submit_bio(%pg) with FLUSH but dummy block already in use (ignored)!\n",
- dev_state->bdev);
- } else {
- struct btrfsic_block *const block =
- &dev_state->dummy_block_for_bio_bh_flush;
-
- block->is_iodone = 0;
- block->never_written = 0;
- block->iodone_w_error = 0;
- block->flush_gen = dev_state->last_flush_gen + 1;
- block->submit_bio_bh_rw = bio->bi_opf;
- block->orig_bio_private = bio->bi_private;
- block->orig_bio_end_io = bio->bi_end_io;
- block->next_in_same_bio = NULL;
- bio->bi_private = block;
- bio->bi_end_io = btrfsic_bio_end_io;
- }
+ mutex_lock(&btrfsic_mutex);
+ if (dev_state) {
+ if (bio_op(bio) == REQ_OP_WRITE && bio_has_data(bio))
+ btrfsic_check_write_bio(bio, dev_state);
+ else if (bio->bi_opf & REQ_PREFLUSH)
+ btrfsic_check_flush_bio(bio, dev_state);
}
-leave:
mutex_unlock(&btrfsic_mutex);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/12] btrfs: split submit_bio from btrfsic checking
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
2022-04-08 5:08 ` [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 03/12] btrfs: simplify btrfsic_read_block Christoph Hellwig
` (10 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Require a separate call to the integrity checking helpers from the
actual bio submission.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/check-integrity.c | 14 +-------------
fs/btrfs/check-integrity.h | 8 ++++----
fs/btrfs/disk-io.c | 6 ++++--
fs/btrfs/extent_io.c | 3 ++-
fs/btrfs/scrub.c | 12 ++++++++----
fs/btrfs/volumes.c | 3 ++-
6 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index ec8a73ff82717..9efd33b4e24d7 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2701,7 +2701,7 @@ static void btrfsic_check_flush_bio(struct bio *bio,
}
}
-static void __btrfsic_submit_bio(struct bio *bio)
+void btrfsic_check_bio(struct bio *bio)
{
struct btrfsic_dev_state *dev_state;
@@ -2723,18 +2723,6 @@ static void __btrfsic_submit_bio(struct bio *bio)
mutex_unlock(&btrfsic_mutex);
}
-void btrfsic_submit_bio(struct bio *bio)
-{
- __btrfsic_submit_bio(bio);
- submit_bio(bio);
-}
-
-int btrfsic_submit_bio_wait(struct bio *bio)
-{
- __btrfsic_submit_bio(bio);
- return submit_bio_wait(bio);
-}
-
int btrfsic_mount(struct btrfs_fs_info *fs_info,
struct btrfs_fs_devices *fs_devices,
int including_extent_data, u32 print_mask)
diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h
index bcc730a06cb58..ed115e0f2ebbd 100644
--- a/fs/btrfs/check-integrity.h
+++ b/fs/btrfs/check-integrity.h
@@ -7,11 +7,11 @@
#define BTRFS_CHECK_INTEGRITY_H
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
-void btrfsic_submit_bio(struct bio *bio);
-int btrfsic_submit_bio_wait(struct bio *bio);
+void btrfsic_check_bio(struct bio *bio);
#else
-#define btrfsic_submit_bio submit_bio
-#define btrfsic_submit_bio_wait submit_bio_wait
+static inline void btrfsic_check_bio(struct bio *bio)
+{
+}
#endif
int btrfsic_mount(struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index dfec67e8a78c7..2bc867d353087 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4167,7 +4167,8 @@ static int write_dev_supers(struct btrfs_device *device,
if (i == 0 && !btrfs_test_opt(device->fs_info, NOBARRIER))
bio->bi_opf |= REQ_FUA;
- btrfsic_submit_bio(bio);
+ btrfsic_check_bio(bio);
+ submit_bio(bio);
if (btrfs_advance_sb_log(device, i))
errors++;
@@ -4280,7 +4281,8 @@ static void write_dev_flush(struct btrfs_device *device)
init_completion(&device->flush_wait);
bio->bi_private = &device->flush_wait;
- btrfsic_submit_bio(bio);
+ btrfsic_check_bio(bio);
+ submit_bio(bio);
set_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state);
}
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 4bcc182744e48..9d5bc6598489b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2368,7 +2368,8 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
bio_add_page(bio, page, length, pg_offset);
- if (btrfsic_submit_bio_wait(bio)) {
+ btrfsic_check_bio(bio);
+ if (submit_bio_wait(bio)) {
/* try to remap that extent elsewhere? */
btrfs_bio_counter_dec(fs_info);
bio_put(bio);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 5c979f7411937..a4f9cfdec8b60 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1475,7 +1475,8 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
bio->bi_iter.bi_sector = sector->physical >> 9;
bio->bi_opf = REQ_OP_READ;
- if (btrfsic_submit_bio_wait(bio)) {
+ btrfsic_check_bio(bio);
+ if (submit_bio_wait(bio)) {
sector->io_error = 1;
sblock->no_io_error_seen = 0;
}
@@ -1559,7 +1560,8 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad,
return -EIO;
}
- if (btrfsic_submit_bio_wait(bio)) {
+ btrfsic_check_bio(bio);
+ if (submit_bio_wait(bio)) {
btrfs_dev_stat_inc_and_print(sector_bad->dev,
BTRFS_DEV_STAT_WRITE_ERRS);
atomic64_inc(&fs_info->dev_replace.num_write_errors);
@@ -1715,7 +1717,8 @@ static void scrub_wr_submit(struct scrub_ctx *sctx)
* orders the requests before sending them to the driver which
* doubled the write performance on spinning disks when measured
* with Linux 3.5 */
- btrfsic_submit_bio(sbio->bio);
+ btrfsic_check_bio(sbio->bio);
+ submit_bio(sbio->bio);
if (btrfs_is_zoned(sctx->fs_info))
sctx->write_pointer = sbio->physical + sbio->sector_count *
@@ -2049,7 +2052,8 @@ static void scrub_submit(struct scrub_ctx *sctx)
sbio = sctx->bios[sctx->curr];
sctx->curr = -1;
scrub_pending_bio_inc(sctx);
- btrfsic_submit_bio(sbio->bio);
+ btrfsic_check_bio(sbio->bio);
+ submit_bio(sbio->bio);
}
static int scrub_add_sector_to_rd_bio(struct scrub_ctx *sctx,
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 26ada24890a5a..6b49d78d15029 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6742,7 +6742,8 @@ static void submit_stripe_bio(struct btrfs_io_context *bioc, struct bio *bio,
btrfs_bio_counter_inc_noblocked(fs_info);
- btrfsic_submit_bio(bio);
+ btrfsic_check_bio(bio);
+ submit_bio(bio);
}
static void bioc_error(struct btrfs_io_context *bioc, struct bio *bio, u64 logical)
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/12] btrfs: simplify btrfsic_read_block
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
2022-04-08 5:08 ` [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio Christoph Hellwig
2022-04-08 5:08 ` [PATCH 02/12] btrfs: split submit_bio from btrfsic checking Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 7:23 ` Qu Wenruo
2022-04-08 5:08 ` [PATCH 04/12] btrfs: simplify repair_io_failure Christoph Hellwig
` (9 subsequent siblings)
12 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
btrfsic_read_block does not need the btrfs_bio structure, so switch to
plain bio_alloc.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/check-integrity.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 9efd33b4e24d7..864a90e825050 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1561,10 +1561,9 @@ static int btrfsic_read_block(struct btrfsic_state *state,
struct bio *bio;
unsigned int j;
- bio = btrfs_bio_alloc(num_pages - i);
- bio_set_dev(bio, block_ctx->dev->bdev);
+ bio = bio_alloc(block_ctx->dev->bdev, num_pages - i,
+ REQ_OP_READ, GFP_NOFS);
bio->bi_iter.bi_sector = dev_bytenr >> 9;
- bio->bi_opf = REQ_OP_READ;
for (j = i; j < num_pages; j++) {
ret = bio_add_page(bio, block_ctx->pagev[j],
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 04/12] btrfs: simplify repair_io_failure
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (2 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 03/12] btrfs: simplify btrfsic_read_block Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 05/12] btrfs: simplify scrub_recheck_block Christoph Hellwig
` (8 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
The I/O in repair_io_failue is synchronous and doesn't need a btrfs_bio,
so just use an on-stack bio. Also cleanup the error handling to use goto
labels and not discard the actual return values.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/extent_io.c | 52 ++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 28 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9d5bc6598489b..ede7a72fe840c 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2305,12 +2305,13 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
u64 length, u64 logical, struct page *page,
unsigned int pg_offset, int mirror_num)
{
- struct bio *bio;
struct btrfs_device *dev;
+ struct bio_vec bvec;
+ struct bio bio;
u64 map_length = 0;
u64 sector;
struct btrfs_io_context *bioc = NULL;
- int ret;
+ int ret = 0;
ASSERT(!(fs_info->sb->s_flags & SB_RDONLY));
BUG_ON(!mirror_num);
@@ -2318,8 +2319,6 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
if (btrfs_repair_one_zone(fs_info, logical))
return 0;
- bio = btrfs_bio_alloc(1);
- bio->bi_iter.bi_size = 0;
map_length = length;
/*
@@ -2337,53 +2336,50 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
*/
ret = btrfs_map_block(fs_info, BTRFS_MAP_READ, logical,
&map_length, &bioc, 0);
- if (ret) {
- btrfs_bio_counter_dec(fs_info);
- bio_put(bio);
- return -EIO;
- }
+ if (ret)
+ goto out_counter_dec;
ASSERT(bioc->mirror_num == 1);
} else {
ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, logical,
&map_length, &bioc, mirror_num);
- if (ret) {
- btrfs_bio_counter_dec(fs_info);
- bio_put(bio);
- return -EIO;
- }
+ if (ret)
+ goto out_counter_dec;
BUG_ON(mirror_num != bioc->mirror_num);
}
sector = bioc->stripes[bioc->mirror_num - 1].physical >> 9;
- bio->bi_iter.bi_sector = sector;
dev = bioc->stripes[bioc->mirror_num - 1].dev;
btrfs_put_bioc(bioc);
+
if (!dev || !dev->bdev ||
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {
- btrfs_bio_counter_dec(fs_info);
- bio_put(bio);
- return -EIO;
+ ret = -EIO;
+ goto out_counter_dec;
}
- bio_set_dev(bio, dev->bdev);
- bio->bi_opf = REQ_OP_WRITE | REQ_SYNC;
- bio_add_page(bio, page, length, pg_offset);
- btrfsic_check_bio(bio);
- if (submit_bio_wait(bio)) {
+ bio_init(&bio, dev->bdev, &bvec, 1, REQ_OP_WRITE | REQ_SYNC);
+ bio.bi_iter.bi_sector = sector;
+ __bio_add_page(&bio, page, length, pg_offset);
+
+ btrfsic_check_bio(&bio);
+ ret = submit_bio_wait(&bio);
+ if (ret) {
/* try to remap that extent elsewhere? */
- btrfs_bio_counter_dec(fs_info);
- bio_put(bio);
btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS);
- return -EIO;
+ goto out_bio_uninit;
}
btrfs_info_rl_in_rcu(fs_info,
"read error corrected: ino %llu off %llu (dev %s sector %llu)",
ino, start,
rcu_str_deref(dev->name), sector);
+ ret = 0;
+
+out_bio_uninit:
+ bio_uninit(&bio);
+out_counter_dec:
btrfs_bio_counter_dec(fs_info);
- bio_put(bio);
- return 0;
+ return ret;
}
int btrfs_repair_eb_io_failure(const struct extent_buffer *eb, int mirror_num)
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 05/12] btrfs: simplify scrub_recheck_block
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (3 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 04/12] btrfs: simplify repair_io_failure Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 06/12] btrfs: simplify scrub_repair_page_from_good_copy Christoph Hellwig
` (7 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
The I/O in repair_io_failue is synchronous and doesn't need a btrfs_bio,
so just use an on-stack bio.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/scrub.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index a4f9cfdec8b60..3790747c449b0 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1458,8 +1458,9 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
return scrub_recheck_block_on_raid56(fs_info, sblock);
for (i = 0; i < sblock->sector_count; i++) {
- struct bio *bio;
struct scrub_sector *sector = sblock->sectors[i];
+ struct bio_vec bvec;
+ struct bio bio;
if (sector->dev->bdev == NULL) {
sector->io_error = 1;
@@ -1468,20 +1469,17 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
}
WARN_ON(!sector->page);
- bio = btrfs_bio_alloc(1);
- bio_set_dev(bio, sector->dev->bdev);
-
- bio_add_page(bio, sector->page, fs_info->sectorsize, 0);
- bio->bi_iter.bi_sector = sector->physical >> 9;
- bio->bi_opf = REQ_OP_READ;
+ bio_init(&bio, sector->dev->bdev, &bvec, 1, REQ_OP_READ);
+ bio_add_page(&bio, sector->page, fs_info->sectorsize, 0);
+ bio.bi_iter.bi_sector = sector->physical >> 9;
- btrfsic_check_bio(bio);
- if (submit_bio_wait(bio)) {
+ btrfsic_check_bio(&bio);
+ if (submit_bio_wait(&bio)) {
sector->io_error = 1;
sblock->no_io_error_seen = 0;
}
- bio_put(bio);
+ bio_uninit(&bio);
}
if (sblock->no_io_error_seen)
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 06/12] btrfs: simplify scrub_repair_page_from_good_copy
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (4 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 05/12] btrfs: simplify scrub_recheck_block Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio Christoph Hellwig
` (6 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
The I/O in repair_io_failue is synchronous and doesn't need a btrfs_bio,
so just use an on-stack bio.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/scrub.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 3790747c449b0..fe25a0d3d7c2d 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1538,7 +1538,8 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad,
BUG_ON(sector_good->page == NULL);
if (force_write || sblock_bad->header_error ||
sblock_bad->checksum_error || sector_bad->io_error) {
- struct bio *bio;
+ struct bio_vec bvec;
+ struct bio bio;
int ret;
if (!sector_bad->dev->bdev) {
@@ -1547,26 +1548,20 @@ static int scrub_repair_sector_from_good_copy(struct scrub_block *sblock_bad,
return -EIO;
}
- bio = btrfs_bio_alloc(1);
- bio_set_dev(bio, sector_bad->dev->bdev);
- bio->bi_iter.bi_sector = sector_bad->physical >> 9;
- bio->bi_opf = REQ_OP_WRITE;
+ bio_init(&bio, sector_bad->dev->bdev, &bvec, 1, REQ_OP_WRITE);
+ bio.bi_iter.bi_sector = sector_bad->physical >> 9;
+ __bio_add_page(&bio, sector_good->page, sectorsize, 0);
- ret = bio_add_page(bio, sector_good->page, sectorsize, 0);
- if (ret != sectorsize) {
- bio_put(bio);
- return -EIO;
- }
+ btrfsic_check_bio(&bio);
+ ret = submit_bio_wait(&bio);
+ bio_uninit(&bio);
- btrfsic_check_bio(bio);
- if (submit_bio_wait(bio)) {
+ if (ret) {
btrfs_dev_stat_inc_and_print(sector_bad->dev,
BTRFS_DEV_STAT_WRITE_ERRS);
atomic64_inc(&fs_info->dev_replace.num_write_errors);
- bio_put(bio);
return -EIO;
}
- bio_put(bio);
}
return 0;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (5 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 06/12] btrfs: simplify scrub_repair_page_from_good_copy Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 7:27 ` Qu Wenruo
2022-04-08 5:08 ` [PATCH 08/12] btrfs: pass a block_device to btrfs_bio_clone Christoph Hellwig
` (5 subsequent siblings)
12 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Prepare for additional refactoring.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/volumes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6b49d78d15029..8e066b9ebfbde 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6738,7 +6738,6 @@ static void submit_stripe_bio(struct btrfs_io_context *bioc, struct bio *bio,
bio_op(bio), bio->bi_opf, bio->bi_iter.bi_sector,
(unsigned long)dev->bdev->bd_dev, rcu_str_deref(dev->name),
dev->devid, bio->bi_iter.bi_size);
- bio_set_dev(bio, dev->bdev);
btrfs_bio_counter_inc_noblocked(fs_info);
@@ -6830,6 +6829,7 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
else
bio = first_bio;
+ bio_set_dev(bio, dev->bdev);
submit_stripe_bio(bioc, bio, bioc->stripes[dev_nr].physical, dev);
}
btrfs_bio_counter_dec(fs_info);
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 08/12] btrfs: pass a block_device to btrfs_bio_clone
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (6 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 09/12] btrfs: initialize ->bi_opf and ->bi_private in rbio_add_io_page Christoph Hellwig
` (4 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Pass the block_device to btrfs_bio_clone so that it can be paased on to
bio_alloc_clone instead of setting it later.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/extent_io.c | 4 ++--
fs/btrfs/extent_io.h | 2 +-
fs/btrfs/volumes.c | 9 +++++----
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ede7a72fe840c..1a5a7ded31758 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3188,13 +3188,13 @@ struct bio *btrfs_bio_alloc(unsigned int nr_iovecs)
return bio;
}
-struct bio *btrfs_bio_clone(struct bio *bio)
+struct bio *btrfs_bio_clone(struct block_device *bdev, struct bio *bio)
{
struct btrfs_bio *bbio;
struct bio *new;
/* Bio allocation backed by a bioset does not fail */
- new = bio_alloc_clone(bio->bi_bdev, bio, GFP_NOFS, &btrfs_bioset);
+ new = bio_alloc_clone(bdev, bio, GFP_NOFS, &btrfs_bioset);
bbio = btrfs_bio(new);
btrfs_bio_init(bbio);
bbio->iter = bio->bi_iter;
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 1331902c75815..05253612ce7bb 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -280,7 +280,7 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array);
struct bio *btrfs_bio_alloc(unsigned int nr_iovecs);
-struct bio *btrfs_bio_clone(struct bio *bio);
+struct bio *btrfs_bio_clone(struct block_device *bdev, struct bio *bio);
struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size);
void end_extent_writepage(struct page *page, int err, u64 start, u64 end);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8e066b9ebfbde..2368a2ffbee75 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6824,12 +6824,13 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
continue;
}
- if (dev_nr < total_devs - 1)
- bio = btrfs_bio_clone(first_bio);
- else
+ if (dev_nr < total_devs - 1) {
+ bio = btrfs_bio_clone(dev->bdev, first_bio);
+ } else {
bio = first_bio;
+ bio_set_dev(bio, dev->bdev);
+ }
- bio_set_dev(bio, dev->bdev);
submit_stripe_bio(bioc, bio, bioc->stripes[dev_nr].physical, dev);
}
btrfs_bio_counter_dec(fs_info);
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/12] btrfs: initialize ->bi_opf and ->bi_private in rbio_add_io_page
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (7 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 08/12] btrfs: pass a block_device to btrfs_bio_clone Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 10/12] btrfs: don't allocate a btrfs_bio for raid56 per-stripe bios Christoph Hellwig
` (3 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Prepare for further refactoring by moving this initialization to a single
place.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/raid56.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index ba6f6be771213..13a998628b90b 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1048,7 +1048,8 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
struct page *page,
int stripe_nr,
unsigned long page_index,
- unsigned long bio_max_len)
+ unsigned long bio_max_len,
+ unsigned int opf)
{
struct bio *last = bio_list->tail;
int ret;
@@ -1085,7 +1086,9 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
btrfs_bio(bio)->device = stripe->dev;
bio->bi_iter.bi_size = 0;
bio_set_dev(bio, stripe->dev->bdev);
+ bio->bi_opf = opf;
bio->bi_iter.bi_sector = disk_start >> 9;
+ bio->bi_private = rbio;
bio_add_page(bio, page, PAGE_SIZE, 0);
bio_list_add(bio_list, bio);
@@ -1254,7 +1257,8 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
}
ret = rbio_add_io_page(rbio, &bio_list,
- page, stripe, pagenr, rbio->stripe_len);
+ page, stripe, pagenr, rbio->stripe_len,
+ REQ_OP_WRITE);
if (ret)
goto cleanup;
}
@@ -1279,7 +1283,8 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
ret = rbio_add_io_page(rbio, &bio_list, page,
rbio->bioc->tgtdev_map[stripe],
- pagenr, rbio->stripe_len);
+ pagenr, rbio->stripe_len,
+ REQ_OP_WRITE);
if (ret)
goto cleanup;
}
@@ -1290,9 +1295,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
BUG_ON(atomic_read(&rbio->stripes_pending) == 0);
while ((bio = bio_list_pop(&bio_list))) {
- bio->bi_private = rbio;
bio->bi_end_io = raid_write_end_io;
- bio->bi_opf = REQ_OP_WRITE;
submit_bio(bio);
}
@@ -1496,7 +1499,8 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
continue;
ret = rbio_add_io_page(rbio, &bio_list, page,
- stripe, pagenr, rbio->stripe_len);
+ stripe, pagenr, rbio->stripe_len,
+ REQ_OP_READ);
if (ret)
goto cleanup;
}
@@ -1519,9 +1523,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio)
*/
atomic_set(&rbio->stripes_pending, bios_to_read);
while ((bio = bio_list_pop(&bio_list))) {
- bio->bi_private = rbio;
bio->bi_end_io = raid_rmw_end_io;
- bio->bi_opf = REQ_OP_READ;
btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56);
@@ -2038,7 +2040,8 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
ret = rbio_add_io_page(rbio, &bio_list,
rbio_stripe_page(rbio, stripe, pagenr),
- stripe, pagenr, rbio->stripe_len);
+ stripe, pagenr, rbio->stripe_len,
+ REQ_OP_READ);
if (ret < 0)
goto cleanup;
}
@@ -2065,9 +2068,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
*/
atomic_set(&rbio->stripes_pending, bios_to_read);
while ((bio = bio_list_pop(&bio_list))) {
- bio->bi_private = rbio;
bio->bi_end_io = raid_recover_end_io;
- bio->bi_opf = REQ_OP_READ;
btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56);
@@ -2398,8 +2399,8 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
struct page *page;
page = rbio_stripe_page(rbio, rbio->scrubp, pagenr);
- ret = rbio_add_io_page(rbio, &bio_list,
- page, rbio->scrubp, pagenr, rbio->stripe_len);
+ ret = rbio_add_io_page(rbio, &bio_list, page, rbio->scrubp,
+ pagenr, rbio->stripe_len, REQ_OP_WRITE);
if (ret)
goto cleanup;
}
@@ -2413,7 +2414,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
page = rbio_stripe_page(rbio, rbio->scrubp, pagenr);
ret = rbio_add_io_page(rbio, &bio_list, page,
bioc->tgtdev_map[rbio->scrubp],
- pagenr, rbio->stripe_len);
+ pagenr, rbio->stripe_len, REQ_OP_WRITE);
if (ret)
goto cleanup;
}
@@ -2429,9 +2430,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
atomic_set(&rbio->stripes_pending, nr_data);
while ((bio = bio_list_pop(&bio_list))) {
- bio->bi_private = rbio;
bio->bi_end_io = raid_write_end_io;
- bio->bi_opf = REQ_OP_WRITE;
submit_bio(bio);
}
@@ -2583,8 +2582,9 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio)
if (PageUptodate(page))
continue;
- ret = rbio_add_io_page(rbio, &bio_list, page,
- stripe, pagenr, rbio->stripe_len);
+ ret = rbio_add_io_page(rbio, &bio_list, page, stripe,
+ pagenr, rbio->stripe_len,
+ REQ_OP_READ);
if (ret)
goto cleanup;
}
@@ -2607,9 +2607,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio)
*/
atomic_set(&rbio->stripes_pending, bios_to_read);
while ((bio = bio_list_pop(&bio_list))) {
- bio->bi_private = rbio;
bio->bi_end_io = raid56_parity_scrub_end_io;
- bio->bi_opf = REQ_OP_READ;
btrfs_bio_wq_end_io(rbio->bioc->fs_info, bio, BTRFS_WQ_ENDIO_RAID56);
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 10/12] btrfs: don't allocate a btrfs_bio for raid56 per-stripe bios
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (8 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 09/12] btrfs: initialize ->bi_opf and ->bi_private in rbio_add_io_page Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 11/12] btrfs: don't allocate a btrfs_bio for scrub bios Christoph Hellwig
` (2 subsequent siblings)
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
Except for the spurious initialization of ->device just after allocation
nothing uses the btrfs_bio, so just allocate a normal bio without extra
data.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/raid56.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 13a998628b90b..1ab77d658bf15 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1082,11 +1082,8 @@ static int rbio_add_io_page(struct btrfs_raid_bio *rbio,
}
/* put a new bio on the list */
- bio = btrfs_bio_alloc(bio_max_len >> PAGE_SHIFT ?: 1);
- btrfs_bio(bio)->device = stripe->dev;
- bio->bi_iter.bi_size = 0;
- bio_set_dev(bio, stripe->dev->bdev);
- bio->bi_opf = opf;
+ bio = bio_alloc(stripe->dev->bdev, max(bio_max_len >> PAGE_SHIFT, 1UL),
+ opf, GFP_NOFS);
bio->bi_iter.bi_sector = disk_start >> 9;
bio->bi_private = rbio;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 11/12] btrfs: don't allocate a btrfs_bio for scrub bios
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (9 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 10/12] btrfs: don't allocate a btrfs_bio for raid56 per-stripe bios Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 5:08 ` [PATCH 12/12] btrfs: stop using the btrfs_bio saved iter in index_rbio_pages Christoph Hellwig
2022-04-08 16:00 ` cleanup btrfs bio handling, part 1 v2 David Sterba
12 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
All the scrub bios go straight to the block device or the raid56 code,
none of which looks at the btrfs_bio.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/scrub.c | 47 ++++++++++++++++++-----------------------------
1 file changed, 18 insertions(+), 29 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index fe25a0d3d7c2d..7de6479020a1b 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1411,8 +1411,8 @@ static void scrub_recheck_block_on_raid56(struct btrfs_fs_info *fs_info,
if (!first_sector->dev->bdev)
goto out;
- bio = btrfs_bio_alloc(BIO_MAX_VECS);
- bio_set_dev(bio, first_sector->dev->bdev);
+ bio = bio_alloc(first_sector->dev->bdev, BIO_MAX_VECS, REQ_OP_READ,
+ GFP_NOFS);
for (i = 0; i < sblock->sector_count; i++) {
struct scrub_sector *sector = sblock->sectors[i];
@@ -1642,8 +1642,6 @@ static int scrub_add_sector_to_wr_bio(struct scrub_ctx *sctx,
}
sbio = sctx->wr_curr_bio;
if (sbio->sector_count == 0) {
- struct bio *bio;
-
ret = fill_writer_pointer_gap(sctx, sector->physical_for_dev_replace);
if (ret) {
mutex_unlock(&sctx->wr_lock);
@@ -1653,17 +1651,14 @@ static int scrub_add_sector_to_wr_bio(struct scrub_ctx *sctx,
sbio->physical = sector->physical_for_dev_replace;
sbio->logical = sector->logical;
sbio->dev = sctx->wr_tgtdev;
- bio = sbio->bio;
- if (!bio) {
- bio = btrfs_bio_alloc(sctx->sectors_per_bio);
- sbio->bio = bio;
+ if (!sbio->bio) {
+ sbio->bio = bio_alloc(sbio->dev->bdev,
+ sctx->sectors_per_bio,
+ REQ_OP_WRITE, GFP_NOFS);
}
-
- bio->bi_private = sbio;
- bio->bi_end_io = scrub_wr_bio_end_io;
- bio_set_dev(bio, sbio->dev->bdev);
- bio->bi_iter.bi_sector = sbio->physical >> 9;
- bio->bi_opf = REQ_OP_WRITE;
+ sbio->bio->bi_private = sbio;
+ sbio->bio->bi_end_io = scrub_wr_bio_end_io;
+ sbio->bio->bi_iter.bi_sector = sbio->physical >> 9;
sbio->status = 0;
} else if (sbio->physical + sbio->sector_count * sectorsize !=
sector->physical_for_dev_replace ||
@@ -1704,7 +1699,6 @@ static void scrub_wr_submit(struct scrub_ctx *sctx)
sbio = sctx->wr_curr_bio;
sctx->wr_curr_bio = NULL;
- WARN_ON(!sbio->bio->bi_bdev);
scrub_pending_bio_inc(sctx);
/* process all writes in a single worker thread. Then the block layer
* orders the requests before sending them to the driver which
@@ -2076,22 +2070,17 @@ static int scrub_add_sector_to_rd_bio(struct scrub_ctx *sctx,
}
sbio = sctx->bios[sctx->curr];
if (sbio->sector_count == 0) {
- struct bio *bio;
-
sbio->physical = sector->physical;
sbio->logical = sector->logical;
sbio->dev = sector->dev;
- bio = sbio->bio;
- if (!bio) {
- bio = btrfs_bio_alloc(sctx->sectors_per_bio);
- sbio->bio = bio;
+ if (!sbio->bio) {
+ sbio->bio = bio_alloc(sbio->dev->bdev,
+ sctx->sectors_per_bio,
+ REQ_OP_READ, GFP_NOFS);
}
-
- bio->bi_private = sbio;
- bio->bi_end_io = scrub_bio_end_io;
- bio_set_dev(bio, sbio->dev->bdev);
- bio->bi_iter.bi_sector = sbio->physical >> 9;
- bio->bi_opf = REQ_OP_READ;
+ sbio->bio->bi_private = sbio;
+ sbio->bio->bi_end_io = scrub_bio_end_io;
+ sbio->bio->bi_iter.bi_sector = sbio->physical >> 9;
sbio->status = 0;
} else if (sbio->physical + sbio->sector_count * sectorsize !=
sector->physical ||
@@ -2207,7 +2196,7 @@ static void scrub_missing_raid56_pages(struct scrub_block *sblock)
goto bioc_out;
}
- bio = btrfs_bio_alloc(BIO_MAX_VECS);
+ bio = bio_alloc(NULL, BIO_MAX_VECS, REQ_OP_READ, GFP_NOFS);
bio->bi_iter.bi_sector = logical >> 9;
bio->bi_private = sblock;
bio->bi_end_io = scrub_missing_raid56_end_io;
@@ -2823,7 +2812,7 @@ static void scrub_parity_check_and_repair(struct scrub_parity *sparity)
if (ret || !bioc || !bioc->raid_map)
goto bioc_out;
- bio = btrfs_bio_alloc(BIO_MAX_VECS);
+ bio = bio_alloc(NULL, BIO_MAX_VECS, REQ_OP_READ, GFP_NOFS);
bio->bi_iter.bi_sector = sparity->logic_start >> 9;
bio->bi_private = sparity;
bio->bi_end_io = scrub_parity_bio_endio;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 12/12] btrfs: stop using the btrfs_bio saved iter in index_rbio_pages
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (10 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 11/12] btrfs: don't allocate a btrfs_bio for scrub bios Christoph Hellwig
@ 2022-04-08 5:08 ` Christoph Hellwig
2022-04-08 7:37 ` Qu Wenruo
2022-04-08 16:00 ` cleanup btrfs bio handling, part 1 v2 David Sterba
12 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-08 5:08 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo; +Cc: Naohiro Aota, linux-btrfs
The bios added to ->bio_list are the original bios fed into
btrfs_map_bio, which are never advanced. Just use the iter in the
bio itself.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/raid56.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 1ab77d658bf15..adc62a7352b82 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1134,9 +1134,6 @@ static void index_rbio_pages(struct btrfs_raid_bio *rbio)
stripe_offset = start - rbio->bioc->raid_map[0];
page_index = stripe_offset >> PAGE_SHIFT;
- if (bio_flagged(bio, BIO_CLONED))
- bio->bi_iter = btrfs_bio(bio)->iter;
-
bio_for_each_segment(bvec, bio, iter) {
rbio->bio_pages[page_index + i] = bvec.bv_page;
i++;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio
2022-04-08 5:08 ` [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio Christoph Hellwig
@ 2022-04-08 7:22 ` Qu Wenruo
0 siblings, 0 replies; 20+ messages in thread
From: Qu Wenruo @ 2022-04-08 7:22 UTC (permalink / raw)
To: Christoph Hellwig, Josef Bacik, David Sterba, Qu Wenruo
Cc: Naohiro Aota, linux-btrfs
On 2022/4/8 13:08, Christoph Hellwig wrote:
> Split out two helpers to mak __btrfsic_submit_bio more readable.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
The refactor itself is already pretty good.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/check-integrity.c | 150 +++++++++++++++++++------------------
> 1 file changed, 78 insertions(+), 72 deletions(-)
>
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index b8f9dfa326207..ec8a73ff82717 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -2633,6 +2633,74 @@ static struct btrfsic_dev_state *btrfsic_dev_state_lookup(dev_t dev)
> &btrfsic_dev_state_hashtable);
> }
>
> +static void btrfsic_check_write_bio(struct bio *bio,
> + struct btrfsic_dev_state *dev_state)
> +{
> + unsigned int segs = bio_segments(bio);
> + u64 dev_bytenr = 512 * bio->bi_iter.bi_sector;
> + u64 cur_bytenr = dev_bytenr;
> + struct bvec_iter iter;
> + struct bio_vec bvec;
> + char **mapped_datav;
> + int bio_is_patched = 0;
> + int i = 0;
> +
> + if (dev_state->state->print_mask & BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
> + pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
> + bio_op(bio), bio->bi_opf, segs,
> + bio->bi_iter.bi_sector, dev_bytenr, bio->bi_bdev);
> +
> + mapped_datav = kmalloc_array(segs, sizeof(*mapped_datav), GFP_NOFS);
> + if (!mapped_datav)
> + return;
> +
> + bio_for_each_segment(bvec, bio, iter) {
> + BUG_ON(bvec.bv_len != PAGE_SIZE);
> + mapped_datav[i] = page_address(bvec.bv_page);
> + i++;
> +
> + if (dev_state->state->print_mask &
> + BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE)
> + pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n",
> + i, cur_bytenr, bvec.bv_len, bvec.bv_offset);
> + cur_bytenr += bvec.bv_len;
> + }
> +
> + btrfsic_process_written_block(dev_state, dev_bytenr, mapped_datav, segs,
> + bio, &bio_is_patched, bio->bi_opf);
> + kfree(mapped_datav);
> +}
> +
> +static void btrfsic_check_flush_bio(struct bio *bio,
> + struct btrfsic_dev_state *dev_state)
> +{
> + if (dev_state->state->print_mask & BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
> + pr_info("submit_bio(rw=%d,0x%x FLUSH, bdev=%p)\n",
> + bio_op(bio), bio->bi_opf, bio->bi_bdev);
> +
> + if (dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
> + struct btrfsic_block *const block =
> + &dev_state->dummy_block_for_bio_bh_flush;
> +
> + block->is_iodone = 0;
> + block->never_written = 0;
> + block->iodone_w_error = 0;
> + block->flush_gen = dev_state->last_flush_gen + 1;
> + block->submit_bio_bh_rw = bio->bi_opf;
> + block->orig_bio_private = bio->bi_private;
> + block->orig_bio_end_io = bio->bi_end_io;
> + block->next_in_same_bio = NULL;
> + bio->bi_private = block;
> + bio->bi_end_io = btrfsic_bio_end_io;
> + } else if ((dev_state->state->print_mask &
> + (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
> + BTRFSIC_PRINT_MASK_VERBOSE))) {
> + pr_info(
> +"btrfsic_submit_bio(%pg) with FLUSH but dummy block already in use (ignored)!\n",
> + dev_state->bdev);
> + }
> +}
> +
> static void __btrfsic_submit_bio(struct bio *bio)
> {
> struct btrfsic_dev_state *dev_state;
> @@ -2640,80 +2708,18 @@ static void __btrfsic_submit_bio(struct bio *bio)
> if (!btrfsic_is_initialized)
> return;
>
> - mutex_lock(&btrfsic_mutex);
> - /* since btrfsic_submit_bio() is also called before
> - * btrfsic_mount(), this might return NULL */
> + /*
> + * We can be called before btrfsic_mount, so there might not be a
> + * dev_state.
> + */
> dev_state = btrfsic_dev_state_lookup(bio->bi_bdev->bd_dev);
> - if (NULL != dev_state &&
> - (bio_op(bio) == REQ_OP_WRITE) && bio_has_data(bio)) {
> - int i = 0;
> - u64 dev_bytenr;
> - u64 cur_bytenr;
> - struct bio_vec bvec;
> - struct bvec_iter iter;
> - int bio_is_patched;
> - char **mapped_datav;
> - unsigned int segs = bio_segments(bio);
> -
> - dev_bytenr = 512 * bio->bi_iter.bi_sector;
> - bio_is_patched = 0;
> - if (dev_state->state->print_mask &
> - BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
> - pr_info("submit_bio(rw=%d,0x%x, bi_vcnt=%u, bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n",
> - bio_op(bio), bio->bi_opf, segs,
> - bio->bi_iter.bi_sector, dev_bytenr, bio->bi_bdev);
> -
> - mapped_datav = kmalloc_array(segs,
> - sizeof(*mapped_datav), GFP_NOFS);
> - if (!mapped_datav)
> - goto leave;
> - cur_bytenr = dev_bytenr;
> -
> - bio_for_each_segment(bvec, bio, iter) {
> - BUG_ON(bvec.bv_len != PAGE_SIZE);
> - mapped_datav[i] = page_address(bvec.bv_page);
> - i++;
> -
> - if (dev_state->state->print_mask &
> - BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE)
> - pr_info("#%u: bytenr=%llu, len=%u, offset=%u\n",
> - i, cur_bytenr, bvec.bv_len, bvec.bv_offset);
> - cur_bytenr += bvec.bv_len;
> - }
> - btrfsic_process_written_block(dev_state, dev_bytenr,
> - mapped_datav, segs,
> - bio, &bio_is_patched,
> - bio->bi_opf);
> - kfree(mapped_datav);
> - } else if (NULL != dev_state && (bio->bi_opf & REQ_PREFLUSH)) {
> - if (dev_state->state->print_mask &
> - BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH)
> - pr_info("submit_bio(rw=%d,0x%x FLUSH, bdev=%p)\n",
> - bio_op(bio), bio->bi_opf, bio->bi_bdev);
> - if (!dev_state->dummy_block_for_bio_bh_flush.is_iodone) {
> - if ((dev_state->state->print_mask &
> - (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH |
> - BTRFSIC_PRINT_MASK_VERBOSE)))
> - pr_info(
> -"btrfsic_submit_bio(%pg) with FLUSH but dummy block already in use (ignored)!\n",
> - dev_state->bdev);
> - } else {
> - struct btrfsic_block *const block =
> - &dev_state->dummy_block_for_bio_bh_flush;
> -
> - block->is_iodone = 0;
> - block->never_written = 0;
> - block->iodone_w_error = 0;
> - block->flush_gen = dev_state->last_flush_gen + 1;
> - block->submit_bio_bh_rw = bio->bi_opf;
> - block->orig_bio_private = bio->bi_private;
> - block->orig_bio_end_io = bio->bi_end_io;
> - block->next_in_same_bio = NULL;
> - bio->bi_private = block;
> - bio->bi_end_io = btrfsic_bio_end_io;
> - }
> + mutex_lock(&btrfsic_mutex);
> + if (dev_state) {
> + if (bio_op(bio) == REQ_OP_WRITE && bio_has_data(bio))
> + btrfsic_check_write_bio(bio, dev_state);
> + else if (bio->bi_opf & REQ_PREFLUSH)
> + btrfsic_check_flush_bio(bio, dev_state);
> }
> -leave:
> mutex_unlock(&btrfsic_mutex);
> }
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 03/12] btrfs: simplify btrfsic_read_block
2022-04-08 5:08 ` [PATCH 03/12] btrfs: simplify btrfsic_read_block Christoph Hellwig
@ 2022-04-08 7:23 ` Qu Wenruo
0 siblings, 0 replies; 20+ messages in thread
From: Qu Wenruo @ 2022-04-08 7:23 UTC (permalink / raw)
To: Christoph Hellwig, Josef Bacik, David Sterba, Qu Wenruo
Cc: Naohiro Aota, linux-btrfs
On 2022/4/8 13:08, Christoph Hellwig wrote:
> btrfsic_read_block does not need the btrfs_bio structure, so switch to
> plain bio_alloc.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/check-integrity.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 9efd33b4e24d7..864a90e825050 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -1561,10 +1561,9 @@ static int btrfsic_read_block(struct btrfsic_state *state,
> struct bio *bio;
> unsigned int j;
>
> - bio = btrfs_bio_alloc(num_pages - i);
> - bio_set_dev(bio, block_ctx->dev->bdev);
> + bio = bio_alloc(block_ctx->dev->bdev, num_pages - i,
> + REQ_OP_READ, GFP_NOFS);
> bio->bi_iter.bi_sector = dev_bytenr >> 9;
> - bio->bi_opf = REQ_OP_READ;
>
> for (j = i; j < num_pages; j++) {
> ret = bio_add_page(bio, block_ctx->pagev[j],
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio
2022-04-08 5:08 ` [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio Christoph Hellwig
@ 2022-04-08 7:27 ` Qu Wenruo
2022-04-08 13:27 ` David Sterba
0 siblings, 1 reply; 20+ messages in thread
From: Qu Wenruo @ 2022-04-08 7:27 UTC (permalink / raw)
To: Christoph Hellwig, Josef Bacik, David Sterba, Qu Wenruo
Cc: Naohiro Aota, linux-btrfs
On 2022/4/8 13:08, Christoph Hellwig wrote:
> Prepare for additional refactoring.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
The change is small enough and doesn't make much sense by itself.
Mind to fold it into the patch which needs this change?
Thanks,
Qu
> ---
> fs/btrfs/volumes.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 6b49d78d15029..8e066b9ebfbde 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -6738,7 +6738,6 @@ static void submit_stripe_bio(struct btrfs_io_context *bioc, struct bio *bio,
> bio_op(bio), bio->bi_opf, bio->bi_iter.bi_sector,
> (unsigned long)dev->bdev->bd_dev, rcu_str_deref(dev->name),
> dev->devid, bio->bi_iter.bi_size);
> - bio_set_dev(bio, dev->bdev);
>
> btrfs_bio_counter_inc_noblocked(fs_info);
>
> @@ -6830,6 +6829,7 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
> else
> bio = first_bio;
>
> + bio_set_dev(bio, dev->bdev);
> submit_stripe_bio(bioc, bio, bioc->stripes[dev_nr].physical, dev);
> }
> btrfs_bio_counter_dec(fs_info);
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 12/12] btrfs: stop using the btrfs_bio saved iter in index_rbio_pages
2022-04-08 5:08 ` [PATCH 12/12] btrfs: stop using the btrfs_bio saved iter in index_rbio_pages Christoph Hellwig
@ 2022-04-08 7:37 ` Qu Wenruo
0 siblings, 0 replies; 20+ messages in thread
From: Qu Wenruo @ 2022-04-08 7:37 UTC (permalink / raw)
To: Christoph Hellwig, Josef Bacik, David Sterba, Qu Wenruo
Cc: Naohiro Aota, linux-btrfs
On 2022/4/8 13:08, Christoph Hellwig wrote:
> The bios added to ->bio_list are the original bios fed into
> btrfs_map_bio, which are never advanced. Just use the iter in the
> bio itself.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
In fact, the bio split at btrfs_map_bio() time will make all endio
functions to only utilize btrfs_bio::iter.
Thus bi_iter will be even less utilized.
Thanks,
Qu
> ---
> fs/btrfs/raid56.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index 1ab77d658bf15..adc62a7352b82 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -1134,9 +1134,6 @@ static void index_rbio_pages(struct btrfs_raid_bio *rbio)
> stripe_offset = start - rbio->bioc->raid_map[0];
> page_index = stripe_offset >> PAGE_SHIFT;
>
> - if (bio_flagged(bio, BIO_CLONED))
> - bio->bi_iter = btrfs_bio(bio)->iter;
> -
> bio_for_each_segment(bvec, bio, iter) {
> rbio->bio_pages[page_index + i] = bvec.bv_page;
> i++;
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio
2022-04-08 7:27 ` Qu Wenruo
@ 2022-04-08 13:27 ` David Sterba
0 siblings, 0 replies; 20+ messages in thread
From: David Sterba @ 2022-04-08 13:27 UTC (permalink / raw)
To: Qu Wenruo
Cc: Christoph Hellwig, Josef Bacik, David Sterba, Qu Wenruo,
Naohiro Aota, linux-btrfs
On Fri, Apr 08, 2022 at 03:27:21PM +0800, Qu Wenruo wrote:
>
>
> On 2022/4/8 13:08, Christoph Hellwig wrote:
> > Prepare for additional refactoring.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> The change is small enough and doesn't make much sense by itself.
>
> Mind to fold it into the patch which needs this change?
Not necessary and I think it's better to make moving the call stand out,
it's the one that's hidden but very important.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: cleanup btrfs bio handling, part 1 v2
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
` (11 preceding siblings ...)
2022-04-08 5:08 ` [PATCH 12/12] btrfs: stop using the btrfs_bio saved iter in index_rbio_pages Christoph Hellwig
@ 2022-04-08 16:00 ` David Sterba
12 siblings, 0 replies; 20+ messages in thread
From: David Sterba @ 2022-04-08 16:00 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Josef Bacik, David Sterba, Qu Wenruo, Naohiro Aota, linux-btrfs
On Fri, Apr 08, 2022 at 07:08:27AM +0200, Christoph Hellwig wrote:
> Hi all,
>
> this series moves btrfs to use the new as of 5.18 bio interface and
> cleans up a few close by areas. Larger cleanups focussed around
> the btrfs_bio will follow as a next step.
>
> Changes since v1:
> - rebased to btrfs/misc-next
> - improve a commit log
Series added to misc-next, thanks. I compared the version I had locally
with the v2, there were only 2 lines swapped, besides the minor style
fixups and reworded subjects when they were too generic.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 03/12] btrfs: simplify btrfsic_read_block
2022-04-04 4:45 cleanup btrfs bio handling, part 1 Christoph Hellwig
@ 2022-04-04 4:45 ` Christoph Hellwig
0 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2022-04-04 4:45 UTC (permalink / raw)
To: Josef Bacik, David Sterba, Qu Wenruo
Cc: Naohiro Aota, linux-btrfs, linux-fsdevel
btrfsic_read_block does not need the btrfs_bio structure, so switch to
plain bio_alloc.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/check-integrity.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 49f9954f1438f..0fd3ca10ec569 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1563,10 +1563,9 @@ static int btrfsic_read_block(struct btrfsic_state *state,
struct bio *bio;
unsigned int j;
- bio = btrfs_bio_alloc(num_pages - i);
- bio_set_dev(bio, block_ctx->dev->bdev);
+ bio = bio_alloc(block_ctx->dev->bdev, num_pages - i,
+ REQ_OP_READ, GFP_NOFS);
bio->bi_iter.bi_sector = dev_bytenr >> 9;
- bio->bi_opf = REQ_OP_READ;
for (j = i; j < num_pages; j++) {
ret = bio_add_page(bio, block_ctx->pagev[j],
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
end of thread, other threads:[~2022-04-08 16:04 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 5:08 cleanup btrfs bio handling, part 1 v2 Christoph Hellwig
2022-04-08 5:08 ` [PATCH 01/12] btrfs: refactor __btrfsic_submit_bio Christoph Hellwig
2022-04-08 7:22 ` Qu Wenruo
2022-04-08 5:08 ` [PATCH 02/12] btrfs: split submit_bio from btrfsic checking Christoph Hellwig
2022-04-08 5:08 ` [PATCH 03/12] btrfs: simplify btrfsic_read_block Christoph Hellwig
2022-04-08 7:23 ` Qu Wenruo
2022-04-08 5:08 ` [PATCH 04/12] btrfs: simplify repair_io_failure Christoph Hellwig
2022-04-08 5:08 ` [PATCH 05/12] btrfs: simplify scrub_recheck_block Christoph Hellwig
2022-04-08 5:08 ` [PATCH 06/12] btrfs: simplify scrub_repair_page_from_good_copy Christoph Hellwig
2022-04-08 5:08 ` [PATCH 07/12] btrfs: move the call to bio_set_dev out of submit_stripe_bio Christoph Hellwig
2022-04-08 7:27 ` Qu Wenruo
2022-04-08 13:27 ` David Sterba
2022-04-08 5:08 ` [PATCH 08/12] btrfs: pass a block_device to btrfs_bio_clone Christoph Hellwig
2022-04-08 5:08 ` [PATCH 09/12] btrfs: initialize ->bi_opf and ->bi_private in rbio_add_io_page Christoph Hellwig
2022-04-08 5:08 ` [PATCH 10/12] btrfs: don't allocate a btrfs_bio for raid56 per-stripe bios Christoph Hellwig
2022-04-08 5:08 ` [PATCH 11/12] btrfs: don't allocate a btrfs_bio for scrub bios Christoph Hellwig
2022-04-08 5:08 ` [PATCH 12/12] btrfs: stop using the btrfs_bio saved iter in index_rbio_pages Christoph Hellwig
2022-04-08 7:37 ` Qu Wenruo
2022-04-08 16:00 ` cleanup btrfs bio handling, part 1 v2 David Sterba
-- strict thread matches above, loose matches on Subject: below --
2022-04-04 4:45 cleanup btrfs bio handling, part 1 Christoph Hellwig
2022-04-04 4:45 ` [PATCH 03/12] btrfs: simplify btrfsic_read_block Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.