From nobody Wed Dec 17 17:29:24 2025 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA7F1204697 for ; Sat, 15 Mar 2025 17:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742059436; cv=none; b=UCLVuFhY7aEu7jAXSaRRk+HqKDc3GrHdNCtQ6prk8Kf/vmIn0gSnZOz3PkYKfw+9RINSYbhmv4epMuh3X1bHuSLYeefO2BhU9qiv3XTU4jM0HnfcwvIAgkqj41M5VwCVaUdz8j9DysQwzKeeQ8GeNXQlPOqW4E7wxKSsSQigV+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742059436; c=relaxed/simple; bh=+Xi783V5yc8Q0yTmbpRV6VJPJ52LNPvr+MMzKPRI0iY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=alaa38gbLsf1vOF/33X5aGqUPDKrgU3sEtWIGeDR9R9ulxzj6nAtP8uIxnXklhql1RgptFR0F3sCwnqWy6M5NxH1blYpv99yXXIpKHys3KIOLoIjdF//LKawpCp6H+Jp29CBCxJJwvVoTYLJ0rjUNNwYy9O15/7ZQCKpTSS75lA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=furiosa.ai; spf=none smtp.mailfrom=furiosa.ai; dkim=pass (2048-bit key) header.d=furiosa-ai.20230601.gappssmtp.com header.i=@furiosa-ai.20230601.gappssmtp.com header.b=XR+8w1xS; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=furiosa-ai.20230601.gappssmtp.com header.i=@furiosa-ai.20230601.gappssmtp.com header.b="XR+8w1xS" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-224100e9a5cso60212705ad.2 for ; Sat, 15 Mar 2025 10:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=furiosa-ai.20230601.gappssmtp.com; s=20230601; t=1742059434; x=1742664234; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fh1zT0Yh0Gu09Ze3QlJjUyNQbYt7kXIeCUqWyJ6HX1w=; b=XR+8w1xSZ52eEGgrsvjZlqmsHjiUdR0c/x4DVJ8n5ypBB/hcZ3XI387Lxzt5vdoZF2 DK36pOavbUDmh4VUDlVvI4kNn+JZnYKKtcqUv9a3qVhbNydHKUDo8Gnjz5bOxu6mahVJ 3W4j4s0eaXTpDAqdusMdiM1VQxwZ6eswUT2CFQvZDd3k/8DXftxPkKtE1ZyR24w8gr8A Mj8GFYc8gK7Gh2vQ95i9UASt0SYwDzBUD2cUzfiqh/aO35Zcb/AlXNQwj33MrbHEe2re NCI+jHZKBv8CgTETcTTiPSoNLLr3p/dxYtHJs1n3b/9wP8VhgSnHzJh3niEBqkqf2cY6 0Mvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742059434; x=1742664234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fh1zT0Yh0Gu09Ze3QlJjUyNQbYt7kXIeCUqWyJ6HX1w=; b=Fa4OKonTNTEzkOuz8aY104oG1SGitscj68120dX0uSrZwaHIg7a+NdUM0zHHX6zDdj S5q4r3n945y3AMRkCMHi5Ld6TrbvjPcmr30FvrEzt6tGSO/c7ks5S9nrxKVuD4JRhGjR 7489RqH54a+1a1XBDZYCWgj0g5vTsTXam6PjLkdWnlcPP96XdTpmyVqNcIwK4ArxxsOh qqutMcd4/mmHVHdqegBqe7nz3pkUGzh93cK+bTHB+L8o+rPHlEKu6+WEeQqIAyYCFkKF cNz5csmHfIcgpro9HkNBkaJxLRHdMUDXr7z2oFivvBzupd8EXrXRF+cR6LnnvysjfI9W OOJQ== X-Forwarded-Encrypted: i=1; AJvYcCVK4DC9k6j/JTF5AuI7N6m4s1Zbqgujxx+jF17E5r87INLfzLdLPc8ZF7AmF12Xmpt2VU/ty7le4gca3Xk=@vger.kernel.org X-Gm-Message-State: AOJu0YycUIlTchDRUyr1lIF6aMCzL5bc5n4HJyYu6HtNRnIlLHIUl8b4 zZGKlS7z1RsPvuCP/sBSxPPQdRr7vH8zRu0SAkeMZIMPi0wUxwu4OjCCappibJ8= X-Gm-Gg: ASbGncuGzXSs0e62UQAGbmPoVG+MfkWorCljUJAn1cxcLcm6XK9BsDcJwK6fCKI9bty lyZMpgAQxKpbh9jS/lBQhFJjIKBCAKcUTGuIK32lOyj1ocVai6vPHopluLVVgfg8+us3bXDfjdw nKK20fgMSJDOUovUJQqooOSByarTz41FEditCN5IVyIbGT458Ddy9wDvcIQy6zjuXlgFqkCpwO0 lyEXyxrczh+Wk/D/+DDs4PfiebDNdknoLKfljY/JF/gjBQINfZsXUngeuSf5f91lCHJt+5IFtRv MsS23nf7Dx3UvjP2KX3qUiTFUZLxiPO+z5PcTpP3dA== X-Google-Smtp-Source: AGHT+IHVzljRXJY/9yHvuSK1uGGuyEVzklZ+ZTzun69UonS6hf3ZhgjvkDffUlPz2KkIuK8CrtWZQg== X-Received: by 2002:a05:6a00:2d95:b0:736:4d44:8b77 with SMTP id d2e1a72fcca58-7372236edfbmr9792278b3a.8.1742059434023; Sat, 15 Mar 2025 10:23:54 -0700 (PDT) Received: from sidong.. ([61.83.209.48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-737115512f0sm4673013b3a.49.2025.03.15.10.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Mar 2025 10:23:53 -0700 (PDT) From: Sidong Yang To: Josef Bacik , David Sterba , Jens Axboe , Pavel Begunkov Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Sidong Yang Subject: [RFC PATCH v3 1/3] io-uring/cmd: add iou_vec field for io_uring_cmd Date: Sat, 15 Mar 2025 17:23:17 +0000 Message-ID: <20250315172319.16770-2-sidong.yang@furiosa.ai> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250315172319.16770-1-sidong.yang@furiosa.ai> References: <20250315172319.16770-1-sidong.yang@furiosa.ai> 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 Content-Type: text/plain; charset="utf-8" This patch adds iou_vec field for io_uring_cmd. Also it needs to be cleanup for cache. It could be used in uring cmd api that imports multiple fixed buffers. Signed-off-by: Sidong Yang --- include/linux/io_uring/cmd.h | 1 + io_uring/io_uring.c | 2 +- io_uring/opdef.c | 1 + io_uring/uring_cmd.c | 20 ++++++++++++++++++++ io_uring/uring_cmd.h | 3 +++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h index 598cacda4aa3..74b9f0aec229 100644 --- a/include/linux/io_uring/cmd.h +++ b/include/linux/io_uring/cmd.h @@ -22,6 +22,7 @@ struct io_uring_cmd { struct io_uring_cmd_data { void *op_data; struct io_uring_sqe sqes[2]; + struct iou_vec iou_vec; }; =20 static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 5ff30a7092ed..55334fa53abf 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -289,7 +289,7 @@ static void io_free_alloc_caches(struct io_ring_ctx *ct= x) io_alloc_cache_free(&ctx->apoll_cache, kfree); io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free); io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free); - io_alloc_cache_free(&ctx->uring_cache, kfree); + io_alloc_cache_free(&ctx->uring_cache, io_cmd_cache_free); io_alloc_cache_free(&ctx->msg_cache, kfree); io_futex_cache_free(ctx); io_rsrc_cache_free(ctx); diff --git a/io_uring/opdef.c b/io_uring/opdef.c index 7fd173197b1e..e275180c2077 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -755,6 +755,7 @@ const struct io_cold_def io_cold_defs[] =3D { }, [IORING_OP_URING_CMD] =3D { .name =3D "URING_CMD", + .cleanup =3D io_uring_cmd_cleanup, }, [IORING_OP_SEND_ZC] =3D { .name =3D "SEND_ZC", diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index de39b602aa82..315c603cfdd4 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -28,6 +28,13 @@ static void io_req_uring_cleanup(struct io_kiocb *req, u= nsigned int issue_flags) =20 if (issue_flags & IO_URING_F_UNLOCKED) return; + + req->flags &=3D ~REQ_F_NEED_CLEANUP; + + io_alloc_cache_vec_kasan(&cache->iou_vec); + if (cache->iou_vec.nr > IO_VEC_CACHE_SOFT_CAP) + io_vec_free(&cache->iou_vec); + if (io_alloc_cache_put(&req->ctx->uring_cache, cache)) { ioucmd->sqe =3D NULL; req->async_data =3D NULL; @@ -35,6 +42,11 @@ static void io_req_uring_cleanup(struct io_kiocb *req, u= nsigned int issue_flags) } } =20 +void io_uring_cmd_cleanup(struct io_kiocb *req) +{ + io_req_uring_cleanup(req, 0); +} + bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx, struct io_uring_task *tctx, bool cancel_all) { @@ -339,3 +351,11 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsign= ed int issue_flags) } EXPORT_SYMBOL_GPL(io_uring_cmd_sock); #endif + +void io_cmd_cache_free(const void *entry) +{ + struct io_uring_cmd_data *cache =3D (struct io_uring_cmd_data *)entry; + + io_vec_free(&cache->iou_vec); + kfree(cache); +} diff --git a/io_uring/uring_cmd.h b/io_uring/uring_cmd.h index f6837ee0955b..d2b9c1522e22 100644 --- a/io_uring/uring_cmd.h +++ b/io_uring/uring_cmd.h @@ -1,7 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 +#include =20 int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags); int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe= ); +void io_uring_cmd_cleanup(struct io_kiocb *req); =20 bool io_uring_try_cancel_uring_cmd(struct io_ring_ctx *ctx, struct io_uring_task *tctx, bool cancel_all); +void io_cmd_cache_free(const void *entry); --=20 2.43.0 From nobody Wed Dec 17 17:29:24 2025 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BEC917995E for ; Sat, 15 Mar 2025 17:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742059438; cv=none; b=hRzQWKfLnsGPlT7lKn2EV8YODKvLoKcip4dmUYhKikF8xsKiBdbsBgPwtrgrt57+8O2BPkg/xlMlMvLJoW7PLZK9BYaFzPjFkxGgX9AsSX1SAsGRl1hJcWsNBEWs2pxPFIxHRroCBocfH2MT6C0w+HuPD9Ys9ormmjy+tODqBn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742059438; c=relaxed/simple; bh=1PpG5wl2vDgUXZOFXh86OOBxn7Ar5lt5SQ/Ndxx/TgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TOnhmJpKkN7Kz0k/KBRlXdbRmJfdWXl+Zf+FEG2gJo4XBFhCBRqANK5DUuVrhxpMCdUhJvQqLnXVeA0V/vuP20pB7X8jRUtMYFzy+NJ/WUl/qfCuQcFHoGuxNUkt6ATRbrIyC6MHeTBH2ph7WfuWwirkjSepOmU9Z16Rtqfg4ZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=furiosa.ai; spf=none smtp.mailfrom=furiosa.ai; dkim=pass (2048-bit key) header.d=furiosa-ai.20230601.gappssmtp.com header.i=@furiosa-ai.20230601.gappssmtp.com header.b=mUmkojfm; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=furiosa-ai.20230601.gappssmtp.com header.i=@furiosa-ai.20230601.gappssmtp.com header.b="mUmkojfm" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-22403cbb47fso55821845ad.0 for ; Sat, 15 Mar 2025 10:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=furiosa-ai.20230601.gappssmtp.com; s=20230601; t=1742059436; x=1742664236; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bgnlVIlZsctNY//AQHA0xHAjDyuSTMqzdv7gveBxpzM=; b=mUmkojfm4Jcb/yjrSlX2/J3IyGZbInyaXOMqgP5/oLof8lIGSJ6HRoZYeRiONfI59Z 3OUXxBF4sXEP5gNPrld/1Y3UHULZ1TDJMruTeE1MCvgxkezjiAZUwrx1Wnf+L1TFW+ck fm/9ETpKMv45bMHzQdBToCzTYB0vqCiAVPeMNsC97JjHw7SlWWjWQTHvne4SlXIrGMbK KHxkekftWCtvV54bCCcANpfDL7krEAUXaiN+JluQ8g/KRgPm4H7o+zwDectpzfSg0WQW aNk65GGodAy0tDCRBmoEUYj/YrMMKj5CXJtYZBmUGlTsYyeHP80MqNeUQg8qDYmUIAW0 yytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742059436; x=1742664236; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bgnlVIlZsctNY//AQHA0xHAjDyuSTMqzdv7gveBxpzM=; b=OAE/BlJyu+ZRyQ8VrAR5Om+5cs026dKQNIyiJ2kuuAsNRzrVvAXVm0wulKcqmtDnWM BeMZitXKC4zMREcfUigLdqOSNMNGtvFYerLhrRXh6ecgK2USdyRzMZId8Lz271y0WCSK AXXFyvIEMIdI5Fk3t2fxfv70ldodIrAS/a8Lr4nC9KPJZbdZmmLCVDvtxY6bFA2hlGuo +XrsFuJruMcW4BLya7gHQYgRoxi1w1AeSXqmMhfhv46eQPQWzON1tQaSIKmL/BhKCknZ efI9oF9/uXSQzMJmVs3JUuEt0jeAiE+PYu99kAggLiZ0PEn/KMIUSruOHb4dGJo4urdu K0cA== X-Forwarded-Encrypted: i=1; AJvYcCX/TjU+3dGSwPqeDtiq8rYmA78eC6tsvDG2MZLWB9fNRqo729/HWFu3A8ixAUiwEzUhYffiur61KTPc6F4=@vger.kernel.org X-Gm-Message-State: AOJu0YxlhSPIQweEa5+5UsQej10EriJlc9SBzI6usdEFdFgYie5IiBiq Pdv9905fQID5OGGWW7qMOYuiDshvmskQEp0HgXPaTN9GLU9/hlQqBqF8QSKs4bs= X-Gm-Gg: ASbGncu2lfIZW9YXLuT08DnfIfyeIrCbPdjLvzBnijgyDCebebgTVMc5MlSPN9ZGvGR g5/N3idwnXp/BUZasfQa94P+sswGZc7hbPjSBe1OY5O7deXc1B1ozPdF/Gvm62YOXlUBYkmvDpJ umJxJxbwBzuuWPDP9tGpafeA0xVcQGNaQSMRgUVrDZgxS5XpoDy8oV7P9871L9s30J+5AbxsZhe byReFpgDKm1Fh6CCldHq12uZBRaA8fNGDnQEjuwn1WNVBaeAcR1H2leM4hNTFdE9en+ufdBkddh w/CLMri2N/eLi63199dappPeQoaCSTd4g6PxzRYV6Q== X-Google-Smtp-Source: AGHT+IFCDUOQgEkaQUJPOtUek3RyqU4kZwZOL0TnYTplGs1jgZy9U0ZODBK3dFkuMeQxYadueVihlA== X-Received: by 2002:a05:6a00:13aa:b0:732:2923:b70f with SMTP id d2e1a72fcca58-7372237712cmr7727611b3a.11.1742059436632; Sat, 15 Mar 2025 10:23:56 -0700 (PDT) Received: from sidong.. ([61.83.209.48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-737115512f0sm4673013b3a.49.2025.03.15.10.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Mar 2025 10:23:56 -0700 (PDT) From: Sidong Yang To: Josef Bacik , David Sterba , Jens Axboe , Pavel Begunkov Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Sidong Yang Subject: [RFC PATCH v3 2/3] io-uring/cmd: introduce io_uring_cmd_import_fixed_vec Date: Sat, 15 Mar 2025 17:23:18 +0000 Message-ID: <20250315172319.16770-3-sidong.yang@furiosa.ai> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250315172319.16770-1-sidong.yang@furiosa.ai> References: <20250315172319.16770-1-sidong.yang@furiosa.ai> 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 Content-Type: text/plain; charset="utf-8" io_uring_cmd_import_fixed_vec() could be used for using multiple fixed buffer in uring_cmd callback. Signed-off-by: Sidong Yang --- include/linux/io_uring/cmd.h | 14 ++++++++++++++ io_uring/uring_cmd.c | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h index 74b9f0aec229..2c7ae8474a56 100644 --- a/include/linux/io_uring/cmd.h +++ b/include/linux/io_uring/cmd.h @@ -45,6 +45,12 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long le= n, int rw, struct io_uring_cmd *ioucmd, unsigned int issue_flags); =20 +int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd, + const struct iovec __user *uvec, + unsigned long uvec_segs, int ddir, + unsigned int issue_flags, + struct iov_iter *iter); + /* * Completes the request, i.e. posts an io_uring CQE and deallocates @iouc= md * and the corresponding io_uring request. @@ -77,6 +83,14 @@ io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, i= nt rw, { return -EOPNOTSUPP; } +int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd, + const struct iovec __user *uvec, + unsigned long uvec_segs, int ddir, + unsigned int issue_flags, + struct iov_iter *iter) +{ + return -EOPNOTSUPP; +} static inline void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, u64 ret2, unsigned issue_flags) { diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 315c603cfdd4..e2bf9edca9df 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -267,6 +267,25 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long = len, int rw, } EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); =20 +int io_uring_cmd_import_fixed_vec(struct io_uring_cmd *ioucmd, + const struct iovec __user *uvec, + unsigned long uvec_segs, int ddir, + unsigned int issue_flags, + struct iov_iter *iter) +{ + struct io_kiocb *req =3D cmd_to_io_kiocb(ioucmd); + struct io_uring_cmd_data *cache =3D req->async_data; + int ret; + + ret =3D io_prep_reg_iovec(req, &cache->iou_vec, uvec, uvec_segs); + if (ret) + return ret; + + return io_import_reg_vec(ddir, iter, req, &cache->iou_vec, + cache->iou_vec.nr, issue_flags); +} +EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed_vec); + void io_uring_cmd_issue_blocking(struct io_uring_cmd *ioucmd) { struct io_kiocb *req =3D cmd_to_io_kiocb(ioucmd); --=20 2.43.0 From nobody Wed Dec 17 17:29:24 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD587205AD0 for ; Sat, 15 Mar 2025 17:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742059441; cv=none; b=T8OXK82ACsW4Eb53QMvLJHHYb8iOrMrbJrVL/3S4nHh+g1bkZkz4FssiKiBt/S24pnV1fTLihbTlFTqZ7URrpzlbEYcSh2mCQ1ASQWdBptrxuw0D4TkV60NgR9+xeXVmEnDZpi0G+tOLl7BsXpJvTajHhKNRkkGSagn/yMWHDpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742059441; c=relaxed/simple; bh=jjy/ipAsVAjM570PsPj8EFg1BR0qzO1tolMoinZ9Ul8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uiY4KdERZY2Cc/KNcYRPPZ4vYW/I8JiC8ySbwzlpZE6IkA38CI8jyyw+dQ9910At2fNsHKE28DC39it9a0JQ96z2AG6yxx+Au/vvbSGfroSFIuth2X9sXl1JfJfH8THjHLnZR7asKfSXAqUHRhGqb5S3cQhJl6tny7b+/gZIF4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=furiosa.ai; spf=none smtp.mailfrom=furiosa.ai; dkim=pass (2048-bit key) header.d=furiosa-ai.20230601.gappssmtp.com header.i=@furiosa-ai.20230601.gappssmtp.com header.b=SqWGaffJ; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=furiosa.ai Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=furiosa-ai.20230601.gappssmtp.com header.i=@furiosa-ai.20230601.gappssmtp.com header.b="SqWGaffJ" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-22349bb8605so65494485ad.0 for ; Sat, 15 Mar 2025 10:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=furiosa-ai.20230601.gappssmtp.com; s=20230601; t=1742059439; x=1742664239; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gA/GFNSLx9g8BrxtQW6nnUtMwtq8vRTEsCNTXthdg1I=; b=SqWGaffJ31cF0n2TnGYhCB3l/Fjtyoyzg4oYOUQod2ilK+ZNwYgZfK3MU+AxByZvHC VU3U5fDjL4ymMK6VpnovNAvbvM8K3uNwCqt2cH6J7xdAUqznHNGe8KV28Gyk9sKs4w0F b6/PaeUVs6rc4BslWUGAFDnrWOl5n03DYCIKniZdXFx/R81LMNj9RmTidvo1SJC0Eokn NREh7W2oMqbdk2rN2lWlouq6Qx/N+2tdTxw3BsrpA3O5HoU3gMmoL6EnLzL97RlwGrpq udBbPbs2vud3YX/HMj1HadMITiYiU8dxlLRaq6vWN/9SkP2ktoc/bu/4wFdDuwEGwuWA 4LDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742059439; x=1742664239; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gA/GFNSLx9g8BrxtQW6nnUtMwtq8vRTEsCNTXthdg1I=; b=We8H4n+xE0TbiPMX4HnVBoalZCsl9xgSkilOnNqEAdMyGYrbniIbkIXwqXxksOgLIV hDnOwIT1zIoje7+B2ppEqynoJs6fkvkBeGL261D/ygaZhKilgw+7DCCUM2oO9OfpYmsN 55/MISKzTPvye2/eQAQu1/j/OqDxHf+qGH8tfG44L51rY0uzOF92/FAGFDH7DP0QDnvh w6WdPWLWhJ7s11SQ7UYGVCqu44xwIOtelBGwZG/13EBncNksNxKg2AoFZkZ3k9omdlyj YK+D56eXZF9Gl/BWeAJIAOfQ9OHRGOtMKhr/mbQipzxqKWxZpMOfPppk7IGsNk0G4wN8 J4tQ== X-Forwarded-Encrypted: i=1; AJvYcCWCj6Vtv94OH/GXgxa6FZnVw2wsD0/IjvSIhzz2w4Cfdzhid7CyfrR/QEjn+3Abs87nCy0Gpr31SqQEHjI=@vger.kernel.org X-Gm-Message-State: AOJu0YwwM3IyVqMV66tB/9W6fWYjpVbEexoJV430iieebs7SnxHsyh0t 8C+nbmHrZRuFefUrhTcSk/P3Vvv82QmtL0WdqUnubOrwnfyngnQpDlW1ZAcj0d8= X-Gm-Gg: ASbGncua9obCdjumqoAyWpNmxVW9r9iO5u8eJA6/DuOx7XchivVgsYsJSlKxikL0kIw jNw90UlWvc5YnzaH0ti9b3+g44mfhnjTkJs8vlf0/JNnoLPXs196sdx8yhSF1OkGao59tp0l5J/ 4R+47+UWdLtdGf1LiLxwCNGUuCI4N8S5Xff06JF+qLgrYfQlaebNm3H6PD8qiNXdOG731s8hxWs nfNtF9jBwvygh8YSeRMnaSxeMUBodIawgXqEgj7c9TsTrWYgz4lR1WQg4H4jOPpoDg3g/58Hm2p nevtMQquAkmtTHi+cvKGtMflOOv4XlPyqgQvEzq8kw== X-Google-Smtp-Source: AGHT+IEbj/fYNWZdaI4EPbRWv9fRRPhjL9271b0qlYx3tRQZvXgQkMey08ub5woVXGP3tvnCVG45+g== X-Received: by 2002:a05:6a00:3d0c:b0:736:4d05:2e2e with SMTP id d2e1a72fcca58-7372238f6c2mr7905409b3a.6.1742059439198; Sat, 15 Mar 2025 10:23:59 -0700 (PDT) Received: from sidong.. ([61.83.209.48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-737115512f0sm4673013b3a.49.2025.03.15.10.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Mar 2025 10:23:58 -0700 (PDT) From: Sidong Yang To: Josef Bacik , David Sterba , Jens Axboe , Pavel Begunkov Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Sidong Yang Subject: [RFC PATCH v3 3/3] btrfs: ioctl: introduce btrfs_uring_import_iovec() Date: Sat, 15 Mar 2025 17:23:19 +0000 Message-ID: <20250315172319.16770-4-sidong.yang@furiosa.ai> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250315172319.16770-1-sidong.yang@furiosa.ai> References: <20250315172319.16770-1-sidong.yang@furiosa.ai> 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 Content-Type: text/plain; charset="utf-8" This patch introduces btrfs_uring_import_iovec(). In encoded read/write with uring cmd, it uses import_iovec without supporting fixed buffer. btrfs_using_import_iovec() could use fixed buffer if cmd flags has IORING_URING_CMD_FIXED. Signed-off-by: Sidong Yang --- fs/btrfs/ioctl.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 6c18bad53cd3..a7b52fd99059 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4802,6 +4802,28 @@ struct btrfs_uring_encoded_data { struct iov_iter iter; }; =20 +static int btrfs_uring_import_iovec(struct io_uring_cmd *cmd, + unsigned int issue_flags, int rw) +{ + struct btrfs_uring_encoded_data *data =3D + io_uring_cmd_get_async_data(cmd)->op_data; + int ret; + + if (cmd && (cmd->flags & IORING_URING_CMD_FIXED)) { + data->iov =3D NULL; + ret =3D io_uring_cmd_import_fixed_vec(cmd, data->args.iov, + data->args.iovcnt, + ITER_DEST, issue_flags, + &data->iter); + } else { + data->iov =3D data->iovstack; + ret =3D import_iovec(rw, data->args.iov, data->args.iovcnt, + ARRAY_SIZE(data->iovstack), &data->iov, + &data->iter); + } + return ret; +} + static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int= issue_flags) { size_t copy_end_kernel =3D offsetofend(struct btrfs_ioctl_encoded_io_args= , flags); @@ -4874,10 +4896,7 @@ static int btrfs_uring_encoded_read(struct io_uring_= cmd *cmd, unsigned int issue goto out_acct; } =20 - data->iov =3D data->iovstack; - ret =3D import_iovec(ITER_DEST, data->args.iov, data->args.iovcnt, - ARRAY_SIZE(data->iovstack), &data->iov, - &data->iter); + ret =3D btrfs_uring_import_iovec(cmd, issue_flags, ITER_DEST); if (ret < 0) goto out_acct; =20 @@ -5022,10 +5041,7 @@ static int btrfs_uring_encoded_write(struct io_uring= _cmd *cmd, unsigned int issu if (data->args.len > data->args.unencoded_len - data->args.unencoded_off= set) goto out_acct; =20 - data->iov =3D data->iovstack; - ret =3D import_iovec(ITER_SOURCE, data->args.iov, data->args.iovcnt, - ARRAY_SIZE(data->iovstack), &data->iov, - &data->iter); + ret =3D btrfs_uring_import_iovec(cmd, issue_flags, ITER_SOURCE); if (ret < 0) goto out_acct; =20 --=20 2.43.0