From patchwork Wed Mar 24 12:19:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 12160911 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 952CEC433C1 for ; Wed, 24 Mar 2021 12:20:15 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 325AC6192B for ; Wed, 24 Mar 2021 12:20:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 325AC6192B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616588414; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NUppJdWriToEulnS9oayHw9dM3k8sGGW6Owz6UkVr1M=; b=NrxLlj5NXqWaVdKLyWbuAQwG5J4wmqXhaMoyW/4je9+5dW/cwThhlMT80GwWwxzGF1TAtv 9qMFV4wp+wUIlz3b6B3d7kz6XVW3kVMOv1QckWAUSBUfa2++rJ/bvuILw3ugxNu8KhtB7s G8GrwUR4s1Kb6rHM87mHO5GHh1AWxHg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-2aZnz8UQN-a53SicG2QV3Q-1; Wed, 24 Mar 2021 08:20:11 -0400 X-MC-Unique: 2aZnz8UQN-a53SicG2QV3Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B26861009E38; Wed, 24 Mar 2021 12:20:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 28CDA6A03D; Wed, 24 Mar 2021 12:20:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DDFBB180B450; Wed, 24 Mar 2021 12:20:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12OCK3Wp005122 for ; Wed, 24 Mar 2021 08:20:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E9D25C5B5; Wed, 24 Mar 2021 12:20:03 +0000 (UTC) Received: from localhost (ovpn-13-127.pek2.redhat.com [10.72.13.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4A805C5AE; Wed, 24 Mar 2021 12:20:01 +0000 (UTC) From: Ming Lei To: Jens Axboe Date: Wed, 24 Mar 2021 20:19:17 +0800 Message-Id: <20210324121927.362525-4-ming.lei@redhat.com> In-Reply-To: <20210324121927.362525-1-ming.lei@redhat.com> References: <20210324121927.362525-1-ming.lei@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: linux-block@vger.kernel.org, Jeffle Xu , dm-devel@redhat.com, Mike Snitzer , Ming Lei Subject: [dm-devel] [PATCH V3 03/13] block: add helper of blk_create_io_context X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add one helper for creating io context and prepare for supporting efficient bio based io poll. Meantime move the code of creating io_context before checking bio's REQ_HIPRI flag because the following patch may change to clear REQ_HIPRI if io_context can't be created. Signed-off-by: Ming Lei --- block/blk-core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index a31371d55b9d..d58f8a0c80de 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -792,6 +792,18 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q, return BLK_STS_OK; } +static inline void blk_create_io_context(struct request_queue *q) +{ + /* + * Various block parts want %current->io_context, so allocate it up + * front rather than dealing with lots of pain to allocate it only + * where needed. This may fail and the block layer knows how to live + * with it. + */ + if (unlikely(!current->io_context)) + create_task_io_context(current, GFP_ATOMIC, q->node); +} + static noinline_for_stack bool submit_bio_checks(struct bio *bio) { struct block_device *bdev = bio->bi_bdev; @@ -836,6 +848,8 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) } } + blk_create_io_context(q); + if (!blk_queue_poll(q)) bio->bi_opf &= ~REQ_HIPRI; @@ -876,15 +890,6 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio) break; } - /* - * Various block parts want %current->io_context, so allocate it up - * front rather than dealing with lots of pain to allocate it only - * where needed. This may fail and the block layer knows how to live - * with it. - */ - if (unlikely(!current->io_context)) - create_task_io_context(current, GFP_ATOMIC, q->node); - if (blk_throtl_bio(bio)) { blkcg_bio_issue_init(bio); return false;