From patchwork Wed Dec 18 09:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferry Meng X-Patchwork-Id: 13913256 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B0EA19C55E; Wed, 18 Dec 2024 09:25:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734513952; cv=none; b=NzSR2LWci5XEkfduUqcd15Ek5kP2/+fahVpvQR6BnTotGJxyUoTcGuipXYbYtRvR4vzS5nDrtc56kTaD1ErRxpedkHEt31Sz9ow7dmLGtfbKGjVcg2vr6w4HZ0FysmADHGu99R3d3d1gKDUCyzXNZJnvamnnrZ6oLRxGfBaoBjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734513952; c=relaxed/simple; bh=wxtQ0TZ7j3ZY1hR9Eku6xzWcBCWgwW5EFBD+bahXas0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EnXFHKOd6ilSN4br2mfkDtOnQQLmAlTsccMLnyNerbi/BPlzt+voOyNRZov/vEQ2XtetBLVtN88kYZOoqs9OGZBWEgOCWyKDLqB9kCAG3Hgi97BapHBBItIfaSTKucHQtzzRGKqe2MDy5hWN02XujBcI6+ZnQD/swKttdDYWjRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ohxVXwiS; arc=none smtp.client-ip=115.124.30.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ohxVXwiS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1734513942; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=c1EfSmJ9YbNZGNCvZnfavVBw0I455mOuEcxsYdW1oE8=; b=ohxVXwiSJ4BpcHKBY4eKEQbe2uUvjBdBdqNm9ieeBpJZbJS8rsbpFAFEIxd2R6ipxxeqr4Qbm3PlhiTg57AVtQk/qCys0Rbdfr6DKqBdhSNIgTRFKl8YPIj5NxWEB/B4KlKb8EJFr+uDXHtZag+s1bW3USsTEAgWQ3VMBv/2mww= Received: from localhost(mailfrom:mengferry@linux.alibaba.com fp:SMTPD_---0WLmA.cP_1734513937 cluster:ay36) by smtp.aliyun-inc.com; Wed, 18 Dec 2024 17:25:41 +0800 From: Ferry Meng To: "Michael S . Tsirkin" , Jason Wang , linux-block@vger.kernel.org, Jens Axboe , virtualization@lists.linux.dev Cc: linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Stefan Hajnoczi , Christoph Hellwig , Joseph Qi , Jeffle Xu , Ferry Meng Subject: [PATCH v1 3/3] virtio-blk: add uring_cmd iopoll support. Date: Wed, 18 Dec 2024 17:24:35 +0800 Message-Id: <20241218092435.21671-4-mengferry@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20241218092435.21671-1-mengferry@linux.alibaba.com> References: <20241218092435.21671-1-mengferry@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add polling support for uring_cmd polling support for virtblk, which will be called during completion-polling. Signed-off-by: Ferry Meng --- drivers/block/virtio_blk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index cd88cf939144..cd4c74e06107 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1464,6 +1464,18 @@ static int virtblk_chr_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue return virtblk_uring_cmd(vblk, ioucmd, issue_flags); } +static int virtblk_chr_uring_cmd_iopoll(struct io_uring_cmd *ioucmd, + struct io_comp_batch *iob, + unsigned int poll_flags) +{ + struct virtblk_uring_cmd_pdu *pdu = virtblk_get_uring_cmd_pdu(ioucmd); + struct request *req = pdu->req; + + if (req && blk_rq_is_poll(req)) + return blk_rq_poll(req, iob, poll_flags); + return 0; +} + static void virtblk_cdev_rel(struct device *dev) { ida_free(&vd_chr_minor_ida, MINOR(dev->devt)); @@ -1512,6 +1524,7 @@ static int virtblk_cdev_add(struct virtio_blk *vblk, static const struct file_operations virtblk_chr_fops = { .owner = THIS_MODULE, .uring_cmd = virtblk_chr_uring_cmd, + .uring_cmd_iopoll = virtblk_chr_uring_cmd_iopoll, }; static unsigned int virtblk_queue_depth;