]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
block: blk_flush_integrity() for bio-based drivers
authorDan Williams <dan.j.williams@intel.com>
Wed, 21 Oct 2015 17:20:23 +0000 (13:20 -0400)
committerJens Axboe <axboe@fb.com>
Wed, 21 Oct 2015 20:43:44 +0000 (14:43 -0600)
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.

Cc: Martin K. Petersen <martin.petersen@oracle.com>
[martin: fix the CONFIG_BLK_DEV_INTEGRITY=n case]
Tested-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/bio-integrity.c
block/blk-core.c
block/blk.h

index 6a90eca9cea123c80b1584f39201117fbc9e0394..f6325d573c10a42c673f844e4fb9585a0d9bd292 100644 (file)
 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
index 9b4d735cb5b8bb2ead4b0dfd977f1e6ca21a9b2b..6ebe33ed5154f7def1cf72c613fbd86a061eee4e 100644 (file)
@@ -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);
index 5b2cd393afbec86ee5163dc47c672b58b9ec2be6..157c93d54dc91e9763cea34cc5bd394803f59d66 100644 (file)
@@ -87,6 +87,14 @@ static inline void blk_queue_enter_live(struct request_queue *q)
        percpu_ref_get(&q->q_usage_counter);
 }
 
+#ifdef CONFIG_BLK_DEV_INTEGRITY
+void blk_flush_integrity(void);
+#else
+static inline void blk_flush_integrity(void)
+{
+}
+#endif
+
 void blk_rq_timed_out_timer(unsigned long data);
 unsigned long blk_rq_timeout(unsigned long timeout);
 void blk_add_timer(struct request *req);