On Thu, 2017-12-14 at 11:19 -0800, tj@xxxxxxxxxx wrote: > On Thu, Dec 14, 2017 at 06:51:11PM +0000, Bart Van Assche wrote: > > On Tue, 2017-12-12 at 11:01 -0800, Tejun Heo wrote: > > > --- a/block/blk-core.c > > > +++ b/block/blk-core.c > > > @@ -126,6 +126,8 @@ void blk_rq_init(struct request_queue *q, struct request *rq) > > > rq->start_time = jiffies; > > > set_start_time_ns(rq); > > > rq->part = NULL; > > > + seqcount_init(&rq->gstate_seq); > > > + u64_stats_init(&rq->aborted_gstate_sync); > > > } > > > EXPORT_SYMBOL(blk_rq_init); > > > > Sorry but the above change looks ugly to me. My understanding is that > > blk_rq_init() is only used inside the block layer to initialize legacy block > > layer requests while gstate_seq and aborted_gstate_sync are only relevant > > for blk-mq requests. Wouldn't it be better to avoid that blk_rq_init() is > > called for blk-mq requests such that the above change can be left out? The > > only callers outside the block layer core of blk_rq_init() I know of are > > ide_prep_sense() and scsi_ioctl_reset(). I can help with converting the SCSI > > code if you want. > > This is also used by flush path. We probably should clean that up, > but let's worry about that later cuz flush handling has enough of its > own complications. We may have a different opinion about this but I think it is more than a detail. This patch needs gstate_seq and aborted_gstate_sync to be preserved across request state transitions from MQ_RQ_IN_FLIGHT to MR_RQ_IDLE. blk_mq_init_request() is called at request allocation time so it's the right context to initialize gstate_seq and aborted_gstate_sync. blk_rq_init() however is called before a every use of a request. Sorry but I'm not enthusiast about the code in blk_rq_init() that reinitializes state information that should survive request reuse. Bart.