linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bio_add_pc_page cleanups
@ 2019-04-25  7:04 Christoph Hellwig
  2019-04-25  7:04 ` [PATCH 1/3] block: remove the __bio_add_pc_page export Christoph Hellwig
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-04-25  7:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Hi Jens,

please take a look at these trivial bio_add_pc_page cleanups.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] block: remove the __bio_add_pc_page export
  2019-04-25  7:04 bio_add_pc_page cleanups Christoph Hellwig
@ 2019-04-25  7:04 ` Christoph Hellwig
  2019-04-25  7:04 ` [PATCH 2/3] block: remove bogus comments in __bio_add_pc_page Christoph Hellwig
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-04-25  7:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

The same page optimization is a rather odd corner case, which is not
used outside bio.c and which really should not be used outside of bio.c
either - we have better highlevel helpers like the rq/bio mapping
helpers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c         | 3 +--
 include/linux/bio.h | 3 ---
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 9ad0d00cdc9b..e717b303e1fb 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -709,7 +709,7 @@ static bool can_add_page_to_seg(struct request_queue *q,
  *
  *	This should only be used by passthrough bios.
  */
-int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
+static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 		struct page *page, unsigned int len, unsigned int offset,
 		bool put_same_page)
 {
@@ -776,7 +776,6 @@ int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 	bio_set_flag(bio, BIO_SEG_VALID);
 	return len;
 }
-EXPORT_SYMBOL(__bio_add_pc_page);
 
 int bio_add_pc_page(struct request_queue *q, struct bio *bio,
 		struct page *page, unsigned int len, unsigned int offset)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 186b2723c61b..077cecdf9437 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -435,9 +435,6 @@ void bio_chain(struct bio *, struct bio *);
 extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int);
 extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
 			   unsigned int, unsigned int);
-extern int __bio_add_pc_page(struct request_queue *, struct bio *,
-			     struct page *, unsigned int, unsigned int,
-			     bool);
 bool __bio_try_merge_page(struct bio *bio, struct page *page,
 		unsigned int len, unsigned int off, bool same_page);
 void __bio_add_page(struct bio *bio, struct page *page,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] block: remove bogus comments in __bio_add_pc_page
  2019-04-25  7:04 bio_add_pc_page cleanups Christoph Hellwig
  2019-04-25  7:04 ` [PATCH 1/3] block: remove the __bio_add_pc_page export Christoph Hellwig
@ 2019-04-25  7:04 ` Christoph Hellwig
  2019-04-25  7:04 ` [PATCH 3/3] block: clean up __bio_add_pc_page a bit Christoph Hellwig
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-04-25  7:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

We are never called with file system pages by defintions for the
passthrough interface, and we also never undo any addition later
these days.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index e717b303e1fb..de26dc18bceb 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -724,11 +724,6 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 	if (((bio->bi_iter.bi_size + len) >> 9) > queue_max_hw_sectors(q))
 		return 0;
 
-	/*
-	 * For filesystems with a blocksize smaller than the pagesize
-	 * we will often be called with the same page as last time and
-	 * a consecutive offset.  Optimize this special case.
-	 */
 	if (bio->bi_vcnt > 0) {
 		bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
 
@@ -760,10 +755,6 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 	if (bio->bi_phys_segments >= queue_max_segments(q))
 		return 0;
 
-	/*
-	 * setup the new entry, we might clear it again later if we
-	 * cannot add the page
-	 */
 	bvec = &bio->bi_io_vec[bio->bi_vcnt];
 	bvec->bv_page = page;
 	bvec->bv_len = len;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] block: clean up __bio_add_pc_page a bit
  2019-04-25  7:04 bio_add_pc_page cleanups Christoph Hellwig
  2019-04-25  7:04 ` [PATCH 1/3] block: remove the __bio_add_pc_page export Christoph Hellwig
  2019-04-25  7:04 ` [PATCH 2/3] block: remove bogus comments in __bio_add_pc_page Christoph Hellwig
