From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 05C8DC433DB for ; Fri, 19 Feb 2021 14:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE1CD64EBD for ; Fri, 19 Feb 2021 14:18:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbhBSOSy (ORCPT ); Fri, 19 Feb 2021 09:18:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38805 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbhBSOSy (ORCPT ); Fri, 19 Feb 2021 09:18:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613744247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vcaXkz3DIMXR6O8tkWCRCDaH2CJZE8gRDs1qdSdAtsA=; b=dqikdrElXxjqxkXSpcP6/9H185Ch2BWOPtQ/c9BXwXkX7JEet9nhTCU7hilHlj5KVwklDr 5LGMzItvQUf2zZt9CPVRLBxBPGuO19fCYKw959utADUJD9wlpZLbxwCGRWaGljR6L7EAF7 9MPsHIpYpM5U8cGs92vvLagKnHkFrv4= 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-142-5tiPo4NSO-ODLee_WA6QXA-1; Fri, 19 Feb 2021 09:17:23 -0500 X-MC-Unique: 5tiPo4NSO-ODLee_WA6QXA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCCB7AFA81; Fri, 19 Feb 2021 14:17:21 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B40145D9C6; Fri, 19 Feb 2021 14:17:14 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 11JEHEkJ007662; Fri, 19 Feb 2021 09:17:14 -0500 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 11JEHCXs007658; Fri, 19 Feb 2021 09:17:13 -0500 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Fri, 19 Feb 2021 09:17:12 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Jeffle Xu cc: snitzer@redhat.com, axboe@kernel.dk, caspar@linux.alibaba.com, hch@lst.de, linux-block@vger.kernel.org, joseph.qi@linux.alibaba.com, dm-devel@redhat.com, io-uring@vger.kernel.org Subject: Re: [dm-devel] [PATCH v3 09/11] dm: support IO polling for bio-based dm device In-Reply-To: <20210208085243.82367-10-jefflexu@linux.alibaba.com> Message-ID: References: <20210208085243.82367-1-jefflexu@linux.alibaba.com> <20210208085243.82367-10-jefflexu@linux.alibaba.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Mon, 8 Feb 2021, Jeffle Xu wrote: > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index c2945c90745e..8423f1347bb8 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -1657,6 +1657,68 @@ static blk_qc_t dm_submit_bio(struct bio *bio) > return BLK_QC_T_NONE; > } > > +static int dm_poll_one_md(struct mapped_device *md); > + > +static int dm_poll_one_dev(struct dm_target *ti, struct dm_dev *dev, > + sector_t start, sector_t len, void *data) > +{ > + int i, *count = data; > + struct request_queue *q = bdev_get_queue(dev->bdev); > + struct blk_mq_hw_ctx *hctx; > + > + if (queue_is_mq(q)) { > + if (!percpu_ref_tryget(&q->q_usage_counter)) > + return 0; > + > + queue_for_each_poll_hw_ctx(q, hctx, i) > + *count += blk_mq_poll_hctx(q, hctx); > + > + percpu_ref_put(&q->q_usage_counter); > + } else > + *count += dm_poll_one_md(dev->bdev->bd_disk->private_data); This is fragile, because in the future there may be other bio-based drivers that support polling. You should check that "q" is really a device mapper device before calling dm_poll_one_md on it. Mikulas From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 C3C77C433E6 for ; Fri, 19 Feb 2021 14:17:37 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EA0364EBD for ; Fri, 19 Feb 2021 14:17:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EA0364EBD 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=1613744256; 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=0Wt17+540MZM5VrJnbtbBsBogMoMfqoGTqHCfWfZblI=; b=hLGDCfO0p1dK5dFTpZ6Qbaw73oQf6Lbt7egpHycbsFMX+flXGP9Zy2HudpjG3BqyHxfVDC jUYcmGjVQk9dWIdyPZNhPicaRJatQjnshtnH9s/WEuAanqS5YezQmUfJZi0Bn4F6mi5yQj opweURxZ5s6iu1ZO1O2Bh/hcE1o6sno= 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-168-zbRlI0cUN8KUBVcPdpM6UQ-1; Fri, 19 Feb 2021 09:17:33 -0500 X-MC-Unique: zbRlI0cUN8KUBVcPdpM6UQ-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 85D46192D785; Fri, 19 Feb 2021 14:17:28 +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 9584F6085D; Fri, 19 Feb 2021 14:17:26 +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 D201F18095CC; Fri, 19 Feb 2021 14:17:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JEHLSb028125 for ; Fri, 19 Feb 2021 09:17:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9D505D9C2; Fri, 19 Feb 2021 14:17:21 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B40145D9C6; Fri, 19 Feb 2021 14:17:14 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 11JEHEkJ007662; Fri, 19 Feb 2021 09:17:14 -0500 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 11JEHCXs007658; Fri, 19 Feb 2021 09:17:13 -0500 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Fri, 19 Feb 2021 09:17:12 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Jeffle Xu In-Reply-To: <20210208085243.82367-10-jefflexu@linux.alibaba.com> Message-ID: References: <20210208085243.82367-1-jefflexu@linux.alibaba.com> <20210208085243.82367-10-jefflexu@linux.alibaba.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: axboe@kernel.dk, snitzer@redhat.com, caspar@linux.alibaba.com, io-uring@vger.kernel.org, linux-block@vger.kernel.org, joseph.qi@linux.alibaba.com, dm-devel@redhat.com, hch@lst.de Subject: Re: [dm-devel] [PATCH v3 09/11] dm: support IO polling for bio-based dm device 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, 8 Feb 2021, Jeffle Xu wrote: > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index c2945c90745e..8423f1347bb8 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -1657,6 +1657,68 @@ static blk_qc_t dm_submit_bio(struct bio *bio) > return BLK_QC_T_NONE; > } > > +static int dm_poll_one_md(struct mapped_device *md); > + > +static int dm_poll_one_dev(struct dm_target *ti, struct dm_dev *dev, > + sector_t start, sector_t len, void *data) > +{ > + int i, *count = data; > + struct request_queue *q = bdev_get_queue(dev->bdev); > + struct blk_mq_hw_ctx *hctx; > + > + if (queue_is_mq(q)) { > + if (!percpu_ref_tryget(&q->q_usage_counter)) > + return 0; > + > + queue_for_each_poll_hw_ctx(q, hctx, i) > + *count += blk_mq_poll_hctx(q, hctx); > + > + percpu_ref_put(&q->q_usage_counter); > + } else > + *count += dm_poll_one_md(dev->bdev->bd_disk->private_data); This is fragile, because in the future there may be other bio-based drivers that support polling. You should check that "q" is really a device mapper device before calling dm_poll_one_md on it. Mikulas -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel