From: alison.schofield@intel.com
To: nvdimm@lists.linux.dev,
	linux-cxl@vger.kernel.org
Cc: Alison Schofield <alison.schofield@intel.com>
Subject: [ndctl PATCH] ndctl,cxl/test: Add a common unit test for creating pmem namespaces
Date: Mon,  8 Jul 2024 21:44:00 -0700
Message-Id: <20240709044400.679650-1-alison.schofield@intel.com>
X-Mailing-List: linux-cxl@vger.kernel.org
List-Id: <linux-cxl.vger.kernel.org>
List-Subscribe: <mailto:linux-cxl+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-cxl+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Xref: photonic.trudheim.com org.kernel.vger.linux-cxl:29345
Newsgroups: org.kernel.vger.linux-cxl,dev.linux.lists.nvdimm
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

From: Alison Schofield <alison.schofield@intel.com>

Replace the nfit-only create.sh unit test with a set of scripts that
test pmem namespace creation in either the nfit or cxl environments.

The intent is to do the same reconfiguring of pmem namespaces as was
done by create.sh and then expand that with devdax namespaces and
create/destroy (no reconfigure) cases.

Script namespace.sh provides the shared functionality.
Scripts cxl-namespace and nfit-namespace set up the environments.
Scripts cxl-namespace.sh and nfit-namespace.sh kick off the tests.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 test/create.sh         | 45 --------------------
 test/cxl-namespace     | 25 +++++++++++
 test/cxl-namespace.sh  |  5 +++
 test/meson.build       |  6 ++-
 test/namespace.sh      | 95 ++++++++++++++++++++++++++++++++++++++++++
 test/nfit-namespace    |  6 +++
 test/nfit-namespace.sh |  5 +++
 7 files changed, 140 insertions(+), 47 deletions(-)
 delete mode 100755 test/create.sh
 create mode 100644 test/cxl-namespace
 create mode 100644 test/cxl-namespace.sh
 create mode 100644 test/namespace.sh
 create mode 100644 test/nfit-namespace
 create mode 100644 test/nfit-namespace.sh

