diff --git a/block/blk-mq.c b/block/blk-mq.c index a7b46b754a7c8107e34ee7cd3e7733220af7fb1b..076cbab9c3e0f5c47c7e8807c730c9ad050a036e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2923,6 +2923,12 @@ EXPORT_SYMBOL_GPL(blk_mq_poll); static int __init blk_mq_init(void) { + /* + * See comment in block/blk.h rq_atomic_flags enum + */ + BUILD_BUG_ON((REQ_ATOM_STARTED / BITS_PER_BYTE) != + (REQ_ATOM_COMPLETE / BITS_PER_BYTE)); + cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL, blk_mq_hctx_notify_dead); return 0; diff --git a/block/blk.h b/block/blk.h index fda5a4632aba3cc3cfcc1942a358329c93f9882c..6ac43dfd68a7d489b295b5416fa1723b6e1cd7e8 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, };