diff mbox

[11/11] block: blk_flush_integrity() for bio-based drivers

Message ID 20151014022857.34443.65126.stgit@dwillia2-desk3.jf.intel.com (mailing list archive)
State Superseded
Headers show

Commit Message

Dan Williams Oct. 14, 2015, 2:28 a.m. UTC
Since they lack requests to pin the request_queue active, synchronous
bio-based drivers may have in-flight integrity work from
bio_integrity_endio() that is not flushed by blk_freeze_queue().  Flush
that work to prevent races to free the queue and the final usage of the
blk_integrity profile.

This is temporary unless/until bio-based drivers start to generically
take a q_usage_counter reference while a bio is in-flight.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 block/bio-integrity.c |    5 +++++
 block/blk-core.c      |    3 +++
 block/blk.h           |    2 ++
 3 files changed, 10 insertions(+)

Comments

Martin K. Petersen Oct. 14, 2015, 10:41 p.m. UTC | #1
>>>>> "Dan" == Dan Williams <dan.j.williams@intel.com> writes:

Dan> Since they lack requests to pin the request_queue active,
Dan> synchronous bio-based drivers may have in-flight integrity work
Dan> from bio_integrity_endio() that is not flushed by
Dan> blk_freeze_queue().  Flush that work to prevent races to free the
Dan> queue and the final usage of the blk_integrity profile.

Does this work when BLK_DEV_INTEGRITY is undefined?
Dan Williams Oct. 14, 2015, 11:20 p.m. UTC | #2
On Wed, Oct 14, 2015 at 3:41 PM, Martin K. Petersen
<martin.petersen@oracle.com> wrote:
>>>>>> "Dan" == Dan Williams <dan.j.williams@intel.com> writes:
>
> Dan> Since they lack requests to pin the request_queue active,
> Dan> synchronous bio-based drivers may have in-flight integrity work
> Dan> from bio_integrity_endio() that is not flushed by
> Dan> blk_freeze_queue().  Flush that work to prevent races to free the
> Dan> queue and the final usage of the blk_integrity profile.
>
> Does this work when BLK_DEV_INTEGRITY is undefined?
>

Nope.  Fixed up this and patch 10.
diff mbox

Patch

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 6a90eca9cea1..f6325d573c10 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -32,6 +32,11 @@ 
 static struct kmem_cache *bip_slab;
 static struct workqueue_struct *kintegrityd_wq;
 
+void blk_flush_integrity(void)
+{
+	flush_workqueue(kintegrityd_wq);
+}
+
 /**
  * bio_integrity_alloc - Allocate integrity payload and attach it to bio
  * @bio:	bio to attach integrity metadata to
diff --git a/block/blk-core.c b/block/blk-core.c
index 9b4d735cb5b8..6ebe33ed5154 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -561,6 +561,9 @@  void blk_cleanup_queue(struct request_queue *q)
 	queue_flag_set(QUEUE_FLAG_DEAD, q);
 	spin_unlock_irq(lock);
 
+	/* for synchronous bio-based driver finish in-flight integrity i/o */
+	blk_flush_integrity();
+
 	/* @q won't process any more request, flush async actions */
 	del_timer_sync(&q->backing_dev_info.laptop_mode_wb_timer);
 	blk_sync_queue(q);
diff --git a/block/blk.h b/block/blk.h
index 5b2cd393afbe..cda2e80ea30e 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -87,6 +87,8 @@  static inline void blk_queue_enter_live(struct request_queue *q)
 	percpu_ref_get(&q->q_usage_counter);
 }
 
+void blk_flush_integrity(void);
+
 void blk_rq_timed_out_timer(unsigned long data);
 unsigned long blk_rq_timeout(unsigned long timeout);
 void blk_add_timer(struct request *req);