Distributed Replicated Block Device (DRBD) development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-mmc@vger.kernel.org,
	drbd-dev@lists.linbit.com
Subject: [Drbd-dev] [PATCH 02/16] block: remove deadline __deadline manipulation helpers
Date: Wed, 14 Nov 2018 17:02:05 +0100	[thread overview]
Message-ID: <20181114160219.28328-3-hch@lst.de> (raw)
In-Reply-To: <20181114160219.28328-1-hch@lst.de>

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-mq.c         |  4 ++--
 block/blk-timeout.c    |  8 +++++---
 block/blk.h            | 35 -----------------------------------
 include/linux/blkdev.h |  4 +---
 4 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 411be60d0cb6..4c82b4b4fa3e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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;
 
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 006cff4390c0..3b0179fbdd6a 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -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)) {
diff --git a/block/blk.h b/block/blk.h
index 41b64e6e101b..08a5845b03ba 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -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
  */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c92aafcde0b8..1aa94759d219 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -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;
-- 
2.19.1


  parent reply	other threads:[~2018-11-14 16:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 16:02 [Drbd-dev] remove more legacy request leftover Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 01/16] block: remove QUEUE_FLAG_BYPASS and ->bypass Christoph Hellwig
2018-11-14 16:02 ` Christoph Hellwig [this message]
2018-11-14 16:02 ` [Drbd-dev] [PATCH 03/16] block: don't hold the queue_lock over blk_abort_request Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 04/16] block: use atomic bitops for ->queue_flags Christoph Hellwig
     [not found]   ` <ddb96188-b2dd-6aaf-90f5-7eb5889691f8@suse.de>
2018-11-15  9:04     ` Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 05/16] block: remove queue_lockdep_assert_held Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 06/16] block-iolatency: remove the unused lock argument to rq_qos_throttle Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 07/16] block: update a few comments for the legacy request removal Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 08/16] block: remove a few unused exports Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 09/16] blk-cgroup: consolidate error handling in blkcg_init_queue Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 10/16] blk-cgroup: move locking into blkg_destroy_all Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 11/16] drbd: don't override the queue_lock Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 12/16] umem: " Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 13/16] mmc: simplify queue initialization Christoph Hellwig
     [not found]   ` <CAPDyKFqq=MiiM7h_GGb3S=+TSD=LayLTefigovuPJAsqMJgOEg@mail.gmail.com>
2018-11-15  9:02     ` Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 14/16] mmc: stop abusing the request queue_lock pointer Christoph Hellwig
     [not found]   ` <CAPDyKFrEWQdOKHu2FeyzPvLCDrRa+QouG6OjEzf=JF1yxoTRgw@mail.gmail.com>
2018-11-15  9:03     ` Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 15/16] block: remove the lock argument to blk_alloc_queue_node Christoph Hellwig
2018-11-14 16:02 ` [Drbd-dev] [PATCH 16/16] block: remove the queue_lock indirection Christoph Hellwig
2018-11-15 19:14 ` [Drbd-dev] remove more legacy request leftover Jens Axboe
2018-11-15 19:20   ` Jens Axboe

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=20181114160219.28328-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /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