Commit 9d5a4e946ce5352f19400b6370f4cd8e72806278

Authored by Mike Snitzer
Committed by Jens Axboe
1 parent ae1b153962

block: skip elevator data initialization for flush requests

Skip elevator initialization for flush requests by passing priv=0 to
blk_alloc_request() in get_request().  As such elv_set_request() is
never called for flush requests.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

Showing 1 changed file with 25 additions and 4 deletions Side-by-side Diff

... ... @@ -738,6 +738,25 @@
738 738 }
739 739  
740 740 /*
  741 + * Determine if elevator data should be initialized when allocating the
  742 + * request associated with @bio.
  743 + */
  744 +static bool blk_rq_should_init_elevator(struct bio *bio)
  745 +{
  746 + if (!bio)
  747 + return true;
  748 +
  749 + /*
  750 + * Flush requests do not use the elevator so skip initialization.
  751 + * This allows a request to share the flush and elevator data.
  752 + */
  753 + if (bio->bi_rw & (REQ_FLUSH | REQ_FUA))
  754 + return false;
  755 +
  756 + return true;
  757 +}
  758 +
  759 +/*
741 760 * Get a free request, queue_lock must be held.
742 761 * Returns NULL on failure, with queue_lock held.
743 762 * Returns !NULL on success, with queue_lock *not held*.
... ... @@ -749,7 +768,7 @@
749 768 struct request_list *rl = &q->rq;
750 769 struct io_context *ioc = NULL;
751 770 const bool is_sync = rw_is_sync(rw_flags) != 0;
752   - int may_queue, priv;
  771 + int may_queue, priv = 0;
753 772  
754 773 may_queue = elv_may_queue(q, rw_flags);
755 774 if (may_queue == ELV_MQUEUE_NO)
... ... @@ -793,9 +812,11 @@
793 812 rl->count[is_sync]++;
794 813 rl->starved[is_sync] = 0;
795 814  
796   - priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
797   - if (priv)
798   - rl->elvpriv++;
  815 + if (blk_rq_should_init_elevator(bio)) {
  816 + priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
  817 + if (priv)
  818 + rl->elvpriv++;
  819 + }
799 820  
800 821 if (blk_queue_io_stat(q))
801 822 rw_flags |= REQ_IO_STAT;