diff mbox series

[blktests,1/2] nvme: enable buffered_io for file-backed namespaces

Message ID 20190117125906.15479-1-jthumshirn@suse.de (mailing list archive)
State New, archived
Headers show
Series [blktests,1/2] nvme: enable buffered_io for file-backed namespaces | expand

Commit Message

Johannes Thumshirn Jan. 17, 2019, 12:59 p.m. UTC
All file-based NVMe over Fabrics tests fail in my test environment as I'm
running these tests form within an initramfs. It turns out the file backing
store of the NVMe target defaults to using direct I/O which is not
available on tmpfs for obvious reasons.

If the backing store of an nvme target is file-based enable the use of
buffered I/O.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 tests/nvme/rc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Chaitanya Kulkarni Jan. 17, 2019, 11:46 p.m. UTC | #1
This will force the user to run all tests in the buffered_io mode.

What we really need is a config for the nvme category option which user can set and decide
whether to run buffered_io or direct_io, you can set by default to the buffered_io mode.


From: linux-block-owner@vger.kernel.org <linux-block-owner@vger.kernel.org> on behalf of Johannes Thumshirn <jthumshirn@suse.de>
Sent: Thursday, January 17, 2019 4:59 AM
To: Omar Sandoval
Cc: Linux Block Layer Mailinglist; Linux NVMe Mailinglist; Anthony Iliopoulos; Johannes Thumshirn
Subject: [PATCH blktests 1/2] nvme: enable buffered_io for file-backed namespaces
  
 
All file-based NVMe over Fabrics tests fail in my test environment as I'm
running these tests form within an initramfs. It turns out the file backing
store of the NVMe target defaults to using direct I/O which is not
available on tmpfs for obvious reasons.

If the backing store of an nvme target is file-based enable the use of
buffered I/O.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 tests/nvme/rc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index eff1dd992460..ec92e41396be 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -48,7 +48,7 @@ _remove_nvmet_port() {
 _create_nvmet_ns() {
         local nvmet_subsystem="$1"
         local nsid="$2"
-       local blkdev="$3"
+       local backstore="$3"
         local uuid="00000000-0000-0000-0000-000000000000"
         local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
         local ns_path="${subsys_path}/namespaces/${nsid}"
@@ -58,8 +58,11 @@ _create_nvmet_ns() {
         fi
 
         mkdir "${ns_path}"
-       printf "%s" "${blkdev}" > "${ns_path}/device_path"
+       printf "%s" "${backstore}" > "${ns_path}/device_path"
         printf "%s" "${uuid}" > "${ns_path}/device_uuid"
+       if [[ -f ${backstore} ]]; then
+               printf 1 > "${ns_path}/buffered_io"
+       fi
         printf 1 > "${ns_path}/enable"
 }
Johannes Thumshirn Jan. 18, 2019, 7:17 a.m. UTC | #2
On 18/01/2019 00:46, Chaitanya Kulkarni wrote:
> This will force the user to run all tests in the buffered_io mode.
> 
> What we really need is a config for the nvme category option which user can set and decide
> whether to run buffered_io or direct_io, you can set by default to the buffered_io mode.

We could also introduce a check if we can use direct IO on the
underlying FS, but the only way I can think of from a shell script is
doing a 'dd of=$TMPDIR/testfile oflag=direct' and then populate the
result to the helper functions.

Chaitanya, Omar any ideas?
Chaitanya Kulkarni Jan. 18, 2019, 7:10 p.m. UTC | #3
xfstest has the following nicely written routine may be we can re-use that?

from  git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git, ${XFSTEST_HOME}/common/rc :-


  2185	# check that kernel and filesystem support direct I/O
  2186	_require_odirect()
  2187	{
  2188		if [ $FSTYP = "ext4" ] ; then
  2189			if echo "$MOUNT_OPTIONS" | grep -q "test_dummy_encryption"; then
  2190				_notrun "ext4 encryption doesn't support O_DIRECT"
  2191			elif echo "$MOUNT_OPTIONS" | grep -q "data=journal"; then
  2192				_notrun "ext4 data journaling doesn't support O_DIRECT"
  2193			fi
  2194		fi
  2195		local testfile=$TEST_DIR/$$.direct
  2196		$XFS_IO_PROG -F -f -d -c "pwrite 0 20k" $testfile > /dev/null 2>&1
  2197		if [ $? -ne 0 ]; then
  2198			_notrun "O_DIRECT is not supported"
  2199		fi
  2200		rm -f $testfile 2>&1 > /dev/null
  2201	}
  2202	

This will require to have xfs_io program.


From: Johannes Thumshirn <jthumshirn@suse.de>
Sent: Thursday, January 17, 2019 11:17 PM
To: Chaitanya Kulkarni; Omar Sandoval
Cc: Linux Block Layer Mailinglist; Linux NVMe Mailinglist; Anthony Iliopoulos
Subject: Re: [PATCH blktests 1/2] nvme: enable buffered_io for file-backed namespaces
  
 
On 18/01/2019 00:46, Chaitanya Kulkarni wrote:
> This will force the user to run all tests in the buffered_io mode.
> 
> What we really need is a config for the nvme category option which user can set and decide
> whether to run buffered_io or direct_io, you can set by default to the buffered_io mode.

We could also introduce a check if we can use direct IO on the
underlying FS, but the only way I can think of from a shell script is
doing a 'dd of=$TMPDIR/testfile oflag=direct' and then populate the
result to the helper functions.

Chaitanya, Omar any ideas?
diff mbox series

Patch

diff --git a/tests/nvme/rc b/tests/nvme/rc
index eff1dd992460..ec92e41396be 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -48,7 +48,7 @@  _remove_nvmet_port() {
 _create_nvmet_ns() {
 	local nvmet_subsystem="$1"
 	local nsid="$2"
-	local blkdev="$3"
+	local backstore="$3"
 	local uuid="00000000-0000-0000-0000-000000000000"
 	local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
 	local ns_path="${subsys_path}/namespaces/${nsid}"
@@ -58,8 +58,11 @@  _create_nvmet_ns() {
 	fi
 
 	mkdir "${ns_path}"
-	printf "%s" "${blkdev}" > "${ns_path}/device_path"
+	printf "%s" "${backstore}" > "${ns_path}/device_path"
 	printf "%s" "${uuid}" > "${ns_path}/device_uuid"
+	if [[ -f ${backstore} ]]; then
+		printf 1 > "${ns_path}/buffered_io"
+	fi
 	printf 1 > "${ns_path}/enable"
 }