From patchwork Mon Mar 3 12:43:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998765 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 7DF0A20F09F for ; Mon, 3 Mar 2025 12:43:46 +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=1741005828; cv=none; b=G3wp5ev405cd0bklZvIORW5LS1tOFOAt6X/5fa4xjKgrYyOpzMmKcuPxA0udl6NIo/X1prWTfuWJkImt8TUrUX7Wk+r6eOR6i1outvZ78HuJ9InkYUOd8y6fbmMjjrHXJlgKxu6+8PI0epB+yroG/tETh1O/zHr/0X6rYjhb0nI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005828; c=relaxed/simple; bh=R/UbvFQKhkE48f7V8KwpGE3Rvfnp+1NUFq5fmOTIqUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gtIRAh00Gzk5zg412C+VUtMohZLlQozhYdUV8Rl4oLJKJOKIaR1U6LBLvF4FRPmQpZMDqSUtBsbsw2kaxVsQ2RNXGdGKe9LsS/oBKcCnnZbZm3m31l0zG/PDmG4APiM/NgKk9UrgRpaggEdZeGqoKiIBUYdZIlVuxFyV4TaAZCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=VWpMvkl2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="VWpMvkl2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005825; 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=NJxJXtg79V4txmYV9tJrHZcZ/bDrEyIKMG5SvuG1GoQ=; b=VWpMvkl2A6OIdvmFOl0HsjxnNhQ44+DX7TOTfouM53DpMBhTp/8rpsIlPxQZeAcpouTB33 ESy+J95t8tmIyLGLkjQi3wUSkjn9oFD9HLtTekicPXPOMX9o1kXQ4d4ZKqDBU8GUfrXrPd TTtFY/LKgj+Lk753m+1Ro8tQp2UIEcs= Received: from mx-prod-mc-04.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-473-0WjyWbN-PU2fv6HMQHDRQg-1; Mon, 03 Mar 2025 07:43:44 -0500 X-MC-Unique: 0WjyWbN-PU2fv6HMQHDRQg-1 X-Mimecast-MFC-AGG-ID: 0WjyWbN-PU2fv6HMQHDRQg_1741005823 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4DE40190ECCB; Mon, 3 Mar 2025 12:43:43 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ED7961956094; Mon, 3 Mar 2025 12:43:41 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 01/11] selftests: ublk: make ublk_stop_io_daemon() more reliable Date: Mon, 3 Mar 2025 20:43:11 +0800 Message-ID: <20250303124324.3563605-2-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Improve ublk_stop_io_daemon() in the following ways: - don't wait if ->ublksrv_pid becomes -1, which means that the disk has been stopped - don't wait if ublk char device doesn't exist any more, so we can avoid to rely on inoitfy for wait until the char device is closed And this way may reduce time of delete command a lot. Signed-off-by: Ming Lei Reviewed-by: Keith Busch --- tools/testing/selftests/ublk/kublk.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c index b65bdaf7e281..2072d880fdc4 100644 --- a/tools/testing/selftests/ublk/kublk.c +++ b/tools/testing/selftests/ublk/kublk.c @@ -691,13 +691,14 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev) return ret; } -static int wait_ublk_dev(char *dev_name, int evt_mask, unsigned timeout) +static int wait_ublk_dev(const char *path, int evt_mask, unsigned timeout) { #define EV_SIZE (sizeof(struct inotify_event)) #define EV_BUF_LEN (128 * (EV_SIZE + 16)) struct pollfd pfd; int fd, wd; int ret = -EINVAL; + const char *dev_name = basename(path); fd = inotify_init(); if (fd < 0) { @@ -761,18 +762,23 @@ static int ublk_stop_io_daemon(const struct ublk_dev *dev) char ublkc[64]; int ret = 0; + if (daemon_pid < 0) + return 0; + /* daemon may be dead already */ if (kill(daemon_pid, 0) < 0) goto wait; - /* - * Wait until ublk char device is closed, when our daemon is shutdown - */ - snprintf(ublkc, sizeof(ublkc), "%s%d", "ublkc", dev_id); - ret = wait_ublk_dev(ublkc, IN_CLOSE_WRITE, 10); - /* double check and inotify may not be 100% reliable */ + snprintf(ublkc, sizeof(ublkc), "/dev/%s%d", "ublkc", dev_id); + + /* ublk char device may be gone already */ + if (access(ublkc, F_OK) != 0) + goto wait; + + /* Wait until ublk char device is closed, when the daemon is shutdown */ + ret = wait_ublk_dev(ublkc, IN_CLOSE, 10); + /* double check and since it may be closed before starting inotify */ if (ret == -ETIMEDOUT) - /* the daemon doesn't exist now if kill(0) fails */ ret = kill(daemon_pid, 0) < 0; wait: waitpid(daemon_pid, NULL, 0); @@ -910,8 +916,6 @@ static int __cmd_dev_del(struct dev_ctx *ctx) __func__, dev->dev_info.ublksrv_pid, number, ret); ublk_ctrl_del_dev(dev); fail: - if (ret >= 0) - ret = ublk_ctrl_get_info(dev); ublk_ctrl_deinit(dev); return (ret >= 0) ? 0 : ret; From patchwork Mon Mar 3 12:43:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998766 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 167F120E714 for ; Mon, 3 Mar 2025 12:43:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005833; cv=none; b=NOExaOUvvRjzjksrEt/x9HiqtA/IcKTbvX3dGLF6aWieb668qcf1hYdK3MnTLdIWfa5bwCl0D1DlTEhjWg2D5CQ36Oju68rQFBGujjE7qAmvzLNuIVCWx5T2/NmP6EuVflfv8QeUZcpHLU30yXSB5I2B5yzCMLEAzM1g5cgc2j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005833; c=relaxed/simple; bh=Ex46o5OERtFZl/wNpZxxHVLaZLO6qBZqtfrS4KZ9bqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RIpamsxbATG8rb1yqezfq3xUJi2LBXGmFqkVaoqmIHNcGzYAKbxmbddK3LwtSA5ykSJ5RZF+h/E0sHHHjR180BujOw+QleaARbtttxB/bxvsU2yLsJJ0Ws0+10lPb/Xpc38d5biV+XUeOiag0n3275zuDu7QZ4Fg2v5NpOLikCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=MtFRwbhn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="MtFRwbhn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UB/acPgMwoK4vkq5V9SDm36yvXOIYaejIqPgfs9rmpU=; b=MtFRwbhnvUVFyLqMw6uxUr4cE0kRThTLweu/CQp8HWcYeLD5DwL4u++hV33IvSgoStbOXD g3TbCx0aC12OksNj1FO3l5r82w60CstvAzTXkPQ467TlKnexN+mz2kkRnPUEnmSBj9czgn Bl88KRZJa0cV1WTmBAFrPEnjedzBNlc= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-EW1Pyuq8OxOTmkY3XSTvGw-1; Mon, 03 Mar 2025 07:43:49 -0500 X-MC-Unique: EW1Pyuq8OxOTmkY3XSTvGw-1 X-Mimecast-MFC-AGG-ID: EW1Pyuq8OxOTmkY3XSTvGw_1741005828 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 64EC9180087A; Mon, 3 Mar 2025 12:43:48 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2805719560AD; Mon, 3 Mar 2025 12:43:46 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 02/11] selftests: ublk: fix build failure Date: Mon, 3 Mar 2025 20:43:12 +0800 Message-ID: <20250303124324.3563605-3-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Fixes the following build failure: ublk//file_backed.c: In function ‘backing_file_tgt_init’: ublk//file_backed.c:28:42: error: ‘O_DIRECT’ undeclared (first use in this function); did you mean ‘O_DIRECTORY’? 28 | fd = open(file, O_RDWR | O_DIRECT); | ^~~~~~~~ | O_DIRECTORY when trying to reuse this same utility for liburing test. Signed-off-by: Ming Lei Reviewed-by: Keith Busch --- tools/testing/selftests/ublk/kublk.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h index 8e43aebf7dfc..8f48eb8568ab 100644 --- a/tools/testing/selftests/ublk/kublk.h +++ b/tools/testing/selftests/ublk/kublk.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include From patchwork Mon Mar 3 12:43:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998767 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 D3BFD20E6E3 for ; Mon, 3 Mar 2025 12:43:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005838; cv=none; b=DGzQSwcR3owlqUJwiAlESg0j0GRKD1p/nJSWh0cbj7fNN0pfUTjQ9fSJBJBaUiw9cziZ7FwXoDzhaq3jEEuEk0PPIderRPYxMzXjbbpkmfZIVQNIncWmDt/19QUBIUd1/Cl9fOFkYneubL1LhvG0NAD8WMAteXjQezxmKIfjlBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005838; c=relaxed/simple; bh=PALAmA07A0ocsHQIxyxYGhUW2CaWEXY/6wTWSrf84Uo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rak8d/0NNxk+EkaBcfILEAhByH19O3Zdl7W/fa2P1ehv4+f734Yjbu7I+zjtQJGODQUrW9/9vCzcp4LMv3/MACYGjaRLZosISmHwM4WXRxfqoqeUtgIXUbuferwWCWucmASY2N+zi/rHEzpS7q4ihlhL2PrFWArj/AWs3YscHWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=QXk2qSjd; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="QXk2qSjd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005835; 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=ZgHwoN4FkuivIO+yjtqGfA61kFi7hVKtRpikbqGM3uU=; b=QXk2qSjdoQ2ZfHXS3xsoDgxCrB9/cp6jAFtOwKIUQ7xRXIIDxW3Rq6+oARWFToi5UDxboH heMKlCYvGxWsl5FH7vQ+n1twm0QoiYvzUImfwZXmGY2EvkJZug3JZccdjN0AeIYgF0ER0q D6O3ewBfHXWN0fKeE8Yz1D99bTlWu/E= Received: from mx-prod-mc-01.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-692-tLrZL-b_N5ScaYPRjuEREA-1; Mon, 03 Mar 2025 07:43:54 -0500 X-MC-Unique: tLrZL-b_N5ScaYPRjuEREA-1 X-Mimecast-MFC-AGG-ID: tLrZL-b_N5ScaYPRjuEREA_1741005833 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5142D1944D03; Mon, 3 Mar 2025 12:43:53 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3CA0180087D; Mon, 3 Mar 2025 12:43:51 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 03/11] selftests: ublk: add --foreground command line Date: Mon, 3 Mar 2025 20:43:13 +0800 Message-ID: <20250303124324.3563605-4-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Add --foreground command for helping to debug. Signed-off-by: Ming Lei Reviewed-by: Keith Busch --- tools/testing/selftests/ublk/kublk.c | 17 +++++++++++++---- tools/testing/selftests/ublk/kublk.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c index 2072d880fdc4..24557a3e5508 100644 --- a/tools/testing/selftests/ublk/kublk.c +++ b/tools/testing/selftests/ublk/kublk.c @@ -679,7 +679,10 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev) } ublk_ctrl_get_info(dev); - ublk_send_dev_event(ctx, dev->dev_info.dev_id); + if (ctx->fg) + ublk_ctrl_dump(dev); + else + ublk_send_dev_event(ctx, dev->dev_info.dev_id); /* wait until we are terminated */ for (i = 0; i < dinfo->nr_hw_queues; i++) @@ -867,6 +870,9 @@ static int cmd_dev_add(struct dev_ctx *ctx) { int res; + if (ctx->fg) + goto run; + ctx->_evtfd = eventfd(0, 0); if (ctx->_evtfd < 0) { ublk_err("%s: failed to create eventfd %s\n", __func__, strerror(errno)); @@ -876,8 +882,9 @@ static int cmd_dev_add(struct dev_ctx *ctx) setsid(); res = fork(); if (res == 0) { - __cmd_dev_add(ctx); - exit(EXIT_SUCCESS); +run: + res = __cmd_dev_add(ctx); + return res; } else if (res > 0) { uint64_t id; @@ -1044,6 +1051,7 @@ int main(int argc, char *argv[]) { "debug_mask", 1, NULL, 0 }, { "quiet", 0, NULL, 0 }, { "zero_copy", 1, NULL, 'z' }, + { "foreground", 0, NULL, 0 }, { 0, 0, 0, 0 } }; int option_idx, opt; @@ -1087,7 +1095,8 @@ int main(int argc, char *argv[]) ublk_dbg_mask = strtol(optarg, NULL, 16); if (!strcmp(longopts[option_idx].name, "quiet")) ublk_dbg_mask = 0; - break; + if (!strcmp(longopts[option_idx].name, "foreground")) + ctx.fg = 1; } } diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h index 8f48eb8568ab..26d9aa9c5ca2 100644 --- a/tools/testing/selftests/ublk/kublk.h +++ b/tools/testing/selftests/ublk/kublk.h @@ -67,6 +67,7 @@ struct dev_ctx { char *files[MAX_BACK_FILES]; unsigned int logging:1; unsigned int all:1; + unsigned int fg:1; int _evtfd; }; From patchwork Mon Mar 3 12:43:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998768 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 1E08C20E332 for ; Mon, 3 Mar 2025 12:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005842; cv=none; b=lofZ5hjavGdl8WlpIXPVuT80jUCJQIClVp34x0AzOAr4WzK4EmkmH0GI3gPsfwvm/UyomUM3Y6IRFspAC6Sq/ftIxgDzk2BScN+0eFz2LqDAlTstlJ2NVBxs7mJOwlthHDuNlyGpRCx2F8VqbLmmJFNj3Ak8UBzi9vLhFokrI8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005842; c=relaxed/simple; bh=pVkArlwes2TAzK9RpR+cWFqfh5RjnveiLwst4i8DyuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e8hMocGBvJCUWygW/brnSQwFMSb1Z+R7xSdPgh9Pg2yKJYZ7P8LJwpjeqgXNH126+eomx2OmD3WPrm2iqeR7N4obxhqQvm7UmS8J460slmZAcYu37HVjqoS0EqRDFHAfiwZ8MMtE/Jsv4EFS90Pemn5oIwpi+722jwJq0NZB0aU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=ONqvRlSE; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="ONqvRlSE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005840; 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=4ZDv6iqWcZmreBmD81+btrs67uOL2A4J/nnlM7fxZZE=; b=ONqvRlSEvZR3Q8zuI7Xe/kCv26PaeQQtP+cdhW6yKRlOiIj6T92P4NCIXgsiviDowoyj9t yZzvslbrnyR8vTxoz52NpLF9ToFhCXqLDU5wVsRnaU2Mk5AgJi9631LFsWUXYZ/Z4QUhf1 kwE7vUYQdQ03vpuZY9DCgBNFnXBpve0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-QS0ic2L3Md6Y71JS3IwYRA-1; Mon, 03 Mar 2025 07:43:59 -0500 X-MC-Unique: QS0ic2L3Md6Y71JS3IwYRA-1 X-Mimecast-MFC-AGG-ID: QS0ic2L3Md6Y71JS3IwYRA_1741005838 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DA64918004A7; Mon, 3 Mar 2025 12:43:57 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E8DA5180035E; Mon, 3 Mar 2025 12:43:56 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 04/11] selftests: ublk: fix parsing '-a' argument Date: Mon, 3 Mar 2025 20:43:14 +0800 Message-ID: <20250303124324.3563605-5-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 The argument of '-a' doesn't follow any value, so fix it by putting it with '-z' together. Fixes: ed5820a7e918 ("selftests: ublk: add ublk zero copy test") Signed-off-by: Ming Lei Reviewed-by: Keith Busch --- tools/testing/selftests/ublk/kublk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c index 24557a3e5508..148355717ee7 100644 --- a/tools/testing/selftests/ublk/kublk.c +++ b/tools/testing/selftests/ublk/kublk.c @@ -1068,7 +1068,7 @@ int main(int argc, char *argv[]) return ret; optind = 2; - while ((opt = getopt_long(argc, argv, "t:n:d:q:a:z", + while ((opt = getopt_long(argc, argv, "t:n:d:q:az", longopts, &option_idx)) != -1) { switch (opt) { case 'a': From patchwork Mon Mar 3 12:43:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998769 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 21F80211285 for ; Mon, 3 Mar 2025 12:44:06 +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=1741005847; cv=none; b=da77qbja6erCqK/YjXPa12wN+Y7q12k6TfQcWPhCGfpIIIKv6LT2y4xBLdimQOFRDgEMP4GI40ME5dNRrKZJ7kc0O/rW07D9hkZB8QAGQ2LP2dQ0oQJpMGiMMq1es5QRL2lICmA0/qS2ltx5VqZEHT+YqEEFypXfYTeA/9XPkD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005847; c=relaxed/simple; bh=+L7g5LVGLGO8UFwoz4/X5nTzXoTux7jDxGJmh4Nm13c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PNcCilLZxQ+vaFXle9gXpcybXfeig20BMtINiW80LmhdSX/sjil+vQ/WsghjHbtAIcYdmOKEFOklL8FgFbUBPJpx7lE354Gd6reDmp1s7raRxRs0wGWqwFy8DUuNylaC4PEXpqixmSV5kPAXlxB0rB95Y9nu6UbKEdXm5hy/pCo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=h/zFxdsk; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="h/zFxdsk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005845; 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=OnHBK1HYK0ZFpwRyuFhNqPfICJsUezdxJ+0g7/+cX+w=; b=h/zFxdsk36LcoyRVa1y0ndzl9ED+iHdU3WZv7DnvdM2TojLIYN0mGsXNrFVmc0tjb6NulD sYfcjDoC1rFnrdevZrzL5ndgZeDInsuxp/c1DxxqEGRj4TTqpym5M2xjC0WWUAGviha9ou jnP8Ijc/ILmx7x8g4hLizmgHlMpQVF4= 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-153-GYSUIPjRNS2QIqcklsuBuw-1; Mon, 03 Mar 2025 07:44:03 -0500 X-MC-Unique: GYSUIPjRNS2QIqcklsuBuw-1 X-Mimecast-MFC-AGG-ID: GYSUIPjRNS2QIqcklsuBuw_1741005842 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 B59081954204; Mon, 3 Mar 2025 12:44:02 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BAD9D180087D; Mon, 3 Mar 2025 12:44:00 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 05/11] selftests: ublk: support shellcheck and fix all warning Date: Mon, 3 Mar 2025 20:43:15 +0800 Message-ID: <20250303124324.3563605-6-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Add shellcheck, meantime fixes all warnings. Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/Makefile | 3 ++ tools/testing/selftests/ublk/test_common.sh | 57 +++++++++++--------- tools/testing/selftests/ublk/test_loop_01.sh | 10 ++-- tools/testing/selftests/ublk/test_loop_02.sh | 10 ++-- tools/testing/selftests/ublk/test_loop_03.sh | 10 ++-- tools/testing/selftests/ublk/test_loop_04.sh | 10 ++-- tools/testing/selftests/ublk/test_null_01.sh | 6 +-- 7 files changed, 58 insertions(+), 48 deletions(-) diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile index 555a3ba5b481..9415f6f6df48 100644 --- a/tools/testing/selftests/ublk/Makefile +++ b/tools/testing/selftests/ublk/Makefile @@ -14,3 +14,6 @@ TEST_GEN_PROGS_EXTENDED = kublk include ../lib.mk $(TEST_GEN_PROGS_EXTENDED): kublk.c null.c file_backed.c + +check: + shellcheck -x -f gcc *.sh diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 304f22ffda58..61044cb58138 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -3,46 +3,49 @@ _create_backfile() { local my_size=$1 - local my_file=`mktemp ublk_bpf_${my_size}_XXXXX` + local my_file - truncate -s ${my_size} ${my_file} - echo $my_file + my_file=$(mktemp ublk_file_"${my_size}"_XXXXX) + truncate -s "${my_size}" "${my_file}" + echo "$my_file" } _remove_backfile() { local file=$1 - [ -f "$file" ] && rm -f $file + [ -f "$file" ] && rm -f "$file" } _create_tmp_dir() { - local my_file=`mktemp -d ublk_bpf_dir_XXXXX` + local my_file; - echo $my_file + my_file=$(mktemp -d ublk_dir_XXXXX) + echo "$my_file" } _remove_tmp_dir() { local dir=$1 - [ -d "$dir" ] && rmdir $dir + [ -d "$dir" ] && rmdir "$dir" } _mkfs_mount_test() { local dev=$1 local err_code=0 - local mnt_dir=`_create_tmp_dir` + local mnt_dir; - mkfs.ext4 -F $dev > /dev/null 2>&1 + mnt_dir=$(_create_tmp_dir) + mkfs.ext4 -F "$dev" > /dev/null 2>&1 err_code=$? if [ $err_code -ne 0 ]; then return $err_code fi - mount -t ext4 $dev $mnt_dir > /dev/null 2>&1 - umount $dev + mount -t ext4 "$dev" "$mnt_dir" > /dev/null 2>&1 + umount "$dev" err_code=$? - _remove_tmp_dir $mnt_dir + _remove_tmp_dir "$mnt_dir" if [ $err_code -ne 0 ]; then return $err_code fi @@ -73,12 +76,12 @@ _prep_test() { _check_root local type=$1 shift 1 - echo "ublk $type: $@" + echo "ublk $type: $*" } _show_result() { - if [ $2 -ne 0 ]; then + if [ "$2" -ne 0 ]; then echo "$1 : [FAIL]" else echo "$1 : [PASS]" @@ -86,28 +89,32 @@ _show_result() } _cleanup_test() { - ${UBLK_PROG} del -n $1 + "${UBLK_PROG}" del -n "$1" } _add_ublk_dev() { - local kublk_temp=`mktemp /tmp/kublk-XXXXXX` - ${UBLK_PROG} add $@ > ${kublk_temp} 2>&1 - if [ $? -ne 0 ]; then - echo "fail to add ublk dev $@" - exit -1 + local kublk_temp; + local dev_id; + + kublk_temp=$(mktemp /tmp/kublk-XXXXXX) + if ! "${UBLK_PROG}" add "$@" > "${kublk_temp}" 2>&1; then + echo "fail to add ublk dev $*" + return 255 fi - local dev_id=`grep "dev id" ${kublk_temp} | awk -F '[ :]' '{print $3}'` + + dev_id=$(grep "dev id" "${kublk_temp}" | awk -F '[ :]' '{print $3}') udevadm settle - rm -f ${kublk_temp} - echo ${dev_id} + rm -f "${kublk_temp}" + echo "${dev_id}" } _have_feature() { - if $UBLK_PROG "features" | grep $1 > /dev/null 2>&1; then + if "$UBLK_PROG" "features" | grep "$1" > /dev/null 2>&1; then return 0 fi return 1 } -export UBLK_PROG=$(pwd)/kublk +UBLK_PROG=$(pwd)/kublk +export UBLK_PROG diff --git a/tools/testing/selftests/ublk/test_loop_01.sh b/tools/testing/selftests/ublk/test_loop_01.sh index 829e8df05942..1d3f934dca4c 100755 --- a/tools/testing/selftests/ublk/test_loop_01.sh +++ b/tools/testing/selftests/ublk/test_loop_01.sh @@ -8,13 +8,13 @@ ERR_CODE=0 _prep_test "loop" "write and verify test" -backfile_0=`_create_backfile 256M` +backfile_0=$(_create_backfile 256M) -dev_id=`_add_ublk_dev -t loop $backfile_0` +dev_id=$(_add_ublk_dev -t loop "$backfile_0") # run fio over the ublk disk fio --name=write_and_verify \ - --filename=/dev/ublkb${dev_id} \ + --filename=/dev/ublkb"${dev_id}" \ --ioengine=libaio --iodepth=16 \ --rw=write \ --size=256M \ @@ -24,8 +24,8 @@ fio --name=write_and_verify \ --bs=4k > /dev/null 2>&1 ERR_CODE=$? -_cleanup_test ${dev_id} "loop" +_cleanup_test "${dev_id}" "loop" -_remove_backfile $backfile_0 +_remove_backfile "$backfile_0" _show_result $TID $ERR_CODE diff --git a/tools/testing/selftests/ublk/test_loop_02.sh b/tools/testing/selftests/ublk/test_loop_02.sh index c71ae63059b8..df06b7804881 100755 --- a/tools/testing/selftests/ublk/test_loop_02.sh +++ b/tools/testing/selftests/ublk/test_loop_02.sh @@ -8,15 +8,15 @@ ERR_CODE=0 _prep_test "loop" "mkfs & mount & umount" -backfile_0=`_create_backfile 256M` +backfile_0=$(_create_backfile 256M) -dev_id=`_add_ublk_dev -t loop $backfile_0` +dev_id=$(_add_ublk_dev -t loop "$backfile_0") -_mkfs_mount_test /dev/ublkb${dev_id} +_mkfs_mount_test /dev/ublkb"${dev_id}" ERR_CODE=$? -_cleanup_test ${dev_id} "loop" +_cleanup_test "${dev_id}" "loop" -_remove_backfile $backfile_0 +_remove_backfile "$backfile_0" _show_result $TID $ERR_CODE diff --git a/tools/testing/selftests/ublk/test_loop_03.sh b/tools/testing/selftests/ublk/test_loop_03.sh index e781ac6db6b4..2255b4296590 100755 --- a/tools/testing/selftests/ublk/test_loop_03.sh +++ b/tools/testing/selftests/ublk/test_loop_03.sh @@ -10,13 +10,13 @@ _have_feature "ZERO_COPY" || exit 4 _prep_test "loop" "write and verify over zero copy" -backfile_0=`_create_backfile 256M` +backfile_0=$(_create_backfile 256M) -dev_id=`_add_ublk_dev -t loop $backfile_0 -z` +dev_id=$(_add_ublk_dev -t loop -z "$backfile_0") # run fio over the ublk disk fio --name=write_and_verify \ - --filename=/dev/ublkb${dev_id} \ + --filename=/dev/ublkb"${dev_id}" \ --ioengine=libaio --iodepth=64 \ --rw=write \ --size=256M \ @@ -26,8 +26,8 @@ fio --name=write_and_verify \ --bs=4k > /dev/null 2>&1 ERR_CODE=$? -_cleanup_test ${dev_id} "loop" +_cleanup_test "${dev_id}" "loop" -_remove_backfile $backfile_0 +_remove_backfile "$backfile_0" _show_result $TID $ERR_CODE diff --git a/tools/testing/selftests/ublk/test_loop_04.sh b/tools/testing/selftests/ublk/test_loop_04.sh index 6ab67247c809..a797b25213ec 100755 --- a/tools/testing/selftests/ublk/test_loop_04.sh +++ b/tools/testing/selftests/ublk/test_loop_04.sh @@ -8,15 +8,15 @@ ERR_CODE=0 _prep_test "loop" "mkfs & mount & umount with zero copy" -backfile_0=`_create_backfile 256M` +backfile_0=$(_create_backfile 256M) -dev_id=`_add_ublk_dev -t loop -z $backfile_0` +dev_id=$(_add_ublk_dev -t loop -z "$backfile_0") -_mkfs_mount_test /dev/ublkb${dev_id} +_mkfs_mount_test /dev/ublkb"${dev_id}" ERR_CODE=$? -_cleanup_test ${dev_id} "loop" +_cleanup_test "${dev_id}" "loop" -_remove_backfile $backfile_0 +_remove_backfile "$backfile_0" _show_result $TID $ERR_CODE diff --git a/tools/testing/selftests/ublk/test_null_01.sh b/tools/testing/selftests/ublk/test_null_01.sh index 04fc3ac7c716..b048ddc4ae6f 100755 --- a/tools/testing/selftests/ublk/test_null_01.sh +++ b/tools/testing/selftests/ublk/test_null_01.sh @@ -8,12 +8,12 @@ ERR_CODE=0 _prep_test "null" "basic IO test" -dev_id=`_add_ublk_dev -t null` +dev_id=$(_add_ublk_dev -t null) # run fio over the two disks -fio --name=job1 --filename=/dev/ublkb${dev_id} --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1 +fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1 ERR_CODE=$? -_cleanup_test ${dev_id} "null" +_cleanup_test "${dev_id}" "null" _show_result $TID $ERR_CODE From patchwork Mon Mar 3 12:43:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998770 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 55604211A05 for ; Mon, 3 Mar 2025 12:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005854; cv=none; b=U6rOPzKsid9GESB487b6337r1Anf+P+RmJRT4WIKA19tTENIMdQnQQR+PCUnyjcafXtDVguIwUrYfup9RLlzoiW0yhH1zv+10nxjzVGrPO/iUOP/fO+1/xsLCa/mk9BsT3zPoeUK3FLhwRr8WFlMEeMKiRtJ2C6BOyFQ0WkqSfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005854; c=relaxed/simple; bh=yuCX0pCjKItWYfTkXXjha3xws1B9peMkdKmDwYsrDVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rt73GedK7X9nbCPAj9RobQXXmeYzgsMjW7nqm3uyJO4JOIPO09oFOQASgqh2KH8ekdQ5OEWwolYZt8LXicyZY93kv1NoaVcdWYv9/q62FlcsBP+JISrylByvRjzPv+fuwGSKVFtoovstOrkUoi0UcYF1TVZwZ/+kv+lg1jx0BUg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=Fy1Dh8V1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="Fy1Dh8V1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005852; 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=vhDWF1mcH5ShKE+FcXGAer8edgRkzR6VpKbo2AlD2+s=; b=Fy1Dh8V1gFUIZpBaUD1qDttk5F1NUcyHnLvvtZUwf7sHK8SsQ/qCaFIPjrHM4y3KLg0VgI QE/0CjhU2bgvNqOFNdl5ZiL2fSwZEmeZxV1kyhxIL1Y1Lv0987h5b+IPhLKb4qfj+spY4P XCpvJaP/YjrgUSw6tstgdEG9VvNj+2I= 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-116-c1FGb191PkmbU5GWBLfu7g-1; Mon, 03 Mar 2025 07:44:09 -0500 X-MC-Unique: c1FGb191PkmbU5GWBLfu7g-1 X-Mimecast-MFC-AGG-ID: c1FGb191PkmbU5GWBLfu7g_1741005848 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 B64C01954202; Mon, 3 Mar 2025 12:44:07 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7216E180035F; Mon, 3 Mar 2025 12:44:06 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 06/11] selftests: ublk: don't pass ${dev_id} to _cleanup_test() Date: Mon, 3 Mar 2025 20:43:16 +0800 Message-ID: <20250303124324.3563605-7-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 More devices can be created in single tests, so simply remove all ublk devices in _cleanup_test(), meantime remove the ${dev_id} argument of _cleanup_test(). Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/test_common.sh | 2 +- tools/testing/selftests/ublk/test_loop_01.sh | 2 +- tools/testing/selftests/ublk/test_loop_02.sh | 2 +- tools/testing/selftests/ublk/test_loop_03.sh | 2 +- tools/testing/selftests/ublk/test_loop_04.sh | 2 +- tools/testing/selftests/ublk/test_null_01.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 61044cb58138..d70690281d14 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -89,7 +89,7 @@ _show_result() } _cleanup_test() { - "${UBLK_PROG}" del -n "$1" + "${UBLK_PROG}" del -a } _add_ublk_dev() { diff --git a/tools/testing/selftests/ublk/test_loop_01.sh b/tools/testing/selftests/ublk/test_loop_01.sh index 1d3f934dca4c..48a85796ca43 100755 --- a/tools/testing/selftests/ublk/test_loop_01.sh +++ b/tools/testing/selftests/ublk/test_loop_01.sh @@ -24,7 +24,7 @@ fio --name=write_and_verify \ --bs=4k > /dev/null 2>&1 ERR_CODE=$? -_cleanup_test "${dev_id}" "loop" +_cleanup_test "loop" _remove_backfile "$backfile_0" diff --git a/tools/testing/selftests/ublk/test_loop_02.sh b/tools/testing/selftests/ublk/test_loop_02.sh index df06b7804881..0a4b5fadbc73 100755 --- a/tools/testing/selftests/ublk/test_loop_02.sh +++ b/tools/testing/selftests/ublk/test_loop_02.sh @@ -15,7 +15,7 @@ dev_id=$(_add_ublk_dev -t loop "$backfile_0") _mkfs_mount_test /dev/ublkb"${dev_id}" ERR_CODE=$? -_cleanup_test "${dev_id}" "loop" +_cleanup_test "loop" _remove_backfile "$backfile_0" diff --git a/tools/testing/selftests/ublk/test_loop_03.sh b/tools/testing/selftests/ublk/test_loop_03.sh index 2255b4296590..5a11356e502c 100755 --- a/tools/testing/selftests/ublk/test_loop_03.sh +++ b/tools/testing/selftests/ublk/test_loop_03.sh @@ -26,7 +26,7 @@ fio --name=write_and_verify \ --bs=4k > /dev/null 2>&1 ERR_CODE=$? -_cleanup_test "${dev_id}" "loop" +_cleanup_test "loop" _remove_backfile "$backfile_0" diff --git a/tools/testing/selftests/ublk/test_loop_04.sh b/tools/testing/selftests/ublk/test_loop_04.sh index a797b25213ec..7e0d4dd8127e 100755 --- a/tools/testing/selftests/ublk/test_loop_04.sh +++ b/tools/testing/selftests/ublk/test_loop_04.sh @@ -15,7 +15,7 @@ dev_id=$(_add_ublk_dev -t loop -z "$backfile_0") _mkfs_mount_test /dev/ublkb"${dev_id}" ERR_CODE=$? -_cleanup_test "${dev_id}" "loop" +_cleanup_test "loop" _remove_backfile "$backfile_0" diff --git a/tools/testing/selftests/ublk/test_null_01.sh b/tools/testing/selftests/ublk/test_null_01.sh index b048ddc4ae6f..af11e73b7df6 100755 --- a/tools/testing/selftests/ublk/test_null_01.sh +++ b/tools/testing/selftests/ublk/test_null_01.sh @@ -14,6 +14,6 @@ dev_id=$(_add_ublk_dev -t null) fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1 ERR_CODE=$? -_cleanup_test "${dev_id}" "null" +_cleanup_test "null" _show_result $TID $ERR_CODE From patchwork Mon Mar 3 12:43:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998771 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 9ED602144DF for ; Mon, 3 Mar 2025 12:44:25 +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=1741005867; cv=none; b=I025O7PvsC+ovV1NmU99euLV8/vQrHqxI6RxJzqHGT1kcoRXSM9ZLrUc5vQx8DrQAKBbIcqBNQASkpzOQx+l+oUew9/N9Z9i2Q3At/uMf4KycggxM01e5DP/vc1GZFvPTOw/NnhFIUHicpWsDMbCR7b1/Byr41LA5iEKCtYt56A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005867; c=relaxed/simple; bh=0C4JkgXQtgeQhzwqubMe5Df6hevktRFvQ5zMLbbFak4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hOUekdefq+BxzoJ+qQFQnOP7ODMqWejor96Fu9zFlAYyzavdLikqlTRsFe+T5x1KmKJqqIHbEI4jsySpV7pYlBsED9ZunI3B+HWe/G7BUBqEXE2Sghgps2C+EGb4GCwGAyysUYak/G6tD10c3kMxIQV8oy49niyhd/mN1pFkgbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=cjwCMOK3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="cjwCMOK3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005864; 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=9d+oOheGf64mOyEFfcHgMgXsNl0DuQhJwDS4FGt+uBk=; b=cjwCMOK3yxTJriNY8/lBPHqw/i3814JJW6hEqYaAarcs4D4UpUaB4pzrk11aotJgw6e29X 1a9mV2k5Vkz+L++RyMi0q8i1szHnKAMzpoUhQeblPwVoVmlq7dJqMH8bpaXsSbfAakaZ5Q jCIzzIbz1onag3k5UVbro+4UM229C5o= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-fL6fEFKPMf6neXXldNwNMw-1; Mon, 03 Mar 2025 07:44:13 -0500 X-MC-Unique: fL6fEFKPMf6neXXldNwNMw-1 X-Mimecast-MFC-AGG-ID: fL6fEFKPMf6neXXldNwNMw_1741005852 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2EBD71800877; Mon, 3 Mar 2025 12:44:12 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 112691800359; Mon, 3 Mar 2025 12:44:10 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 07/11] selftests: ublk: move zero copy feature check into _add_ublk_dev() Date: Mon, 3 Mar 2025 20:43:17 +0800 Message-ID: <20250303124324.3563605-8-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Move zero copy feature check into _add_ublk_dev() since we will have more tests which requires to cover zero copy. Then one check function of _check_add_dev() has to be added for dealing with cleanup since '_add_ublk_dev()' is run in sub-shell, and we can't exit from it to terminal shell. Meantime always return error code from _add_ublk_dev(). Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/test_common.sh | 56 ++++++++++++++++---- tools/testing/selftests/ublk/test_loop_01.sh | 1 + tools/testing/selftests/ublk/test_loop_02.sh | 2 +- tools/testing/selftests/ublk/test_loop_03.sh | 4 +- tools/testing/selftests/ublk/test_loop_04.sh | 2 +- tools/testing/selftests/ublk/test_null_01.sh | 1 + 6 files changed, 50 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index d70690281d14..40bf42f1bed2 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -1,6 +1,8 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +UBLK_SKIP_CODE=4 + _create_backfile() { local my_size=$1 local my_file @@ -79,12 +81,37 @@ _prep_test() { echo "ublk $type: $*" } +_remove_test_files() +{ + local files=$* + + for file in ${files}; do + [ -f "${file}" ] && rm -f "${file}" + done +} + _show_result() { - if [ "$2" -ne 0 ]; then - echo "$1 : [FAIL]" - else + if [ "$2" -eq 0 ]; then echo "$1 : [PASS]" + elif [ "$2" -eq 4 ]; then + echo "$1 : [SKIP]" + else + echo "$1 : [FAIL]" + fi + [ "$2" -ne 0 ] && exit "$2" + return 0 +} + +# don't call from sub-shell, otherwise can't exit +_check_add_dev() +{ + local tid=$1 + local code=$2 + shift 2 + if [ "${code}" -ne 0 ]; then + _remove_test_files "$@" + _show_result "${tid}" "${code}" fi } @@ -92,13 +119,28 @@ _cleanup_test() { "${UBLK_PROG}" del -a } +_have_feature() +{ + if $UBLK_PROG "features" | grep "$1" > /dev/null 2>&1; then + return 0 + fi + return 1 +} + _add_ublk_dev() { local kublk_temp; local dev_id; + if echo "$@" | grep -q "\-z"; then + if ! _have_feature "ZERO_COPY"; then + return ${UBLK_SKIP_CODE} + fi + fi + kublk_temp=$(mktemp /tmp/kublk-XXXXXX) if ! "${UBLK_PROG}" add "$@" > "${kublk_temp}" 2>&1; then echo "fail to add ublk dev $*" + rm -f "${kublk_temp}" return 255 fi @@ -108,13 +150,5 @@ _add_ublk_dev() { echo "${dev_id}" } -_have_feature() -{ - if "$UBLK_PROG" "features" | grep "$1" > /dev/null 2>&1; then - return 0 - fi - return 1 -} - UBLK_PROG=$(pwd)/kublk export UBLK_PROG diff --git a/tools/testing/selftests/ublk/test_loop_01.sh b/tools/testing/selftests/ublk/test_loop_01.sh index 48a85796ca43..12bba9e5daa5 100755 --- a/tools/testing/selftests/ublk/test_loop_01.sh +++ b/tools/testing/selftests/ublk/test_loop_01.sh @@ -11,6 +11,7 @@ _prep_test "loop" "write and verify test" backfile_0=$(_create_backfile 256M) dev_id=$(_add_ublk_dev -t loop "$backfile_0") +_check_add_dev $TID $? "${backfile_0}" # run fio over the ublk disk fio --name=write_and_verify \ diff --git a/tools/testing/selftests/ublk/test_loop_02.sh b/tools/testing/selftests/ublk/test_loop_02.sh index 0a4b5fadbc73..9a163296ac83 100755 --- a/tools/testing/selftests/ublk/test_loop_02.sh +++ b/tools/testing/selftests/ublk/test_loop_02.sh @@ -9,8 +9,8 @@ ERR_CODE=0 _prep_test "loop" "mkfs & mount & umount" backfile_0=$(_create_backfile 256M) - dev_id=$(_add_ublk_dev -t loop "$backfile_0") +_check_add_dev $TID $? "$backfile_0" _mkfs_mount_test /dev/ublkb"${dev_id}" ERR_CODE=$? diff --git a/tools/testing/selftests/ublk/test_loop_03.sh b/tools/testing/selftests/ublk/test_loop_03.sh index 5a11356e502c..72a1d072cfbd 100755 --- a/tools/testing/selftests/ublk/test_loop_03.sh +++ b/tools/testing/selftests/ublk/test_loop_03.sh @@ -6,13 +6,11 @@ TID="loop_03" ERR_CODE=0 -_have_feature "ZERO_COPY" || exit 4 - _prep_test "loop" "write and verify over zero copy" backfile_0=$(_create_backfile 256M) - dev_id=$(_add_ublk_dev -t loop -z "$backfile_0") +_check_add_dev $TID $? "$backfile_0" # run fio over the ublk disk fio --name=write_and_verify \ diff --git a/tools/testing/selftests/ublk/test_loop_04.sh b/tools/testing/selftests/ublk/test_loop_04.sh index 7e0d4dd8127e..676c4652d758 100755 --- a/tools/testing/selftests/ublk/test_loop_04.sh +++ b/tools/testing/selftests/ublk/test_loop_04.sh @@ -9,8 +9,8 @@ ERR_CODE=0 _prep_test "loop" "mkfs & mount & umount with zero copy" backfile_0=$(_create_backfile 256M) - dev_id=$(_add_ublk_dev -t loop -z "$backfile_0") +_check_add_dev $TID $? "$backfile_0" _mkfs_mount_test /dev/ublkb"${dev_id}" ERR_CODE=$? diff --git a/tools/testing/selftests/ublk/test_null_01.sh b/tools/testing/selftests/ublk/test_null_01.sh index af11e73b7df6..e2847a50823a 100755 --- a/tools/testing/selftests/ublk/test_null_01.sh +++ b/tools/testing/selftests/ublk/test_null_01.sh @@ -9,6 +9,7 @@ ERR_CODE=0 _prep_test "null" "basic IO test" dev_id=$(_add_ublk_dev -t null) +_check_add_dev $TID $? # run fio over the two disks fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1 From patchwork Mon Mar 3 12:43:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998774 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 C9351210F71 for ; Mon, 3 Mar 2025 12:44:33 +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=1741005875; cv=none; b=tfIRIrQ79Jc3BLh8AQ3U5PVQ3PpNbdBsoROs9HhhgZ4VXO46U7brRR8zKl7sdgP/VJxrEru1AdKCtlgwm+LJ1zvDhaOKlZwwITltQZ32zT7wgEHWqTl5CzGv/rpGP2SVXncBdVjezJAoxUpCeWY14HAZL1O295zNfwN4emsok4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005875; c=relaxed/simple; bh=dr+e7jSPepXj4wEctbueFxfKfGyx1PgvUi00ml24KJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UVOf5/6cVu18oCVuLHniUx/TTUGsG3hLiPCBGovgXkm8e8mtTcWQtyyBvMnkva43Zgq62wJ0agvv1ztE7Y5XBJ03Bu0bp56F/Uy+BHQICGFCrs7f4vbuuRf38p6wVfPGqrOKH/UF7sOzEJcmvsoOYbWUpa14L0/iwQdJCUgh4T8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=QX7tDPLY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="QX7tDPLY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005873; 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=Yi7XL+5N6pTduXp2PEW7UNcPPWNHp7KLLmffm1FzOjM=; b=QX7tDPLYxcq/DVvknfcDvfyPxVymnU4ZsZpXNuYZMI/fNSmYOx6Gz6YBEPls3Z0cZO8cvo liLmJws6PDIG1ZnjnVY8/Xzcs5ijaW3Wlb/cRXPhxZKHnEEvvNyo9bmsS3tPgSPYFE/KE9 cvRA7QYVwWzuJyR4JZbH6U1EcVJyKO4= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-OGeELeY6MXmOKNzle2pqqg-1; Mon, 03 Mar 2025 07:44:17 -0500 X-MC-Unique: OGeELeY6MXmOKNzle2pqqg-1 X-Mimecast-MFC-AGG-ID: OGeELeY6MXmOKNzle2pqqg_1741005856 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CC8A51800980; Mon, 3 Mar 2025 12:44:16 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A634A180035F; Mon, 3 Mar 2025 12:44:15 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 08/11] selftests: ublk: load/unload ublk_drv when preparing & cleaning up tests Date: Mon, 3 Mar 2025 20:43:18 +0800 Message-ID: <20250303124324.3563605-9-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Load ublk_drv module in _prep_test(), and unload it in _cleanup_test(), so that test can always be done in consistent state. Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/test_common.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 40bf42f1bed2..bcb0c7aa3956 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -64,6 +64,7 @@ _check_root() { _remove_ublk_devices() { ${UBLK_PROG} del -a + modprobe -r ublk_drv } _get_ublk_dev_state() { @@ -78,6 +79,7 @@ _prep_test() { _check_root local type=$1 shift 1 + modprobe ublk_drv echo "ublk $type: $*" } @@ -131,6 +133,9 @@ _add_ublk_dev() { local kublk_temp; local dev_id; + if [ ! -c /dev/ublk-control ]; then + return ${UBLK_SKIP_CODE} + fi if echo "$@" | grep -q "\-z"; then if ! _have_feature "ZERO_COPY"; then return ${UBLK_SKIP_CODE} From patchwork Mon Mar 3 12:43:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998772 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 E0FF22147E8 for ; Mon, 3 Mar 2025 12:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005868; cv=none; b=JZkb2kyanP3m9qFle4m02H6jH1ZswrMVrwSQuYibfOJ10Z9r0p2ltyNSC1+oOrff0CgtfCMM5H1mWgIM0KIVwW5mQzEbrmWzfVWCT8L1gXIlQaVqwhrKIVi5Rqt0we9RYIu12ZIjW4Mkwcm+kQAYJyKR3M3dIRG46KarPPUUqIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005868; c=relaxed/simple; bh=yzen7vGiasuqWpPiMRv8npN+/wnYlavCS0OTkAhg93I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZL+fZkDureyhrzERo43MpgMPIsoMnYQcKcwy4SbOaF6wATrya6becCDswMKFVxZj+I8728i3mJLZrUb5UYVhrm8SHI0UX7ASvCkvQP5Ab56xx554dOAKjImsc0OFuhUoT2mr5bCSo9eFeVCuaTokyab/k2G3znOTY6GxUzNvTvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=LEmF1jWE; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="LEmF1jWE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005865; 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=au45iy9Z4vYO/0vG2IShtPayiK/hMU7zUbUz9ZFnV1M=; b=LEmF1jWE/xtRAhGfQRZRJldXJkhYO3ayynHWZkyunNSoLHTtU2epmxyGPqQ+CeB0yyyM+V pAcYnHE2Pzs4M71g3Vx07Vx+/klolGDiG6hKnsDhtAX0YEP9g9pkY0JA+x39R8QCSHcqlP FTdmIQlcRfxTyehtd/XXIg/QXdLr8GU= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-576-0DHCWXsXMuiNdRb2OUunMg-1; Mon, 03 Mar 2025 07:44:22 -0500 X-MC-Unique: 0DHCWXsXMuiNdRb2OUunMg-1 X-Mimecast-MFC-AGG-ID: 0DHCWXsXMuiNdRb2OUunMg_1741005861 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1DB21801A18; Mon, 3 Mar 2025 12:44:21 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C259300019F; Mon, 3 Mar 2025 12:44:19 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 09/11] selftests: ublk: add one stress test for covering IO vs. removing device Date: Mon, 3 Mar 2025 20:43:19 +0800 Message-ID: <20250303124324.3563605-10-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Add stress_test_01 for running IO vs. removing device for verifying that ublk device removal can work as expected when heavy IO workloads are in progress. null, loop and loop/zc are covered in this tests. Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/Makefile | 2 + tools/testing/selftests/ublk/test_common.sh | 26 ++++++++++ .../testing/selftests/ublk/test_stress_01.sh | 47 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_stress_01.sh diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile index 9415f6f6df48..40af938cd277 100644 --- a/tools/testing/selftests/ublk/Makefile +++ b/tools/testing/selftests/ublk/Makefile @@ -9,6 +9,8 @@ TEST_PROGS += test_loop_02.sh TEST_PROGS += test_loop_03.sh TEST_PROGS += test_loop_04.sh +TEST_PROGS += test_stress_01.sh + TEST_GEN_PROGS_EXTENDED = kublk include ../lib.mk diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index bcb0c7aa3956..89244a7e275c 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -155,5 +155,31 @@ _add_ublk_dev() { echo "${dev_id}" } +__remove_ublk_dev_return() { + local dev_id=$1 + + ${UBLK_PROG} del -n "${dev_id}" + local res=$? + udevadm settle + return ${res} +} + +__run_io_and_remove() +{ + local dev_id=$1 + local size=$2 + + fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \ + --rw=readwrite --iodepth=64 --size="${size}" --numjobs=4 \ + --runtime=20 --time_based > /dev/null 2>&1 & + sleep 2 + if ! __remove_ublk_dev_return "${dev_id}"; then + echo "delete dev ${dev_id} failed" + return 255 + fi + wait +} + + UBLK_PROG=$(pwd)/kublk export UBLK_PROG diff --git a/tools/testing/selftests/ublk/test_stress_01.sh b/tools/testing/selftests/ublk/test_stress_01.sh new file mode 100755 index 000000000000..2dfd01cfd265 --- /dev/null +++ b/tools/testing/selftests/ublk/test_stress_01.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. test_common.sh +TID="stress_01" +ERR_CODE=0 +DEV_ID=-1 + +ublk_io_and_remove() +{ + local size=$1 + shift 1 + local backfile="" + if echo "$@" | grep -q "loop"; then + backfile=${*: -1} + fi + DEV_ID=$(_add_ublk_dev "$@") + _check_add_dev $TID $? "${backfile}" + + echo "run ublk IO vs. remove device(ublk add $*)" + if ! __run_io_and_remove "${DEV_ID}" "${size}"; then + echo "/dev/ublkc${DEV_ID} isn't removed" + _remove_backfile "${backfile}" + exit 255 + fi +} + +_prep_test "stress" "run IO and remove device" + +ublk_io_and_remove 8G -t null +ERR_CODE=$? +if [ ${ERR_CODE} -ne 0 ]; then + _show_result $TID $ERR_CODE +fi + +BACK_FILE=$(_create_backfile 256M) +ublk_io_and_remove 256M -t loop "${BACK_FILE}" +ERR_CODE=$? +if [ ${ERR_CODE} -ne 0 ]; then + _show_result $TID $ERR_CODE +fi + +ublk_io_and_remove 256M -t loop -z "${BACK_FILE}" +ERR_CODE=$? +_cleanup_test "stress" +_remove_backfile "${BACK_FILE}" +_show_result $TID $ERR_CODE From patchwork Mon Mar 3 12:43:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998773 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 804911EE7C6 for ; Mon, 3 Mar 2025 12:44:31 +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=1741005874; cv=none; b=YIwbxhkYFv9No+z9Luuwi5lGoo/FWtDgdJTwPzvnnznw30lkdDJkxFDjHlwytrIgscoK3cxAqGxZUFNCE81KdW7JPxBCmUPZfT1vQrdnqLjaxIE4Ja33dFSRocj0TPsshxa4UErGfNEIkJe0GQoNv/opqfkqtSeX0R0OnwBECwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005874; c=relaxed/simple; bh=RhgCzhGQmspDhwt6h7K2VsgtZAx/zYR/kyWLK77dikk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b6q6CLHAVLVhLybKTjoDRtGavAqAO5KF3DMeFLeHLwL3UL+O51nvs6ntV3Ca2r0hBm13/tjZ+9I/jtLTO11yYQa9f3mR7XrayICwkulj/ss5NB3TK1B98OuUtpzjUW3JVBLQ5tt7OoUL+PNGqfrk3Pvyr8TE7GeCFkuaeJWdYKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=CYHhsJjS; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="CYHhsJjS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005870; 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=YeME8YQChJWPab2nKPNhbBsN368ho/Xr+RmOIFOIMBs=; b=CYHhsJjSMdo7lHtzCBNv4rF4C3D+7Jmm9qJohDqQl8KmYJ9rLwqBwBM4nxgIM2TuYDtWjW 4ICODAwccRR+YWhwO9OsXRA8sDHDk18t+2aGTNa++HI6xytFswvMhCVg1BIHCyMW6KjWlE 99qH2dYFPUkk1R0xojF2f6lwp5cbHuc= Received: from mx-prod-mc-03.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-693-WL-_RIHcPvSg1IJz3GslmQ-1; Mon, 03 Mar 2025 07:44:27 -0500 X-MC-Unique: WL-_RIHcPvSg1IJz3GslmQ-1 X-Mimecast-MFC-AGG-ID: WL-_RIHcPvSg1IJz3GslmQ_1741005866 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A626D1944EB2; Mon, 3 Mar 2025 12:44:26 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6B4F3180035F; Mon, 3 Mar 2025 12:44:24 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 10/11] selftests: ublk: add stress test for covering IO vs. killing ublk server Date: Mon, 3 Mar 2025 20:43:20 +0800 Message-ID: <20250303124324.3563605-11-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Add stress_test_01 for running IO vs. killing ublk server, so io_uring exit & cancel code path can be covered, same with ublk's cancel code path. Especially IO buffer lifetime is one big thing for ublk zero copy, the added test can verify if this area works as expected. Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/Makefile | 1 + tools/testing/selftests/ublk/test_common.sh | 29 ++++++++++++ .../testing/selftests/ublk/test_stress_01.sh | 2 +- .../testing/selftests/ublk/test_stress_02.sh | 47 +++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/ublk/test_stress_02.sh diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile index 40af938cd277..5d8d5939f051 100644 --- a/tools/testing/selftests/ublk/Makefile +++ b/tools/testing/selftests/ublk/Makefile @@ -10,6 +10,7 @@ TEST_PROGS += test_loop_03.sh TEST_PROGS += test_loop_04.sh TEST_PROGS += test_stress_01.sh +TEST_PROGS += test_stress_02.sh TEST_GEN_PROGS_EXTENDED = kublk diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 89244a7e275c..92596d0d0013 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -155,6 +155,26 @@ _add_ublk_dev() { echo "${dev_id}" } +# kill the ublk daemon and return ublk device state +__ublk_kill_daemon() +{ + local dev_id=$1 + local exp_state=$2 + local daemon_pid + local state + + daemon_pid=$(_get_ublk_daemon_pid "${dev_id}") + state=$(_get_ublk_dev_state "${dev_id}") + + for ((j=0;j<50;j++)); do + [ "$state" == "$exp_state" ] && break + kill -9 "$daemon_pid" > /dev/null 2>&1 + sleep 1 + state=$(_get_ublk_dev_state "${dev_id}") + done + echo "$state" +} + __remove_ublk_dev_return() { local dev_id=$1 @@ -168,11 +188,20 @@ __run_io_and_remove() { local dev_id=$1 local size=$2 + local kill_server=$3 fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \ --rw=readwrite --iodepth=64 --size="${size}" --numjobs=4 \ --runtime=20 --time_based > /dev/null 2>&1 & sleep 2 + if [ "${kill_server}" = "yes" ]; then + local state + state=$(__ublk_kill_daemon "${dev_id}" "DEAD") + if [ "$state" != "DEAD" ]; then + echo "device isn't dead($state) after killing daemon" + return 255 + fi + fi if ! __remove_ublk_dev_return "${dev_id}"; then echo "delete dev ${dev_id} failed" return 255 diff --git a/tools/testing/selftests/ublk/test_stress_01.sh b/tools/testing/selftests/ublk/test_stress_01.sh index 2dfd01cfd265..c1cdde3e79f7 100755 --- a/tools/testing/selftests/ublk/test_stress_01.sh +++ b/tools/testing/selftests/ublk/test_stress_01.sh @@ -18,7 +18,7 @@ ublk_io_and_remove() _check_add_dev $TID $? "${backfile}" echo "run ublk IO vs. remove device(ublk add $*)" - if ! __run_io_and_remove "${DEV_ID}" "${size}"; then + if ! __run_io_and_remove "${DEV_ID}" "${size}" "no"; then echo "/dev/ublkc${DEV_ID} isn't removed" _remove_backfile "${backfile}" exit 255 diff --git a/tools/testing/selftests/ublk/test_stress_02.sh b/tools/testing/selftests/ublk/test_stress_02.sh new file mode 100755 index 000000000000..ec758f649a97 --- /dev/null +++ b/tools/testing/selftests/ublk/test_stress_02.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. test_common.sh +TID="stress_02" +ERR_CODE=0 +DEV_ID=-1 + +ublk_io_and_kill_daemon() +{ + local size=$1 + shift 1 + local backfile="" + if echo "$@" | grep -q "loop"; then + backfile=${*: -1} + fi + DEV_ID=$(_add_ublk_dev "$@") + _check_add_dev $TID $? "${backfile}" + + echo "run ublk IO vs kill ublk server(ublk add $*)" + if ! __run_io_and_remove "${DEV_ID}" "${size}" "yes"; then + echo "/dev/ublkc${DEV_ID} isn't removed res ${res}" + _remove_backfile "${backfile}" + exit 255 + fi +} + +_prep_test "stress" "run IO and kill ublk server" + +ublk_io_and_kill_daemon 8G -t null +ERR_CODE=$? +if [ ${ERR_CODE} -ne 0 ]; then + _show_result $TID $ERR_CODE +fi + +BACK_FILE=$(_create_backfile 256M) +ublk_io_and_kill_daemon 256M -t loop "${BACK_FILE}" +ERR_CODE=$? +if [ ${ERR_CODE} -ne 0 ]; then + _show_result $TID $ERR_CODE +fi + +ublk_io_and_kill_daemon 256M -t loop -z "${BACK_FILE}" +ERR_CODE=$? +_cleanup_test "stress" +_remove_backfile "${BACK_FILE}" +_show_result $TID $ERR_CODE From patchwork Mon Mar 3 12:43:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 13998775 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 9BC7A20E332 for ; Mon, 3 Mar 2025 12:44:45 +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=1741005887; cv=none; b=g1XTjSuqQsqvZpCiSzjrR2u1dPs6MaXQEY+gUmEctC7xBVtGhGDmCAE1/ZAJb6EMWNoaFQ8hUa/N2p3dLUaMPWt0+QHrblFYxDw4vuItSqnZ0smpk1LMn+/whHu5inG4Il7J47jGNGYJ4q1hKaSU83KQTQIp6GSekr1WaQzAACc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741005887; c=relaxed/simple; bh=FGAah+nZFfve3WCpEi0Ybu1HjWrSfpCAz+yiiAE7w9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fk3SG05DOAcYPaoJAl/UIl2pkogA9Qv9LXDawGjpfp27aNzvNViEvPtUELX9DGW8dJxhx6/WzovXKRsks4yi2nMbustesFcn1EfF2NhIOeELqcEbsxhKK/tKdhSx8/vkKMW+ObEqn8Y7v8j54BaWIds2j8jZ3WhI4vllOgoGPTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=MLgfCs2v; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="MLgfCs2v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741005884; 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=Quo9GFqH1Xb63xK1C4YcntZoNhBsXEt5C3tvQgLnKJE=; b=MLgfCs2vYIG/r5oaxkKr8oCNC9yuzLS9EX3UP/gcZgieLBRXH5+RnM8adGpJ0tTrCIn0bh lsqfTvvhIWe8z+xr+d8aXsODojcN64KbsGFDKyPCeq20nM2NoqdbmM3Uie0LntvpioRECi nEz7ap5UVXLGVV+iufZ6LyTKEg687FQ= Received: from mx-prod-mc-02.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-33-YU6gR_67OaKZj4tz8IcTrg-1; Mon, 03 Mar 2025 07:44:33 -0500 X-MC-Unique: YU6gR_67OaKZj4tz8IcTrg-1 X-Mimecast-MFC-AGG-ID: YU6gR_67OaKZj4tz8IcTrg_1741005872 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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E2CD19540EE; Mon, 3 Mar 2025 12:44:32 +0000 (UTC) Received: from localhost (unknown [10.72.120.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 67B66300019F; Mon, 3 Mar 2025 12:44:30 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Ming Lei Subject: [PATCH 11/11] selftests: ublk: improve test usability Date: Mon, 3 Mar 2025 20:43:21 +0800 Message-ID: <20250303124324.3563605-12-ming.lei@redhat.com> In-Reply-To: <20250303124324.3563605-1-ming.lei@redhat.com> References: <20250303124324.3563605-1-ming.lei@redhat.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Add UBLK_TEST_QUIET, so we can print test result(PASS/SKIP/FAIL) only. Also always run from test script's current directory, then the same test script can be started from other work directory. This way helps a lot to reuse this test source code and scripts for other projects(liburing, blktests, ...) Signed-off-by: Ming Lei --- tools/testing/selftests/ublk/test_common.sh | 10 ++++++++-- tools/testing/selftests/ublk/test_loop_01.sh | 2 +- tools/testing/selftests/ublk/test_loop_02.sh | 2 +- tools/testing/selftests/ublk/test_loop_03.sh | 2 +- tools/testing/selftests/ublk/test_loop_04.sh | 2 +- tools/testing/selftests/ublk/test_null_01.sh | 2 +- tools/testing/selftests/ublk/test_stress_01.sh | 4 ++-- tools/testing/selftests/ublk/test_stress_02.sh | 4 ++-- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh index 92596d0d0013..350380facd9f 100755 --- a/tools/testing/selftests/ublk/test_common.sh +++ b/tools/testing/selftests/ublk/test_common.sh @@ -80,7 +80,7 @@ _prep_test() { local type=$1 shift 1 modprobe ublk_drv - echo "ublk $type: $*" + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*" } _remove_test_files() @@ -209,6 +209,12 @@ __run_io_and_remove() wait } +_ublk_test_top_dir() +{ + cd "$(dirname "$0")" && pwd +} -UBLK_PROG=$(pwd)/kublk +UBLK_PROG=$(_ublk_test_top_dir)/kublk +UBLK_TEST_QUIET=1 export UBLK_PROG +export UBLK_TEST_QUIET diff --git a/tools/testing/selftests/ublk/test_loop_01.sh b/tools/testing/selftests/ublk/test_loop_01.sh index 12bba9e5daa5..c882d2a08e13 100755 --- a/tools/testing/selftests/ublk/test_loop_01.sh +++ b/tools/testing/selftests/ublk/test_loop_01.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="loop_01" ERR_CODE=0 diff --git a/tools/testing/selftests/ublk/test_loop_02.sh b/tools/testing/selftests/ublk/test_loop_02.sh index 9a163296ac83..03863d825e07 100755 --- a/tools/testing/selftests/ublk/test_loop_02.sh +++ b/tools/testing/selftests/ublk/test_loop_02.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="loop_02" ERR_CODE=0 diff --git a/tools/testing/selftests/ublk/test_loop_03.sh b/tools/testing/selftests/ublk/test_loop_03.sh index 72a1d072cfbd..269c96787d7d 100755 --- a/tools/testing/selftests/ublk/test_loop_03.sh +++ b/tools/testing/selftests/ublk/test_loop_03.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="loop_03" ERR_CODE=0 diff --git a/tools/testing/selftests/ublk/test_loop_04.sh b/tools/testing/selftests/ublk/test_loop_04.sh index 676c4652d758..1435422c38ec 100755 --- a/tools/testing/selftests/ublk/test_loop_04.sh +++ b/tools/testing/selftests/ublk/test_loop_04.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="loop_04" ERR_CODE=0 diff --git a/tools/testing/selftests/ublk/test_null_01.sh b/tools/testing/selftests/ublk/test_null_01.sh index e2847a50823a..a34203f72668 100755 --- a/tools/testing/selftests/ublk/test_null_01.sh +++ b/tools/testing/selftests/ublk/test_null_01.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="null_01" ERR_CODE=0 diff --git a/tools/testing/selftests/ublk/test_stress_01.sh b/tools/testing/selftests/ublk/test_stress_01.sh index c1cdde3e79f7..7177f6c57bc5 100755 --- a/tools/testing/selftests/ublk/test_stress_01.sh +++ b/tools/testing/selftests/ublk/test_stress_01.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="stress_01" ERR_CODE=0 DEV_ID=-1 @@ -17,7 +17,7 @@ ublk_io_and_remove() DEV_ID=$(_add_ublk_dev "$@") _check_add_dev $TID $? "${backfile}" - echo "run ublk IO vs. remove device(ublk add $*)" + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)" if ! __run_io_and_remove "${DEV_ID}" "${size}" "no"; then echo "/dev/ublkc${DEV_ID} isn't removed" _remove_backfile "${backfile}" diff --git a/tools/testing/selftests/ublk/test_stress_02.sh b/tools/testing/selftests/ublk/test_stress_02.sh index ec758f649a97..2a8e60579a06 100755 --- a/tools/testing/selftests/ublk/test_stress_02.sh +++ b/tools/testing/selftests/ublk/test_stress_02.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -. test_common.sh +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh TID="stress_02" ERR_CODE=0 DEV_ID=-1 @@ -17,7 +17,7 @@ ublk_io_and_kill_daemon() DEV_ID=$(_add_ublk_dev "$@") _check_add_dev $TID $? "${backfile}" - echo "run ublk IO vs kill ublk server(ublk add $*)" + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)" if ! __run_io_and_remove "${DEV_ID}" "${size}" "yes"; then echo "/dev/ublkc${DEV_ID} isn't removed res ${res}" _remove_backfile "${backfile}"