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=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,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 1ECD0C433DB for ; Wed, 24 Feb 2021 01:43:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B642464E7C for ; Wed, 24 Feb 2021 01:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbhBXBni (ORCPT ); Tue, 23 Feb 2021 20:43:38 -0500 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:65491 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbhBXBnh (ORCPT ); Tue, 23 Feb 2021 20:43:37 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UPP9wNK_1614130975; Received: from admindeMacBook-Pro-2.local(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0UPP9wNK_1614130975) by smtp.aliyun-inc.com(127.0.0.1); Wed, 24 Feb 2021 09:42:55 +0800 Subject: Re: [dm-devel] [PATCH v3 09/11] dm: support IO polling for bio-based dm device To: Mikulas Patocka 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 References: <20210208085243.82367-1-jefflexu@linux.alibaba.com> <20210208085243.82367-10-jefflexu@linux.alibaba.com> From: JeffleXu Message-ID: <83c2ec7a-d000-d9cc-d54a-5e69c35c5eb9@linux.alibaba.com> Date: Wed, 24 Feb 2021 09:42:55 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On 2/19/21 10:17 PM, Mikulas Patocka wrote: > > > 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. > Sorry I missed this reply. Your advice matters, thanks. -- Thanks, Jeffle