From nobody Wed Dec 17 19:21:10 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