linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: preserve BIO_REFFED flag in bio_reset()
@ 2019-04-06 13:03 Alex Lyakas
  2019-04-06 18:58 ` Jens Axboe
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Lyakas @ 2019-04-06 13:03 UTC (permalink / raw)
  To: linux-block; +Cc: axboe

Commit dac56212e8127dbc0bff7be35c508bc280213309 titled
"bio: skip atomic inc/dec of ->bi_cnt for most use cases"
made __bi_cnt dependent on the new BIO_REFFED flag.

bio_reset() does not reset __bi_cnt, but it does reset the BIO_REFFED flag.
But __bi_cnt depends now on the BIO_REFFED flag, so bio_reset()
needs to preserve this flag.

Signed-off-by: Alex Lyakas <alex@zadara.com>
---
 block/bio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/block/bio.c b/block/bio.c
index b64cedc..96f8dca 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -301,11 +301,17 @@ void bio_init(struct bio *bio, struct bio_vec *table,
 void bio_reset(struct bio *bio)
 {
 	unsigned long flags = bio->bi_flags & (~0UL << BIO_RESET_BITS);
+	bool bio_reffed = bio_flagged(bio, BIO_REFFED);
 
 	bio_uninit(bio);
 
 	memset(bio, 0, BIO_RESET_BYTES);
 	bio->bi_flags = flags;
+
+	/* we are not resetting __bi_cnt, but it depends on correct BIO_REFFED */
+	if (bio_reffed)
+		bio_set_flag(bio, BIO_REFFED);
+
 	atomic_set(&bio->__bi_remaining, 1);
 }
 EXPORT_SYMBOL(bio_reset);
-- 
1.9.1


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

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

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-06 13:03 [PATCH] block: preserve BIO_REFFED flag in bio_reset() Alex Lyakas
2019-04-06 18:58 ` Jens Axboe
2019-04-07  7:42   ` Alex Lyakas
2019-04-07  7:56   ` Christoph Hellwig
2019-04-07 14:35     ` Alex Lyakas
2019-04-08  6:30       ` Christoph Hellwig
2019-05-13  8:08         ` Christoph Hellwig
2019-04-07 19:38     ` 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).