From owner-svn-src-projects@freebsd.org Sun Dec 13 23:32:51 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5B08D4C792E for ; Sun, 13 Dec 2020 23:32:51 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CvLRR2C3wz3PXY; Sun, 13 Dec 2020 23:32:51 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3E9B517FD0; Sun, 13 Dec 2020 23:32:51 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BDNWp0P097441; Sun, 13 Dec 2020 23:32:51 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0BDNWpA6097440; Sun, 13 Dec 2020 23:32:51 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <202012132332.0BDNWpA6097440@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 13 Dec 2020 23:32:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r368621 - projects/aio_writev/tests/sys/aio X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/aio_writev/tests/sys/aio X-SVN-Commit-Revision: 368621 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 23:32:51 -0000 Author: asomers Date: Sun Dec 13 23:32:50 2020 New Revision: 368621 URL: https://svnweb.freebsd.org/changeset/base/368621 Log: aio_writev: fix the vector_unaligned test It turns out that a zvol with volmode=dev has the correct properties for this test. While I'm here, add a vectored_zvol_poll test to test the bio path with a non-geom device. Modified: projects/aio_writev/tests/sys/aio/aio_test.c Modified: projects/aio_writev/tests/sys/aio/aio_test.c ============================================================================== --- projects/aio_writev/tests/sys/aio/aio_test.c Sun Dec 13 22:42:48 2020 (r368620) +++ projects/aio_writev/tests/sys/aio/aio_test.c Sun Dec 13 23:32:50 2020 (r368621) @@ -838,6 +838,53 @@ ATF_TC_CLEANUP(md_waitcomplete, tc) aio_md_cleanup(); } +#define ZVOL_VDEV_PATHNAME "test_vdev" +#define POOL_SIZE (1 << 28) /* 256 MB */ +#define ZVOL_SIZE "64m" +#define POOL_NAME "aio_testpool" +#define ZVOL_NAME "aio_testvol" + +static int +aio_zvol_setup(void) +{ + int fd; + + ATF_REQUIRE_KERNEL_MODULE("aio"); + ATF_REQUIRE_KERNEL_MODULE("zfs"); + + fd = open(ZVOL_VDEV_PATHNAME, O_RDWR | O_CREAT, 0600); + ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); + ATF_REQUIRE_EQ_MSG(0, + ftruncate(fd, POOL_SIZE), "ftruncate failed: %s", strerror(errno)); + close(fd); + + ATF_REQUIRE_EQ_MSG(0, + system("zpool create " POOL_NAME " $PWD/" ZVOL_VDEV_PATHNAME), + "zpool create failed: %s", strerror(errno)); + ATF_REQUIRE_EQ_MSG(0, + system("zfs create -o volblocksize=8192 -o volmode=dev -V " + ZVOL_SIZE " " POOL_NAME "/" ZVOL_NAME), + "zfs create failed: %s", strerror(errno)); + /* + * XXX Due to bug 251828, we need an extra "zfs set here" + * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251828 + */ + ATF_REQUIRE_EQ_MSG(0, + system("zfs set volmode=dev " POOL_NAME "/" ZVOL_NAME), + "zfs set failed: %s", strerror(errno)); + + fd = open("/dev/zvol/" POOL_NAME "/" ZVOL_NAME, O_RDWR); + ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno)); + return (fd); +} + +static void +aio_zvol_cleanup(void) +{ + system("zpool destroy " POOL_NAME); +} + + ATF_TC_WITHOUT_HEAD(aio_large_read_test); ATF_TC_BODY(aio_large_read_test, tc) { @@ -1450,7 +1497,11 @@ ATF_TC_BODY(vectored_unaligned, tc) ATF_REQUIRE_KERNEL_MODULE("aio"); ATF_REQUIRE_UNSAFE_AIO(); - fd = aio_md_setup(); + /* + * Use a zvol with volmode=dev, so it will allow .d_write with + * unaligned uio. geom devices use physio, which doesn't allow that. + */ + fd = aio_zvol_setup(); aio_context_init(&ac, fd, fd, FILE_LEN); /* Break the buffer into 3 parts: @@ -1486,9 +1537,44 @@ ATF_TC_BODY(vectored_unaligned, tc) } ATF_TC_CLEANUP(vectored_unaligned, tc) { - aio_md_cleanup(); + aio_zvol_cleanup(); } +static void +aio_zvol_test(completion comp, struct sigevent *sev, bool vectored) +{ + struct aio_context ac; + int fd; + + fd = aio_zvol_setup(); + aio_context_init(&ac, fd, fd, MD_LEN); + if (vectored) + aio_writev_test(&ac, comp, sev); + else + aio_write_test(&ac, comp, sev); + aio_read_test(&ac, comp, sev); + + close(fd); +} + +/* + * Note that unlike md, the zvol is not a geom device, does not allow unmapped + * buffers, and does not use physio. + */ +ATF_TC_WITH_CLEANUP(vectored_zvol_poll); +ATF_TC_HEAD(vectored_zvol_poll, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} +ATF_TC_BODY(vectored_zvol_poll, tc) +{ + aio_zvol_test(poll, NULL, true); +} +ATF_TC_CLEANUP(vectored_zvol_poll, tc) +{ + aio_zvol_cleanup(); +} + ATF_TP_ADD_TCS(tp) { @@ -1535,6 +1621,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, vectored_big_iovcnt); ATF_TP_ADD_TC(tp, vectored_file_poll); ATF_TP_ADD_TC(tp, vectored_md_poll); + ATF_TP_ADD_TC(tp, vectored_zvol_poll); ATF_TP_ADD_TC(tp, vectored_unaligned); ATF_TP_ADD_TC(tp, vectored_socket_poll);