Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package zonefs-tools for openSUSE:Factory checked in at 2021-03-24 16:16:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/zonefs-tools (Old) and /work/SRC/openSUSE:Factory/.zonefs-tools.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "zonefs-tools" Wed Mar 24 16:16:09 2021 rev:3 rq:880870 version:1.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/zonefs-tools/zonefs-tools.changes 2021-01-31 16:52:17.892727471 +0100 +++ /work/SRC/openSUSE:Factory/.zonefs-tools.new.2401/zonefs-tools.changes 2021-03-24 16:17:49.952246267 +0100 @@ -1,0 +2,18 @@ +Tue Mar 23 08:09:48 UTC 2021 - Johannes Thumshirn <[email protected]> + +- Update to upstream version 1.5 + This new release fixes some problems with mkzonefs and improves the test suite. + + * mkzonefs: + * Improved zone reset handling, forcing an all zone reset, always. + * Use O_EXCL mode flag to open a device file to avoid formatting a device in use. + * Fix make install directive + * Add the new make rpm directive + * Test suite: + * New zio tool to execute IO operations of various types using various flags + * Fix stale data access when running tests + * zonefs-tests-nullblk.sh improvements (new options) + * Add test cases related to using zonefs files as swap files + * Various other minor improvements. + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ zonefs-tools.spec ++++++ --- /var/tmp/diff_new_pack.PIB47d/_old 2021-03-24 16:17:50.376246711 +0100 +++ /var/tmp/diff_new_pack.PIB47d/_new 2021-03-24 16:17:50.376246711 +0100 @@ -18,7 +18,7 @@ Name: zonefs-tools -Version: 1.4.0 +Version: 1.5.0 Release: 0 Summary: Utilities for the Zonefs filesystem License: GPL-2.0-or-later ++++++ zonefs-tools.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/.gitignore new/zonefs-tools-1.5.0/.gitignore --- old/zonefs-tools-1.4.0/.gitignore 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/.gitignore 2021-03-23 05:28:31.000000000 +0100 @@ -28,8 +28,8 @@ *.i*86 *.x86_64 *.hex - src/mkzonefs +tests/tools/zio # Kernel compile files *.symvers @@ -44,29 +44,34 @@ Thumbs.db desktop.ini -# Mac-specific things (thanks to Michael Aaron Safyan) +# Mac-specific things .DS_Store +._.DS_Store # Editors temporary files *~ # Autotools stuff m4/*.m4 -*.in aclocal.m4 autom4te.cache/ build-aux/ configure +Makefile.in Makefile config.log config.status src/stamp-h1 -src/config.h +config.h +config.h.in .deps libtool .libs .dirstamp +# Built RPMs +*.rpm + # Tests files tests/*.state tests/*.log diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/Makefile.am new/zonefs-tools-1.5.0/Makefile.am --- old/zonefs-tools-1.4.0/Makefile.am 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/Makefile.am 2021-03-23 05:28:31.000000000 +0100 @@ -4,5 +4,34 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src man +SUBDIRS = src man tests/tools EXTRA_DIST = autogen.sh + +if BUILD_RPM + +rpmdir = $(abs_top_builddir)/rpmbuild + +EXTRA_DIST += zonefs-tools.spec +RPMARCH=`$(RPM) --eval %_target_cpu` + +spec: zonefs-tools.spec.in + @echo "Generating rpm spec file..." + @echo "Version: $(PACKAGE_VERSION)" > zonefs-tools.spec + @cat zonefs-tools.spec.in | grep -v '# ' >> zonefs-tools.spec + +rpm: spec dist + @echo "Building RPM package..." + @mkdir -p $(rpmdir) + $(RPMBUILD) -ta --clean -D "_topdir $(rpmdir)" zonefs-tools-$(PACKAGE_VERSION).tar.gz + @mv -f $(rpmdir)/RPMS/$(RPMARCH)/*.rpm $(abs_top_builddir) + @mv -f $(rpmdir)/SRPMS/*.rpm $(abs_top_builddir) + @rm -rf $(rpmdir) + @rm -f zonefs-tools-$(PACKAGE_VERSION).tar.gz + @rm -f zonefs-tools.spec +else + +rpm: + @echo "Building RPM packages requires rpmbuild and rpm utilities" + exit 1 + +endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/configure.ac new/zonefs-tools-1.5.0/configure.ac --- old/zonefs-tools-1.4.0/configure.ac 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/configure.ac 2021-03-23 05:28:31.000000000 +0100 @@ -2,7 +2,7 @@ # # Copyright (C) 2019 Western Digital Corporation or its affiliates. -AC_INIT([zonefs tools], [1.4.0], [[email protected]]) +AC_INIT([zonefs tools], [1.5.0], [[email protected]]) AC_PREFIX_DEFAULT(/usr) AC_CONFIG_HEADER([src/config.h]) @@ -34,6 +34,8 @@ [AC_MSG_ERROR([Couldn't find linux/fs.h])]) AC_CHECK_HEADER(blkid/blkid.h, [], [AC_MSG_ERROR([Couldn't find blkid/blkid.h])]) +AC_CHECK_HEADER(linux/aio_abi.h, [], + [AC_MSG_ERROR([Couldn't find linux/aio_abi.h])]) AC_CHECK_HEADER(linux/blkzoned.h, [], [AC_MSG_ERROR([Couldn't find linux/blkzoned.h])]) @@ -43,10 +45,17 @@ AC_SEARCH_LIBS([uuid_generate], [uuid], [], [AC_MSG_ERROR([Couldn't find libuuid])]) +# Checks for rpm package builds +AC_PATH_PROG([RPMBUILD], [rpmbuild], [notfound]) +AC_PATH_PROG([RPM], [rpm], [notfound]) +AM_CONDITIONAL([BUILD_RPM], + [test "x$RPMBUILD" != xnotfound && test "x$RPM" != xnotfound]) + AC_CONFIG_FILES([ Makefile man/Makefile src/Makefile + tests/tools/Makefile ]) AC_OUTPUT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/src/Makefile.am new/zonefs-tools-1.5.0/src/Makefile.am --- old/zonefs-tools-1.4.0/src/Makefile.am 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/src/Makefile.am 2021-03-23 05:28:31.000000000 +0100 @@ -15,8 +15,8 @@ mkzonefs_LDFLAGS = -luuid -lblkid install-exec-hook: - rm -f $(DESTDIR)$(sbindir)/mkfs.zonefs - $(LN_S) $(DESTDIR)$(sbindir)/mkzonefs $(DESTDIR)$(sbindir)/mkfs.zonefs + (cd $(DESTDIR)${sbindir}; rm -f mkfs.zonefs) + (cd $(DESTDIR)${sbindir}; $(LN_S) mkzonefs mkfs.zonefs) uninstall-hook: - rm -f $(DESTDIR)$(sbindir)/mkfs.zonefs + (cd $(DESTDIR)${sbindir}; rm -f mkfs.zonefs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/src/zonefs.h new/zonefs-tools-1.5.0/src/zonefs.h --- old/zonefs-tools-1.4.0/src/zonefs.h 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/src/zonefs.h 2021-03-23 05:28:31.000000000 +0100 @@ -127,7 +127,6 @@ void zonefs_close_dev(struct zonefs_dev *dev); int zonefs_sync_dev(struct zonefs_dev *dev); int zonefs_finish_zone(struct zonefs_dev *dev, struct blk_zone *zone); -int zonefs_reset_zone(struct zonefs_dev *dev, struct blk_zone *zone); int zonefs_reset_zones(struct zonefs_dev *dev); /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/src/zonefs_dev.c new/zonefs-tools-1.5.0/src/zonefs_dev.c --- old/zonefs-tools-1.4.0/src/zonefs_dev.c 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/src/zonefs_dev.c 2021-03-23 05:28:31.000000000 +0100 @@ -78,6 +78,30 @@ } /* + * Check that the device supports reset all zones operation. + * For now, simply exclude DM devices as that operation is never + * supported on these devices. + */ +static bool zonefs_dev_has_reset_all(struct zonefs_dev *dev) +{ + char path[PATH_MAX]; + struct stat st; + int len; + + /* Check if this is a DM device */ + len = snprintf(path, sizeof(path), + "/sys/block/%s/dm/name", + dev->name); + if (len >= PATH_MAX) { + fprintf(stderr, "name %s failed: %s\n", path, + strerror(ENAMETOOLONG)); + return false; + } + + return stat(path, &st) != 0; +} + +/* * Check that the device is a zoned block device. */ static bool zonefs_dev_is_zoned(struct zonefs_dev *dev) @@ -400,10 +424,14 @@ blkid_probe pr; int ret = -1; - pr = blkid_new_probe_from_filename(dev->path); + pr = blkid_new_probe(); if (!pr) goto out; + ret = blkid_probe_set_device(pr, dev->fd, 0, 0); + if (ret < 0) + goto out; + ret = blkid_probe_enable_superblocks(pr, 1); if (ret < 0) goto out; @@ -480,13 +508,6 @@ return -1; } - if (check_overwrite && !(dev->flags & ZONEFS_OVERWRITE)) { - /* Check for existing valid content */ - ret = zonefs_check_overwrite(dev); - if (ret <= 0) - return -1; - } - if (zonefs_dev_mounted(dev)) { fprintf(stderr, "%s is mounted\n", @@ -502,7 +523,7 @@ } /* Open device */ - dev->fd = open(dev->path, O_RDWR | O_DIRECT); + dev->fd = open(dev->path, O_RDWR | O_EXCL); if (dev->fd < 0) { fprintf(stderr, "Open %s failed %d (%s)\n", @@ -511,13 +532,31 @@ return -1; } - /* Get device capacity and zone configuration */ - if (zonefs_get_dev_info(dev) < 0) { - zonefs_close_dev(dev); - return -1; + if (check_overwrite && !(dev->flags & ZONEFS_OVERWRITE)) { + /* Check for existing valid content */ + ret = zonefs_check_overwrite(dev); + if (ret <= 0) + goto err; + } + + /* We need direct writes */ + ret = fcntl(dev->fd, F_SETFL, O_DIRECT); + if (ret) { + fprintf(stderr, + "Set O_DIRECT failed %d (%s)\n", + errno, strerror(errno)); + goto err; } + /* Get device capacity and zone configuration */ + if (zonefs_get_dev_info(dev) < 0) + goto err; + return 0; + +err: + zonefs_close_dev(dev); + return -1; } /* @@ -602,15 +641,14 @@ /* * Reset a zone. */ -int zonefs_reset_zone(struct zonefs_dev *dev, struct blk_zone *zone) +static int zonefs_reset_zone(struct zonefs_dev *dev, struct blk_zone *zone) { struct blk_zone_range range; - if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL || - zone->cond == BLK_ZONE_COND_EMPTY) + if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) return 0; - /* Non empty sequential zone: reset */ + /* Sequential zone: reset */ range.sector = zone->start; range.nr_sectors = zone->len; if (ioctl(dev->fd, BLKRESETZONE, &range) < 0) { @@ -631,11 +669,30 @@ */ int zonefs_reset_zones(struct zonefs_dev *dev) { + struct blk_zone_range range; unsigned int i; + int ret; + + /* + * Try to reset all zones. This does not work on all devices so if + * this fails, fall back to resetting zones one at a time. + */ + if (zonefs_dev_has_reset_all(dev)) { + range.sector = 0; + range.nr_sectors = dev->capacity; + ret = ioctl(dev->fd, BLKRESETZONE, &range); + if (!ret) { + for (i = 0; i < dev->nr_zones; i++) + dev->zones[i].wp = dev->zones[i].start; + return 0; + } + } + /* Fallback to zone reset zones one at a time */ for (i = 0; i < dev->nr_zones; i++) { - if (zonefs_reset_zone(dev, &dev->zones[i]) < 0) - return -1; + ret = zonefs_reset_zone(dev, &dev->zones[i]); + if (ret) + return ret; } return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0076.sh new/zonefs-tools-1.5.0/tests/scripts/0076.sh --- old/zonefs-tools-1.4.0/tests/scripts/0076.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0076.sh 2021-03-23 05:28:31.000000000 +0100 @@ -24,7 +24,7 @@ zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ - --rw=randwrite --ioengine=libaio --iodepth=8 \ + --rw=randwrite --ioengine=libaio --iodepth=8 --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0077.sh new/zonefs-tools-1.5.0/tests/scripts/0077.sh --- old/zonefs-tools-1.4.0/tests/scripts/0077.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0077.sh 2021-03-23 05:28:31.000000000 +0100 @@ -24,7 +24,7 @@ zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ - --rw=randwrite --ioengine=libaio --iodepth=8 \ + --rw=randwrite --ioengine=libaio --iodepth=8 --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0078.sh new/zonefs-tools-1.5.0/tests/scripts/0078.sh --- old/zonefs-tools-1.4.0/tests/scripts/0078.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0078.sh 2021-03-23 05:28:31.000000000 +0100 @@ -27,7 +27,7 @@ fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ - --bs=4096 --verify=md5 --do_verify=1 --overwrite=1 \ + --bs="${iosize}" --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" @@ -38,9 +38,9 @@ zonefs_mount "$1" fio --name=cnv_mmaprd --filename="$zonefs_mntdir"/cnv/0 \ - --rw=randread --ioengine=mmap -size="$maxsize" \ + --rw=randread --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ - --bs=4096 --verify=md5 --do_verify=1 --continue_on_error=none || \ + --bs="${iosize}" --verify=md5 --do_verify=1 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0079.sh new/zonefs-tools-1.5.0/tests/scripts/0079.sh --- old/zonefs-tools-1.4.0/tests/scripts/0079.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0079.sh 2021-03-23 05:28:31.000000000 +0100 @@ -23,11 +23,11 @@ zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" -maxsize=$(file_max_size "$zonefs_mntdir"/cnv/0) +maxsize=$(aggr_cnv_size) fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ - --bs=4096 --verify=md5 --do_verify=1 --overwrite=1 \ + --bs="${iosize}" --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" @@ -38,9 +38,9 @@ zonefs_mount "$1" fio --name=cnv_mmaprd --filename="$zonefs_mntdir"/cnv/0 \ - --rw=randread --ioengine=mmap -size="$maxsize" \ + --rw=randread --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ - --bs=4096 --verify=md5 --do_verify=1 --continue_on_error=none || \ + --bs="${iosize}" --verify=md5 --do_verify=1 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0084.sh new/zonefs-tools-1.5.0/tests/scripts/0084.sh --- old/zonefs-tools-1.4.0/tests/scripts/0084.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0084.sh 2021-03-23 05:28:31.000000000 +0100 @@ -12,8 +12,6 @@ exit 0 fi -require_program fio - echo "Check sequential file unaligned write (sync IO)" zonefs_mkfs "$1" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0085.sh new/zonefs-tools-1.5.0/tests/scripts/0085.sh --- old/zonefs-tools-1.4.0/tests/scripts/0085.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0085.sh 2021-03-23 05:28:31.000000000 +0100 @@ -12,6 +12,8 @@ exit 0 fi +require_program fio + echo "Check sequential file unaligned write (async IO)" zonefs_mkfs "$1" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0086.sh new/zonefs-tools-1.5.0/tests/scripts/0086.sh --- old/zonefs-tools-1.4.0/tests/scripts/0086.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0086.sh 2021-03-23 05:28:31.000000000 +0100 @@ -17,6 +17,9 @@ zonefs_mkfs "$1" zonefs_mount "$1" +# Check with O_APPEND file open +echo "Check append writes with O_APPEND" + dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" @@ -24,8 +27,25 @@ [ "$sz" != "4096" ] && \ exit_failed " --> Invalid file size $sz B, expected 4096 B" -dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct,append bs=4096 \ - count=$(( seq_file_0_max_size / 4096 - 1)) conv=notrunc || \ +tools/zio --write --fflag=direct --fflag=append \ + --size=135168 "$zonefs_mntdir"/seq/0 || \ + exit_failed " --> FAILED" + +sz=$(file_size "$zonefs_mntdir"/seq/0) +[ "$sz" != "$seq_file_0_max_size" ] && \ + exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" + +# Test with RWF_APPEND I/O flag +echo "Check append writes with RWF_APPEND" + +truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ + exit_failed " --> FAILED" + +dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ + exit_failed " --> FAILED" + +tools/zio --write --fflag=direct --ioflag=append \ + --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0087.sh new/zonefs-tools-1.5.0/tests/scripts/0087.sh --- old/zonefs-tools-1.4.0/tests/scripts/0087.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0087.sh 2021-03-23 05:28:31.000000000 +0100 @@ -12,17 +12,40 @@ exit 0 fi -require_program fio - echo "Check sequential file append (async)" zonefs_mkfs "$1" zonefs_mount "$1" -fio --name=seq_wr --filename="$zonefs_mntdir"/seq/0 \ - --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ - --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ - --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ - --continue_on_error=none --direct=1 || \ + +# Test with O_APPEND file open +echo "Check append writes with O_APPEND" + +dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ + exit_failed " --> FAILED" + +sz=$(file_size "$zonefs_mntdir"/seq/0) +[ "$sz" != "4096" ] && \ + exit_failed " --> Invalid file size $sz B, expected 4096 B" + +tools/zio --write --fflag=direct --fflag=append \ + --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ + exit_failed " --> FAILED" + +sz=$(file_size "$zonefs_mntdir"/seq/0) +[ "$sz" != "$seq_file_0_max_size" ] && \ + exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" + +# Test with RWF_APPEND I/O flag +echo "Check append writes with RWF_APPEND" + +truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ + exit_failed " --> FAILED" + +dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ + exit_failed " --> FAILED" + +tools/zio --write --fflag=direct --ioflag=append \ + --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0089.sh new/zonefs-tools-1.5.0/tests/scripts/0089.sh --- old/zonefs-tools-1.4.0/tests/scripts/0089.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0089.sh 2021-03-23 05:28:31.000000000 +0100 @@ -43,7 +43,7 @@ fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=64 --max-jobs=8 \ - --bs=4096 --size="$maxsize" --verify=md5 --do_verify=1 \ + --bs="${iosize}" --size="$maxsize" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" @@ -60,7 +60,7 @@ fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=randread --ioengine=mmap --max-jobs=8 \ --create_on_open=0 --allow_file_create=0 --unlink=0 \ - --bs=4096 --size="$maxsize" --verify=md5 --do_verify=1 \ + --bs="${iosize}" --size="$maxsize" --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio mmap rand read FAILED" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0092.sh new/zonefs-tools-1.5.0/tests/scripts/0092.sh --- old/zonefs-tools-1.4.0/tests/scripts/0092.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0092.sh 2021-03-23 05:28:31.000000000 +0100 @@ -16,6 +16,11 @@ filename="$filename:$zonefs_mntdir/seq/$i" done + filesize=$(file_max_size "$zonefs_mntdir"/seq/0) + if $short; then + filesize=$((zone_sectors * 512 / 64)) + fi + cat > 0092.fio << EOF [global] create_on_open=0 @@ -24,8 +29,8 @@ unlink=0 rw=write ioengine=psync -bs=4k -filesize=$(file_max_size "$zonefs_mntdir"/seq/0) +bs=${iosize} +filesize=${filesize} continue_on_error=none direct=1 @@ -40,7 +45,7 @@ trap cleanup EXIT if [ $# == 0 ]; then - echo "explicit-open mounts" + echo "Sequential file explicit-open zone resources" exit 0 fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0100.sh new/zonefs-tools-1.5.0/tests/scripts/0100.sh --- old/zonefs-tools-1.4.0/tests/scripts/0100.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0100.sh 2021-03-23 05:28:31.000000000 +0100 @@ -0,0 +1,37 @@ +#!/bin/bash +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2021 Western Digital Corporation or its affiliates. +# + +. scripts/test_lib + +if [ $# == 0 ]; then + echo "Swap file on conventional file" + exit 0 +fi + +if [ "$nr_cnv_files" == 0 ]; then + exit_skip +fi + +echo "Check swap file on conventional file" + +zonefs_mkfs "$1" +zonefs_mount "$1" + +chmod 600 "$zonefs_mntdir"/cnv/0 || \ + exit_failed " --> FAILED" +mkswap "$zonefs_mntdir"/cnv/0 || \ + exit_failed " --> FAILED" + +swapon "$zonefs_mntdir"/cnv/0 || \ + exit_failed " --> FAILED" + +swapoff "$zonefs_mntdir"/cnv/0 || \ + exit_failed " --> FAILED" + +zonefs_umount + +exit 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/0101.sh new/zonefs-tools-1.5.0/tests/scripts/0101.sh --- old/zonefs-tools-1.4.0/tests/scripts/0101.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/0101.sh 2021-03-23 05:28:31.000000000 +0100 @@ -0,0 +1,49 @@ +#!/bin/bash +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2021 Western Digital Corporation or its affiliates. +# + +. scripts/test_lib + +if [ $# == 0 ]; then + echo "Swap file on sequential file" + exit 0 +fi + +echo "Check swap file on sequential file" + +zonefs_mkfs "$1" +zonefs_mount "$1" + +# Fill the file +tools/zio --write --fflag=direct \ + --size=131072 --async=8 "$zonefs_mntdir"/seq/0 || \ + exit_failed " --> FAILED" +chmod 600 "$zonefs_mntdir"/seq/0 || \ + exit_failed " --> FAILED" + +# mkswap should fail (cannot write swap file header) +mkswap "$zonefs_mntdir"/seq/0 && \ + exit_failed " --> SUCCESS (should FAIL)" + +# Create a swap file and copy it to a sequential file to check +# the kernel side zonefs swap activate check. +sudo fallocate -l "$seq_file_0_max_size" /tmp/swapfile +chmod 600 /tmp/swapfile || \ + exit_failed " --> FAILED" +mkswap /tmp/swapfile || \ + exit_failed " --> FAILED" +dd if=/tmp/swapfile of="$zonefs_mntdir"/seq/0 \ + bs=131072 oflag=direct || + exit_failed " --> FAILED" + +swapon "$zonefs_mntdir"/seq/0 && \ + exit_failed " --> SUCCESS (should FAIL)" + +zonefs_umount + +rm -f /tmp/swapfile + +exit 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/scripts/test_lib new/zonefs-tools-1.5.0/tests/scripts/test_lib --- old/zonefs-tools-1.4.0/tests/scripts/test_lib 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/scripts/test_lib 2021-03-23 05:28:31.000000000 +0100 @@ -107,6 +107,10 @@ if [ $nrcnv == 0 ]; then blkzone reset --offset 0 -c 1 "$1" || (echo "Reset super block zone failed"; exit 1) + # Resetting a zone does not clear the page cache of cached zone data + # pages. Take a big hammer and clear the page cache to avoid access + # to stale data. + echo 1 > /proc/sys/vm/drop_caches else dd if=/dev/zero of="$1" bs=4096 oflag=direct count=1 || (echo "Clear super block failed"; exit 1) @@ -156,7 +160,7 @@ while read -r line; do fp=(${line}) - f=$(basename "${fp[0]}") + f=${fp[0]##*/} perm=${fp[1]} if [ "$perm" != "$1" ]; then @@ -171,7 +175,7 @@ while read -r line; do fp=(${line}) - f=$(basename "${fp[0]}") + f=${fp[0]##*/} perm=${fp[1]} if [ "$perm" != "$1" ]; then @@ -189,7 +193,7 @@ while read -r line; do fug=(${line}) - f=$(basename "${fug[0]}") + f=${fug[0]##*/} uid=${fug[1]} gid=${fug[2]} @@ -209,7 +213,7 @@ while read -r line; do fug=(${line}) - f=$(basename "${fug[0]}") + f=${fug[0]##*/} uid=${fug[1]} gid=${fug[2]} @@ -237,6 +241,18 @@ echo "$(( nr_blocks * block_size ))" } +function aggr_cnv_size() +{ + size=$(file_max_size "$zonefs_mntdir"/cnv/0) + two_zones_size=$((zone_sectors * 2 * 512)) + + if $short && ((two_zones_size < size)); then + size="${two_zones_size}" + fi + + echo "${size}" +} + function check_size() { aggr_cnv=$1 @@ -253,7 +269,7 @@ while read -r line; do fsz=(${line}) - f=$(basename "${fsz[0]}") + f=${fsz[0]##*/} sz=${fsz[1]} if [ "$sz" != "$expected_sz" ]; then @@ -268,7 +284,7 @@ while read -r line; do fsz=(${line}) - f=$(basename "${fsz[0]}") + f=${fsz[0]##*/} sz=${fsz[1]} if [ "$sz" != "0" ]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/tools/Makefile.am new/zonefs-tools-1.5.0/tests/tools/Makefile.am --- old/zonefs-tools-1.4.0/tests/tools/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/tools/Makefile.am 2021-03-23 05:28:31.000000000 +0100 @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: CC0-1.0 +# +# Copyright (C) 2021 Western Digital Corporation or its affiliates. + +AM_CPPFLAGS = -O2 -Wall -Wextra -Wno-unused-parameter + +noinst_PROGRAMS = zio + +zio_SOURCES = zio.c +zio_LDADD = +zio_LDFLAGS = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/tools/zio.c new/zonefs-tools-1.5.0/tests/tools/zio.c --- old/zonefs-tools-1.4.0/tests/tools/zio.c 1970-01-01 01:00:00.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/tools/zio.c 2021-03-23 05:28:31.000000000 +0100 @@ -0,0 +1,573 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2019 Western Digital Corporation or its affiliates. + * Author: Damien Le Moal <[email protected]> + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <unistd.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/stat.h> +#include <sys/uio.h> +#include <sys/syscall.h> +#include <fcntl.h> +#include <linux/aio_abi.h> +#include <linux/fs.h> + +/* + * IO descriptor. + */ +struct zio { + int nr; + void *buf; + struct iocb iocb; +}; + +/* + * Run parameters. + */ +struct zio_params { + bool verbose; + int fd; + + bool read; + bool async; + + int fflags; + bool append; + loff_t fsize; + loff_t fmaxsize; + + size_t iosize; + loff_t ioofst; + unsigned int ionum; + int ioflags; + unsigned int iodepth; + struct zio *io; + + aio_context_t ioctx; + struct iocb **iocbs; + + unsigned int nr_ios; +}; + +/* + * Utilities. + */ +#define zio_vprintf(zio,format,args...) \ + if ((zio)->verbose) { \ + printf(format, ## args); \ + } + +static inline unsigned long long zio_usec(void) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + return tv.tv_sec * 1000000ULL + tv.tv_usec; +} + +/* + * System call wrappers. + */ +ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, + off_t offset, int flags) +{ + return syscall(SYS_preadv2, fd, iov, iovcnt, offset, 0, flags); +} + +ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt, + off_t offset, int flags) +{ + return syscall(SYS_pwritev2, fd, iov, iovcnt, offset, 0, flags); +} + +static inline int io_setup(unsigned int nr, aio_context_t *ctxp) +{ + return syscall(__NR_io_setup, nr, ctxp); +} + +static inline int io_destroy(aio_context_t ctx) +{ + return syscall(__NR_io_destroy, ctx); +} + +static inline int io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp) +{ + return syscall(__NR_io_submit, ctx, nr, iocbpp); +} + +static inline int io_getevents(aio_context_t ctx, long min_nr, long max_nr, + struct io_event *events, + struct timespec *timeout) +{ + return syscall(__NR_io_getevents, ctx, min_nr, max_nr, events, timeout); +} + +static inline bool zio_done(struct zio_params *zio) +{ + if (zio->ionum) + return zio->nr_ios >= zio->ionum; + + return (zio->read && zio->ioofst >= zio->fsize) || + (!zio->read && zio->ioofst >= zio->fmaxsize); +} + +/* + * Sync IO run. + */ +static int zio_run_sync(struct zio_params *zio) +{ + ssize_t ret; + loff_t ofst; + struct iovec iov = { + .iov_base = zio->io[0].buf, + .iov_len = zio->iosize, + }; + + while (!zio_done(zio)) { + + if (zio->read) { + ofst = zio->ioofst; + ret = preadv2(zio->fd, &iov, 1, ofst, zio->ioflags); + } else { + if (zio->append) + ofst = 0; + else + ofst = zio->ioofst; + ret = pwritev2(zio->fd, &iov, 1, ofst, zio->ioflags); + } + if (ret <= 0) { + fprintf(stderr, "%05u: %s %zu B at %ld failed %d (%s)\n", + zio->nr_ios, + zio->read ? "READ" : "WRITE", + zio->iosize, zio->ioofst, + errno, strerror(errno)); + return errno; + } + + zio_vprintf(zio, "%05u: %s %zu B at %ld\n", + zio->nr_ios, + zio->read ? "READ" : "WRITE", + zio->iosize, zio->ioofst); + + zio->nr_ios++; + zio->ioofst += ret; + } + + return 0; +} + +/* + * Async IO run. + */ +static int zio_submit_async(struct zio_params *zio) +{ + struct iocb *iocb; + struct zio *io; + unsigned int i, n = 0; + int ret; + + for (i = 0; i < zio->iodepth; i++) { + if (zio_done(zio)) + break; + + io = &zio->io[i]; + if (io->nr >= 0) + continue; + + iocb = &io->iocb; + memset(iocb, 0, sizeof(struct iocb)); + iocb->aio_fildes = zio->fd; + if (zio->read) { + iocb->aio_lio_opcode = IOCB_CMD_PREAD; + iocb->aio_offset = zio->ioofst; + } else { + iocb->aio_lio_opcode = IOCB_CMD_PWRITE; + if (zio->append) + iocb->aio_offset = 0; + else + iocb->aio_offset = zio->ioofst; + } + iocb->aio_buf = (unsigned long)io->buf; + iocb->aio_nbytes = zio->iosize; + iocb->aio_rw_flags = zio->ioflags; + iocb->aio_data = (unsigned long)io; + + io->nr = zio->nr_ios; + + zio_vprintf(zio, "%05d: %s %zu B at %ld issued\n", + io->nr, + zio->read ? "READ" : "WRITE", + zio->iosize, zio->ioofst); + + zio->iocbs[n] = iocb; + n++; + zio->nr_ios++; + + zio->ioofst += zio->iosize; + } + + if (!n) + return 0; + + ret = io_submit(zio->ioctx, n, zio->iocbs); + if (ret < 0) { + fprintf(stderr, "io_submit failed %d (%s)\n", + errno, strerror(errno)); + return -1; + } + + return n; +} + +static int zio_check_async(struct zio_params *zio, + int submitted, int in_flight) +{ + struct io_event ioevent; + struct iocb *iocb; + struct zio *io; + int ret, min_nr, n = 0; + + while (n < in_flight) { + + if (!submitted || (in_flight - n) >= (int)zio->iodepth) + min_nr = 1; + else + min_nr = 0; + + ret = io_getevents(zio->ioctx, min_nr, 1, &ioevent, NULL); + if (!ret) + break; + + if (ret != 1) { + fprintf(stderr, "io_getevents failed %d (%s)\n", + ret, strerror(ret)); + return -1; + } + + iocb = (struct iocb *) ioevent.obj; + io = (struct zio *)ioevent.data; + + if (ioevent.res < 0) { + ret = -ioevent.res; + fprintf(stderr, "%05d: %s %llu B at %lld failed %d (%s)\n", + io->nr, + zio->read ? "READ" : "WRITE", + iocb->aio_nbytes, iocb->aio_offset, + ret, strerror(ret)); + return -1; + } + + zio_vprintf(zio, "%05d: %s %llu B at %lld completed\n", + io->nr, + zio->read ? "READ" : "WRITE", + iocb->aio_nbytes, iocb->aio_offset); + + io->nr = -1; + n++; + } + + return n; +} + +static int zio_run_async(struct zio_params *zio) +{ + struct io_event ioevent; + int n, in_flight = 0; + ssize_t ret; + + /* Setup IO context */ + memset(&zio->ioctx, 0, sizeof(aio_context_t)); + memset(&ioevent, 0, sizeof(struct io_event)); + ret = io_setup(zio->iodepth, &zio->ioctx); + if (ret < 0) { + fprintf(stderr, "io_setup failed %d (%s)\n", + errno, strerror(errno)); + return -1; + } + + /* Do IOs until submission stops */ + while (1) { + + n = zio_submit_async(zio); + if (n < 0) { + ret = -1; + break; + } + + if (!n && !in_flight) + break; + + in_flight += n; + + n = zio_check_async(zio, n, in_flight); + if (n < 0) { + ret = -1; + break; + } + + in_flight -= n; + } + + io_destroy(zio->ioctx); + + return ret; +} + +static void zio_cleanup(struct zio_params *zio) +{ + unsigned int i; + + if (!zio->io) + return; + + for (i = 0; i < zio->iodepth; i++) + free(zio->io[i].buf); + free(zio->io); + zio->io = NULL; + + free(zio->iocbs); + zio->iocbs = NULL; + + if (zio->fd > 0) { + close(zio->fd); + zio->fd = -1; + } +} + +static int zio_init(struct zio_params *zio, char *path) +{ + struct stat st; + unsigned int i; + int ret; + + /* Allocate and initialize IO array */ + zio->io = calloc(zio->iodepth, sizeof(struct zio)); + if (!zio->io) { + fprintf(stderr, "No memory for IO array\n"); + return -1; + } + + for (i = 0; i < zio->iodepth; i++) { + zio->io[i].nr = -1; + ret = posix_memalign((void **) &zio->io[i].buf, + sysconf(_SC_PAGESIZE), zio->iosize); + if (ret != 0) { + fprintf(stderr, "Allocate IO buffer failed %d (%s)\n", + -ret, strerror(-ret)); + goto err; + } + } + + zio->iocbs = calloc(zio->iodepth, sizeof(struct iocb *)); + if (!zio->iocbs) { + fprintf(stderr, "No memory for async IO array\n"); + goto err; + } + + /* Open file */ + zio->fd = open(path, zio->fflags, 0); + if (zio->fd < 0) { + fprintf(stderr, "Open %s failed %d (%s)\n", + path, errno, strerror(errno)); + goto err; + } + + ret = fstat(zio->fd, &st); + if (ret) { + fprintf(stderr, "Stat %s failed %d (%s)\n", + path, errno, strerror(errno)); + goto err; + } + zio->fsize = st.st_size; + zio->fmaxsize = st.st_blocks << 9; + + /* If we do append writes, set offset to EOF */ + if (!zio->read) { + zio->append = + ((zio->fflags & O_APPEND) == O_APPEND) || + (zio->ioflags & RWF_APPEND) == RWF_APPEND; + if (zio->append) + zio->ioofst = zio->fsize; + } + + return 0; + +err: + zio_cleanup(zio); + return -1; +} + +static void zio_usage(char *cmd) +{ + printf("Usage: %s [options] <file path>\n", + cmd); + printf("Options:\n" + " -h | --help : print usage and exit\n" + " --v : Verbose output (stats)\n" + " --vv : Very verbose output (IOs)\n" + " --read : do read (default)\n" + " --write : do write\n" + " --size=<bytes> : Do <bytes> sized IOs (default: 4096)\n" + " --ofst=<bytes> : Start IOs at <offset> (default: 0)\n" + " --nio=<num> : Do <num> IOs and exit\n" + " (default: IOs until EOF)\n" + " --async=<depth> : Do asynchronous IOs, issuing at most\n" + " <depth> IOs at a time\n" + " --fflag=<flag> : Use O_<flag> to open file.\n" + " <flag> can be:\n" + " - direct\n" + " - append\n" + " - ndelay\n" + " - sync\n" + " - trunc\n" + " This option can be used multiple times.\n" + " --ioflag=<flag> : Use RWF_<flag> for IOs. <flag> can be:\n" + " - nowait\n" + " - hipri\n" + " - append\n" + " This option can be used multiple times.\n"); +} + +int main(int argc, char **argv) +{ + struct zio_params zio; + unsigned long long start; + long long arg; + int ret, i; + + /* Set default values */ + memset(&zio, 0, sizeof(struct zio_params)); + zio.fd = -1; + zio.read = true; + zio.async = false; + zio.append = false; + zio.fflags = O_LARGEFILE; + zio.iosize = 4096; + zio.iodepth = 1; + zio.verbose = false; + + if (argc <= 1) { + zio_usage(argv[0]); + return 1; + } + + /* Parse command line */ + for (i = 1; i < argc; i++) { + + if (strcmp(argv[i], "-h") == 0 || + strcmp(argv[i], "--help") == 0) { + zio_usage(argv[0]); + return 0; + } + + if (strcmp(argv[i], "--v") == 0) { + zio.verbose = true; + } else if (strcmp(argv[i], "--read") == 0) { + zio.read = true; + zio.fflags |= O_RDONLY; + } else if (strcmp(argv[i], "--write") == 0) { + zio.read = false; + zio.fflags |= O_WRONLY; + } else if (strncmp(argv[i], "--size=", 7) == 0) { + arg = atol(argv[i] + 7); + if (arg <= 0) { + fprintf(stderr, "Invalid IO size\n"); + return 1; + } + zio.iosize = arg; + } else if (strncmp(argv[i], "--ofst=", 7) == 0) { + arg = atoll(argv[i] + 7); + if (arg < 0) { + fprintf(stderr, "Invalid IO offset\n"); + return 1; + } + zio.ioofst = arg; + } else if (strncmp(argv[i], "--nio=", 6) == 0) { + arg = atoi(argv[i] + 6); + if (arg <= 0) { + fprintf(stderr, "Invalid number of IOs\n"); + return 1; + } + zio.ionum = arg; + } else if (strncmp(argv[i], "--async=", 8) == 0) { + zio.async = true; + arg = atoi(argv[i] + 8); + if (arg <= 0) { + fprintf(stderr, "Invalid async IO depth\n"); + return 1; + } + zio.iodepth = arg; + } else if (strncmp(argv[i], "--fflag=", 8) == 0) { + if (strcmp(argv[i] + 8, "direct") == 0) { + zio.fflags |= O_DIRECT; + } else if (strcmp(argv[i] + 8, "append") == 0) { + zio.fflags |= O_APPEND; + } else if (strcmp(argv[i] + 8, "ndelay") == 0) { + zio.fflags |= O_NDELAY; + } else if (strcmp(argv[i] + 8, "sync") == 0) { + zio.fflags |= O_SYNC; + } else if (strcmp(argv[i] + 8, "trunc") == 0) { + zio.fflags |= O_TRUNC; + } else { + fprintf(stderr, "Invalid file open flag\n"); + return 1; + } + } else if (strncmp(argv[i], "--ioflag=", 9) == 0) { + if (strcmp(argv[i] + 9, "append") == 0) { + zio.ioflags |= RWF_APPEND; + } else if (strcmp(argv[i] + 9, "nowait") == 0) { + zio.ioflags |= RWF_NOWAIT; + } else if (strcmp(argv[i] + 9, "hipri") == 0) { + zio.ioflags |= RWF_HIPRI; + } else { + fprintf(stderr, "Invalid IO flag\n"); + return 1; + } + } else if (argv[i][0] == '-') { + fprintf(stderr, "Invalid option \"%s\"\n", argv[i]); + return 1; + } + } + + ret = zio_init(&zio, argv[argc - 1]); + if (ret != 0) + return 1; + + start = zio_usec(); + + if (zio.async) + ret = zio_run_async(&zio); + else + ret = zio_run_sync(&zio); + if (ret != 0) + ret = 1; + + if (ret == 0) { + unsigned long long elapsed = zio_usec() - start; + unsigned long long bw, iops; + + iops = zio.nr_ios * 1000000ULL / elapsed; + bw = zio.nr_ios * zio.iosize * 1000000ULL / elapsed; + + printf("%u IOs done in %llu ms (%llu us)\n", + zio.nr_ios, elapsed / 1000, elapsed); + printf(" %llu IOPS, %llu.%03llu MB/s\n", + iops, bw / 1000000, (bw % 1000000) / 1000); + } + + zio_cleanup(&zio); + + return ret; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/zonefs-tests-nullblk.sh new/zonefs-tools-1.5.0/tests/zonefs-tests-nullblk.sh --- old/zonefs-tools-1.4.0/tests/zonefs-tests-nullblk.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/zonefs-tests-nullblk.sh 2021-03-23 05:28:31.000000000 +0100 @@ -15,12 +15,18 @@ # Capacity (MB) capacity=4096 +# Default number of conventional zones to test +nr_conv=(16 1 0) + function usage() { echo "Usage: $0 [options]" echo "Options:" - echo " -h | --help: Display help" - echo " -c | --cap: Test with zone capacity < zone size (default: off)" - echo " -o | --moz: Test with max open zone limit set (default: no limit)" + echo " -h | --help : Display help" + echo " -c | --cap : Test with zone capacity < zone size (default: off)" + echo " -o | --moz : Test with max open zone limit set (default: no limit)" + echo " -t <test num> : Test to execute. Can be specified multiple times." + echo " If used, only the first nullb config is used" + echo " -n <nr conv> : Specify the number of conventional zones to use." } # Check credentials @@ -29,6 +35,8 @@ exit 1 fi +testopts="" + # Check options while [[ $# -gt 0 ]]; do case "$1" in @@ -44,6 +52,16 @@ usage "$0" exit 0 ;; + "-t") + shift + testopts+=" -t $1" + shift + ;; + "-n") + shift + nr_conv=($1) + shift + ;; *) echo "Invalid option $1" exit 1 @@ -84,9 +102,9 @@ fi echo 4096 > "$dev"/blocksize - echo 0 > "$dev"/completion_nsec - echo 0 > "$dev"/irqmode echo 2 > "$dev"/queue_mode + echo 2 > "$dev"/irqmode + echo 5000 > "$dev"/completion_nsec echo $capacity > "$dev"/size echo 1024 > "$dev"/hw_queue_depth @@ -118,9 +136,8 @@ declare -i rc=0 -# Do 3 runs for 3 different drives: 16 conventional zones, -# 1 conventional zone and no conventional zones. -for c in 16 1 0; do +# Run all drive configurations (3 by default) +for c in ${nr_conv[@]}; do echo "" echo "Run tests against device with $c conventional zones..." @@ -130,13 +147,14 @@ nulld=$(create_zoned_nullb $c) logfile="nullb${nulld}-cnv${c}-zonefs-tests.log" - if ! ./zonefs-tests.sh "-g" "$logfile" "/dev/nullb$nulld"; then + + if ! ./zonefs-tests.sh ${testopts} "-g" "$logfile" "/dev/nullb$nulld"; then rc=1 fi destroy_zoned_nullb "$nulld" - if [ "$aborted" == 1 ]; then + if [ "$aborted" == 1 ] || [ "$testopts" != "" ]; then break fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/tests/zonefs-tests.sh new/zonefs-tools-1.5.0/tests/zonefs-tests.sh --- old/zonefs-tools-1.4.0/tests/zonefs-tests.sh 2021-01-20 03:23:06.000000000 +0100 +++ new/zonefs-tools-1.5.0/tests/zonefs-tests.sh 2021-03-23 05:28:31.000000000 +0100 @@ -27,6 +27,7 @@ echo " -g <file name>: Use file name for the test log file." echo " default: <dev name>-zonefs-tests.log" echo " -t <test num>: Test to execute. Can be specified multiple times." + echo " -s: Run short test" echo " -h || --help: This help message" } @@ -39,6 +40,7 @@ declare -a tests declare list=false logfile="" +export short=false while [ "${1#-}" != "$1" ]; do case "$1" in @@ -65,6 +67,10 @@ logfile="$1" shift ;; + -s) + short=true + shift + ;; -*) echo "unknow option $1" exit 1 @@ -148,6 +154,7 @@ export nr_cnv_zones=$(get_nr_cnv_zones "$dev") export nr_seq_zones=$(get_nr_seq_zones "$dev") export total_usable_sectors=$(get_total_zone_capacity_sectors "$dev") +export iosize=$((4096 * 64)) # Expected number of files if [ "$nr_cnv_zones" == 0 ]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zonefs-tools-1.4.0/zonefs-tools.spec.in new/zonefs-tools-1.5.0/zonefs-tools.spec.in --- old/zonefs-tools-1.4.0/zonefs-tools.spec.in 1970-01-01 01:00:00.000000000 +0100 +++ new/zonefs-tools-1.5.0/zonefs-tools.spec.in 2021-03-23 05:28:31.000000000 +0100 @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (c) 2021 Western Digital Corporation or its affiliates. + +Name: zonefs-tools +Release: 1%{?dist} +Summary: User utilities for the zonefs file system +Group: System Environment/Libraries +License: GPLv2 +URL: https://github.com/westerndigitalcorporation/zonefs-tools +Source: %{name}-%{version}.tar.gz + +BuildRequires: autoconf +BuildRequires: autoconf-archive +BuildRequires: automake +BuildRequires: libtool +BuildRequires: libblkid +BuildRequires: libuuid +BuildRequires: gcc + +%description +zonefs-tools provides the mkzonefs user utility to format zoned +block devices for use with the zonefs file system. + +%prep +%setup + +%build +sh autogen.sh +%configure +%make_build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT +make install PREFIX=%{_prefix} DESTDIR=$RPM_BUILD_ROOT +chmod -x $RPM_BUILD_ROOT%{_mandir}/man8/*.8 + +find $RPM_BUILD_ROOT -name '*.la' -delete + +%ldconfig_scriptlets + +%files +%{_sbindir}/* +%{_mandir}/man8/*