@ 2019-04-25  7:04 ` Christoph Hellwig
  2019-04-30 15:05 ` bio_add_pc_page cleanups Christoph Hellwig
  2019-04-30 15:27 ` Jens Axboe
  4 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-04-25  7:04 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Share the bi_size update by moving the done label up, and duplicate
the bv_len update in the two callers to get rid of the bvec_merge
label.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index de26dc18bceb..029afb121a48 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -731,9 +731,7 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 		    offset == bvec->bv_offset + bvec->bv_len) {
 			if (put_same_page)
 				put_page(page);
- bvec_merge:
 			bvec->bv_len += len;
-			bio->bi_iter.bi_size += len;
 			goto done;
 		}
 
@@ -745,8 +743,10 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 			return 0;
 
 		if (page_is_mergeable(bvec, page, len, offset, false) &&
-				can_add_page_to_seg(q, bvec, page, len, offset))
-			goto bvec_merge;
+		    can_add_page_to_seg(q, bvec, page, len, offset)) {
+			bvec->bv_len += len;
+			goto done;
+		}
 	}
 
 	if (bio_full(bio))
@@ -760,9 +760,8 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
 	bvec->bv_len = len;
 	bvec->bv_offset = offset;
 	bio->bi_vcnt++;
-	bio->bi_iter.bi_size += len;
-
  done:
+	bio->bi_iter.bi_size += len;
 	bio->bi_phys_segments = bio->bi_vcnt;
 	bio_set_flag(bio, BIO_SEG_VALID);
 	return len;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: bio_add_pc_page cleanups
  2019-04-25  7:04 bio_add_pc_page cleanups Christoph Hellwig
                   ` (2 preceding siblings ...)
  2019-04-25  7:04 ` [PATCH 3/3] block: clean up __bio_add_pc_page a bit Christoph Hellwig
@ 2019-04-30 15:05 ` Christoph Hellwig
  2019-04-30 15:27 ` Jens Axboe
  4 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-04-30 15:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

ping?

On Thu, Apr 25, 2019 at 09:04:32AM +0200, Christoph Hellwig wrote:
> Hi Jens,
> 
> please take a look at these trivial bio_add_pc_page cleanups.
---end quoted text---

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bio_add_pc_page cleanups
  2019-04-25  7:04 bio_add_pc_page cleanups Christoph Hellwig
                   ` (3 preceding siblings ...)
  2019-04-30 15:05 ` bio_add_pc_page cleanups Christoph Hellwig
@ 2019-04-30 15:27 ` Jens Axboe
  4 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2019-04-30 15:27 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block

On 4/25/19 1:04 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> please take a look at these trivial bio_add_pc_page cleanups.

LGTM, applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bio_add_pc_page cleanups
  2019-08-12 15:39 Christoph Hellwig
  2019-08-22  1:00 ` Christoph Hellwig
@ 2019-08-22 13:15 ` Jens Axboe
  1 sibling, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2019-08-22 13:15 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-block

On 8/12/19 9:39 AM, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series cleans up the bio_add_pc_page code and reuses more code
> from the regular bio path.

LGTM, applied for 5.4, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bio_add_pc_page cleanups
  2019-08-12 15:39 Christoph Hellwig
@ 2019-08-22  1:00 ` Christoph Hellwig
  2019-08-22 13:15 ` Jens Axboe
  1 sibling, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-08-22  1:00 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

On Mon, Aug 12, 2019 at 05:39:55PM +0200, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series cleans up the bio_add_pc_page code and reuses more code
> from the regular bio path.

ping?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bio_add_pc_page cleanups
@ 2019-08-12 15:39 Christoph Hellwig
  2019-08-22  1:00 ` Christoph Hellwig
  2019-08-22 13:15 ` Jens Axboe
  0 siblings, 2 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-08-12 15:39 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Hi Jens,

this series cleans up the bio_add_pc_page code and reuses more code
from the regular bio path.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bio_add_pc_page cleanups
@ 2019-07-03 13:00 Christoph Hellwig
  0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2019-07-03 13:00 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

Hi Jens,

this series cleans up the bio_add_pc_page code and reuses more code
from the regular bio path.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-08-22 13:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25  7:04 bio_add_pc_page cleanups Christoph Hellwig
2019-04-25  7:04 ` [PATCH 1/3] block: remove the __bio_add_pc_page export Christoph Hellwig
2019-04-25  7:04 ` [PATCH 2/3] block: remove bogus comments in __bio_add_pc_page Christoph Hellwig
2019-04-25  7:04 ` [PATCH 3/3] block: clean up __bio_add_pc_page a bit Christoph Hellwig
2019-04-30 15:05 ` bio_add_pc_page cleanups Christoph Hellwig
2019-04-30 15:27 ` Jens Axboe
2019-07-03 13:00 Christoph Hellwig
2019-08-12 15:39 Christoph Hellwig
2019-08-22  1:00 ` Christoph Hellwig
2019-08-22 13:15 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).