From nobody Wed Dec 17 10:20:57 2025 Received: from mail-qv1-f100.google.com (mail-qv1-f100.google.com [209.85.219.100]) (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 DA3AEE545 for ; Fri, 28 Mar 2025 19:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743190963; cv=none; b=I5SxTAkNYMcCAEp0gp7AchTMCz1sQjEfHUndLyyQhI8QvxoGlg+4zJvlfew9IedvmaivHRBVbY6c5VXy0XxvzLz3BOBngio1SBleiTKpbIwhFFqkg/YT+o28pd+qJURmpsu9Wh3uvSuvqXNvnLo1jXH2c5X3wWk0lVDNwI7nsLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743190963; c=relaxed/simple; bh=IIFz4j2C2Eh7fAQD0vF3myZwWOH3MPOPveM/pvRkH1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YOyMsqfvrQGZJS5rGUC00roqZ09k0rOiV6soIzmuMt2q1YG5mLKr06udzldNgoSvxv3rzwV9/vza3CUpGrUwwlNmCPNgPX9Y5QdaaF+i121OP/YonxuMtGEPHhI0ZtrpUyzKHxw2w6QaeKTQ+qKET9wt/Q+34X9aK7ut6CBRlCY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=dcPP/t60; arc=none smtp.client-ip=209.85.219.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="dcPP/t60" Received: by mail-qv1-f100.google.com with SMTP id 6a1803df08f44-6e8ff1b051dso3830486d6.1 for ; Fri, 28 Mar 2025 12:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1743190961; x=1743795761; 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=lLazX2sR1QiGKeTx3lHr1mcmdxpFqxEOFWM2x5oC3Fg=; b=dcPP/t60EJ04nWA4KNJSsA28QsWcIhbE+btJeaFWjL8RBB9EWMcwDo7Jrw3pJ0a6Uy OUhC42H5kJO3/3DtTC+OXjC963gJ5P3BfRtSvJ9BVfZdq4EIToMyLzU1MClaCAhc10qp xpNSJ3Cq59ANj2a+VWs4SM18EBFgaM35wCrAB1PG1XZxXOpEPWt3iJ2aXGneAIiwhqrJ z3FJA8V4LTgpMvSjhokkSeZYcTaM6eamUnAwMZRf/nkOnNjcfUb2KmXip3e12QRLtfSG YMJ7LFo+ZE6aTGjH+xqiRcMq47/kYEOogqoLH+sTsIuP/xHQgktgLq+s3usLAuVQwJdS PlaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743190961; x=1743795761; 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=lLazX2sR1QiGKeTx3lHr1mcmdxpFqxEOFWM2x5oC3Fg=; b=b0C2/cHqCSwNrHFzTUHXRcIlBDetJOh8FgrTj5zQgF8T94k7hgCnZIldZCQFUQe2T9 Tv0M9whDq2hw1tx5fdX3c3ZVOBFI6rGXJbTp/4CunwMB1L4YdPk4QT47c+C1Ux2aUcat WzLqZsn/aXD7QRoh8nVMZhOnj/Kp3f81yBTT2Lqr5piWVVh4KwV+BFRpF5SN0akMGdAk sz5rYMZN39nva02NfwKBCYgIY0g3OeLPlTYOl9n9BPKN9BelO8/7QOrUxuTTiLYXSfKM smIsQ0s2u5Mg/LOLA9zqSusT8NBDTmhXlGWA4miOHgJD1w/NaJSv2m862InBP3xaFrRl RAgA== X-Forwarded-Encrypted: i=1; AJvYcCVPoXAOGgv5sUgRHSkF8OsQLhuRxu/t/GVBEmXSNVq6MLsO1BudotrfmHzl7rM+toYthKo7i2w7o9LQ/do=@vger.kernel.org X-Gm-Message-State: AOJu0YzhVjBINmy2ky3mrhzJ2Fp2L7ycIR1DWAuRFl9rW534UrSAoF9z v7RAbe8fIMSw3UwskVnM82+eMEDpGEurBdk47/hVLglJpKabNVYQ/0jX9TTGJgGVYPB/L92AZiO 9spT5z5DnacMlWZhfixmOI5ogvHTf/MUG X-Gm-Gg: ASbGnctfE/NyJOXLV4gHVnhUcJk5mdrk/4WH33mDbU31+9VOe8859i2veloga67zm8m GIr+neliG8bcr6RJC0rN3KxuKcYSr6JStWsUdulIon2oTIn9Wvt0GGb4g3tcIzfMusrWCcce9L8 ImfBOr9AtmgarTMa7Yy7zoGNR+lUEkYneZta6y90OKsFRDw+/N/qNlcDvsZIS2/2fHkM//jCU3A oPFv01tJHE45Nvi9Ufl93NoQ7nzN+KDw08evK33H7RghHYm/B/9zSQWDrsbaOnMoU3Pc5W/hHz+ CVPLTgei2UzsWr1FbJZejvVxJxnBzE9pg7j3LH1zK1DUGEGz X-Google-Smtp-Source: AGHT+IGTVuJ9wsa8D0YOPf/IR0bLXPoK/A+oaStmp2cHkFUKuudrLMCf9S4wmCfByWcdBV5jz2al3JueEfox X-Received: by 2002:a05:622a:110f:b0:474:e996:197a with SMTP id d75a77b69052e-477ed7b2291mr3086091cf.10.1743190960620; Fri, 28 Mar 2025 12:42:40 -0700 (PDT) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id d75a77b69052e-47782a2849asm2198541cf.6.2025.03.28.12.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 12:42:40 -0700 (PDT) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 8A3F73402DD; Fri, 28 Mar 2025 13:42:39 -0600 (MDT) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 8669BE40DF3; Fri, 28 Mar 2025 13:42:39 -0600 (MDT) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe , Shuah Khan Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 1/2] ublk: specify io_cmd_buf pointer type Date: Fri, 28 Mar 2025 13:42:29 -0600 Message-ID: <20250328194230.2726862-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250328194230.2726862-1-csander@purestorage.com> References: <20250328194230.2726862-1-csander@purestorage.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 Content-Type: text/plain; charset="utf-8" io_cmd_buf points to an array of ublksrv_io_desc structs but its type is char *. Indexing the array requires an explicit multiplication and cast. The compiler also can't check the pointer types. Change io_cmd_buf's type to struct ublksrv_io_desc * so it can be indexed directly and the compiler can type-check the code. Signed-off-by: Caleb Sander Mateos Acked-by: Shuah Khan Reviewed-by: Ming Lei --- drivers/block/ublk_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 355a59c78539..ed73e2ffdf09 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -153,11 +153,11 @@ struct ublk_queue { int q_id; int q_depth; =20 unsigned long flags; struct task_struct *ubq_daemon; - char *io_cmd_buf; + struct ublksrv_io_desc *io_cmd_buf; =20 bool force_abort; bool timeout; bool canceling; bool fail_io; /* copy of dev->state =3D=3D UBLK_S_DEV_FAIL_IO */ @@ -701,15 +701,15 @@ static inline bool ublk_rq_has_data(const struct requ= est *rq) } =20 static inline struct ublksrv_io_desc *ublk_get_iod(struct ublk_queue *ubq, int tag) { - return (struct ublksrv_io_desc *) - &(ubq->io_cmd_buf[tag * sizeof(struct ublksrv_io_desc)]); + return &ubq->io_cmd_buf[tag]; } =20 -static inline char *ublk_queue_cmd_buf(struct ublk_device *ub, int q_id) +static inline struct ublksrv_io_desc * +ublk_queue_cmd_buf(struct ublk_device *ub, int q_id) { return ublk_get_queue(ub, q_id)->io_cmd_buf; } =20 static inline int __ublk_queue_cmd_buf_size(int depth) --=20 2.45.2 From nobody Wed Dec 17 10:20:57 2025 Received: from mail-qv1-f98.google.com (mail-qv1-f98.google.com [209.85.219.98]) (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 97AF01DF24D for ; Fri, 28 Mar 2025 19:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743190995; cv=none; b=sA/D93a2iQXmLoGEX7PYGP1vf9ovk1r4MqcqACGNteYSM8I91hQVXeXl7OYmV2LtRhwOcj3j/S3Vv7fpgu/cLwmzRowRXFqEZYUE2eL294mFV9OgPrcIWksUbOgItvtMhWBL4fV+fCb+B12ZKYnyUAIboop+luHiTYdb8xvoAW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743190995; c=relaxed/simple; bh=flOtsZf7EBjh13FNyMsTD/5FQtLGeN9iZpmU8bbk1i0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RHNm/RNJ8i947fKAn574/LaFbW9uIeNzUCq2ZyVqj5W9UH+l3CpwU7fuKSHHKJkOQKs6DvczGshKzfnyb+zAbY3LWp37CdyDAgMW160ygJJ+jh6QRvbXL0X2p95cMBt1CVvGVEGVFkXEK+WpbZYGREeuc5ZO0+kTcDc8bse2AeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=XyjY05Iw; arc=none smtp.client-ip=209.85.219.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="XyjY05Iw" Received: by mail-qv1-f98.google.com with SMTP id 6a1803df08f44-6e8ff1b051dso3830946d6.1 for ; Fri, 28 Mar 2025 12:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1743190991; x=1743795791; 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=Mx6Kws4EehWQnJaxPytGf8blP84+Tos6v3LWW/hBgTg=; b=XyjY05IwJf4CtrRETT91urQ3w1rKNhpRDzT57zdo7OEYwR3ZDB64EyuaT2BxVCt4+s jZzpIxPNXfOBGdkbagHa+PPIMyZ0+FV1LJAcHr8C3jEP6+eFilqmlkapncB8zJbQQVWr qfx5Q8sWGqkidWiXE6lGInnI/xPnWTSz/5mEd+JLAlC0bKQnTLsp2UgT+RWjsMkAgTuK jylwsyFtAexyLd30ltuA04rsZbdK4u7H70y3uiCjeTiFrII9pyyNyytxd89zkhYugIRW oiCJ+MlBOnku7vM0Z3Uvzfm9Q028K61jHBqFVvmwtC7zhVfh9oi3mMm2GWvPO+jG1JqH HxRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743190991; x=1743795791; 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=Mx6Kws4EehWQnJaxPytGf8blP84+Tos6v3LWW/hBgTg=; b=X1y8nTe8OloItGLG7tdHgNrYsc7tcqMB8Y5hs/r9lVH/fL3rEZB+rVi33HsGPApavr 9zmLzZFk4UN0CobIYcDzkJdS+o06ZzCoRhMMpIavZDwylYzr7nyeA4zur8esanhEqzDz uvDk9sgHgUWLZa14pUtvMElvuxcaVLalX0Wd0EwdYm6DhSGPoVUVYOMD4tth5RcwCHTg biId5bY/BASqqqIF+0lvXXG7s9AScg8hD9e26i+td85hhLXcoF7enitoUliz2TxuzYvA nao8x9V0fn2dAAb9eWObyiev2dIWZj4DVmMJBNR1xSc3Am3ng9kaJRPDIGjI2fEqE6Eq Wc5A== X-Forwarded-Encrypted: i=1; AJvYcCV+HsqMa8qcy37Bm/F6Ge/3SjAf40A+l7QB+LYzZF0IVHlVETEs8F/pVrXC64wBlMkzLf7vh2FAgp9CqH4=@vger.kernel.org X-Gm-Message-State: AOJu0Yym/xg/nQ+ppYI1itFPQgdkYl6YEh/3FC5qzJXWYKMwCdJg1zm0 hSKb63LntZQNwyf6kXM/1SbPUcG/rk1mMT8k3dx53mBmBTUQpZoJFLsE8yis8rujF0v871zl0m2 fgbCjjXv4HgrukSgPXKCnI1Jm2yG4AJqD X-Gm-Gg: ASbGncszf/vbpucGE9lQNq92+9F7+ddJ/NRFaufNgafej/8OCa5ZQcbQ0Xvg3MOevU6 55TdcBLWIQplvA4+gYGVyqNecnnr2AbBz3Ixwy6FYoO6/diVzuK+oZz9r5jQYVQZ7RTlKIeh2AR 1IEqwl2ArvXGmpydUebkLECz5SM3fiGQyNJ+P/K5vIlKQdwPWSM4uimqa9O4ILrUpYwo2P7Zhhp NdDYcvpUgYE5YiS+OaQNfFUBO+B+YC9uvmSQ3jw5Ouyufspi8SicTVXCn5M4rtyHgsLVaxgZ/Hp 3DNdp2l8UtPMZIdLrG4YRv+HygKYdbnhqqcUflXH06LJ1WQz X-Google-Smtp-Source: AGHT+IFQh9Pcs5CAbScmakAUo+ucuKKnoyChirklEpCbSZtv64yiMBBKapJk+vPUTDfe74Ad8xyLWKkPfmB2 X-Received: by 2002:ad4:596f:0:b0:6e8:9ed4:140c with SMTP id 6a1803df08f44-6eed61f0b0bmr1762166d6.7.1743190991334; Fri, 28 Mar 2025 12:43:11 -0700 (PDT) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id 6a1803df08f44-6eec963b60bsm2865306d6.17.2025.03.28.12.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Mar 2025 12:43:11 -0700 (PDT) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 479CE3402DD; Fri, 28 Mar 2025 13:43:10 -0600 (MDT) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 3CDC7E40DF3; Fri, 28 Mar 2025 13:42:40 -0600 (MDT) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe , Shuah Khan Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH 2/2] selftests: ublk: specify io_cmd_buf pointer type Date: Fri, 28 Mar 2025 13:42:30 -0600 Message-ID: <20250328194230.2726862-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250328194230.2726862-1-csander@purestorage.com> References: <20250328194230.2726862-1-csander@purestorage.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 Content-Type: text/plain; charset="utf-8" Matching the ublk driver, change the type of io_cmd_buf from char * to struct ublksrv_io_desc *. Signed-off-by: Caleb Sander Mateos Acked-by: Shuah Khan Reviewed-by: Ming Lei --- tools/testing/selftests/ublk/kublk.c | 2 +- tools/testing/selftests/ublk/kublk.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests= /ublk/kublk.c index 05147b53c361..83756f97c26e 100644 --- a/tools/testing/selftests/ublk/kublk.c +++ b/tools/testing/selftests/ublk/kublk.c @@ -320,11 +320,11 @@ static int ublk_queue_init(struct ublk_queue *q) q->state |=3D UBLKSRV_ZC; } =20 cmd_buf_size =3D ublk_queue_cmd_buf_sz(q); off =3D UBLKSRV_CMD_BUF_OFFSET + q->q_id * ublk_queue_max_cmd_buf_sz(); - q->io_cmd_buf =3D (char *)mmap(0, cmd_buf_size, PROT_READ, + q->io_cmd_buf =3D mmap(0, cmd_buf_size, PROT_READ, MAP_SHARED | MAP_POPULATE, dev->fds[0], off); if (q->io_cmd_buf =3D=3D MAP_FAILED) { ublk_err("ublk dev %d queue %d map io_cmd_buf failed %m\n", q->dev->dev_info.dev_id, q->q_id); goto fail; diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests= /ublk/kublk.h index f31a5c4d4143..760ff8ffb810 100644 --- a/tools/testing/selftests/ublk/kublk.h +++ b/tools/testing/selftests/ublk/kublk.h @@ -126,11 +126,11 @@ struct ublk_queue { int q_depth; unsigned int cmd_inflight; unsigned int io_inflight; struct ublk_dev *dev; const struct ublk_tgt_ops *tgt_ops; - char *io_cmd_buf; + struct ublksrv_io_desc *io_cmd_buf; struct io_uring ring; struct ublk_io ios[UBLK_QUEUE_DEPTH]; #define UBLKSRV_QUEUE_STOPPING (1U << 0) #define UBLKSRV_QUEUE_IDLE (1U << 1) #define UBLKSRV_NO_BUF (1U << 2) @@ -300,11 +300,11 @@ static inline void ublk_mark_io_done(struct ublk_io *= io, int res) io->result =3D res; } =20 static inline const struct ublksrv_io_desc *ublk_get_iod(const struct ublk= _queue *q, int tag) { - return (struct ublksrv_io_desc *)&(q->io_cmd_buf[tag * sizeof(struct ublk= srv_io_desc)]); + return &q->io_cmd_buf[tag]; } =20 static inline void ublk_set_sqe_cmd_op(struct io_uring_sqe *sqe, __u32 cmd= _op) { __u32 *addr =3D (__u32 *)&sqe->off; --=20 2.45.2