diff --git a/test/create.sh b/test/create.sh
deleted file mode 100755
index 9a6f3733939e..000000000000
--- a/test/create.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash -x
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
-
-set -e
-
-SECTOR_SIZE="4096"
-rc=77
-
-. $(dirname $0)/common
-
-check_min_kver "4.5" || do_skip "may lack namespace mode attribute"
-
-trap 'err $LINENO' ERR
-
-# setup (reset nfit_test dimms)
-modprobe nfit_test
-reset
-
-rc=1
-
-# create pmem
-dev="x"
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m raw)
-eval $(echo $json | json2var )
-[ $dev = "x" ] && echo "fail: $LINENO" && exit 1
-[ $mode != "raw" ] && echo "fail: $LINENO" &&  exit 1
-
-# convert pmem to fsdax mode
-json=$($NDCTL create-namespace -m fsdax -f -e $dev)
-eval $(echo $json | json2var)
-[ $mode != "fsdax" ] && echo "fail: $LINENO" &&  exit 1
-
-# convert pmem to sector mode
-json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev)
-eval $(echo $json | json2var)
-[ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" &&  exit 1
-[ $mode != "sector" ] && echo "fail: $LINENO" &&  exit 1
-
-# free capacity for blk creation
-$NDCTL destroy-namespace -f $dev
-
-_cleanup
-
-exit 0
diff --git a/test/cxl-namespace b/test/cxl-namespace
new file mode 100644
index 000000000000..8a7c23b8ce95
--- /dev/null
+++ b/test/cxl-namespace
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+cxl_create_region()
+{
+	decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] |
+		select(.pmem_capable == true) |
+		select(.nr_targets == 1) |
+		.decoder")
+
+	port_dev0=$($CXL list -T -d "$decoder" | jq -r ".[] |
+		.targets | .[] | select(.position == 0) | .target")
+	mem0=$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev")
+
+	region=$($CXL create-region -d "$decoder" -m "$mem0" |
+		jq -r ".region")
+	if [[ ! $region ]]; then
+		err "$LINENO"
+	fi
+}
+
+modprobe -r cxl_test
+modprobe cxl_test
+rc=1
+cxl_create_region
diff --git a/test/cxl-namespace.sh b/test/cxl-namespace.sh
new file mode 100644
index 000000000000..15259ea09603
--- /dev/null
+++ b/test/cxl-namespace.sh
@@ -0,0 +1,5 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+. $(dirname $0)/namespace.sh cxl
diff --git a/test/meson.build b/test/meson.build
index a965a79fd6cb..02bd368743b7 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -132,7 +132,7 @@ revoke_devmem = executable('revoke_devmem', testcore + [
 
 mmap = executable('mmap', 'mmap.c',)
 
-create = find_program('create.sh')
+nfit_namespace = find_program('nfit-namespace.sh')
 clear = find_program('clear.sh')
 pmem_errors = find_program('pmem-errors.sh')
 daxdev_errors_sh = find_program('daxdev-errors.sh')
@@ -160,11 +160,12 @@ cxl_events = find_program('cxl-events.sh')
 cxl_sanitize = find_program('cxl-sanitize.sh')
 cxl_destroy_region = find_program('cxl-destroy-region.sh')
 cxl_qos_class = find_program('cxl-qos-class.sh')
+cxl_namespace = find_program('cxl-namespace.sh')
 
 tests = [
   [ 'libndctl',               libndctl,		  'ndctl' ],
   [ 'dsm-fail',               dsm_fail,	      	  'ndctl' ],
-  [ 'create.sh',              create,	      	  'ndctl' ],
+  [ 'nfit-namespace.sh',      nfit_namespace,     'ndctl' ],
   [ 'clear.sh',               clear,	      	  'ndctl' ],
   [ 'pmem-errors.sh',         pmem_errors,    	  'ndctl' ],
   [ 'daxdev-errors.sh',       daxdev_errors_sh,	  'dax'	  ],
@@ -192,6 +193,7 @@ tests = [
   [ 'cxl-sanitize.sh',        cxl_sanitize,       'cxl'   ],
   [ 'cxl-destroy-region.sh',  cxl_destroy_region, 'cxl'   ],
   [ 'cxl-qos-class.sh',       cxl_qos_class,      'cxl'   ],
+  [ 'cxl-namespace.sh',       cxl_namespace,      'cxl'   ],
 ]
 
 if get_option('destructive').enabled()
diff --git a/test/namespace.sh b/test/namespace.sh
new file mode 100644
index 000000000000..9e7e27af6c35
--- /dev/null
+++ b/test/namespace.sh
@@ -0,0 +1,95 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+. "$(dirname "$0")/common"
+
+rc=77
+trap 'err $LINENO' ERR
+check_prereq "jq"
+
+
+do_set_up()
+{
+	# Set up based on calling environment
+	if [[ "$1" == "nfit" ]]; then
+		. "$(dirname "$0")/nfit-namespace"
+		target=(-b "$NFIT_TEST_BUS0")
+	elif [[ "$1" == "cxl" ]]; then
+		. "$(dirname "$0")/cxl-namespace"
+		target=(--region="$region")
+	else
+		do_skip "Missing nfit or cxl input parameter"
+	fi
+
+	rc=1
+}
+
+test_namespace_create()
+{
+	local mode_list=("raw" "fsdax" "devdax" "sector")
+
+	for ns_mode in "${mode_list[@]}"; do
+		local params json
+		local dev="x"
+
+		if [[ "$ns_mode" == "devdax" || "$ns_mode" == "fsdax" ]]; then
+			params=("${target[@]}" -m "$ns_mode" --map=mem)
+		else
+			params=("${target[@]}" -m "$ns_mode")
+		fi
+
+		json=$($NDCTL create-namespace "${params[@]}")
+		eval "$(echo "$json" | json2var)"
+
+		if [[ "$dev" == "x" || "$mode" != "$ns_mode" ]]; then
+			err "$LINENO"
+		fi
+
+		$NDCTL destroy-namespace -f $dev || err "$LINENO"
+	done
+}
+
+test_namespace_reconfigure()
+{
+	# Create a raw pmem namespace then reconfigure it.
+	# Based on the original nfit create.sh plus devdax.
+
+	local json mode sector_size
+	local dev="x"
+
+	json=$($NDCTL create-namespace "${target[@]}" -t pmem -m raw)
+	eval "$(echo "$json" | json2var )"
+	[ "$dev" = "x" ] && err "$LINENO"
+	[ "$mode" != "raw" ] && err "$LINENO"
+
+	# convert pmem to fsdax mode
+	json=$($NDCTL create-namespace -m fsdax -f -e "$dev" --map=mem)
+	eval "$(echo "$json" | json2var )"
+	[ "$mode" != "fsdax" ] && err "$LINENO"
+
+	# convert pmem to sector mode
+	json=$($NDCTL create-namespace -m sector -l 4096 -f -e "$dev")
+	eval "$(echo "$json" | json2var )"
+	[ "$sector_size" != 4096 ] && err "$LINENO"
+	[ "$mode" != "sector" ] && err "$LINENO"
+
+	# convert pmem to devdax mode
+	json=$($NDCTL create-namespace -m devdax -f -e "$dev" --map=mem)
+	eval "$(echo "$json" | json2var )"
+	[ "$mode" != "devdax" ] && err "$LINENO"
+
+	$NDCTL destroy-namespace -f "$dev" || err "$LINENO"
+}
+
+do_set_up "$1"
+test_namespace_create
+test_namespace_reconfigure
+
+check_dmesg "$LINENO"
+
+if [ "$1" = "nfit" ]; then
+	_cleanup
+elif [ "$1" = "cxl" ]; then
+	_cxl_cleanup
+fi
diff --git a/test/nfit-namespace b/test/nfit-namespace
new file mode 100644
index 000000000000..1f7db4051537
--- /dev/null
+++ b/test/nfit-namespace
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+modprobe -r nfit_test
+modprobe nfit_test
+reset
diff --git a/test/nfit-namespace.sh b/test/nfit-namespace.sh
new file mode 100644
index 000000000000..28f4deac69d6
--- /dev/null
+++ b/test/nfit-namespace.sh
@@ -0,0 +1,5 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+. $(dirname $0)/namespace.sh nfit

base-commit: 16f45755f991f4fb6d76fec70a42992426c84234
-- 
2.37.3

.

Date: Tue, 09 Jul 2024 20:16:40 +0800
From: kernel test robot <lkp@intel.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>,
 Vishal Verma <vishal.l.verma@intel.com>,
 Ira Weiny <ira.weiny@intel.com>,
 Dan Williams <dan.j.williams@intel.com>, linux-cxl@vger.kernel.org
Subject: [cxl:next] BUILD SUCCESS
 86588139b84386a47108b024d703c3c24ddbbec8
Message-ID: <202407092037.KJAGIcAQ-lkp@intel.com>
X-Mailing-List: linux-cxl@vger.kernel.org
List-Id: <linux-cxl.vger.kernel.org>
List-Subscribe: <mailto:linux-cxl+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-cxl+unsubscribe@vger.kernel.org>
Xref: photonic.trudheim.com org.kernel.vger.linux-cxl:29353
Newsgroups: org.kernel.vger.linux-cxl
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git next
branch HEAD: 86588139b84386a47108b024d703c3c24ddbbec8  Documentation: CXL Maturity Map

elapsed time: 791m

configs tested: 246
configs skipped: 5

The following configs have been built successfully.
More configs may be tested in the coming days.

tested configs:
alpha                            alldefconfig   gcc-13.2.0
alpha                             allnoconfig   gcc-13.2.0
alpha                            allyesconfig   gcc-13.2.0
alpha                               defconfig   gcc-13.2.0
arc                              allmodconfig   gcc-13.2.0
arc                               allnoconfig   gcc-13.2.0
arc                              allyesconfig   gcc-13.2.0
arc                                 defconfig   gcc-13.2.0
arc                   randconfig-001-20240709   gcc-13.2.0
arc                   randconfig-002-20240709   gcc-13.2.0
arm                              allmodconfig   gcc-13.2.0
arm                               allnoconfig   clang-19
arm                               allnoconfig   gcc-13.2.0
arm                              allyesconfig   gcc-13.2.0
arm                     am200epdkit_defconfig   gcc-13.2.0
arm                                 defconfig   clang-14
arm                                 defconfig   gcc-13.2.0
arm                          ixp4xx_defconfig   gcc-13.2.0
arm                         nhk8815_defconfig   gcc-13.2.0
arm                           omap1_defconfig   gcc-13.2.0
arm                   randconfig-001-20240709   gcc-13.2.0
arm                   randconfig-002-20240709   clang-19
arm                   randconfig-003-20240709   clang-19
arm                   randconfig-004-20240709   gcc-13.2.0
arm                         socfpga_defconfig   gcc-13.2.0
arm                           spitz_defconfig   gcc-13.2.0
arm64                            allmodconfig   clang-19
arm64                            allmodconfig   gcc-13.2.0
arm64                             allnoconfig   gcc-13.2.0
arm64                               defconfig   gcc-13.2.0
arm64                 randconfig-001-20240709   clang-19
arm64                 randconfig-002-20240709   clang-17
arm64                 randconfig-003-20240709   clang-19
arm64                 randconfig-004-20240709   clang-19
csky                              allnoconfig   gcc-13.2.0
csky                                defconfig   gcc-13.2.0
csky                  randconfig-001-20240709   gcc-13.2.0
csky                  randconfig-002-20240709   gcc-13.2.0
hexagon                          allmodconfig   clang-19
hexagon                           allnoconfig   clang-19
hexagon                          allyesconfig   clang-19
hexagon                             defconfig   clang-19
hexagon               randconfig-001-20240709   clang-19
hexagon               randconfig-002-20240709   clang-19
i386                             allmodconfig   clang-18
i386                             allmodconfig   gcc-13
i386                              allnoconfig   clang-18
i386                              allnoconfig   gcc-13
i386                             allyesconfig   clang-18
i386                             allyesconfig   gcc-13
i386         buildonly-randconfig-001-20240709   gcc-11
i386         buildonly-randconfig-002-20240709   gcc-11
i386         buildonly-randconfig-002-20240709   gcc-13
i386         buildonly-randconfig-003-20240709   clang-18
i386         buildonly-randconfig-003-20240709   gcc-11
i386         buildonly-randconfig-004-20240709   clang-18
i386         buildonly-randconfig-004-20240709   gcc-11
i386         buildonly-randconfig-005-20240709   clang-18
i386         buildonly-randconfig-005-20240709   gcc-11
i386         buildonly-randconfig-006-20240709   clang-18
i386         buildonly-randconfig-006-20240709   gcc-11
i386                                defconfig   clang-18
i386                  randconfig-001-20240709   gcc-11
i386                  randconfig-001-20240709   gcc-13
i386                  randconfig-002-20240709   clang-18
i386                  randconfig-002-20240709   gcc-11
i386                  randconfig-003-20240709   gcc-11
i386                  randconfig-004-20240709   gcc-11
i386                  randconfig-004-20240709   gcc-13
i386                  randconfig-005-20240709   gcc-11
i386                  randconfig-005-20240709   gcc-13
i386                  randconfig-006-20240709   gcc-11
i386                  randconfig-006-20240709   gcc-13
i386                  randconfig-011-20240709   clang-18
i386                  randconfig-011-20240709   gcc-11
i386                  randconfig-012-20240709   gcc-11
i386                  randconfig-012-20240709   gcc-13
i386                  randconfig-013-20240709   gcc-11
i386                  randconfig-013-20240709   gcc-12
i386                  randconfig-014-20240709   clang-18
i386                  randconfig-014-20240709   gcc-11
i386                  randconfig-015-20240709   clang-18
i386                  randconfig-015-20240709   gcc-11
i386                  randconfig-016-20240709   gcc-10
i386                  randconfig-016-20240709   gcc-11
loongarch                        allmodconfig   gcc-13.2.0
loongarch                         allnoconfig   gcc-13.2.0
loongarch                           defconfig   gcc-13.2.0
loongarch             randconfig-001-20240709   gcc-13.2.0
loongarch             randconfig-002-20240709   gcc-13.2.0
m68k                             allmodconfig   gcc-13.2.0
m68k                              allnoconfig   gcc-13.2.0
m68k                             allyesconfig   gcc-13.2.0
m68k                                defconfig   gcc-13.2.0
m68k                            mac_defconfig   gcc-13.2.0
m68k                        mvme16x_defconfig   gcc-13.2.0
microblaze                       allmodconfig   gcc-13.2.0
microblaze                        allnoconfig   gcc-13.2.0
microblaze                       allyesconfig   gcc-13.2.0
microblaze                          defconfig   gcc-13.2.0
mips                              allnoconfig   gcc-13.2.0
mips                         bigsur_defconfig   gcc-13.2.0
mips                       lemote2f_defconfig   gcc-13.2.0
mips                      malta_kvm_defconfig   gcc-13.2.0
mips                        maltaup_defconfig   clang-19
mips                    maltaup_xpa_defconfig   gcc-13.2.0
nios2                         3c120_defconfig   gcc-13.2.0
nios2                             allnoconfig   gcc-13.2.0
nios2                               defconfig   gcc-13.2.0
nios2                 randconfig-001-20240709   gcc-13.2.0
nios2                 randconfig-002-20240709   gcc-13.2.0
openrisc                          allnoconfig   gcc-13.2.0
openrisc                         allyesconfig   gcc-13.2.0
openrisc                            defconfig   gcc-13.2.0
openrisc                 simple_smp_defconfig   gcc-13.2.0
parisc                           allmodconfig   gcc-13.2.0
parisc                            allnoconfig   gcc-13.2.0
parisc                           allyesconfig   gcc-13.2.0
parisc                              defconfig   gcc-13.2.0
parisc                randconfig-001-20240709   gcc-13.2.0
parisc                randconfig-002-20240709   gcc-13.2.0
parisc64                            defconfig   gcc-13.2.0
powerpc                          allmodconfig   gcc-13.2.0
powerpc                           allnoconfig   gcc-13.2.0
powerpc                          allyesconfig   clang-19
powerpc                          allyesconfig   gcc-13.2.0
powerpc                   lite5200b_defconfig   gcc-13.2.0
powerpc                   motionpro_defconfig   clang-17
powerpc                    mvme5100_defconfig   gcc-13.2.0
powerpc                      pcm030_defconfig   gcc-13.2.0
powerpc                     powernv_defconfig   gcc-13.2.0
powerpc                         ps3_defconfig   gcc-13.2.0
powerpc               randconfig-001-20240709   clang-19
powerpc               randconfig-002-20240709   gcc-13.2.0
powerpc               randconfig-003-20240709   clang-15
powerpc                     redwood_defconfig   gcc-13.2.0
powerpc                      tqm8xx_defconfig   gcc-13.2.0
powerpc64             randconfig-001-20240709   gcc-13.2.0
powerpc64             randconfig-002-20240709   gcc-13.2.0
powerpc64             randconfig-003-20240709   clang-19
riscv                            allmodconfig   clang-19
riscv                            allmodconfig   gcc-13.2.0
riscv                             allnoconfig   gcc-13.2.0
riscv                            allyesconfig   clang-19
riscv                            allyesconfig   gcc-13.2.0
riscv                               defconfig   clang-19
riscv                               defconfig   gcc-13.2.0
riscv                 randconfig-001-20240709   clang-17
riscv                 randconfig-002-20240709   gcc-13.2.0
s390                             allmodconfig   clang-19
s390                              allnoconfig   clang-19
s390                              allnoconfig   gcc-13.2.0
s390                             allyesconfig   clang-19
s390                             allyesconfig   gcc-13.2.0
s390                                defconfig   clang-19
s390                                defconfig   gcc-13.2.0
s390                  randconfig-001-20240709   gcc-13.2.0
s390                  randconfig-002-20240709   clang-19
sh                               allmodconfig   gcc-13.2.0
sh                                allnoconfig   gcc-13.2.0
sh                               allyesconfig   gcc-13.2.0
sh                                  defconfig   gcc-13.2.0
sh                ecovec24-romimage_defconfig   gcc-13.2.0
sh                    randconfig-001-20240709   gcc-13.2.0
sh                    randconfig-002-20240709   gcc-13.2.0
sh                          rsk7203_defconfig   gcc-13.2.0
sh                           se7206_defconfig   gcc-13.2.0
sh                           se7619_defconfig   gcc-13.2.0
sh                           se7751_defconfig   gcc-13.2.0
sh                        sh7757lcr_defconfig   gcc-13.2.0
sparc                            allmodconfig   gcc-13.2.0
sparc                       sparc64_defconfig   gcc-13.2.0
sparc64                          alldefconfig   gcc-13.2.0
sparc64                             defconfig   gcc-13.2.0
sparc64               randconfig-001-20240709   gcc-13.2.0
sparc64               randconfig-002-20240709   gcc-13.2.0
um                               allmodconfig   clang-19
um                               allmodconfig   gcc-13.2.0
um                                allnoconfig   clang-17
um                                allnoconfig   gcc-13.2.0
um                               allyesconfig   gcc-13
um                               allyesconfig   gcc-13.2.0
um                                  defconfig   clang-19
um                                  defconfig   gcc-13.2.0
um                             i386_defconfig   gcc-13
um                             i386_defconfig   gcc-13.2.0
um                    randconfig-001-20240709   gcc-13
um                    randconfig-002-20240709   gcc-11
um                           x86_64_defconfig   clang-15
um                           x86_64_defconfig   gcc-13.2.0
x86_64                            allnoconfig   clang-18
x86_64                           allyesconfig   clang-18
x86_64       buildonly-randconfig-001-20240709   gcc-11
x86_64       buildonly-randconfig-002-20240709   clang-18
x86_64       buildonly-randconfig-002-20240709   gcc-11
x86_64       buildonly-randconfig-003-20240709   clang-18
x86_64       buildonly-randconfig-003-20240709   gcc-11
x86_64       buildonly-randconfig-004-20240709   gcc-11
x86_64       buildonly-randconfig-004-20240709   gcc-9
x86_64       buildonly-randconfig-005-20240709   gcc-11
x86_64       buildonly-randconfig-005-20240709   gcc-13
x86_64       buildonly-randconfig-006-20240709   clang-18
x86_64       buildonly-randconfig-006-20240709   gcc-11
x86_64                              defconfig   clang-18
x86_64                              defconfig   gcc-13
x86_64                randconfig-001-20240709   clang-18
x86_64                randconfig-001-20240709   gcc-11
x86_64                randconfig-002-20240709   gcc-10
x86_64                randconfig-002-20240709   gcc-11
x86_64                randconfig-003-20240709   clang-18
x86_64                randconfig-003-20240709   gcc-11
x86_64                randconfig-004-20240709   gcc-11
x86_64                randconfig-004-20240709   gcc-12
x86_64                randconfig-005-20240709   gcc-11
x86_64                randconfig-005-20240709   gcc-13
x86_64                randconfig-006-20240709   gcc-11
x86_64                randconfig-006-20240709   gcc-8
x86_64                randconfig-011-20240709   clang-18
x86_64                randconfig-011-20240709   gcc-11
x86_64                randconfig-012-20240709   clang-18
x86_64                randconfig-012-20240709   gcc-11
x86_64                randconfig-013-20240709   clang-18
x86_64                randconfig-013-20240709   gcc-11
x86_64                randconfig-014-20240709   clang-18
x86_64                randconfig-014-20240709   gcc-11
x86_64                randconfig-015-20240709   clang-18
x86_64                randconfig-015-20240709   gcc-11
x86_64                randconfig-016-20240709   clang-18
x86_64                randconfig-016-20240709   gcc-11
x86_64                randconfig-071-20240709   gcc-11
x86_64                randconfig-071-20240709   gcc-7
x86_64                randconfig-072-20240709   clang-18
x86_64                randconfig-072-20240709   gcc-11
x86_64                randconfig-073-20240709   gcc-11
x86_64                randconfig-073-20240709   gcc-13
x86_64                randconfig-074-20240709   gcc-11
x86_64                randconfig-074-20240709   gcc-13
x86_64                randconfig-075-20240709   gcc-11
x86_64                randconfig-076-20240709   gcc-11
x86_64                randconfig-076-20240709   gcc-13
x86_64                          rhel-8.3-rust   clang-18
xtensa                            allnoconfig   gcc-13.2.0
xtensa                  nommu_kc705_defconfig   gcc-13.2.0
xtensa                randconfig-001-20240709   gcc-13.2.0
xtensa                randconfig-002-20240709   gcc-13.2.0
xtensa                    xip_kc705_defconfig   gcc-13.2.0

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
.

From: Dongsheng Yang <dongsheng.yang@linux.dev>
To: axboe@kernel.dk,
	dan.j.williams@intel.com,
	gregory.price@memverge.com,
	John@groves.net,
	Jonathan.Cameron@Huawei.com,
	bbhushan2@marvell.com,
	chaitanyak@nvidia.com,
	rdunlap@infradead.org
Cc: linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-cxl@vger.kernel.org,
	Dongsheng Yang <dongsheng.yang@linux.dev>
Subject: [PATCH v1 0/7] Introduce CBD (CXL Block Device)
Date: Tue,  9 Jul 2024 13:03:36 +0000
Message-Id: <20240709130343.858363-1-dongsheng.yang@linux.dev>
X-Mailing-List: linux-block@vger.kernel.org
List-Id: <linux-block.vger.kernel.org>
List-Subscribe: <mailto:linux-block+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:linux-block+unsubscribe@vger.kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Xref: photonic.trudheim.com org.kernel.vger.linux-block:93970 org.kernel.vger.linux-cxl:29354 org.kernel.vger.linux-kernel:1272049
Newsgroups: org.kernel.vger.linux-block,org.kernel.vger.linux-cxl,org.kernel.vger.linux-kernel
Path: photonic.trudheim.com!nntp.lore.kernel.org!not-for-mail

Hi all,
        This is V1 for CXL Block Device. This patchset is based on v6.9 and
it's available at: https://github.com/DataTravelGuide/linux branch cbd.

changes from RFC: (https://lore.kernel.org/lkml/20240422071606.52637-1-dongsheng.yang@easystack.cn/)
        (1) only support hardware-consistency cxl shared memory.
		As discussed in the RFC, the current cbd only supports
hardware-consistency for CXL shared memory, and some code related to
software-consistency support has been removed from the RFC. In the
current tests, whether using local PMEM or QEMU-simulated shared memory
devices, they all are hardware-consistency.

        (2) add a segment abstraction for transport data space management.
		The layout of the transport remains essentially
unchanged, with the only difference being the addition of a segment
abstraction for scalability purposes. A channel is a type of segment
used for data transfer between the blkdev and the backend. In the
future, there will be more segment types, such as a cache segment for
caching data for the blkdev.

        (3) add CONFIG_CBD_CRC option in Kconfig
		We only support hardware-consistency, so theoretically,
there should be no data consistency issues when transferring data
between blkdev and the backend. However, cbd provides a verification
mechanism, offering CRC checks for both metadata and data to verify
after data reception. This method impacts performance, so it is an
option in Kconfig.

        (4) allow user to clear dead object in transport metadata
		When a host using cbd, whether backend or blkdev, dies
without unregistering, the metadata in the transport will retain some
dead information. In v1, users are allowed to clear this dead metadata
via sysfs. Of course, there is a heartbeat mechanism to ensure users do
not mistakenly delete alive metadata.

        (5) allow user to force stop blkdev and reattach backend
		This also handles scenarios where the host goes offline
unexpectedly. When the backend goes offline unexpectedly, the
corresponding blkdev might have I/O operations that cannot finish. In
such cases, cbd provides two ways to handle this:
		a) If the backend can recover, we can re-add the backend to the
corresponding transport, allowing the blkdev's I/O operations to continue being processed.
		b) If the backend cannot recover, the blkdev can be force-stopped, and
the incomplete I/O operations will return EIO, but they will no longer remain blocked.

        (6) dont allocate new pages in hander for bio data.
		The backend handler does not allocate pages for bio.
Instead, the handler can directly map the data pages from the transport
to the bio, and then send the bio to the backend disk, achieving zero
copy on the backend side.

        (7) new test project cbd-tests:
		cbd-tests (https://github.com/DataTravelGuide/cbd-tests), for testing cbd. It is
an automated testing project based on the Avocado testing framework. Currently,
it includes xfstests on cbd block devices with XFS, V1 Passed all 944 tests in xfstests
(https://datatravelguide.github.io/dtg-blog/cbd/test-results/test_result_v1/test-results/xfstests-1-xfstests.py_Xfstests.test_run-cbdd_timeout-no_timeout-disk_type-fs_type-fs_xfs-f090/debug.log). as well as fio performance testing directly on /dev/cbdX block devices.

The test results can be viewed here in [test results]:
	https://datatravelguide.github.io/dtg-blog/cbd/cbd.html#test-results

Thanx

Dongsheng Yang (7):
  cbd: introduce cbd_transport
  cbd: introduce cbd_host
  cbd: introduce cbd_segment
  cbd: introduce cbd_channel
  cbd: introduce cbd_blkdev
  cbd: introduce cbd_backend
  block: Init for CBD(CXL Block Device) module

 drivers/block/Kconfig             |   2 +
 drivers/block/Makefile            |   2 +
 drivers/block/cbd/Kconfig         |  23 +
 drivers/block/cbd/Makefile        |   3 +
 drivers/block/cbd/cbd_backend.c   | 296 ++++++++++
 drivers/block/cbd/cbd_blkdev.c    | 417 ++++++++++++++
 drivers/block/cbd/cbd_channel.c   | 153 ++++++
 drivers/block/cbd/cbd_handler.c   | 263 +++++++++
 drivers/block/cbd/cbd_host.c      | 128 +++++
 drivers/block/cbd/cbd_internal.h  | 848 ++++++++++++++++++++++++++++
 drivers/block/cbd/cbd_main.c      | 224 ++++++++
 drivers/block/cbd/cbd_queue.c     | 526 ++++++++++++++++++
 drivers/block/cbd/cbd_segment.c   | 108 ++++
 drivers/block/cbd/cbd_transport.c | 883 ++++++++++++++++++++++++++++++
 14 files changed, 3876 insertions(+)
 create mode 100644 drivers/block/cbd/Kconfig
 create mode 100644 drivers/block/cbd/Makefile
 create mode 100644 drivers/block/cbd/cbd_backend.c
 create mode 100644 drivers/block/cbd/cbd_blkdev.c
 create mode 100644 drivers/block/cbd/cbd_channel.c
 create mode 100644 drivers/block/cbd/cbd_handler.c
 create mode 100644 drivers/block/cbd/cbd_host.c
 create mode 100644 drivers/block/cbd/cbd_internal.h
 create mode 100644 drivers/block/cbd/cbd_main.c
 create mode 100644 drivers/block/cbd/cbd_queue.c
 create mode 100644 drivers/block/cbd/cbd_segment.c
 create mode 100644 drivers/block/cbd/cbd_transport.c

-- 
2.34.1

.

