Skip to contentSkip to conversation

block: remove bio_last_bvec_all

PATCH Applied Keith Busch 5 participants 6 messages Jan 26 – Jan 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: remove bio_last_bvec_all

From: Keith Busch <[email protected]>

There are no more callers of this function after commit f6b2d8b134b2413 ("btrfs: track the next file offset in struct btrfs_bio_ctrl"), so remove the function.

---
 Documentation/block/biovecs.rst | 1 -
 include/linux/bio.h             | 6 ------
 2 files changed, 7 deletions(-)
Documentation/block/biovecs.rst +0 -1
index b9dc0c9dbee44..11126ed6f40f7 100644
@@ -135,7 +135,6 @@ Usage of helpers:
 	bio_first_bvec_all()
 	bio_first_page_all()
 	bio_first_folio_all()
-	bio_last_bvec_all()
 
 * The following helpers iterate over single-page segment. The passed 'struct
   bio_vec' will contain a single-page IO vector during the iteration::
include/linux/bio.h +0 -6
index 95cfc79b88b89..69d56b1d1bd21 100644
@@ -256,12 +256,6 @@ static inline struct folio *bio_first_folio_all(struct bio *bio)
 	return page_folio(bio_first_page_all(bio));
 }
 
-static inline struct bio_vec *bio_last_bvec_all(struct bio *bio)
-{
-	WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
-	return &bio->bi_io_vec[bio->bi_vcnt - 1];
-}
-
 /**
  * struct folio_iter - State for iterating all folios in a bio.
  * @folio: The current folio we're iterating.  NULL after the last folio.
Signature · 1 line
2.47.3
maintainer Applied
#2 lore raw
In reply to Keith Busch
Quoted 5 lines · Keith Busch

There are no more callers of this function after commit f6b2d8b134b2413 ("btrfs: track the next file offset in struct btrfs_bio_ctrl"), so remove the function.

Applied, thanks!

[1/1] block: remove bio_last_bvec_all

      commit: 72a41750f1a35b46caa5bbd70df7b5d3ce4f4b0a

Best regards,

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 8 lines · Jens Axboe
Quoted 5 lines · Keith Busch

There are no more callers of this function after commit f6b2d8b134b2413 ("btrfs: track the next file offset in struct btrfs_bio_ctrl"), so remove the function.

Quoted 4 lines

Applied, thanks!

[1/1] block: remove bio_last_bvec_all

       commit: 72a41750f1a35b46caa5bbd70df7b5d3ce4f4b0a

My bad, btrfs is recently add a usage of bio_last_bvec_all().

The reason is a little complex, and please let me explain it:

Previously btrfs compression does the following workflow:

- Allocate a compressed_folios[] array

- Allocate new folios when needed during compression And the new folio will be at compressed_folios[].

- Queue those folios in compressed_folios[] into a bio

- Submit the bio

Now we are getting rid of the temporary compressed_folios[] by

- Allocate a new bio

- Allocate new folios when needed during compression And each new folio will be directly queued into a bio

- Submit the bio

The problem is we need the unaligned compressed size, thus when queuing the last folio the bio, we use the real compressed size other than the rounded up size into the folio.

The reason is we also support inlined compressed extents, and if we always round up the bio size, we lose the ability the create such extents (the content must be smaller than one fs block).

So before we submit the bio, we have to round up the last folio of the bio, that's why we're using bio_last_bvec_all().

Although what we really want is bio_last_folio_all(), it's not that hard to do the conversion.

So what's the best next step?
Keep the old bio_last_bvec_all()? Or just implement it inside btrfs?

Thanks,
Qu

Quoted 2 lines

Best regards,

#4 lore raw
Quoted 1 line · Qu Wenruo

My bad, btrfs is recently add a usage of bio_last_bvec_all().

...

Quoted 2 lines

So what's the best next step?
Keep the old bio_last_bvec_all()? Or just implement it inside btrfs?

I noticed it's currently unused because I was doing an audit of bi_vcnt usage. There are new patches that bounce for stable pages, and the read side does some clever tricks that make bi_vcnt not always mean what this function expects. As there are no current in-tree users, it seemed safe to prevent any potential misuse by removing the function.

But if you need it for btrfs, I think you should reintroduce it inside btrfs since I think the fs would know if it's using the iomap bounce helpers or not.

#5 lore raw
Quoted 14 lines · Keith Busch
Quoted 1 line · Qu Wenruo

My bad, btrfs is recently add a usage of bio_last_bvec_all().

...

Quoted 2 lines

So what's the best next step?
Keep the old bio_last_bvec_all()? Or just implement it inside btrfs?

I noticed it's currently unused because I was doing an audit of bi_vcnt usage. There are new patches that bounce for stable pages, and the read side does some clever tricks that make bi_vcnt not always mean what this function expects. As there are no current in-tree users, it seemed safe to prevent any potential misuse by removing the function.

Quoted 4 lines

But if you need it for btrfs, I think you should reintroduce it inside btrfs since I think the fs would know if it's using the iomap bounce helpers or not.

Makes sense. Will re-introduce it inside btrfs, as we are sure it's not the page bounced bio.

Thanks,
Qu