From nobody Tue Dec 2 02:19:54 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 9BA7626D4C3 for ; Fri, 21 Nov 2025 01:59:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763690384; cv=none; b=Yb5bCsDjR4OpVHVmeOezczlVUrk87/0KTiOZZdCoZdNVFnpN4vYHllL3qHRBYHBg4DaJQlCYf/fUTgFD5uSxR3Aidj6stn7M6aIWq9IupVAuTq3p4xczyt4mtT1ictA5VEL6THXrZCENT3XjS5DNSjgmWbcue01a5YftH8MCpYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763690384; c=relaxed/simple; bh=9lz/zTnuBVl9xO+Syb30DgeeOR4F5ieQ9i3f2HRRm7Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EFtaghqyrckZlXM3VsO5A+HRcC7xFKSRySYe1YSMdN2iOHEqklCASwBkE+vxZF+d0ShRCJ9RZX9q99BwN1ciAgAUYEXBkbt1Ps37SyAfG8+iPq+WRWSDT/qGT1b5Rm/a4eYpIEeF5DuZSkdI3iknpuDi74kL91Pu5nAxySvWYpg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Rx5yBgC6; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Rx5yBgC6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763690380; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PO6f5jz42DBlQAUhK3se1j7b6gW7jvpeEuu1PFTGky4=; b=Rx5yBgC68eL5XeinhaIR/WCUkoCGhqRXyws39EjuPcNoUaJJegE1EV3/FIYS3jujDP7NOI cE8P4nsUKku7afkgJfu8n2tZu5dP7RkEgYHGlJT+6UKlDF410QM8RHWHoBFDu/dZebade+ 2bMKcLGfgWyNKIQ/JmnFz8ksuYh+Gl4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-161-5tEhFnH9Nba6nKW0iXWT6w-1; Thu, 20 Nov 2025 20:59:36 -0500 X-MC-Unique: 5tEhFnH9Nba6nKW0iXWT6w-1 X-Mimecast-MFC-AGG-ID: 5tEhFnH9Nba6nKW0iXWT6w_1763690373 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 44D1219560B5; Fri, 21 Nov 2025 01:59:33 +0000 (UTC) Received: from localhost (unknown [10.72.116.211]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 28F6330044DB; Fri, 21 Nov 2025 01:59:31 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Caleb Sander Mateos , Uday Shankar , Stefani Seibold , Andrew Morton , linux-kernel@vger.kernel.org, Ming Lei Subject: [PATCH V4 07/27] ublk: define ublk_ch_batch_io_fops for the coming feature F_BATCH_IO Date: Fri, 21 Nov 2025 09:58:29 +0800 Message-ID: <20251121015851.3672073-8-ming.lei@redhat.com> In-Reply-To: <20251121015851.3672073-1-ming.lei@redhat.com> References: <20251121015851.3672073-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Introduces the basic structure for a batched I/O feature in the ublk driver. It adds placeholder functions and a new file operations structure, ublk_ch_batch_io_fops, which will be used for fetching and committing I/O commands in batches. Currently, the feature is disabled. Reviewed-by: Caleb Sander Mateos Signed-off-by: Ming Lei --- drivers/block/ublk_drv.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index dd9c35758a46..1fcca52591c3 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -254,6 +254,11 @@ static inline struct request *__ublk_check_and_get_req= (struct ublk_device *ub, u16 q_id, u16 tag, struct ublk_io *io, size_t offset); static inline unsigned int ublk_req_build_flags(struct request *req); =20 +static inline bool ublk_dev_support_batch_io(const struct ublk_device *ub) +{ + return false; +} + static inline struct ublksrv_io_desc * ublk_get_iod(const struct ublk_queue *ubq, unsigned tag) { @@ -2512,6 +2517,12 @@ static int ublk_ch_uring_cmd(struct io_uring_cmd *cm= d, unsigned int issue_flags) return ublk_ch_uring_cmd_local(cmd, issue_flags); } =20 +static int ublk_ch_batch_io_uring_cmd(struct io_uring_cmd *cmd, + unsigned int issue_flags) +{ + return -EOPNOTSUPP; +} + static inline bool ublk_check_ubuf_dir(const struct request *req, int ubuf_dir) { @@ -2618,6 +2629,16 @@ static const struct file_operations ublk_ch_fops =3D= { .mmap =3D ublk_ch_mmap, }; =20 +static const struct file_operations ublk_ch_batch_io_fops =3D { + .owner =3D THIS_MODULE, + .open =3D ublk_ch_open, + .release =3D ublk_ch_release, + .read_iter =3D ublk_ch_read_iter, + .write_iter =3D ublk_ch_write_iter, + .uring_cmd =3D ublk_ch_batch_io_uring_cmd, + .mmap =3D ublk_ch_mmap, +}; + static void ublk_deinit_queue(struct ublk_device *ub, int q_id) { struct ublk_queue *ubq =3D ub->queues[q_id]; @@ -2778,7 +2799,10 @@ static int ublk_add_chdev(struct ublk_device *ub) if (ret) goto fail; =20 - cdev_init(&ub->cdev, &ublk_ch_fops); + if (ublk_dev_support_batch_io(ub)) + cdev_init(&ub->cdev, &ublk_ch_batch_io_fops); + else + cdev_init(&ub->cdev, &ublk_ch_fops); ret =3D cdev_device_add(&ub->cdev, dev); if (ret) goto fail; --=20 2.47.0