]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
block: remove deadline __deadline manipulation helpers
authorChristoph Hellwig <hch@lst.de>
Wed, 14 Nov 2018 16:02:05 +0000 (17:02 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 15 Nov 2018 19:13:16 +0000 (12:13 -0700)
No users left since the removal of the legacy request interface, we can
remove all the magic bit stealing now and make it a normal field.

But use WRITE_ONCE/READ_ONCE on the new deadline field, given that we
don't seem to have any mechanism to guarantee a new value actually
gets seen by other threads.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c
block/blk-timeout.c
block/blk.h
include/linux/blkdev.h

index 411be60d0cb61905889e262d0fd22adbe03f8602..4c82b4b4fa3eadc5f06feb6612d6dbfcceb2ca43 100644 (file)
@@ -325,7 +325,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
        rq->special = NULL;
        /* tag was already set */
        rq->extra_len = 0;
-       rq->__deadline = 0;
+       WRITE_ONCE(rq->deadline, 0);
 
        rq->timeout = 0;
 
@@ -839,7 +839,7 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)
        if (rq->rq_flags & RQF_TIMED_OUT)
                return false;
 
-       deadline = blk_rq_deadline(rq);
+       deadline = READ_ONCE(rq->deadline);
        if (time_after_eq(jiffies, deadline))
                return true;
 
index 006cff4390c0e5381529d68d12cfdd4eefd61776..3b0179fbdd6ab495197c1ec6a747a63129c6fcb2 100644 (file)
@@ -84,7 +84,7 @@ void blk_abort_request(struct request *req)
         * immediately and that scan sees the new timeout value.
         * No need for fancy synchronizations.
         */
-       blk_rq_set_deadline(req, jiffies);
+       WRITE_ONCE(req->deadline, jiffies);
        kblockd_schedule_work(&req->q->timeout_work);
 }
 EXPORT_SYMBOL_GPL(blk_abort_request);
@@ -121,14 +121,16 @@ void blk_add_timer(struct request *req)
                req->timeout = q->rq_timeout;
 
        req->rq_flags &= ~RQF_TIMED_OUT;
-       blk_rq_set_deadline(req, jiffies + req->timeout);
+
+       expiry = jiffies + req->timeout;
+       WRITE_ONCE(req->deadline, expiry);
 
        /*
         * If the timer isn't already pending or this timeout is earlier
         * than an existing one, modify the timer. Round up to next nearest
         * second.
         */
-       expiry = blk_rq_timeout(round_jiffies_up(blk_rq_deadline(req)));
+       expiry = blk_rq_timeout(round_jiffies_up(expiry));
 
        if (!timer_pending(&q->timeout) ||
            time_before(expiry, q->timeout.expires)) {
index 41b64e6e101b164dcb93f6a7417335504d345155..08a5845b03ba2644c3977e05a6c1d71fc8c50b1c 100644 (file)
@@ -238,26 +238,6 @@ void blk_account_io_start(struct request *req, bool new_io);
 void blk_account_io_completion(struct request *req, unsigned int bytes);
 void blk_account_io_done(struct request *req, u64 now);
 
-/*
- * EH timer and IO completion will both attempt to 'grab' the request, make
- * sure that only one of them succeeds. Steal the bottom bit of the
- * __deadline field for this.
- */
-static inline int blk_mark_rq_complete(struct request *rq)
-{
-       return test_and_set_bit(0, &rq->__deadline);
-}
-
-static inline void blk_clear_rq_complete(struct request *rq)
-{
-       clear_bit(0, &rq->__deadline);
-}
-
-static inline bool blk_rq_is_complete(struct request *rq)
-{
-       return test_bit(0, &rq->__deadline);
-}
-
 /*
  * Internal elevator interface
  */
@@ -322,21 +302,6 @@ static inline void req_set_nomerge(struct request_queue *q, struct request *req)
                q->last_merge = NULL;
 }
 
-/*
- * Steal a bit from this field for legacy IO path atomic IO marking. Note that
- * setting the deadline clears the bottom bit, potentially clearing the
- * completed bit. The user has to be OK with this (current ones are fine).
- */
-static inline void blk_rq_set_deadline(struct request *rq, unsigned long time)
-{
-       rq->__deadline = time & ~0x1UL;
-}
-
-static inline unsigned long blk_rq_deadline(struct request *rq)
-{
-       return rq->__deadline & ~0x1UL;
-}
-
 /*
  * Internal io_context interface
  */
index dd1e53fd4acfc53cb114a9db045fdfa132369d48..60507ab7b35894f944b405d915f9b2b5f044b048 100644 (file)
@@ -224,9 +224,7 @@ struct request {
        refcount_t ref;
 
        unsigned int timeout;
-
-       /* access through blk_rq_set_deadline, blk_rq_deadline */
-       unsigned long __deadline;
+       unsigned long deadline;
 
        union {
                struct __call_single_data csd;