From fc13457f74dcf054b0d17efb7b94b46fdf17f412 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 4 Oct 2017 11:22:24 -0600 Subject: blk-mq: document the need to have STARTED and COMPLETED share a byte For memory ordering guarantees on stores, we need to ensure that these two bits share the same byte of storage in the unsigned long. Add a comment as to why, and a BUILD_BUG_ON() to ensure that we don't violate this requirement. Suggested-by: Boqun Feng Signed-off-by: Jens Axboe --- block/blk.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'block/blk.h') diff --git a/block/blk.h b/block/blk.h index fda5a4632aba..6ac43dfd68a7 100644 --- a/block/blk.h +++ b/block/blk.h @@ -122,8 +122,15 @@ void blk_account_io_done(struct request *req); * Internal atomic flags for request handling */ enum rq_atomic_flags { + /* + * Keep these two bits first - not because we depend on the + * value of them, but we do depend on them being in the same + * byte of storage to ensure ordering on writes. Keeping them + * first will achieve that nicely. + */ REQ_ATOM_COMPLETE = 0, REQ_ATOM_STARTED, + REQ_ATOM_POLL_SLEPT, }; -- cgit v1.2.3-55-g7522