From: Bart Van Assche <bart.vanassche@wdc.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Bart Van Assche <bart.vanassche@wdc.com>,
Mike Snitzer <snitzer@redhat.com>, Hannes Reinecke <hare@suse.de>,
Johannes Thumshirn <jthumshirn@suse.de>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 10/11] block: Complain if queue_flag_(set|clear)_unlocked() is abused
Date: Wed, 28 Feb 2018 11:28:22 -0800 [thread overview]
Message-ID: <20180228192823.5191-11-bart.vanassche@wdc.com> (raw)
In-Reply-To: <20180228192823.5191-1-bart.vanassche@wdc.com>
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 <bart.vanassche@wdc.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Ming Lei <ming.lei@redhat.com>
---
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, &q->queue_flags) &&
+ kref_read(&q->kobj.kref))
+ lockdep_assert_held(q->queue_lock);
__set_bit(flag, &q->queue_flags);
}
static inline void queue_flag_clear_unlocked(unsigned int flag,
struct request_queue *q)
{
+ if (test_bit(QUEUE_FLAG_INIT_DONE, &q->queue_flags) &&
+ kref_read(&q->kobj.kref))
+ lockdep_assert_held(q->queue_lock);
__clear_bit(flag, &q->queue_flags);
}
--
2.16.2
next prev parent reply other threads:[~2018-02-28 19:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 19:28 [PATCH 00/11] Make all concurrent queue flag manipulations safe Bart Van Assche
2018-02-28 19:28 ` [PATCH 01/11] block: Reorder the queue flag manipulaton function definitions Bart Van Assche
2018-03-01 8:42 ` Johannes Thumshirn
2018-03-02 23:09 ` Martin K. Petersen
2018-03-08 1:02 ` Bart Van Assche
2018-02-28 19:28 ` [PATCH 02/11] block: Use the queue_flag_*() functions instead of open-coding these Bart Van Assche
2018-03-01 8:43 ` Johannes Thumshirn
2018-03-02 23:09 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 03/11] block: Introduce blk_queue_flag_{set,clear,test_and_{set,clear}}() Bart Van Assche
2018-03-01 8:46 ` Johannes Thumshirn
2018-03-02 23:11 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 04/11] block: Protect queue flag changes with the queue lock Bart Van Assche
2018-03-01 8:51 ` Johannes Thumshirn
2018-03-01 15:19 ` Bart Van Assche
2018-03-01 15:22 ` Johannes Thumshirn
2018-03-02 23:12 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 05/11] mtip32xx: Use the blk_queue_flag_*() functions Bart Van Assche
2018-03-01 8:52 ` Johannes Thumshirn
2018-03-02 23:12 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 06/11] bcache: Use the blk_queue_flag_{set,clear}() functions Bart Van Assche
2018-02-28 20:18 ` Michael Lyle
2018-03-01 8:52 ` Johannes Thumshirn
2018-03-02 23:12 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 07/11] iscsi: Use blk_queue_flag_set() Bart Van Assche
2018-03-01 8:53 ` Johannes Thumshirn
2018-03-02 23:14 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 08/11] target/tcm_loop: " Bart Van Assche
2018-03-01 8:53 ` Johannes Thumshirn
2018-03-02 23:17 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 09/11] block: Use blk_queue_flag_*() in drivers instead of queue_flag_*() Bart Van Assche
2018-03-02 23:17 ` Martin K. Petersen
2018-02-28 19:28 ` Bart Van Assche [this message]
2018-03-01 8:57 ` [PATCH 10/11] block: Complain if queue_flag_(set|clear)_unlocked() is abused Johannes Thumshirn
2018-03-02 23:18 ` Martin K. Petersen
2018-02-28 19:28 ` [PATCH 11/11] block: Move the queue_flag_*() functions from a public into a private header file Bart Van Assche
2018-03-01 8:57 ` Johannes Thumshirn
2018-03-02 23:20 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180228192823.5191-11-bart.vanassche@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=snitzer@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox