Re: [PATCH 10/11] block: Complain if queue_flag_(set|clear)_unlocked() is abused

2018-03-02 Thread Martin K. Petersen

Bart,

> Since it is not safe to use queue_flag_(set|clear)_unlocked() without
> holding the queue lock after the sysfs entries for a queue have been
> created, complain if this happens.

Reviewed-by: Martin K. Petersen 

-- 
Martin K. Petersen  Oracle Linux Engineering


Re: [PATCH 10/11] block: Complain if queue_flag_(set|clear)_unlocked() is abused

2018-03-01 Thread Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[PATCH 10/11] block: Complain if queue_flag_(set|clear)_unlocked() is abused

2018-02-28 Thread Bart Van Assche
Since it is not safe to use queue_flag_(set|clear)_unlocked()
without holding the queue lock after the sysfs entries for a
queue have been created, complain if this happens.

Signed-off-by: Bart Van Assche 
Cc: Mike Snitzer 
Cc: Christoph Hellwig 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
Cc: Ming Lei 
---
 include/linux/blkdev.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index eca31d0ef2df..1f3ec9a7fbc7 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -726,12 +726,18 @@ static inline void queue_lockdep_assert_held(struct 
request_queue *q)
 static inline void queue_flag_set_unlocked(unsigned int flag,
   struct request_queue *q)
 {
+   if (test_bit(QUEUE_FLAG_INIT_DONE, >queue_flags) &&
+   kref_read(>kobj.kref))
+   lockdep_assert_held(q->queue_lock);
__set_bit(flag, >queue_flags);
 }
 
 static inline void queue_flag_clear_unlocked(unsigned int flag,
 struct request_queue *q)
 {
+   if (test_bit(QUEUE_FLAG_INIT_DONE, >queue_flags) &&
+   kref_read(>kobj.kref))
+   lockdep_assert_held(q->queue_lock);
__clear_bit(flag, >queue_flags);
 }
 
-- 
2.16.2