├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING ├── COPYING.GPL ├── LICENSES ├── CC0-1.0.txt └── GPL-2.0-or-later.txt ├── Makefile.am ├── README.md ├── autogen.sh ├── configure.ac ├── m4 └── dontremove ├── man ├── Makefile.am └── mkzonefs.8 ├── src ├── Makefile.am ├── mkzonefs.c ├── zonefs.h └── zonefs_dev.c ├── tests ├── scripts │ ├── 0001.sh │ ├── 0002.sh │ ├── 0003.sh │ ├── 0004.sh │ ├── 0020.sh │ ├── 0021.sh │ ├── 0022.sh │ ├── 0023.sh │ ├── 0040.sh │ ├── 0041.sh │ ├── 0042.sh │ ├── 0043.sh │ ├── 0044.sh │ ├── 0045.sh │ ├── 0060.sh │ ├── 0061.sh │ ├── 0062.sh │ ├── 0063.sh │ ├── 0064.sh │ ├── 0065.sh │ ├── 0080.sh │ ├── 0081.sh │ ├── 0082.sh │ ├── 0083.sh │ ├── 0084.sh │ ├── 0085.sh │ ├── 0100.sh │ ├── 0101.sh │ ├── 0110.sh │ ├── 0111.sh │ ├── 0200.sh │ ├── 0201.sh │ ├── 0202.sh │ ├── 0203.sh │ ├── 0204.sh │ ├── 0205.sh │ ├── 0206.sh │ ├── 0207.sh │ ├── 0208.sh │ ├── 0209.sh │ ├── 0210.sh │ ├── 0211.sh │ ├── 0212.sh │ ├── 0213.sh │ ├── 0214.sh │ ├── 0215.sh │ ├── 0216.sh │ ├── 0217.sh │ ├── 0218.sh │ ├── 0219.sh │ ├── 0220.sh │ ├── 0221.sh │ ├── 0222.sh │ ├── 0223.sh │ ├── 0300.sh │ ├── 0301.sh │ ├── 0302.sh │ ├── 0303.sh │ ├── 0304.sh │ ├── 0305.sh │ ├── 0306.sh │ ├── 0307.sh │ ├── 0309.sh │ ├── 0310.sh │ ├── 0311.sh │ ├── 0312.sh │ ├── 0320.sh │ ├── 0321.sh │ ├── 0322.sh │ ├── 0323.sh │ ├── 0324.sh │ ├── 0325.sh │ ├── 0326.sh │ ├── 0327.sh │ ├── 0328.sh │ ├── 0329.sh │ ├── 0330.sh │ ├── 0400.sh │ ├── 0401.sh │ ├── 0510.sh │ ├── 0511.sh │ ├── 0512.sh │ ├── 0513.sh │ ├── 0514.sh │ ├── 0515.sh │ ├── 0516.sh │ ├── 0517.sh │ ├── 0518.sh │ ├── 0519.sh │ ├── 0600.sh │ ├── 0601.sh │ ├── 0602.sh │ ├── 0603.sh │ ├── 0604.sh │ ├── 0605.sh │ ├── 0606.sh │ ├── 0607.sh │ ├── 0610.sh │ ├── 0611.sh │ ├── 0612.sh │ ├── 0613.sh │ ├── 0614.sh │ ├── 0615.sh │ ├── 0616.sh │ ├── 0617.sh │ ├── 0620.sh │ ├── 0621.sh │ ├── 0622.sh │ ├── 0623.sh │ ├── 0624.sh │ ├── 0625.sh │ ├── 0626.sh │ ├── 0627.sh │ └── test_lib ├── tools │ ├── Makefile.am │ ├── zio.c │ └── zopen.c ├── zonefs-tests-nullblk.sh ├── zonefs-tests-scsi-debug.sh └── zonefs-tests.sh └── zonefs-tools.spec /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (c) 2019 Western Digital Corporation or its affiliates. 4 | 5 | # Object files 6 | *.o 7 | *.lo 8 | *.ko 9 | *.obj 10 | *.elf 11 | *.mod.c 12 | .*.o.cmd 13 | .*.ko.cmd 14 | *.lib 15 | *.a 16 | *.la 17 | 18 | # Shared objects (inc. Windows DLLs) 19 | *.dll 20 | *.so 21 | *.so.* 22 | *.dylib 23 | 24 | # Executables 25 | *.exe 26 | *.out 27 | *.app 28 | *.i*86 29 | *.x86_64 30 | *.hex 31 | src/mkzonefs 32 | tests/log* 33 | tests/tools/zio 34 | tests/tools/zopen 35 | 36 | # Kernel compile files 37 | *.symvers 38 | modules.order 39 | .tmp_versions 40 | 41 | # Dependency files 42 | .depfile 43 | .depend 44 | 45 | # Windows-specific files 46 | Thumbs.db 47 | desktop.ini 48 | 49 | # Mac-specific things 50 | .DS_Store 51 | ._.DS_Store 52 | 53 | # Editors temporary files 54 | *~ 55 | 56 | # Autotools stuff 57 | m4/*.m4 58 | aclocal.m4 59 | autom4te.cache/ 60 | build-aux/ 61 | configure 62 | Makefile.in 63 | Makefile 64 | config.log 65 | config.status 66 | src/stamp-h1 67 | config.h 68 | config.h.in 69 | .deps 70 | libtool 71 | .libs 72 | .dirstamp 73 | 74 | # Built RPMs 75 | *.rpm 76 | 77 | # Tests files 78 | tests/*.state 79 | tests/*.log 80 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributor Covenant Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | We as members, contributors, and leaders pledge to make participation in our 7 | community a harassment-free experience for everyone, regardless of age, body 8 | size, visible or invisible disability, ethnicity, sex characteristics, gender 9 | identity and expression, level of experience, education, socio-economic status, 10 | nationality, personal appearance, race, caste, color, religion, or sexual 11 | identity and orientation. 12 | 13 | We pledge to act and interact in ways that contribute to an open, welcoming, 14 | diverse, inclusive, and healthy community. 15 | 16 | ## Our Standards 17 | 18 | Examples of behavior that contributes to a positive environment for our 19 | community include: 20 | 21 | * Demonstrating empathy and kindness toward other people 22 | * Being respectful of differing opinions, viewpoints, and experiences 23 | * Giving and gracefully accepting constructive feedback 24 | * Accepting responsibility and apologizing to those affected by our mistakes, 25 | and learning from the experience 26 | * Focusing on what is best not just for us as individuals, but for the 27 | overall community 28 | 29 | Examples of unacceptable behavior include: 30 | 31 | * The use of sexualized language or imagery, and sexual attention or 32 | advances of any kind 33 | * Trolling, insulting or derogatory comments, and personal or political attacks 34 | * Public or private harassment 35 | * Publishing others' private information, such as a physical or email 36 | address, without their explicit permission 37 | * Other conduct which could reasonably be considered inappropriate in a 38 | professional setting 39 | 40 | ## Enforcement Responsibilities 41 | 42 | Community leaders are responsible for clarifying and enforcing our standards of 43 | acceptable behavior and will take appropriate and fair corrective action in 44 | response to any behavior that they deem inappropriate, threatening, offensive, 45 | or harmful. 46 | 47 | Community leaders have the right and responsibility to remove, edit, or reject 48 | comments, commits, code, wiki edits, issues, and other contributions that are 49 | not aligned to this Code of Conduct, and will communicate reasons for moderation 50 | decisions when appropriate. 51 | 52 | ## Scope 53 | 54 | This Code of Conduct applies within all community spaces, and also applies when 55 | an individual is officially representing the community in public spaces. 56 | Examples of representing our community include using an official e-mail address, 57 | posting via an official social media account, or acting as an appointed 58 | representative at an online or offline event. 59 | 60 | ## Enforcement 61 | 62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 63 | reported to the community leaders responsible for enforcement at 64 | [Open Source Inquiries][contact]. 65 | All complaints will be reviewed and investigated promptly and fairly. 66 | 67 | All community leaders are obligated to respect the privacy and security of the 68 | reporter of any incident. 69 | 70 | ## Enforcement Guidelines 71 | 72 | Community leaders will follow these Community Impact Guidelines in determining 73 | the consequences for any action they deem in violation of this Code of Conduct: 74 | 75 | ### 1. Correction 76 | 77 | **Community Impact**: Use of inappropriate language or other behavior deemed 78 | unprofessional or unwelcome in the community. 79 | 80 | **Consequence**: A private, written warning from community leaders, providing 81 | clarity around the nature of the violation and an explanation of why the 82 | behavior was inappropriate. A public apology may be requested. 83 | 84 | ### 2. Warning 85 | 86 | **Community Impact**: A violation through a single incident or series 87 | of actions. 88 | 89 | **Consequence**: A warning with consequences for continued behavior. No 90 | interaction with the people involved, including unsolicited interaction with 91 | those enforcing the Code of Conduct, for a specified period of time. This 92 | includes avoiding interactions in community spaces as well as external channels 93 | like social media. Violating these terms may lead to a temporary or 94 | permanent ban. 95 | 96 | ### 3. Temporary Ban 97 | 98 | **Community Impact**: A serious violation of community standards, including 99 | sustained inappropriate behavior. 100 | 101 | **Consequence**: A temporary ban from any sort of interaction or public 102 | communication with the community for a specified period of time. No public or 103 | private interaction with the people involved, including unsolicited interaction 104 | with those enforcing the Code of Conduct, is allowed during this period. 105 | Violating these terms may lead to a permanent ban. 106 | 107 | ### 4. Permanent Ban 108 | 109 | **Community Impact**: Demonstrating a pattern of violation of community 110 | standards, including sustained inappropriate behavior, harassment of an 111 | individual, or aggression toward or disparagement of classes of individuals. 112 | 113 | **Consequence**: A permanent ban from any sort of public interaction within 114 | the community. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 2.0, available at 120 | [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. 121 | 122 | Community Impact Guidelines were inspired by 123 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available 127 | at [https://www.contributor-covenant.org/translations][translations]. 128 | 129 | [homepage]: https://www.contributor-covenant.org 130 | [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html 131 | [Mozilla CoC]: https://github.com/mozilla/diversity 132 | [FAQ]: https://www.contributor-covenant.org/faq 133 | [translations]: https://www.contributor-covenant.org/translations 134 | [contact]: https://www.westerndigital.com/contact/contact-open-source 135 | -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- 1 | SPDX-License-Identifier: CC0-1.0 2 | 3 | Copyright (C) 2019 Western Digital Corporation or its affiliates. 4 | 5 | This project embraces the Developer Certificate of Origin (DCO) for 6 | contributions. This means you must agree to the following prior to submitting 7 | patches, if you agree with this developer certificate you acknowledge this by 8 | adding a Signed-off-by tag to your patch commit log. Every submitted patch 9 | must have this. 10 | 11 | The source for the DCO: 12 | 13 | http://developercertificate.org/ 14 | 15 | ----------------------------------------------------------------------- 16 | 17 | Developer Certificate of Origin 18 | Version 1.1 19 | 20 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 21 | 660 York Street, Suite 102, 22 | San Francisco, CA 94110 USA 23 | 24 | Everyone is permitted to copy and distribute verbatim copies of this 25 | license document, but changing it is not allowed. 26 | 27 | 28 | Developer's Certificate of Origin 1.1 29 | 30 | By making a contribution to this project, I certify that: 31 | 32 | (a) The contribution was created in whole or in part by me and I 33 | have the right to submit it under the open source license 34 | indicated in the file; or 35 | 36 | (b) The contribution is based upon previous work that, to the best 37 | of my knowledge, is covered under an appropriate open source 38 | license and I have the right under that license to submit that 39 | work with modifications, whether created in whole or in part 40 | by me, under the same open source license (unless I am 41 | permitted to submit under a different license), as indicated 42 | in the file; or 43 | 44 | (c) The contribution was provided directly to me by some other 45 | person who certified (a), (b) or (c) and I have not modified 46 | it. 47 | 48 | (d) I understand and agree that this project and the contribution 49 | are public and that a record of the contribution (including all 50 | personal information I submit with it, including my sign-off) is 51 | maintained indefinitely and may be redistributed consistent with 52 | this project or the open source license(s) involved. 53 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 4 | 5 | ACLOCAL_AMFLAGS = -I m4 6 | 7 | SUBDIRS = src man 8 | if BUILD_TESTS 9 | SUBDIRS += tests/tools 10 | endif 11 | 12 | EXTRA_DIST = autogen.sh README.md COPYING.GPL CONTRIBUTING 13 | 14 | if BUILD_RPM 15 | 16 | rpmdir = $(abs_top_builddir)/rpmbuild 17 | 18 | EXTRA_DIST += zonefs-tools.spec tests 19 | RPMARCH=`$(RPM) --eval %_target_cpu` 20 | 21 | rpm: dist 22 | @echo "Building RPM package..." 23 | @mkdir -p $(rpmdir) 24 | $(RPMBUILD) -ta --clean \ 25 | -D "_topdir $(rpmdir)" \ 26 | -D "pkg_name $(PACKAGE_NAME)" \ 27 | -D "pkg_version $(PACKAGE_VERSION)" \ 28 | zonefs-tools-$(PACKAGE_VERSION).tar.gz 29 | @mv -f $(rpmdir)/RPMS/$(RPMARCH)/*.rpm $(abs_top_builddir) 30 | @mv -f $(rpmdir)/SRPMS/*.rpm $(abs_top_builddir) 31 | @rm -rf $(rpmdir) 32 | @rm -f zonefs-tools-$(PACKAGE_VERSION).tar.gz 33 | else 34 | rpm: 35 | @echo "Building RPM packages requires rpmbuild and rpm utilities" 36 | exit 1 37 | endif 38 | 39 | CLEANFILES = *.rpm *.tar.gz 40 | DISTCLEANFILES = *.rpm *.tar.gz configure configure~ 41 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | 7 | exec autoreconf -f -i 8 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 4 | 5 | AC_INIT([zonefs-tools], [1.6.0], [dlemoal@kernel.org]) 6 | 7 | AC_PREFIX_DEFAULT(/usr) 8 | AC_CONFIG_HEADERS([src/config.h]) 9 | AC_CONFIG_MACRO_DIR([m4]) 10 | AC_CONFIG_AUX_DIR([build-aux]) 11 | AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) 12 | AM_SILENT_RULES([yes]) 13 | 14 | AC_USE_SYSTEM_EXTENSIONS 15 | AC_SYS_LARGEFILE 16 | 17 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 18 | m4_pattern_allow([AM_PROG_AR]) 19 | LT_INIT 20 | 21 | # Checks for programs. 22 | AC_PROG_CC 23 | AM_PROG_CC_C_O 24 | AC_PROG_LN_S 25 | 26 | # Checks for header files. 27 | AC_CHECK_HEADER(libgen.h, [], 28 | [AC_MSG_ERROR([Couldn't find libgen.h])]) 29 | AC_CHECK_HEADER(mntent.h, [], 30 | [AC_MSG_ERROR([Couldn't find mntent.h])]) 31 | AC_CHECK_HEADER(linux/fs.h, [], 32 | [AC_MSG_ERROR([Couldn't find linux/fs.h])]) 33 | AC_CHECK_HEADER(blkid/blkid.h, [], 34 | [AC_MSG_ERROR([Couldn't find blkid/blkid.h])]) 35 | AC_CHECK_HEADER(linux/blkzoned.h, [], 36 | [AC_MSG_ERROR([Couldn't find linux/blkzoned.h])]) 37 | 38 | # Checks for libraries. 39 | AC_SEARCH_LIBS([blkid_do_fullprobe], [blkid], [], 40 | [AC_MSG_ERROR([Couldn't find libblkid])]) 41 | AC_SEARCH_LIBS([uuid_generate], [uuid], [], 42 | [AC_MSG_ERROR([Couldn't find libuuid])]) 43 | 44 | # Checks for rpm package builds 45 | AC_PATH_PROG([RPMBUILD], [rpmbuild], [notfound]) 46 | AC_PATH_PROG([RPM], [rpm], [notfound]) 47 | AM_CONDITIONAL([BUILD_RPM], 48 | [test "x$RPMBUILD" != xnotfound && test "x$RPM" != xnotfound]) 49 | 50 | # Build tests 51 | AC_ARG_WITH([tests], 52 | [AS_HELP_STRING([--with-tests], [Build test suite [default=no]])], 53 | [AM_CONDITIONAL([BUILD_TESTS], true) 54 | AC_CHECK_HEADER(linux/aio_abi.h, [], 55 | [AC_MSG_ERROR([Couldn't find linux/aio_abi.h])])], 56 | [AM_CONDITIONAL([BUILD_TESTS], false)]) 57 | 58 | AC_CONFIG_FILES([ 59 | Makefile 60 | man/Makefile 61 | src/Makefile 62 | tests/tools/Makefile 63 | ]) 64 | 65 | AC_OUTPUT 66 | 67 | -------------------------------------------------------------------------------- /m4/dontremove: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 4 | 5 | the only purpose of this file is to keep the m4 directory in git 6 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 4 | 5 | dist_man_MANS = mkzonefs.8 6 | 7 | install-data-hook: 8 | (cd $(DESTDIR)${mandir}/man8; rm -f mkfs.zonefs.8.gz) 9 | (cd $(DESTDIR)${mandir}/man8; $(LN_S) mkzonefs.8.gz mkfs.zonefs.8.gz) 10 | 11 | uninstall-hook: 12 | (cd $(DESTDIR)${mandir}/man8; rm -f mkfs.zonefs.8.gz) 13 | -------------------------------------------------------------------------------- /man/mkzonefs.8: -------------------------------------------------------------------------------- 1 | .\" SPDX-License-Identifier: GPL-2.0-or-later 2 | .\" 3 | .\" Copyright (C) 2019, Western Digital Corporation or its affiliates. 4 | .\" Written by Damien Le Moal 5 | .\" 6 | .TH mkzonefs 8 7 | .SH NAME 8 | mkzonefs \- Create a zonefs file system on a zoned block device 9 | 10 | .SH SYNOPSIS 11 | .B mkzonefs 12 | [ 13 | .B \-h|\-\-help 14 | ] 15 | [ 16 | .B \-v 17 | ] 18 | [ 19 | .B \-f 20 | ] 21 | [ 22 | .B \-L 23 | .I label 24 | ] 25 | [ 26 | .B \-o 27 | .I features 28 | ] 29 | .I device 30 | 31 | .SH DESCRIPTION 32 | .B mkzonefs 33 | is used to create a zonefs file system on a zoned block device. 34 | 35 | .SH OPTIONS 36 | .TP 37 | \fB\-h\fR, \fB\-\-help\fR 38 | Display a short usage message and return 39 | 40 | .TP 41 | .BI \-v 42 | Verbose output 43 | 44 | .TP 45 | .BI \-f 46 | Overwrite existing file system format on the device 47 | 48 | .TP 49 | .BI \-L " label" 50 | Specify a label (volume name). A label must not exceed 32 characters. 51 | 52 | .TP 53 | .BI \-o " features" 54 | .RS 55 | Specify optional features. Features are comma separated and may take an 56 | argument using the equal ("=") sign. The following features are supported. 57 | .TP 58 | .BR aggr_cnv 59 | Aggregate contiguous conventional zones into a single file. 60 | Default: off (create one file per zone). 61 | .TP 62 | .BR uid =\fIUID\fR 63 | Create files with \fIUID\fR as owner user. The default is "root" user (UID 0). 64 | .TP 65 | .BR gid =\fIGID\fR 66 | Create files with \fIGID\fR as group owner. The default is "root" group (GID 0). 67 | .TP 68 | .BR perm =\fIpermissions\fR 69 | Create files with \fIpermissions\fR as access rights. The default is "640". 70 | .RE 71 | 72 | .SH AUTHOR 73 | This version of \fBmkzonefs\fR was written by Damien Le Moal. 74 | 75 | .SH AVAILABILITY 76 | .B mkzonefs 77 | is available from https://github.com/westerndigitalcorporation/zonefs-tools/ 78 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 4 | 5 | AM_CFLAGS = -O2 -Wall -Wextra -Wno-unused-parameter 6 | 7 | sbin_PROGRAMS = mkzonefs 8 | 9 | CFILES = zonefs_dev.c \ 10 | mkzonefs.c 11 | HFILES = zonefs.h 12 | 13 | mkzonefs_SOURCES = ${CFILES} ${HFILES} 14 | mkzonefs_LDADD = 15 | mkzonefs_LDFLAGS = -luuid -lblkid 16 | 17 | install-exec-hook: 18 | (cd $(DESTDIR)${sbindir}; rm -f mkfs.zonefs) 19 | (cd $(DESTDIR)${sbindir}; $(LN_S) mkzonefs mkfs.zonefs) 20 | 21 | uninstall-hook: 22 | (cd $(DESTDIR)${sbindir}; rm -f mkfs.zonefs) 23 | -------------------------------------------------------------------------------- /src/mkzonefs.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | /* 3 | * This file is part of zonefs tools. 4 | * Copyright (c) 2019 Western Digital Corporation or its affiliates. 5 | * 6 | * Authors: Damien Le Moal (damien.lemoal@wdc.com) 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "zonefs.h" 20 | 21 | /* 22 | * For super block checksum (CRC32) 23 | */ 24 | #define CRCPOLY_LE 0xedb88320 25 | 26 | __u32 zonefs_crc32(__u32 crc, const void *buf, size_t length) 27 | { 28 | unsigned char *p = (unsigned char *)buf; 29 | int i; 30 | 31 | while (length--) { 32 | crc ^= *p++; 33 | for (i = 0; i < 8; i++) 34 | crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); 35 | } 36 | 37 | return crc; 38 | } 39 | 40 | /* 41 | * Fill and write a super block. 42 | */ 43 | static int zonefs_write_super(struct zonefs_dev *dev) 44 | { 45 | struct zonefs_super *super; 46 | __u32 crc; 47 | int ret; 48 | 49 | ret = posix_memalign((void **)&super, sysconf(_SC_PAGESIZE), 50 | sizeof(*super)); 51 | if (ret) { 52 | fprintf(stderr, "Not enough memory\n"); 53 | return -1; 54 | } 55 | 56 | memset(super, 0, sizeof(*super)); 57 | super->s_magic = __cpu_to_le32(ZONEFS_MAGIC); 58 | uuid_copy(super->s_uuid, dev->uuid); 59 | strcpy(super->s_label, dev->label); 60 | super->s_features = __cpu_to_le64(dev->features); 61 | super->s_uid = __cpu_to_le32(dev->uid); 62 | super->s_gid = __cpu_to_le32(dev->gid); 63 | super->s_perm = __cpu_to_le32(dev->perm); 64 | 65 | crc = zonefs_crc32(~0U, super, sizeof(*super)); 66 | super->s_crc = __cpu_to_le32(crc); 67 | 68 | ret = pwrite(dev->fd, super, sizeof(*super), 0); 69 | free(super); 70 | 71 | if (ret < 0) { 72 | fprintf(stderr, 73 | "%s: Write super block failed %d (%s)\n", 74 | dev->name, errno, strerror(errno)); 75 | return -1; 76 | } 77 | 78 | return zonefs_finish_zone(dev, &dev->zones[0]); 79 | } 80 | 81 | /* 82 | * Parse features string. 83 | */ 84 | static int zonefs_parse_features(struct zonefs_dev *dev, char *features) 85 | { 86 | char *ef, *f = features; 87 | 88 | while (*f) { 89 | 90 | if (strncmp(f, "aggr_cnv", 8) == 0) { 91 | dev->features |= ZONEFS_F_AGGRCNV; 92 | f += 8; 93 | } else if (strncmp(f, "uid=", 4) == 0) { 94 | dev->features |= ZONEFS_F_UID; 95 | f += 4; 96 | dev->uid = strtol(f, &ef, 10); 97 | if (errno == ERANGE) { 98 | fprintf(stderr, "Invalid UID\n"); 99 | return -1; 100 | } 101 | f = ef; 102 | } else if (strncmp(f, "gid=", 4) == 0) { 103 | dev->features |= ZONEFS_F_GID; 104 | f += 4; 105 | dev->gid = strtol(f, &ef, 10); 106 | if (errno == ERANGE) { 107 | fprintf(stderr, "Invalid GID\n"); 108 | return -1; 109 | } 110 | f = ef; 111 | } else if (strncmp(f, "perm=", 5) == 0) { 112 | dev->features |= ZONEFS_F_PERM; 113 | f += 5; 114 | dev->perm = strtol(f, &ef, 8); 115 | if (errno == ERANGE) { 116 | fprintf(stderr, "Invalid file permissions\n"); 117 | return -1; 118 | } 119 | f = ef; 120 | } 121 | 122 | if (*f) { 123 | if (*f != ',') { 124 | fprintf(stderr, "Invalid feature string\n"); 125 | return -1; 126 | } 127 | f++; 128 | } 129 | } 130 | 131 | return 0; 132 | } 133 | 134 | /* 135 | * Print usage. 136 | */ 137 | static void mkzonefs_usage(void) 138 | { 139 | printf("Usage: mkzonefs [options] \n"); 140 | printf("Options:\n" 141 | " --version : Print version number and exit\n" 142 | " --help | -h : General help message\n" 143 | " -v : Verbose output\n" 144 | " -f : Force overwrite of existing content\n" 145 | " -o : Optional features\n"); 146 | } 147 | 148 | /* 149 | * Main function. 150 | */ 151 | int main(int argc, char **argv) 152 | { 153 | unsigned int nr_zones; 154 | struct zonefs_dev dev; 155 | char uuid_str[UUID_STR_LEN]; 156 | int i, ret; 157 | 158 | /* Compile time checks */ 159 | ZONEFS_STATIC_ASSERT(sizeof(struct zonefs_super) == ZONEFS_SUPER_SIZE); 160 | ZONEFS_STATIC_ASSERT(sizeof(uuid_t) == ZONEFS_UUID_SIZE); 161 | 162 | /* Initialize */ 163 | memset(&dev, 0, sizeof(dev)); 164 | dev.fd = -1; 165 | 166 | /* Defaults */ 167 | dev.uid = 0; /* root */ 168 | dev.gid = 0; /* root */ 169 | dev.perm = S_IRUSR | S_IWUSR | S_IRGRP; /* 0640 */ 170 | 171 | /* Parse options */ 172 | for (i = 1; i < argc; i++) { 173 | if (strcmp(argv[i], "--version") == 0) { 174 | printf("mkzonefs, version %s\n", PACKAGE_VERSION); 175 | printf("Copyright (C) 2019, Western Digital Corporation" 176 | " or its affiliates.\n"); 177 | return 0; 178 | } 179 | 180 | if (strcmp(argv[i], "--help") == 0 || 181 | strcmp(argv[i], "-h") == 0) { 182 | mkzonefs_usage(); 183 | printf("See \"man mkzonefs\" for more information\n"); 184 | return 0; 185 | } 186 | 187 | if (strcmp(argv[i], "-f") == 0) { 188 | dev.flags |= ZONEFS_OVERWRITE; 189 | } else if (strcmp(argv[i], "-v") == 0) { 190 | dev.flags |= ZONEFS_VERBOSE; 191 | } else if (strcmp(argv[i], "-L") == 0) { 192 | i++; 193 | if (i >= argc - 1) { 194 | fprintf(stderr, "Invalid command line\n"); 195 | return 1; 196 | } 197 | if (strlen(argv[i]) > ZONEFS_LABEL_LEN) { 198 | fprintf(stderr, 199 | "Label too long (%d chars allowed)\n", 200 | ZONEFS_LABEL_LEN); 201 | return 1; 202 | } 203 | memcpy(dev.label, argv[i], strlen(argv[i])); 204 | } else if (strcmp(argv[i], "-o") == 0) { 205 | i++; 206 | if (i >= argc - 1) { 207 | fprintf(stderr, "Invalid command line\n"); 208 | return 1; 209 | } 210 | if (zonefs_parse_features(&dev, argv[i]) < 0) 211 | return 1; 212 | } else if (argv[i][0] == '-') { 213 | fprintf(stderr, "Invalid option '%s'\n", argv[i]); 214 | return 1; 215 | } else { 216 | break; 217 | } 218 | } 219 | 220 | if (i != argc - 1) { 221 | fprintf(stderr, "No device specified\n"); 222 | return 1; 223 | } 224 | 225 | /* Get device path */ 226 | dev.path = realpath(argv[i], NULL); 227 | if (!dev.path) { 228 | fprintf(stderr, "Failed to get device real path\n"); 229 | return 1; 230 | } 231 | 232 | /* Open the device */ 233 | if (zonefs_open_dev(&dev, true) < 0) 234 | return 1; 235 | 236 | printf("%s: %llu 512-byte sectors (%llu GiB)\n", 237 | dev.path, 238 | dev.capacity, 239 | (dev.capacity << 9) / (1024ULL * 1024ULL * 1024ULL)); 240 | printf(" Host-%s device\n", 241 | (dev.model == ZONEFS_DEV_HM) ? "managed" : "aware"); 242 | nr_zones = dev.capacity / dev.zone_nr_sectors; 243 | printf(" %u zones of %zu 512-byte sectors (%zu MiB)\n", 244 | nr_zones, 245 | dev.zone_nr_sectors, 246 | (dev.zone_nr_sectors << 9) / (1024 * 1024)); 247 | if (nr_zones < dev.nr_zones) { 248 | size_t runt_sectors = dev.capacity & (dev.zone_nr_sectors - 1); 249 | 250 | printf(" 1 runt zone of %zu 512-byte sectors (%zu MiB)\n", 251 | runt_sectors, 252 | (runt_sectors << 9) / (1024 * 1024)); 253 | } 254 | printf(" %u conventional zones, %u sequential zones\n", 255 | dev.nr_conv_zones, dev.nr_seq_zones); 256 | printf(" %u read-only zones, %u offline zones\n", 257 | dev.nr_ro_zones, dev.nr_ol_zones); 258 | 259 | if (dev.nr_ol_zones >= dev.nr_zones - 1) { 260 | fprintf(stderr, "No useable zones\n"); 261 | ret = 1; 262 | goto out; 263 | } 264 | 265 | printf("Format:\n"); 266 | printf(" %u usable zones\n", dev.nr_zones - dev.nr_ol_zones - 1); 267 | printf(" Aggregate conventional zones: %s\n", 268 | dev.features & ZONEFS_F_AGGRCNV ? "enabled" : "disabled"); 269 | printf(" File UID: %u\n", dev.uid); 270 | printf(" File GID: %u\n", dev.gid); 271 | printf(" File access permissions: %o\n", dev.perm); 272 | 273 | if (strlen(dev.label)) 274 | printf(" FS label: %s\n", dev.label); 275 | 276 | uuid_generate(dev.uuid); 277 | uuid_unparse(dev.uuid, uuid_str); 278 | printf(" FS UUID: %s\n", uuid_str); 279 | 280 | ret = 1; 281 | 282 | printf("Resetting sequential zones\n"); 283 | if (zonefs_reset_zones(&dev) < 0) 284 | goto out; 285 | 286 | printf("Writing super block\n"); 287 | if (zonefs_write_super(&dev) < 0) 288 | goto out; 289 | 290 | /* Sync */ 291 | if (zonefs_sync_dev(&dev) < 0) 292 | goto out; 293 | 294 | ret = 0; 295 | 296 | out: 297 | zonefs_close_dev(&dev); 298 | 299 | return ret; 300 | } 301 | 302 | -------------------------------------------------------------------------------- /src/zonefs.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-or-later 2 | /* 3 | * This file is part of zonefs tools. 4 | * Copyright (c) 2019 Western Digital Corporation or its affiliates. 5 | * 6 | * Authors: Damien Le Moal (damien.lemoal@wdc.com) 7 | */ 8 | #ifndef ZONEFS_H 9 | #define ZONEFS_H 10 | 11 | #define _LARGEFILE64_SOURCE 12 | 13 | #include "config.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* 23 | * On-disk super block magic. 24 | */ 25 | #ifndef ZONEFS_MAGIC 26 | #define ZONEFS_MAGIC 0x5a4f4653 /* 'Z' 'O' 'F' 'S' */ 27 | #endif 28 | 29 | /* 30 | * Feature flags. 31 | */ 32 | #define ZONEFS_F_AGGRCNV (1ULL << 0) 33 | #define ZONEFS_F_UID (1ULL << 1) 34 | #define ZONEFS_F_GID (1ULL << 2) 35 | #define ZONEFS_F_PERM (1ULL << 3) 36 | 37 | /* 38 | * Volume label and UUID size. 39 | */ 40 | #define ZONEFS_LABEL_LEN 64 41 | #define ZONEFS_UUID_SIZE 16 42 | 43 | /* 44 | * On disk super block. 45 | * This uses a full 4KB block. 46 | */ 47 | #define ZONEFS_SUPER_SIZE 4096U 48 | struct zonefs_super { 49 | 50 | /* Magic number */ 51 | __le32 s_magic; /* 4 */ 52 | 53 | /* Checksum */ 54 | __le32 s_crc; /* 8 */ 55 | 56 | /* Volume label */ 57 | char s_label[ZONEFS_LABEL_LEN]; /* 72 */ 58 | 59 | /* 128-bit uuid */ 60 | __u8 s_uuid[ZONEFS_UUID_SIZE]; /* 88 */ 61 | 62 | /* Features */ 63 | __le64 s_features; /* 96 */ 64 | 65 | /* UID/GID to use for files */ 66 | __le32 s_uid; /* 100 */ 67 | __le32 s_gid; /* 104 */ 68 | 69 | /* File permissions */ 70 | __le32 s_perm; /* 108 */ 71 | 72 | /* Padding to ZONEFS_SUPER_SIZE bytes */ 73 | __u8 s_reserved[3988]; /* 4096 */ 74 | 75 | } __attribute__ ((packed)); 76 | 77 | /* 78 | * Device descriptor. 79 | */ 80 | struct zonefs_dev { 81 | 82 | /* Device file path and basename */ 83 | char *path; 84 | char *name; 85 | 86 | /* Flags and features */ 87 | unsigned int flags; 88 | unsigned long long features; 89 | unsigned int uid; 90 | unsigned int gid; 91 | unsigned int perm; 92 | char label[ZONEFS_LABEL_LEN]; 93 | uuid_t uuid; 94 | 95 | /* Device info */ 96 | unsigned int model; 97 | unsigned long long capacity; 98 | size_t zone_nr_sectors; 99 | unsigned int nr_zones; 100 | unsigned int nr_conv_zones; 101 | unsigned int nr_seq_zones; 102 | unsigned int nr_ro_zones; 103 | unsigned int nr_ol_zones; 104 | struct blk_zone *zones; 105 | 106 | /* Device file descriptor */ 107 | int fd; 108 | 109 | }; 110 | 111 | /* 112 | * Device model. 113 | */ 114 | #define ZONEFS_DEV_HM 1 115 | #define ZONEFS_DEV_HA 2 116 | 117 | /* 118 | * Device flags. 119 | */ 120 | #define ZONEFS_VERBOSE (1 << 0) 121 | #define ZONEFS_OVERWRITE (1 << 1) 122 | 123 | #define zonefs_zone_id(dev, z) \ 124 | (unsigned int)((z)->start / (dev)->zone_nr_sectors) 125 | 126 | int zonefs_open_dev(struct zonefs_dev *dev, bool check_overwrite); 127 | void zonefs_close_dev(struct zonefs_dev *dev); 128 | int zonefs_sync_dev(struct zonefs_dev *dev); 129 | int zonefs_finish_zone(struct zonefs_dev *dev, struct blk_zone *zone); 130 | int zonefs_reset_zones(struct zonefs_dev *dev); 131 | 132 | /* 133 | * For compile time checks 134 | */ 135 | #define ZONEFS_STATIC_ASSERT(cond) \ 136 | void zonefs_static_assert(int dummy[(cond) ? 1 : -1]) 137 | 138 | #endif /* ZONEFS_H */ 139 | -------------------------------------------------------------------------------- /tests/scripts/0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mkzonefs (options)" 12 | exit 0 13 | fi 14 | 15 | # Test various good mkzonefs options 16 | OPTS_OK=("" 17 | "-h" 18 | "--help" 19 | "--help" 20 | "-v" 21 | "-f" 22 | "-o aggr_cnv" 23 | "-o uid=0" 24 | "-o gid=0" 25 | "-o perm=777" 26 | "-o aggr_cnv,uid=0,gid=0,perm=777") 27 | 28 | for ((i = 0; i < ${#OPTS_OK[@]}; i++)); do 29 | clear_sb "$1" 30 | 31 | cmd="mkzonefs ${OPTS_OK[$i]} $1" 32 | 33 | echo "Check mkzonefs command: $cmd" 34 | 35 | $cmd || exit_failed " --> FAILED" 36 | done 37 | 38 | # Test various bad mkzonefs options 39 | OPTS_BAD=("-bad-option" 40 | "-o" 41 | "-o invalid_feature" 42 | "-o invalid,,list") 43 | 44 | for ((i = 0; i < ${#OPTS_BAD[@]}; i++)); do 45 | cmd="mkzonefs ${OPTS_BAD[$i]} $1" 46 | 47 | echo "Check mkzonefs command: $cmd" 48 | 49 | $cmd && exit_failed " --> SUCCESS (should FAIL)" 50 | done 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /tests/scripts/0002.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mkzonefs (force format)" 12 | exit 0 13 | fi 14 | 15 | require_program mkfs.f2fs 16 | require_cnv_files 17 | 18 | # Format with f2fs. Cap filesystem size up to 16TB per f2fs design. 19 | sectors=$((nr_zones * zone_sectors)) 20 | sectors_16TB=$((16 * 1024 * 1024 * 1024 * 1024 / 512)) 21 | ((sectors > sectors_16TB)) && sectors=$((sectors_16TB)) 22 | f2fs_sectors=$((sectors / ($(get_logical_block_size "$1") / 512))) 23 | mkfs.f2fs -f -m "$1" $((f2fs_sectors)) || exit_failed " --> f2fs format FAILED" 24 | 25 | # This should fail 26 | echo "Check mkzonefs with used super block and not forced" 27 | mkzonefs "$1" && exit_failed " --> FAILED" 28 | 29 | # And pass if -f is specified 30 | echo "Check mkzonefs with used super block and forced" 31 | mkzonefs -f "$1" || exit_failed " --> FAILED" 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /tests/scripts/0003.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mkzonefs (invalid device)" 12 | exit 0 13 | fi 14 | 15 | # Not a block device 16 | echo "# Trying /dev/console" 17 | 18 | mkzonefs /dev/console && exit_failed " --> SUCCESS (should FAIL)" 19 | 20 | # Regular block device 21 | nulldev=$(create_regular_nullb) 22 | echo "# Trying regular block device /dev/nullb$nulldev" 23 | 24 | mkzonefs "/dev/nullb$nulldev" && exit_failed " --> SUCCESS (should FAIL)" 25 | 26 | destroy_nullb $nulldev 27 | 28 | exit 0 29 | -------------------------------------------------------------------------------- /tests/scripts/0004.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mkzonefs (super block zone state)" 12 | exit 0 13 | fi 14 | 15 | if zone_is_conventional "$1" "0"; then 16 | # The super block is in a conventional zone: nothing to do 17 | echo "conventional zone" 18 | exit 0 19 | fi 20 | 21 | zonefs_mkfs "$1" 22 | 23 | zone_is_full "$1" "0" || exit_failed " --> Super block zone is not in full state" 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/scripts/0020.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mount (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check default mount" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | zonefs_umount 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/scripts/0021.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mount (invalid device)" 12 | exit 0 13 | fi 14 | 15 | # Invalid device 16 | echo "Check mount with invalid device" 17 | zonefs_mount_err /dev/console 18 | 19 | # Regular device 20 | echo "Check mount with non-zoned block device" 21 | nulldev=$(create_regular_nullb) 22 | 23 | zonefs_mount_err "/dev/nullb$nulldev" 24 | 25 | destroy_nullb $nulldev 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/scripts/0022.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mount (check mount directory sub-directories)" 12 | exit 0 13 | fi 14 | 15 | zonefs_mkfs "$1" 16 | zonefs_mount "$1" 17 | 18 | if [ "$nr_cnv_zones" -le 1 ]; then 19 | if [ -d "$zonefs_mntdir/cnv/" ]; then 20 | echo "$zonefs_mntdir/cnv/ exits (should not exist)" 21 | exit 1 22 | fi 23 | else 24 | if [ ! -d "$zonefs_mntdir/cnv/" ]; then 25 | echo "$zonefs_mntdir/cnv/ does not exit (should exist)" 26 | exit 1 27 | fi 28 | fi 29 | 30 | if [ ! -d "$zonefs_mntdir/seq/" ]; then 31 | echo "$zonefs_mntdir/seq/ does not exit (should exit)" 32 | exit 1 33 | fi 34 | 35 | zonefs_umount 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /tests/scripts/0023.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "mount (options)" 12 | exit 0 13 | fi 14 | 15 | zonefs_mkfs "$1" 16 | 17 | # Test good mount options 18 | OPTS=("-o errors=repair" 19 | "-o errors=remount-ro" 20 | "-o errors=zone-ro" 21 | "-o errors=zone-offline") 22 | for ((i = 0; i < ${#OPTS[@]}; i++)); do 23 | zonefs_mount "${OPTS[$i]} $1" 24 | zonefs_umount "$1" 25 | done 26 | 27 | # Test invalid mount options 28 | OPTS=("-o errors=continue" 29 | "-o errors=panic" 30 | "-o foo=bar" 31 | "-o bad_option") 32 | for ((i = 0; i < ${#OPTS[@]}; i++)); do 33 | zonefs_mount_err "${OPTS[$i]} $1" 34 | done 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /tests/scripts/0040.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Number of files (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for number of files: $nr_cnv_files cnv, $nr_seq_files seq" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | if [ "$nr_cnv_files" != 0 ]; then 21 | nr_files=$(ls_nr_files "$zonefs_mntdir/cnv/") 22 | if [ "$nr_files" != "$nr_cnv_files" ]; then 23 | echo " --> Invalid number of conventional zones file:" 24 | echo " --> Expected $nr_cnv_files, got $nr_files" 25 | exit 1 26 | fi 27 | 28 | nr_files=$(file_size "$zonefs_mntdir/cnv") 29 | if [ "$nr_files" != "$nr_cnv_files" ]; then 30 | echo " --> Invalid cnv directory size:" 31 | echo " --> Expected $nr_cnv_files, got $nr_files" 32 | exit 1 33 | fi 34 | fi 35 | 36 | nr_files=$(ls_nr_files "$zonefs_mntdir/seq/") 37 | if [ "$nr_files" != "$nr_seq_files" ]; then 38 | echo " --> Invalid number of sequential zones file:" 39 | echo " --> Expected $nr_seq_files, got $nr_files" 40 | exit 1 41 | fi 42 | 43 | nr_files=$(file_size "$zonefs_mntdir/seq/") 44 | if [ "$nr_files" != "$nr_seq_files" ]; then 45 | echo " --> Invalid seq directory size:" 46 | echo " --> Expected $nr_seq_files, got $nr_files" 47 | exit 1 48 | fi 49 | 50 | zonefs_umount 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /tests/scripts/0041.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Number of files (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for number of files: 1 cnv, $nr_seq_files seq" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | 22 | nr_files=$(ls_nr_files "$zonefs_mntdir/cnv/") 23 | if [ "$nr_files" != 1 ]; then 24 | echo " --> Invalid number of conventional zones file:" 25 | echo " --> Expected 1, got $nr_files" 26 | exit 1 27 | fi 28 | 29 | nr_files=$(file_size "$zonefs_mntdir/cnv") 30 | if [ "$nr_files" != 1 ]; then 31 | echo " --> Invalid cnv directory size:" 32 | echo " --> Expected 1, got $nr_files" 33 | exit 1 34 | fi 35 | 36 | nr_files=$(ls_nr_files "$zonefs_mntdir/seq/") 37 | if [ "$nr_files" != "$nr_seq_files" ]; then 38 | echo " --> Invalid number of sequential zones file:" 39 | echo " --> Expected $nr_seq_files, got $nr_files" 40 | exit 1 41 | fi 42 | 43 | nr_files=$(file_size "$zonefs_mntdir/seq") 44 | if [ "$nr_files" != "$nr_seq_files" ]; then 45 | echo " --> Invalid seq directory size:" 46 | echo " --> Expected $nr_seq_files, got $nr_files" 47 | exit 1 48 | fi 49 | 50 | zonefs_umount 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /tests/scripts/0042.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Number of files using stat (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for number of files: $nr_cnv_files cnv, $nr_seq_files seq" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | nr_s_files=$nr_seq_files 21 | if [ "$nr_seq_files" != 0 ]; then 22 | nr_s_files=$(( nr_s_files + 1 )) 23 | fi 24 | 25 | nr_c_files=$nr_cnv_files 26 | if [ "$nr_cnv_files" != 0 ]; then 27 | nr_c_files=$(( nr_c_files + 1 )) 28 | fi 29 | 30 | nr_expected_files=$(( nr_s_files + nr_c_files )) 31 | 32 | nr_files=$(stat_nr_files "$zonefs_mntdir") 33 | if [ "$nr_files" != "$nr_expected_files" ]; then 34 | echo " --> Invalid total number of zone files:" 35 | echo " --> Expected $nr_expected_files, got $nr_files" 36 | exit 1 37 | fi 38 | 39 | zonefs_umount 40 | 41 | exit 0 42 | -------------------------------------------------------------------------------- /tests/scripts/0043.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Number of files using stat (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for number of files: 1 aggr_cnv, $num_seq_files seq" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | 22 | nr_s_files=$nr_seq_files 23 | if [ "$nr_seq_files" != 0 ]; then 24 | nr_s_files=$(( nr_s_files + 1 )) 25 | fi 26 | 27 | if [ $nr_cnv_files != 0 ]; then 28 | nr_c_files=2 29 | else 30 | nr_c_files=0 31 | fi 32 | 33 | nr_expected_files=$(( nr_s_files + nr_c_files )) 34 | 35 | nr_files=$(stat_nr_files "$zonefs_mntdir") 36 | if [ "$nr_files" != "$nr_expected_files" ]; then 37 | echo " --> Invalid total number of zone files:" 38 | echo " --> Expected $nr_expected_files, got $nr_files" 39 | exit 1 40 | fi 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0044.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Number of blocks using stat (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for number of blocks for the file system" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | nr_blocks=$(block_number "$zonefs_mntdir") 21 | sz_blocks=$(block_size "$zonefs_mntdir") 22 | capacity_bytes=$(( total_usable_sectors * 512)) 23 | nr_expected_blocks=$(( capacity_bytes / sz_blocks )) 24 | 25 | if [ "$nr_blocks" != "$nr_expected_blocks" ]; then 26 | echo " --> Invalid total number of blocks:" 27 | echo " --> Expected $nr_expected_blocks, got $nr_blocks" 28 | exit 1 29 | fi 30 | 31 | zonefs_umount 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /tests/scripts/0045.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Number of blocks using stat (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for number of blocks of the file system" 16 | 17 | zonefs_mkfs "-o aggr_cnv $1" 18 | zonefs_mount "$1" 19 | 20 | nr_blocks=$(block_number "$zonefs_mntdir") 21 | sz_blocks=$(block_size "$zonefs_mntdir") 22 | capacity_bytes=$(( total_usable_sectors * 512)) 23 | nr_expected_blocks=$(( capacity_bytes / sz_blocks )) 24 | 25 | if [ "$nr_blocks" != "$nr_expected_blocks" ]; then 26 | echo " --> Invalid total number of blocks:" 27 | echo " --> Expected $nr_expected_blocks, got $nr_blocks" 28 | exit 1 29 | fi 30 | 31 | zonefs_umount 32 | 33 | exit 0 34 | 35 | -------------------------------------------------------------------------------- /tests/scripts/0060.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files permissions (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for files permission 640" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | check_perm "640" 20 | zonefs_umount 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/scripts/0061.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files permissions (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for files permission 640 (aggr_cnv)" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | check_perm "640" 22 | zonefs_umount 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /tests/scripts/0062.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files permissions (format set value)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for files permission 770" 16 | zonefs_mkfs "-o perm=770 $1" 17 | zonefs_mount "$1" 18 | check_perm "770" 19 | zonefs_umount 20 | 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/scripts/0063.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files permissions (format set value + aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for files permission 770 (aggr_cnv)" 18 | 19 | zonefs_mkfs "-o aggr_cnv,perm=770 $1" 20 | zonefs_mount "$1" 21 | check_perm "770" 22 | zonefs_umount 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /tests/scripts/0064.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files permissions (user set value)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for files permission persistence" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | if [ "$nr_cnv_files" != 0 ]; then 21 | check_file_perm "$zonefs_mntdir/cnv/0" "640" 22 | chmod 770 "$zonefs_mntdir"/cnv/0 23 | check_file_perm "$zonefs_mntdir/cnv/0" "770" 24 | 25 | # Drop inode cache and check again 26 | drop_inode_cache 27 | check_file_perm "$zonefs_mntdir/cnv/0" "770" 28 | fi 29 | 30 | check_file_perm "$zonefs_mntdir/seq/0" "640" 31 | chmod 770 "$zonefs_mntdir"/seq/0 32 | check_file_perm "$zonefs_mntdir/seq/0" "770" 33 | 34 | # Drop inode cache and check again 35 | drop_inode_cache 36 | check_file_perm "$zonefs_mntdir/seq/0" "770" 37 | 38 | zonefs_umount 39 | 40 | exit 0 41 | -------------------------------------------------------------------------------- /tests/scripts/0065.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files permissions (user set value + aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for files permission persistence" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | check_file_perm "$zonefs_mntdir/cnv/0" "640" 23 | chmod 770 "$zonefs_mntdir"/cnv/0 24 | check_file_perm "$zonefs_mntdir/cnv/0" "770" 25 | 26 | # Drop inode cache and check again 27 | drop_inode_cache 28 | check_file_perm "$zonefs_mntdir/cnv/0" "770" 29 | 30 | check_file_perm "$zonefs_mntdir/seq/0" "640" 31 | chmod 770 "$zonefs_mntdir"/seq/0 32 | check_file_perm "$zonefs_mntdir/seq/0" "770" 33 | 34 | # Drop inode cache and check again 35 | drop_inode_cache 36 | check_file_perm "$zonefs_mntdir/seq/0" "770" 37 | 38 | zonefs_umount 39 | 40 | exit 0 41 | -------------------------------------------------------------------------------- /tests/scripts/0080.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files owner (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for default UID 0 and GID 0" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | check_uid_gid "0" "0" 20 | zonefs_umount 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/scripts/0081.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files owner (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for default UID 0 and GID 0, aggr_cnv" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | check_uid_gid "0" "0" 22 | zonefs_umount 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /tests/scripts/0082.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files owner (format set value)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for UID 1000, GID 0" 16 | 17 | zonefs_mkfs "-o uid=1000 $1" 18 | zonefs_mount "$1" 19 | check_uid_gid "1000" "0" 20 | zonefs_umount 21 | 22 | echo "Check for UID 0, GID 1000" 23 | 24 | zonefs_mkfs "-o gid=1000 $1" 25 | zonefs_mount "$1" 26 | check_uid_gid "0" "1000" 27 | zonefs_umount 28 | 29 | echo "Check for UID 1000, GID 2000" 30 | 31 | zonefs_mkfs "-o uid=1000,gid=2000 $1" 32 | zonefs_mount "$1" 33 | check_uid_gid "1000" "2000" 34 | zonefs_umount 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /tests/scripts/0083.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files owner (format set value + aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for UID 1000, GID 0, aggr_cnv" 18 | 19 | zonefs_mkfs "-o aggr_cnv,uid=1000 $1" 20 | zonefs_mount "$1" 21 | check_uid_gid "1000" "0" 22 | zonefs_umount 23 | 24 | echo "Check for UID 0, GID 1000, aggr_cnv" 25 | 26 | zonefs_mkfs "-o aggr_cnv,gid=1000 $1" 27 | zonefs_mount "$1" 28 | check_uid_gid "0" "1000" 29 | zonefs_umount 30 | 31 | echo "Check for UID 1000, GID 2000, aggr_cnv" 32 | 33 | zonefs_mkfs "-o aggr_cnv,uid=1000,gid=2000 $1" 34 | zonefs_mount "$1" 35 | check_uid_gid "1000" "2000" 36 | zonefs_umount 37 | 38 | exit 0 39 | -------------------------------------------------------------------------------- /tests/scripts/0084.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files owner (user set value)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for files UID/GID persistence" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | if [ "$nr_cnv_files" != 0 ]; then 21 | check_file_uid_gid "$zonefs_mntdir/cnv/0" "0 0" 22 | chown 1000:1000 "$zonefs_mntdir"/cnv/0 23 | check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" 24 | 25 | # Drop inode cache and check again 26 | drop_inode_cache 27 | check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" 28 | fi 29 | 30 | check_file_uid_gid "$zonefs_mntdir/seq/0" "0 0" 31 | chown 1000:1000 "$zonefs_mntdir"/seq/0 32 | check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" 33 | 34 | # Drop inode cache and check again 35 | drop_inode_cache 36 | check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" 37 | 38 | zonefs_umount 39 | 40 | exit 0 41 | -------------------------------------------------------------------------------- /tests/scripts/0085.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files owner (user set value + aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for files UID/GID persistence" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | check_file_uid_gid "$zonefs_mntdir/cnv/0" "0 0" 23 | chown 1000:1000 "$zonefs_mntdir"/cnv/0 24 | check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" 25 | 26 | # Drop inode cache and check again 27 | drop_inode_cache 28 | check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" 29 | 30 | check_file_uid_gid "$zonefs_mntdir/seq/0" "0 0" 31 | chown 1000:1000 "$zonefs_mntdir"/seq/0 32 | check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" 33 | 34 | # Drop inode cache and check again 35 | drop_inode_cache 36 | check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" 37 | 38 | zonefs_umount 39 | 40 | exit 0 41 | -------------------------------------------------------------------------------- /tests/scripts/0100.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files size (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check for $zone_bytes B file size" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | check_size false 20 | zonefs_umount 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/scripts/0101.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Files size (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check for $(( zone_bytes * (nr_cnv_zones - 1) )) B file size" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | check_size true 22 | zonefs_umount 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /tests/scripts/0110.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "File names and inode numbers (default)" 12 | exit 0 13 | fi 14 | 15 | echo "Check file names and their inode numbers" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Checking root inode $zonefs_mntdir" 21 | check_dir_ino "$zonefs_mntdir" ${nr_zones} 22 | 23 | if [ "$nr_cnv_files" != "0" ]; then 24 | echo "Checking conventional files" 25 | 26 | if $short; then 27 | nrfiles=$(min ${nr_cnv_files} 500) 28 | else 29 | nrfiles=${nr_cnv_files} 30 | fi 31 | 32 | echo "Checking cnv directory inode number" 33 | check_dir_ino "$zonefs_mntdir/cnv" $(( nr_zones + 1 )) 34 | 35 | echo "Checking cnv directory files inode number" 36 | check_files_ino "$zonefs_mntdir/cnv" ${nrfiles} 1 37 | fi 38 | 39 | echo "Checking sequential files" 40 | 41 | if $short; then 42 | nrfiles=$(min ${nr_seq_files} 2000) 43 | else 44 | nrfiles=${nr_seq_files} 45 | fi 46 | 47 | echo "Checking seq directory inode number" 48 | check_dir_ino "$zonefs_mntdir/seq" $(( nr_zones + 2 )) 49 | 50 | echo "Checking seq directory files inode number" 51 | check_files_ino "$zonefs_mntdir/seq" \ 52 | ${nrfiles} \ 53 | $(( seq_file_0_zone_start_sector / zone_sectors )) 54 | 55 | zonefs_umount 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/scripts/0111.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "File names and inode numbers (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check file names and their inode numbers" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | 22 | echo "Checking root inode $zonefs_mntdir" 23 | check_dir_ino "$zonefs_mntdir" ${nr_zones} 24 | 25 | echo "Checking cnv directory inode number" 26 | check_dir_ino "$zonefs_mntdir/cnv" $(( nr_zones + 1 )) 27 | 28 | echo "Checking cnv directory files inode number" 29 | check_files_ino "$zonefs_mntdir/cnv" ${nr_cnv_files} 1 30 | 31 | if $short; then 32 | nrfiles=$(min ${nr_seq_files} 2000) 33 | else 34 | nrfiles=${nr_seq_files} 35 | fi 36 | 37 | echo "Checking seq directory inode number" 38 | check_dir_ino "$zonefs_mntdir/seq" $(( nr_zones + 2 )) 39 | 40 | echo "Checking seq directory files inode number" 41 | check_files_ino "$zonefs_mntdir/seq" \ 42 | ${nrfiles} \ 43 | $(( seq_file_0_zone_start_sector / zone_sectors )) 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/scripts/0200.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file truncate" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check conventional file truncate" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | truncate --no-create --size=0 "$zonefs_mntdir"/cnv/0 && \ 23 | exit_failed " --> SUCCESS (should FAIL)" 24 | 25 | zonefs_umount 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/scripts/0201.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file truncate (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check conventional file truncate, aggr_cnv" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | 22 | truncate --no-create --size=0 "$zonefs_mntdir"/cnv/0 && \ 23 | exit_failed " --> SUCCESS (should FAIL)" 24 | 25 | zonefs_umount 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/scripts/0202.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file unlink" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check conventional file unlink" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | rm -f "$zonefs_mntdir"/cnv/0 && \ 23 | exit_failed " --> SUCCESS (should FAIL)" 24 | 25 | zonefs_umount 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/scripts/0203.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file unlink (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check conventional file unlink, aggr_cnv" 18 | 19 | zonefs_mkfs "-o aggr_cnv $1" 20 | zonefs_mount "$1" 21 | 22 | rm -f "$zonefs_mntdir"/cnv/0 && \ 23 | exit_failed " --> SUCCESS (should FAIL)" 24 | 25 | zonefs_umount 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/scripts/0204.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file random write" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file random write" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=randwrite --ioengine=libaio --iodepth=8 \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | exit 0 32 | -------------------------------------------------------------------------------- /tests/scripts/0205.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file random write (direct)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file random write, direct IO (sync)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=randwrite --ioengine=psync \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none --direct=1 || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file random write, direct IO (async)" 32 | 33 | zonefs_mkfs "$1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=randwrite --ioengine=libaio --iodepth=64 \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none --direct=1 || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0206.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file random write (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file random write, aggr_cnv (sync)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=randwrite --ioengine=psync --size="$(aggr_cnv_size)" \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file random write, aggr_cnv (async)" 32 | 33 | zonefs_mkfs "-o aggr_cnv $1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=randwrite --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0207.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file random write (aggr_cnv, direct)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file random write, aggr_cnv, direct (sync)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=randwrite --ioengine=psync --size="$(aggr_cnv_size)" \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none --direct=1 || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file random write, aggr_cnv, direct (async)" 32 | 33 | zonefs_mkfs "-o aggr_cnv $1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=randwrite --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none --direct=1 || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0208.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file mmap read/write" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file mmap write" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | maxsize=$(file_max_size "$zonefs_mntdir"/cnv/0) 24 | fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/cnv/0 \ 25 | --rw=randwrite --ioengine=mmap --size="$maxsize" \ 26 | --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ 27 | --bs="${iosize}" --verify=md5 --do_verify=1 --overwrite=1 \ 28 | --continue_on_error=none || \ 29 | exit_failed " --> FAILED" 30 | 31 | zonefs_umount 32 | 33 | echo "Check conventional file mmap read" 34 | 35 | zonefs_mount "$1" 36 | 37 | fio --name=cnv_mmaprd --filename="$zonefs_mntdir"/cnv/0 \ 38 | --rw=randread --ioengine=mmap --size="$maxsize" \ 39 | --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ 40 | --bs="${iosize}" --verify=md5 --do_verify=1 --continue_on_error=none || \ 41 | exit_failed " --> FAILED" 42 | 43 | zonefs_umount 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/scripts/0209.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file mmap read/write (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file mmap write (aggr_cnv)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | maxsize=$(aggr_cnv_size) 24 | fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/cnv/0 \ 25 | --rw=randwrite --ioengine=mmap --size="$maxsize" \ 26 | --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ 27 | --bs="${iosize}" --verify=md5 --do_verify=1 --overwrite=1 \ 28 | --continue_on_error=none || \ 29 | exit_failed " --> FAILED" 30 | 31 | zonefs_umount 32 | 33 | echo "Check conventional file mmap read (aggr_cnv)" 34 | 35 | zonefs_mount "$1" 36 | 37 | fio --name=cnv_mmaprd --filename="$zonefs_mntdir"/cnv/0 \ 38 | --rw=randread --ioengine=mmap --size="$maxsize" \ 39 | --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ 40 | --bs="${iosize}" --verify=md5 --do_verify=1 --continue_on_error=none || \ 41 | exit_failed " --> FAILED" 42 | 43 | zonefs_umount 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/scripts/0210.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq write" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq write (sync)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=write --ioengine=psync \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file seq write (async)" 32 | 33 | zonefs_mkfs "$1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=write --ioengine=libaio --iodepth=64 \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0211.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq write (direct)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq write, direct IO (sync)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=write --ioengine=psync \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none --direct=1 || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file seq write, direct IO (async)" 32 | 33 | zonefs_mkfs "$1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=write --ioengine=libaio --iodepth=64 \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none --direct=1 || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0212.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq write (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq write, aggr_cnv (sync)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=write --ioengine=psync --size="$(aggr_cnv_size)" \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file seq write, aggr_cnv (async)" 32 | 33 | zonefs_mkfs "-o aggr_cnv $1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=write --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0213.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq write (aggr_cnv, direct)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq write, aggr_cnv, direct (sync)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=write --ioengine=psync --size="$(aggr_cnv_size)" \ 25 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 26 | --continue_on_error=none --direct=1 || \ 27 | exit_failed " --> FAILED" 28 | 29 | zonefs_umount 30 | 31 | echo "Check conventional file seq write, aggr_cnv, direct (async)" 32 | 33 | zonefs_mkfs "-o aggr_cnv $1" 34 | zonefs_mount "$1" 35 | 36 | fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ 37 | --rw=write --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ 38 | --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ 39 | --continue_on_error=none --direct=1 || \ 40 | exit_failed " --> FAILED" 41 | 42 | zonefs_umount 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/scripts/0214.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq write (large IOs)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program dd 17 | 18 | echo "Check conventional file seq write (large IOs, buffered)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | bs=$(file_size "$zonefs_mntdir"/cnv/0) 24 | 25 | dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ 26 | bs="$bs" count=1 conv=notrunc || \ 27 | exit_failed " --> FAILED" 28 | 29 | sync || exit_failed " --> FAILED" 30 | 31 | echo "Check conventional file seq write (large_IOs, direct)" 32 | 33 | dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ 34 | bs="$bs" count=1 conv=notrunc oflag=direct || \ 35 | exit_failed " --> FAILED" 36 | 37 | zonefs_umount 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /tests/scripts/0215.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq write (aggr_cnv, large IOs)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program dd 17 | 18 | zonefs_mkfs "-o aggr_cnv $1" 19 | zonefs_mount "$1" 20 | 21 | fsz=$(aggr_cnv_size) 22 | bs=$(( 16 * 1024 * 1024 )) 23 | if [ $bs -gt $fsz ]; then 24 | bs="$fsz" 25 | fi 26 | count=$(( fsz / bs )) 27 | 28 | echo "Check conventional file seq write (aggr_cnv, large IOs, buffered)" 29 | echo "bs: $bs, count: $count, fsz: $fsz" 30 | 31 | dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ 32 | bs="$bs" count="$count" conv=notrunc || \ 33 | exit_failed " --> FAILED" 34 | 35 | sync || exit_failed " --> FAILED" 36 | 37 | echo "Check conventional file seq write (aggr_cnv, large_IOs, direct)" 38 | echo "bs: $bs, count: $count, fsz: $fsz" 39 | 40 | dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ 41 | bs="$bs" count="$count" conv=notrunc oflag=direct || \ 42 | exit_failed " --> FAILED" 43 | 44 | zonefs_umount 45 | 46 | exit 0 47 | -------------------------------------------------------------------------------- /tests/scripts/0216.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq read" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq read (sync)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=read --ioengine=psync \ 25 | --bs=131072 --continue_on_error=none || \ 26 | exit_failed " --> FAILED" 27 | 28 | zonefs_umount 29 | 30 | echo "Check conventional file seq read (async)" 31 | 32 | zonefs_mkfs "$1" 33 | zonefs_mount "$1" 34 | 35 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 36 | --rw=read --ioengine=libaio --iodepth=64 \ 37 | --bs=131072 --continue_on_error=none || \ 38 | exit_failed " --> FAILED" 39 | 40 | zonefs_umount 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /tests/scripts/0217.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq read (direct)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq read, direct IO (sync)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=read --ioengine=psync \ 25 | --bs=131072 --continue_on_error=none --direct=1 || \ 26 | exit_failed " --> FAILED" 27 | 28 | zonefs_umount 29 | 30 | echo "Check conventional file seq read, direct IO (async)" 31 | 32 | zonefs_mkfs "$1" 33 | zonefs_mount "$1" 34 | 35 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 36 | --rw=read --ioengine=libaio --iodepth=64 \ 37 | --bs=131072 --continue_on_error=none --direct=1 || \ 38 | exit_failed " --> FAILED" 39 | 40 | zonefs_umount 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /tests/scripts/0218.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq read (aggr_cnv)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq read, aggr_cnv (sync)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=read --ioengine=psync --size="$(aggr_cnv_size)" \ 25 | --bs=131072 --continue_on_error=none || \ 26 | exit_failed " --> FAILED" 27 | 28 | zonefs_umount 29 | 30 | echo "Check conventional file seq read, aggr_cnv (async)" 31 | 32 | zonefs_mkfs "-o aggr_cnv $1" 33 | zonefs_mount "$1" 34 | 35 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 36 | --rw=read --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ 37 | --bs=131072 --continue_on_error=none || \ 38 | exit_failed " --> FAILED" 39 | 40 | zonefs_umount 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /tests/scripts/0219.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq read (aggr_cnv, direct)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program fio 17 | 18 | echo "Check conventional file seq read, aggr_cnv, direct (sync)" 19 | 20 | zonefs_mkfs "-o aggr_cnv $1" 21 | zonefs_mount "$1" 22 | 23 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 24 | --rw=read --ioengine=psync --size="$(aggr_cnv_size)" \ 25 | --bs=131072 --continue_on_error=none --direct=1 || \ 26 | exit_failed " --> FAILED" 27 | 28 | zonefs_umount 29 | 30 | echo "Check conventional file seq read, aggr_cnv, direct (async)" 31 | 32 | zonefs_mkfs "-o aggr_cnv $1" 33 | zonefs_mount "$1" 34 | 35 | fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ 36 | --rw=read --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ 37 | --bs=131072 --continue_on_error=none --direct=1 || \ 38 | exit_failed " --> FAILED" 39 | 40 | zonefs_umount 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /tests/scripts/0220.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq read (large IOs)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program dd 17 | 18 | echo "Check conventional file seq read (large IOs, buffered)" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | bs=$(file_size "$zonefs_mntdir"/cnv/0) 24 | 25 | dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ 26 | bs="$bs" count=1 || \ 27 | exit_failed " --> FAILED" 28 | 29 | sync || exit_failed " --> FAILED" 30 | 31 | echo "Check conventional file seq read (large_IOs, direct)" 32 | 33 | dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ 34 | bs="$bs" count=1 iflag=direct || \ 35 | exit_failed " --> FAILED" 36 | 37 | zonefs_umount 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /tests/scripts/0221.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file seq read (aggr_cnv, large IOs)" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program dd 17 | 18 | zonefs_mkfs "-o aggr_cnv $1" 19 | zonefs_mount "$1" 20 | 21 | fsz=$(aggr_cnv_size) 22 | bs=$(( 16 * 1024 * 1024 )) 23 | if [ $bs -gt $fsz ]; then 24 | bs="$fsz" 25 | fi 26 | count=$(( fsz / bs )) 27 | if [ $(( count * bs )) -ne $fsz ]; then 28 | count=$(( count + 1 )) 29 | fi 30 | 31 | echo "Check conventional file seq read (aggr_cnv, large IOs, buffered)" 32 | echo "bs: $bs, count: $count, fsz: $fsz" 33 | 34 | dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ 35 | bs="$bs" count="$count" || \ 36 | exit_failed " --> FAILED" 37 | 38 | sync || exit_failed " --> FAILED" 39 | 40 | echo "Check conventional file seq read (aggr_cnv, large_IOs, direct)" 41 | echo "bs: $bs, count: $count, fsz: $fsz" 42 | 43 | dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ 44 | bs="$bs" count="$count" iflag=direct || \ 45 | exit_failed " --> FAILED" 46 | 47 | zonefs_umount 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /tests/scripts/0222.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file readahead" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program dd 17 | 18 | echo "Check conventional file readahead" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | bs=$(block_size "$zonefs_mntdir"/cnv/0) 24 | 25 | dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 conv=notrunc \ 26 | oflag=direct bs="$bs" count=1 || \ 27 | exit_failed " --> FAILED" 28 | 29 | dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ 30 | bs="$bs" count=1 || \ 31 | exit_failed " --> FAILED" 32 | 33 | zonefs_umount 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /tests/scripts/0223.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Conventional file read beyond eof" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_program dd 17 | 18 | echo "Check conventional file read beyond eof" 19 | 20 | zonefs_mkfs "$1" 21 | zonefs_mount "$1" 22 | 23 | bs=$(block_size "$zonefs_mntdir"/seq/0) 24 | 25 | sz=$(file_size "$zonefs_mntdir"/cnv/0) 26 | ofst=$(( ($sz - 512) / 512 )) 27 | dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ 28 | bs="$(( bs * 2 ))" count=1 seek="$ofst" || \ 29 | exit_failed " --> FAILED" 30 | 31 | zonefs_umount 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /tests/scripts/0300.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file truncate" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file truncate" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ 21 | exit_failed " --> FAILED" 22 | 23 | sz=$(file_size "$zonefs_mntdir"/seq/0) 24 | [ "$sz" != "4096" ] && \ 25 | exit_failed " --> Invalid file size $sz B, expected 4096 B" 26 | 27 | echo "## file truncate to 0 (zone reset)" 28 | 29 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 30 | exit_failed " --> FAILED" 31 | 32 | sz=$(file_size "$zonefs_mntdir"/seq/0) 33 | [ "$sz" != "0" ] && \ 34 | exit_failed " --> Invalid file size $sz B, expected 0 B" 35 | 36 | echo "## file truncate to after zone wp (e.g. 4096B)" 37 | 38 | truncate --no-create --size=4096 "$zonefs_mntdir"/seq/0 && \ 39 | exit_failed " --> SUCCESS (should FAIL)" 40 | 41 | sz=$(file_size "$zonefs_mntdir"/seq/0) 42 | [ "$sz" != "0" ] && \ 43 | exit_failed " --> Invalid file size $sz B, expected 0 B" 44 | 45 | echo "## file truncate to zone size (zone finish)" 46 | 47 | maxsize=$(file_max_size "$zonefs_mntdir"/seq/0) 48 | truncate --no-create --size=$maxsize "$zonefs_mntdir"/seq/0 || \ 49 | exit_failed " --> FAILED" 50 | 51 | sz=$(file_size "$zonefs_mntdir"/seq/0) 52 | [ "$sz" != "$maxsize" ] && \ 53 | exit_failed " --> Invalid file size $sz B, expected $maxsize B" 54 | 55 | zonefs_umount 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/scripts/0301.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file unlink" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file unlink" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | rm -f "$zonefs_mntdir"/seq/0 && \ 21 | exit_failed " --> SUCCESS (should FAIL)" 22 | 23 | zonefs_umount 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/scripts/0302.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file buffered write IO" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file buffered write IO" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 bs=4096 count=1 && \ 21 | exit_failed " --> SUCCESS (should FAIL)" 22 | 23 | sz=$(file_size "$zonefs_mntdir"/seq/0) 24 | [ "$sz" != "0" ] && \ 25 | exit_failed " --> Invalid file size $sz B, expected 0 B" 26 | 27 | zonefs_umount 28 | 29 | exit 0 30 | -------------------------------------------------------------------------------- /tests/scripts/0303.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file overwrite" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file overwrite" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ 21 | exit_failed " --> FAILED" 22 | 23 | sz=$(file_size "$zonefs_mntdir"/seq/0) 24 | [ "$sz" != "4096" ] && \ 25 | exit_failed " --> Invalid file size $sz B, expected 4096 B" 26 | 27 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 conv=notrunc && \ 28 | exit_failed " --> SUCCESS (should FAIL)" 29 | 30 | sz=$(file_size "$zonefs_mntdir"/seq/0) 31 | [ "$sz" != "4096" ] && \ 32 | exit_failed " --> Invalid file size $sz B, expected 4096 B" 33 | 34 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 35 | exit_failed " --> FAILED" 36 | 37 | sz=$(file_size "$zonefs_mntdir"/seq/0) 38 | [ "$sz" != "0" ] && \ 39 | exit_failed " --> Invalid file size $sz B, expected 0 B" 40 | 41 | zonefs_umount 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/scripts/0304.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file unaligned write (sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file unaligned write (sync IO)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct \ 21 | bs=4096 count=1 seek=1 && \ 22 | exit_failed " --> SUCCESS (should FAIL)" 23 | 24 | sz=$(file_size "$zonefs_mntdir"/seq/0) 25 | [ "$sz" != "0" ] && \ 26 | exit_failed " --> Invalid file size $sz B, expected 0 B" 27 | 28 | # The file should still be writable 29 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct \ 30 | bs=4096 count=1 conv=notrunc || \ 31 | exit_failed " --> FAILED (should SUCCEED)" 32 | 33 | zonefs_umount 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /tests/scripts/0305.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file unaligned write (async)" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | echo "Check sequential file unaligned write (async IO)" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | tools/zio --write --fflag=direct --ofst=4096 \ 23 | --size=135168 --async=8 "$zonefs_mntdir"/seq/0 && \ 24 | exit_failed " --> SUCCESS (should FAIL)" 25 | 26 | sz=$(file_size "$zonefs_mntdir"/seq/0) 27 | [ "$sz" != "0" ] && \ 28 | exit_failed " --> Invalid file size $sz B, expected 0 B" 29 | 30 | # The file should still be writable 31 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct \ 32 | bs=4096 count=1 conv=notrunc || \ 33 | exit_failed " --> FAILED (should SUCCEED)" 34 | 35 | zonefs_umount 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /tests/scripts/0306.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file append (sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file append (sync)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Check with O_APPEND file open 21 | echo "Check sync append writes with O_APPEND" 22 | 23 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ 24 | exit_failed " --> FAILED" 25 | 26 | sz=$(file_size "$zonefs_mntdir"/seq/0) 27 | [ "$sz" != "4096" ] && \ 28 | exit_failed " --> Invalid file size $sz B, expected 4096 B" 29 | 30 | tools/zio --write --fflag=direct --fflag=append \ 31 | --size=135168 "$zonefs_mntdir"/seq/0 || \ 32 | exit_failed " --> FAILED" 33 | 34 | sz=$(file_size "$zonefs_mntdir"/seq/0) 35 | [ "$sz" != "$seq_file_0_max_size" ] && \ 36 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 37 | 38 | # Test with RWF_APPEND I/O flag 39 | echo "Check sync append writes with RWF_APPEND" 40 | 41 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 42 | exit_failed " --> FAILED" 43 | 44 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ 45 | exit_failed " --> FAILED" 46 | 47 | tools/zio --write --fflag=direct --ioflag=append \ 48 | --size=135168 "$zonefs_mntdir"/seq/0 || \ 49 | exit_failed " --> FAILED" 50 | 51 | sz=$(file_size "$zonefs_mntdir"/seq/0) 52 | [ "$sz" != "$seq_file_0_max_size" ] && \ 53 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 54 | 55 | zonefs_umount 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/scripts/0307.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file append (async)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file append (async)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Test with O_APPEND file open 21 | echo "Check append writes with O_APPEND" 22 | 23 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ 24 | exit_failed " --> FAILED" 25 | 26 | sz=$(file_size "$zonefs_mntdir"/seq/0) 27 | [ "$sz" != "4096" ] && \ 28 | exit_failed " --> Invalid file size $sz B, expected 4096 B" 29 | 30 | tools/zio --write --fflag=direct --fflag=append \ 31 | --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ 32 | exit_failed " --> FAILED" 33 | 34 | sz=$(file_size "$zonefs_mntdir"/seq/0) 35 | [ "$sz" != "$seq_file_0_max_size" ] && \ 36 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 37 | 38 | # Test with RWF_APPEND I/O flag 39 | echo "Check append writes with RWF_APPEND" 40 | 41 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 42 | exit_failed " --> FAILED" 43 | 44 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ 45 | exit_failed " --> FAILED" 46 | 47 | tools/zio --write --fflag=direct --ioflag=append \ 48 | --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ 49 | exit_failed " --> FAILED" 50 | 51 | sz=$(file_size "$zonefs_mntdir"/seq/0) 52 | [ "$sz" != "$seq_file_0_max_size" ] && \ 53 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 54 | 55 | zonefs_umount 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/scripts/0309.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file mmap read/write" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | echo "Check sequential file mmap write (should fail)" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | # Fill the file for mmap 23 | maxsize=$(file_max_size "$zonefs_mntdir"/seq/0) 24 | truncate --no-create --size=$maxsize "$zonefs_mntdir"/seq/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | sz=$(file_size "$zonefs_mntdir"/seq/0) 28 | [ "$sz" != "$maxsize" ] && \ 29 | exit_failed " --> Invalid file size $sz B, expected $maxsize B" 30 | 31 | # mmpa(MAP_WRITE) should fail 32 | fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/seq/0 \ 33 | --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ 34 | --rw=randwrite --ioengine=mmap --size="$sz" --max-jobs=8 \ 35 | --bs=4096 --continue_on_error=none && \ 36 | exit_failed " --> FAILED" 37 | 38 | # Reset the file 39 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 40 | exit_failed " --> FAILED" 41 | 42 | # Fill file 43 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 44 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 45 | --rw=write --ioengine=libaio --iodepth=64 --max-jobs=8 \ 46 | --bs="${iosize}" --size="$maxsize" --verify=md5 --do_verify=1 \ 47 | --continue_on_error=none --direct=1 || \ 48 | exit_failed "fio write FAILED" 49 | 50 | sz=$(file_size "$zonefs_mntdir"/seq/0) 51 | [ "$sz" != "$seq_file_0_max_size" ] && \ 52 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 53 | 54 | zonefs_umount 55 | 56 | echo "Check sequential file mmap read" 57 | 58 | zonefs_mount "$1" 59 | 60 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 61 | --rw=randread --ioengine=mmap --max-jobs=8 \ 62 | --create_on_open=0 --allow_file_create=0 --unlink=0 \ 63 | --bs="${iosize}" --size="$maxsize" --verify=md5 --do_verify=1 \ 64 | --continue_on_error=none || \ 65 | exit_failed "fio mmap rand read FAILED" 66 | 67 | zonefs_umount 68 | 69 | exit 0 70 | -------------------------------------------------------------------------------- /tests/scripts/0310.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2020 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "sequential file 4K synchronous write" 12 | exit 0 13 | fi 14 | 15 | set -x 16 | 17 | require_program fio 18 | 19 | echo "Check sequential file 4K sync write" 20 | 21 | zonefs_mkfs "$1" 22 | zonefs_mount "$1" 23 | 24 | sz=$(file_max_size "$zonefs_mntdir"/seq/0) 25 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 26 | exit_failed " --> FAILED" 27 | 28 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 29 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 30 | --rw=write --ioengine=psync --max-jobs=8 \ 31 | --bs=4096 --size="$sz" --verify=md5 --do_verify=1 \ 32 | --continue_on_error=none --direct=1 || \ 33 | exit_failed "fio write FAILED" 34 | 35 | zonefs_umount 36 | 37 | set +x 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /tests/scripts/0311.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2020 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file large synchronous write" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | echo "Check sequential file sync write bigger than max-append size" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | sz=$(file_max_size "$zonefs_mntdir"/seq/0) 23 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 24 | exit_failed " --> FAILED" 25 | 26 | pbs=$(block_size "$1") 27 | mask=$(($pbs - 1)) 28 | 29 | bs=$(get_write_max_bytes "$1") 30 | bs=$(($bs + $pbs)) 31 | if [ ${bs} -gt ${sz} ]; then 32 | bs=${sz} 33 | fi 34 | bs=$((($bs + $mask) & ~$mask)) 35 | 36 | echo "Using ${bs} IO size" 37 | 38 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 39 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 40 | --rw=write --ioengine=psync \ 41 | --bs="$bs" --size="$sz" --verify=md5 --do_verify=1 \ 42 | --continue_on_error=none --direct=1 || \ 43 | exit_failed "fio write FAILED" 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | 49 | -------------------------------------------------------------------------------- /tests/scripts/0312.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2020 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | generate_fio() { 11 | local nseq="$1" 12 | 13 | filesize=$(file_max_size "$zonefs_mntdir"/seq/0) 14 | if $short; then 15 | filesize=$((zone_sectors * 512 / 64)) 16 | fi 17 | 18 | cat > 0312.fio << EOF 19 | [global] 20 | create_on_open=0 21 | allow_file_create=0 22 | file_append=1 23 | unlink=0 24 | rw=write 25 | ioengine=psync 26 | bs=${iosize} 27 | filesize=${filesize} 28 | continue_on_error=none 29 | direct=1 30 | 31 | [writefiles] 32 | EOF 33 | 34 | for (( i=0; i<$nseq; i++ )); do 35 | truncate -s 0 "$zonefs_mntdir/seq/$i" 36 | echo "filename=$zonefs_mntdir/seq/$i" >> 0312.fio 37 | done 38 | } 39 | 40 | function cleanup { 41 | rm -f 0312.fio > /dev/null 2>&1 42 | } 43 | trap cleanup EXIT 44 | 45 | if [ $# == 0 ]; then 46 | echo "Sequential file explicit-open zone resources" 47 | exit 0 48 | fi 49 | 50 | require_program fio 51 | 52 | echo "Check explicit-open mounts" 53 | 54 | max_open_zones=$(get_max_open_zones "$1") 55 | if [ "$max_open_zones" == 0 ]; then 56 | exit_skip "No maximum open zone limit" 57 | fi 58 | 59 | zonefs_mkfs "$1" 60 | zonefs_mount "-o explicit-open $1" 61 | 62 | # fio write with less than $max_open_zones must succeed 63 | echo "Check write in less than $max_open_zones max open files" 64 | if [ "$max_open_zones" -gt "1" ]; then 65 | generate_fio "$(( max_open_zones - 1 ))" 66 | fio 0312.fio || exit_failed "fio write failed" 67 | fi 68 | 69 | # fio write with $max_open_zones must succeed 70 | echo "Check write in exactly $max_open_zones max open files" 71 | generate_fio "$max_open_zones" 72 | fio 0312.fio || exit_failed "fio write failed" 73 | 74 | # fio write with 2 * $max_open_zones must fail 75 | echo "Check write in double $max_open_zones max open files" 76 | nrfiles=$(min $(( max_open_zones * 2 )) $nr_seq_files) 77 | generate_fio "$nrfiles" 78 | fio 0312.fio && exit_failed "fio write succeeded (should fail)" 79 | 80 | zonefs_umount 81 | 82 | exit 0 83 | -------------------------------------------------------------------------------- /tests/scripts/0320.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file random read (buffered)" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Fill sequential file" 21 | 22 | # Fill file 23 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 24 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 25 | --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ 26 | --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ 27 | --continue_on_error=none --direct=1 || \ 28 | exit_failed "fio write FAILED" 29 | 30 | sz=$(file_size "$zonefs_mntdir"/seq/0) 31 | [ "$sz" != "$seq_file_0_max_size" ] && \ 32 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 33 | 34 | zonefs_umount 35 | 36 | echo "Check sequential file random read (sync)" 37 | 38 | zonefs_mount "$1" 39 | 40 | # Sync buffered random read 41 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 42 | --rw=randread --ioengine=psync --max-jobs=8 \ 43 | --bs=131072 --verify=md5 --do_verify=1 \ 44 | --continue_on_error=none || \ 45 | exit_failed "fio sync rand read FAILED" 46 | 47 | zonefs_umount 48 | 49 | zonefs_mount "$1" 50 | 51 | echo "Check sequential file random read (async)" 52 | 53 | # Async buffered random read 54 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 55 | --rw=randread --ioengine=libaio --iodepth=8 --max-jobs=8 \ 56 | --bs=131072 --verify=md5 --do_verify=1 \ 57 | --continue_on_error=none || \ 58 | exit_failed "fio async rand read FAILED" 59 | 60 | zonefs_umount 61 | 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0321.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file random read (direct)" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Fill sequential file" 21 | 22 | # Fill file 23 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 24 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 25 | --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ 26 | --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ 27 | --continue_on_error=none --direct=1 || \ 28 | exit_failed "fio write FAILED" 29 | 30 | sz=$(file_size "$zonefs_mntdir"/seq/0) 31 | [ "$sz" != "$seq_file_0_max_size" ] && \ 32 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 33 | 34 | zonefs_umount 35 | 36 | echo "Check sequential file random read (sync)" 37 | 38 | zonefs_mount "$1" 39 | 40 | # Sync direct random read 41 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 42 | --rw=randread --ioengine=psync --max-jobs=8 \ 43 | --direct=1 --bs=131072 --verify=md5 --do_verify=1 \ 44 | --continue_on_error=none || \ 45 | exit_failed "fio sync direct rand read FAILED" 46 | 47 | zonefs_umount 48 | 49 | zonefs_mount "$1" 50 | 51 | echo "Check sequential file random read (async)" 52 | 53 | # Async direct random read 54 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 55 | --rw=randread --ioengine=libaio --iodepth=8 --max-jobs=8 \ 56 | --direct=1 --bs=131072 --verify=md5 --do_verify=1 \ 57 | --continue_on_error=none || \ 58 | exit_failed "fio async direct rand read FAILED" 59 | 60 | zonefs_umount 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0322.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file seq read (buffered)" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Fill sequential file" 21 | 22 | # Fill file 23 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 24 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 25 | --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ 26 | --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ 27 | --continue_on_error=none --direct=1 || \ 28 | exit_failed "fio write FAILED" 29 | 30 | sz=$(file_size "$zonefs_mntdir"/seq/0) 31 | [ "$sz" != "$seq_file_0_max_size" ] && \ 32 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 33 | 34 | zonefs_umount 35 | 36 | echo "Check sequential file sequential read (sync)" 37 | 38 | zonefs_mount "$1" 39 | 40 | # Sync buffered sequential read 41 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 42 | --rw=read --ioengine=psync \ 43 | --bs=131072 --verify=md5 --do_verify=1 \ 44 | --continue_on_error=none || \ 45 | exit_failed "fio sync sequential read FAILED" 46 | 47 | zonefs_umount 48 | 49 | zonefs_mount "$1" 50 | 51 | echo "Check sequential file sequential read (async)" 52 | 53 | # Async buffered sequential read 54 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 55 | --rw=read --ioengine=libaio --iodepth=8 \ 56 | --bs=131072 --verify=md5 --do_verify=1 \ 57 | --continue_on_error=none || \ 58 | exit_failed "fio async sequential read FAILED" 59 | 60 | zonefs_umount 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0323.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file seq read (direct)" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Fill sequential file" 21 | 22 | # Fill file 23 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 24 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 25 | --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ 26 | --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ 27 | --continue_on_error=none --direct=1 || \ 28 | exit_failed "fio write FAILED" 29 | 30 | sz=$(file_size "$zonefs_mntdir"/seq/0) 31 | [ "$sz" != "$seq_file_0_max_size" ] && \ 32 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 33 | 34 | zonefs_umount 35 | 36 | echo "Check sequential file sequential read (sync)" 37 | 38 | zonefs_mount "$1" 39 | 40 | # Sync direct sequential read 41 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 42 | --rw=read --ioengine=psync --direct=1 \ 43 | --bs=131072 --verify=md5 --do_verify=1 \ 44 | --continue_on_error=none || \ 45 | exit_failed "fio sync direct sequential read FAILED" 46 | 47 | zonefs_umount 48 | 49 | zonefs_mount "$1" 50 | 51 | echo "Check sequential file random read (async)" 52 | 53 | # Async direct sequential read 54 | fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ 55 | --rw=read --ioengine=libaio --iodepth=8 \ 56 | --direct=1 --bs=131072 --verify=md5 --do_verify=1 \ 57 | --continue_on_error=none || \ 58 | exit_failed "fio async direct sequential read FAILED" 59 | 60 | zonefs_umount 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0324.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readahead" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file readahead" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | bs=$(block_size "$zonefs_mntdir"/seq/0) 21 | 22 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs="$bs" count=1 || \ 23 | exit_failed " --> FAILED" 24 | 25 | sz=$(file_size "$zonefs_mntdir"/seq/0) 26 | [ "$sz" != "$bs" ] && \ 27 | exit_failed " --> Invalid file size $sz B, expected $bs B" 28 | 29 | dd if="$zonefs_mntdir"/seq/0 of=/dev/null bs="$bs" count=1 || \ 30 | exit_failed " --> FAILED" 31 | 32 | zonefs_umount 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /tests/scripts/0325.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file read beyond eof" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file read beyond eof" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | bs=$(block_size "$zonefs_mntdir"/seq/0) 21 | 22 | dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs="$bs" count=1 || \ 23 | exit_failed " --> FAILED" 24 | 25 | sz=$(file_size "$zonefs_mntdir"/seq/0) 26 | [ "$sz" != "$bs" ] && \ 27 | exit_failed " --> Invalid file size $sz B, expected $bs B" 28 | 29 | dd if="$zonefs_mntdir"/seq/0 of=/dev/null bs="$(( bs * 2 ))" count=1 || \ 30 | exit_failed " --> FAILED" 31 | 32 | echo "Check sequential file read beyond max size" 33 | 34 | # Fill file 35 | fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ 36 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 37 | --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ 38 | --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ 39 | --continue_on_error=none --direct=1 || \ 40 | exit_failed "fio write FAILED" 41 | 42 | sz=$(file_size "$zonefs_mntdir"/seq/0) 43 | [ "$sz" != "$seq_file_0_max_size" ] && \ 44 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 45 | 46 | ofst=$(( ($seq_file_0_max_size - 512) / 512 )) 47 | dd if="$zonefs_mntdir"/seq/0 of=/dev/null \ 48 | bs="$(( bs * 2 ))" count=1 seek="$ofst" || \ 49 | exit_failed " --> FAILED" 50 | 51 | zonefs_umount 52 | 53 | exit 0 54 | -------------------------------------------------------------------------------- /tests/scripts/0326.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file dsync write (sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file dsync write (sync)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Check with O_DSYNC file open 21 | echo "Check writes with O_DSYNC" 22 | 23 | tools/zio --write --fflag=direct --fflag=dsync \ 24 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | sz=$(file_size "$zonefs_mntdir"/seq/0) 28 | [ "$sz" != "$seq_file_0_max_size" ] && \ 29 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 30 | 31 | # Test with RWF_DSYNC I/O flag 32 | echo "Check writes with RWF_DSYNC" 33 | 34 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 35 | exit_failed " --> FAILED" 36 | 37 | tools/zio --write --fflag=direct --ioflag=dsync \ 38 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 39 | exit_failed " --> FAILED" 40 | 41 | sz=$(file_size "$zonefs_mntdir"/seq/0) 42 | [ "$sz" != "$seq_file_0_max_size" ] && \ 43 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/scripts/0327.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file dsync write (async)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file dsync write (async)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Check with O_DSYNC file open 21 | echo "Check async writes with O_DSYNC" 22 | 23 | tools/zio --write --fflag=direct --fflag=dsync --async=8 \ 24 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | sz=$(file_size "$zonefs_mntdir"/seq/0) 28 | [ "$sz" != "$seq_file_0_max_size" ] && \ 29 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 30 | 31 | # Test with RWF_DSYNC I/O flag 32 | echo "Check writes with RWF_DSYNC" 33 | 34 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 35 | exit_failed " --> FAILED" 36 | 37 | tools/zio --write --fflag=direct --ioflag=dsync --async=8 \ 38 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 39 | exit_failed " --> FAILED" 40 | 41 | sz=$(file_size "$zonefs_mntdir"/seq/0) 42 | [ "$sz" != "$seq_file_0_max_size" ] && \ 43 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/scripts/0328.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file dsync write (sync, iovec)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file dsync write (sync, iovec)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Check with O_DSYNC file open 21 | echo "Check writes with O_DSYNC and iovecs" 22 | 23 | tools/zio --write --iovec --fflag=direct --fflag=dsync \ 24 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | sz=$(file_size "$zonefs_mntdir"/seq/0) 28 | [ "$sz" != "$seq_file_0_max_size" ] && \ 29 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 30 | 31 | # Test with RWF_DSYNC I/O flag 32 | echo "Check writes with RWF_DSYNC and iovecs" 33 | 34 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 35 | exit_failed " --> FAILED" 36 | 37 | tools/zio --write --iovec --fflag=direct --ioflag=dsync \ 38 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 39 | exit_failed " --> FAILED" 40 | 41 | sz=$(file_size "$zonefs_mntdir"/seq/0) 42 | [ "$sz" != "$seq_file_0_max_size" ] && \ 43 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/scripts/0329.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file dsync write (async, iovec)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file dsync write (async, iovec)" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Check with O_DSYNC file open 21 | echo "Check async writes with O_DSYNC and iovecs" 22 | 23 | tools/zio --write --fflag=direct --fflag=dsync --async=8 \ 24 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | sz=$(file_size "$zonefs_mntdir"/seq/0) 28 | [ "$sz" != "$seq_file_0_max_size" ] && \ 29 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 30 | 31 | # Test with RWF_DSYNC I/O flag 32 | echo "Check writes with RWF_APPEND and iovecs" 33 | 34 | truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ 35 | exit_failed " --> FAILED" 36 | 37 | tools/zio --write --fflag=direct --ioflag=dsync --async=8 \ 38 | --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ 39 | exit_failed " --> FAILED" 40 | 41 | sz=$(file_size "$zonefs_mntdir"/seq/0) 42 | [ "$sz" != "$seq_file_0_max_size" ] && \ 43 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/scripts/0330.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file large read (buffered)" 12 | exit 0 13 | fi 14 | 15 | require_program fio 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Fill sequential file" 21 | 22 | bs=$(( 4 * 1024 * 1024 )) 23 | if [ ${bs} -gt ${zone_cap_bytes} ]; then 24 | bs=${zone_cap_bytes} 25 | fi 26 | if [ ${bs} -lt ${seq_file_0_max_size} ]; then 27 | bs=${seq_file_0_max_size} 28 | fi 29 | 30 | # Fill file 31 | fio --name=seqwrite --filename="${zonefs_mntdir}"/seq/0 \ 32 | --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ 33 | --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ 34 | --bs=${bs} --size="${seq_file_0_max_size}" --verify=md5 --do_verify=1 \ 35 | --continue_on_error=none --direct=1 || \ 36 | exit_failed "fio write FAILED" 37 | 38 | sz=$(file_size "$zonefs_mntdir"/seq/0) 39 | [ "$sz" != "$seq_file_0_max_size" ] && \ 40 | exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" 41 | 42 | zonefs_umount 43 | 44 | echo "Check sequential file large read (sync)" 45 | 46 | zonefs_mount "$1" 47 | 48 | # Sync buffered sequential read 49 | fio --name=verify_sync --filename="${zonefs_mntdir}"/seq/0 \ 50 | --rw=read --ioengine=psync \ 51 | --bs=${bs} --verify=md5 --do_verify=1 \ 52 | --continue_on_error=none || \ 53 | exit_failed "fio sync sequential read FAILED" 54 | 55 | zonefs_umount 56 | 57 | zonefs_mount "$1" 58 | 59 | echo "Check sequential file large read (async)" 60 | 61 | # Async buffered sequential read 62 | fio --name=verify_async --filename="$zonefs_mntdir"/seq/0 \ 63 | --rw=read --ioengine=libaio --iodepth=8 \ 64 | --bs=${bs} --verify=md5 --do_verify=1 \ 65 | --continue_on_error=none || \ 66 | exit_failed "fio async sequential read FAILED" 67 | 68 | zonefs_umount 69 | 70 | exit 0 71 | -------------------------------------------------------------------------------- /tests/scripts/0400.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2021 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Swap file on conventional file" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | 17 | echo "Check swap file on conventional file" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | chmod 600 "$zonefs_mntdir"/cnv/0 || \ 23 | exit_failed " --> FAILED" 24 | mkswap "$zonefs_mntdir"/cnv/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | swapon "$zonefs_mntdir"/cnv/0 || \ 28 | exit_failed " --> FAILED" 29 | 30 | swapoff "$zonefs_mntdir"/cnv/0 || \ 31 | exit_failed " --> FAILED" 32 | 33 | zonefs_umount 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /tests/scripts/0401.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2021 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Swap file on sequential file" 12 | exit 0 13 | fi 14 | 15 | echo "Check swap file on sequential file" 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | # Fill the file 21 | tools/zio --write --fflag=direct \ 22 | --size=131072 --async=8 "$zonefs_mntdir"/seq/0 || \ 23 | exit_failed " --> FAILED" 24 | chmod 600 "$zonefs_mntdir"/seq/0 || \ 25 | exit_failed " --> FAILED" 26 | 27 | # mkswap should fail (cannot write swap file header) 28 | mkswap "$zonefs_mntdir"/seq/0 && \ 29 | exit_failed " --> SUCCESS (should FAIL)" 30 | 31 | # Create a swap file and copy it to a sequential file to check 32 | # the kernel side zonefs swap activate check. 33 | sudo fallocate -l "$seq_file_0_max_size" /tmp/swapfile 34 | chmod 600 /tmp/swapfile || \ 35 | exit_failed " --> FAILED" 36 | mkswap /tmp/swapfile || \ 37 | exit_failed " --> FAILED" 38 | dd if=/tmp/swapfile of="$zonefs_mntdir"/seq/0 \ 39 | bs=131072 oflag=direct || 40 | exit_failed " --> FAILED" 41 | 42 | swapon "$zonefs_mntdir"/seq/0 && \ 43 | exit_failed " --> SUCCESS (should FAIL)" 44 | 45 | zonefs_umount 46 | 47 | rm -f /tmp/swapfile 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /tests/scripts/0510.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs attr after format" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | echo "Check max write open seq files" 21 | 22 | dev_val=$(get_max_open_zones "$1") 23 | sysfs_val=$(sysfs_max_wro_seq_files "$1") 24 | [[ ${sysfs_val} -eq ${dev_val} ]] || \ 25 | exit_failed "max_wro_seq_files is ${sysfs_val} (should be ${dev_val})" 26 | 27 | echo "Check max active seq files" 28 | 29 | dev_val=$(get_max_active_zones "$1") 30 | sysfs_val=$(sysfs_max_active_seq_files "$1") 31 | [[ ${sysfs_val} -eq ${dev_val} ]] || \ 32 | exit_failed "max_active_seq_files is ${sysfs_val} (should be ${dev_val})" 33 | 34 | echo "Check write open seq files count" 35 | 36 | sysfs_val=$(sysfs_nr_wro_seq_files "$1") 37 | [[ ${sysfs_val} -eq 0 ]] || \ 38 | exit_failed "nr_wro_seq_files is ${sysfs_val} (should be 0)" 39 | 40 | echo "Check active seq files count" 41 | 42 | sysfs_val=$(sysfs_nr_active_seq_files "$1") 43 | [[ ${sysfs_val} -eq 0 ]] || \ 44 | exit_failed "nr_active_seq_files is ${sysfs_val} (should be 0)" 45 | 46 | zonefs_umount 47 | 48 | exit 0 49 | -------------------------------------------------------------------------------- /tests/scripts/0511.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files active after mount (open zones)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | # Format and then write the first file seq zone to activate it 18 | # (emulate an EPO event after a file was open) 19 | zonefs_mkfs "$1" 20 | 21 | zstart=$(( (nr_cnv_zones + 1) * zone_sectors )) 22 | blkzone open -o ${zstart} -l ${zone_sectors} "$1" || \ 23 | exit_failed "Explicit open zone failed" 24 | 25 | echo "Check active seq files count" 26 | 27 | zonefs_mount "$1" 28 | 29 | sysfs_val=$(sysfs_nr_active_seq_files "$1") 30 | [[ ${sysfs_val} -eq 0 ]] || \ 31 | exit_failed "nr_active_seq_files is ${sysfs_val} (should be 0)" 32 | 33 | zonefs_umount 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /tests/scripts/0512.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files active after mount (active zones)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | # Check that the number of active files matches the number of 18 | # active zones. 19 | zonefs_mkfs "$1" 20 | 21 | i=0 22 | nract=$(get_max_open_zones "$1") 23 | if [ ${nract} -eq 0 ]; then 24 | nract=4 25 | fi 26 | 27 | echo "Writing 4K in ${nract} zones" 28 | 29 | for((i=1; i<=${nract}; i++)); do 30 | zstart=$(( (nr_cnv_zones + i) * zone_bytes / 4096 )) 31 | dd if=/dev/zero of="$1" bs=4096 seek=${zstart} count=1 oflag=direct || 32 | exit_failed "write seq zone failed" 33 | done 34 | 35 | echo "Check active seq files count" 36 | 37 | zonefs_mount "$1" 38 | 39 | sysfs_val=$(sysfs_nr_active_seq_files "$1") 40 | [[ ${sysfs_val} -eq ${nract} ]] || \ 41 | exit_failed "nr_active_seq_files is ${sysfs_val} (should be 4)" 42 | 43 | zonefs_umount 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/scripts/0513.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files write-open (default)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | i=0 21 | maxopen=$(get_max_open_zones "$1") 22 | if [ ${maxopen} -eq 0 ]; then 23 | maxopen=4 24 | fi 25 | 26 | echo "Check read open" 27 | 28 | # Check that any number of file can be read-open 29 | for((i=1; i<=$(( maxopen + 1 )); i++)); do 30 | echo "Opening ${i} files for reading" 31 | 32 | tools/zopen --nrfiles="$i" --fflag=read --pause "${zonefs_mntdir}/seq" & 33 | zopid=$! 34 | sleep 1 35 | 36 | nract=$(sysfs_nr_active_seq_files "$1") 37 | nrwro=$(sysfs_nr_wro_seq_files "$1") 38 | 39 | kill ${zopid} 40 | wait ${zopid} 41 | 42 | [[ ${nract} -eq 0 ]] || \ 43 | exit_failed "nr_active_seq_files is ${nract} (should be 0)" 44 | [[ ${nrwro} -eq 0 ]] || \ 45 | exit_failed "nr_wro_seq_files is ${nrwro} (should be 0)" 46 | done 47 | 48 | echo "Check write open" 49 | 50 | # Check that any number of file can be write-open 51 | for((i=1; i<=$(( maxopen + 1 )); i++)); do 52 | echo "Opening ${i} files for writing" 53 | 54 | tools/zopen --nrfiles="$i" --fflag=write --pause "${zonefs_mntdir}/seq" & 55 | zopid=$! 56 | sleep 1 57 | 58 | nract=$(sysfs_nr_active_seq_files "$1") 59 | nrwro=$(sysfs_nr_wro_seq_files "$1") 60 | 61 | kill ${zopid} 62 | wait ${zopid} 63 | 64 | [[ ${nract} -eq 0 ]] || \ 65 | exit_failed "nr_active_seq_files is ${nract} (should be 0)" 66 | [[ ${nrwro} -eq ${i} ]] || \ 67 | exit_failed "nr_wro_seq_files is ${nrwro} (should be $i)" 68 | done 69 | 70 | zonefs_umount 71 | 72 | exit 0 73 | -------------------------------------------------------------------------------- /tests/scripts/0514.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files write-open (explicit-open)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "-o explicit-open $1" 19 | 20 | i=0 21 | devmaxopen=$(get_max_open_zones "$1") 22 | devmaxactive=$(get_max_active_zones "$1") 23 | maxopen=${devmaxopen} 24 | if [ ${maxopen} -eq 0 ]; then 25 | maxopen=${devmaxactive} 26 | if [ ${maxopen} -eq 0 ]; then 27 | maxopen=4 28 | fi 29 | fi 30 | 31 | echo "Check read open" 32 | 33 | # Check that any number of file can be read-open 34 | for((i=1; i<=$(( maxopen + 1 )); i++)); do 35 | echo "Opening ${i} files for reading" 36 | 37 | tools/zopen --nrfiles="$i" --fflag=read --pause "${zonefs_mntdir}/seq" & 38 | zopid=$! 39 | sleep 1 40 | 41 | nract=$(sysfs_nr_active_seq_files "$1") 42 | nrwro=$(sysfs_nr_wro_seq_files "$1") 43 | 44 | kill ${zopid} 45 | wait ${zopid} 46 | 47 | [[ ${nract} -eq 0 ]] || \ 48 | exit_failed "nr_active_seq_files is ${nract} (should be 0)" 49 | [[ ${nrwro} -eq 0 ]] || \ 50 | exit_failed "nr_wro_seq_files is ${nrwro} (should be 0)" 51 | done 52 | 53 | echo "Check write open" 54 | 55 | function exit_error() 56 | { 57 | local zopid="$1" 58 | 59 | # Close the files 60 | kill ${zopid} 61 | wait ${zopid} 62 | 63 | exit_failed "$2" 64 | } 65 | 66 | # Check that any number of file can be write-open 67 | for((i=1; i<=${maxopen}; i++)); do 68 | echo "Opening ${i} files for writing" 69 | 70 | tools/zopen --nrfiles="$i" --fflag=write --pause "${zonefs_mntdir}/seq" & 71 | zopid=$! 72 | sleep 1 73 | 74 | if [ ${devmaxopen} -ne 0 ]; then 75 | nract=$(sysfs_nr_active_seq_files "$1") 76 | [[ ${nract} -eq ${i} ]] || \ 77 | exit_error ${zopid} "nr_active_seq_files is ${nract} (should be ${i})" 78 | fi 79 | 80 | nrwro=$(sysfs_nr_wro_seq_files "$1") 81 | [[ ${nrwro} -eq ${i} ]] || \ 82 | exit_error ${zopid} "nr_wro_seq_files is ${nrwro} (should be ${i})" 83 | 84 | # Close the files 85 | kill ${zopid} 86 | wait ${zopid} 87 | 88 | # Now all counters should be back to 0 since the files where not written 89 | nract=$(sysfs_nr_active_seq_files "$1") 90 | [[ ${nract} -eq 0 ]] || \ 91 | exit_failed "nr_active_seq_files is ${nract} after close (should be 0)" 92 | 93 | nrwro=$(sysfs_nr_wro_seq_files "$1") 94 | [[ ${nrwro} -eq 0 ]] || \ 95 | exit_failed "nr_wro_seq_files is ${nrwro} after close (should be 0)" 96 | done 97 | 98 | if [ ${devmaxopen} -ne 0 ]; then 99 | # Opening one more file than max-open should fail 100 | echo "Opening $(( maxopen + 1 )) files for writing (failure expected)" 101 | tools/zopen --nrfiles="$(( maxopen + 1 ))" \ 102 | --fflag=write "${zonefs_mntdir}/seq" && \ 103 | exit_failed "Write-opening $(( maxopen + 1 )) > ${maxopen} files succedded (should fail)" 104 | fi 105 | 106 | sleep 1 107 | 108 | nract=$(sysfs_nr_active_seq_files "$1") 109 | [[ ${nract} -eq 0 ]] || \ 110 | exit_failed "nr_active_seq_files is ${nract} after close (should be 0)" 111 | 112 | nrwro=$(sysfs_nr_wro_seq_files "$1") 113 | [[ ${nrwro} -eq 0 ]] || \ 114 | exit_failed "nr_wro_seq_files is ${nrwro} after close (should be 0)" 115 | 116 | zonefs_umount 117 | 118 | exit 0 119 | -------------------------------------------------------------------------------- /tests/scripts/0515.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files active after write (default)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | i=0 21 | maxact=$(get_max_active_zones "$1") 22 | if [ ${maxact} -eq 0 ]; then 23 | maxact=4 24 | fi 25 | 26 | # Write 4K in maxact files 27 | n=0 28 | for((i=0; i<${maxact}; i++)); do 29 | echo "Writing seq file ${i}" 30 | 31 | dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ 32 | count=1 oflag=direct || \ 33 | exit_failed " --> Write seq file ${i} FAILED" 34 | 35 | n=$(( n + 1 )) 36 | 37 | nract=$(sysfs_nr_active_seq_files "$1") 38 | [[ ${nract} -eq ${n} ]] || \ 39 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" 40 | 41 | nrwro=$(sysfs_nr_wro_seq_files "$1") 42 | [[ ${nrwro} -eq 0 ]] || \ 43 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 44 | done 45 | 46 | # Remount and check again 47 | zonefs_umount 48 | zonefs_mount "$1" 49 | 50 | nract=$(sysfs_nr_active_seq_files "$1") 51 | [[ ${nract} -eq ${maxact} ]] || \ 52 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${maxact})" 53 | 54 | nrwro=$(sysfs_nr_wro_seq_files "$1") 55 | [[ ${nrwro} -eq 0 ]] || \ 56 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 57 | 58 | # Fill-up the files: the active count should go to 0 59 | n=${maxact} 60 | for((i=0; i<${maxact}; i++)); do 61 | echo "Filling seq file ${i}" 62 | 63 | fsize=$(file_max_size "${zonefs_mntdir}/seq/${i}") 64 | wcount=$(( fsize / 1048576 - 1 )) 65 | 66 | dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ 67 | seek=1 count=${wcount} oflag=direct conv=notrunc || \ 68 | exit_failed " --> Fill seq file ${i} FAILED" 69 | 70 | n=$(( n - 1 )) 71 | 72 | nract=$(sysfs_nr_active_seq_files "$1") 73 | [[ ${nract} -eq ${n} ]] || \ 74 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" 75 | 76 | nrwro=$(sysfs_nr_wro_seq_files "$1") 77 | [[ ${nrwro} -eq 0 ]] || \ 78 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 79 | done 80 | 81 | zonefs_umount 82 | 83 | exit 0 84 | -------------------------------------------------------------------------------- /tests/scripts/0516.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files active after truncate to 0 (default)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | i=0 21 | maxact=$(get_max_active_zones "$1") 22 | if [ ${maxact} -eq 0 ]; then 23 | maxact=4 24 | fi 25 | 26 | # Write 4K in maxact files 27 | n = 0 28 | for((i=0; i<${maxact}; i++)); do 29 | echo "Writing seq file ${i}" 30 | 31 | dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ 32 | count=1 oflag=direct || \ 33 | exit_failed " --> Write seq file ${i} FAILED" 34 | 35 | n=$(( n + 1 )) 36 | 37 | nract=$(sysfs_nr_active_seq_files "$1") 38 | [[ ${nract} -eq ${n} ]] || \ 39 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" 40 | 41 | nrwro=$(sysfs_nr_wro_seq_files "$1") 42 | [[ ${nrwro} -eq 0 ]] || \ 43 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 44 | done 45 | 46 | # Remount and check again 47 | zonefs_umount 48 | zonefs_mount "$1" 49 | 50 | nract=$(sysfs_nr_active_seq_files "$1") 51 | [[ ${nract} -eq ${maxact} ]] || \ 52 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${maxact})" 53 | 54 | nrwro=$(sysfs_nr_wro_seq_files "$1") 55 | [[ ${nrwro} -eq 0 ]] || \ 56 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 57 | 58 | # Truncate the files: the active count should go to 0 59 | n=${maxact} 60 | for((i=0; i<${maxact}; i++)); do 61 | echo "Truncating seq file ${i}" 62 | 63 | truncate_file "${zonefs_mntdir}/seq/${i}" 0 || \ 64 | exit_failed " --> Truncate seq file ${i} to 0 FAILED" 65 | 66 | n=$(( n - 1 )) 67 | 68 | nract=$(sysfs_nr_active_seq_files "$1") 69 | [[ ${nract} -eq ${n} ]] || \ 70 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" 71 | 72 | nrwro=$(sysfs_nr_wro_seq_files "$1") 73 | [[ ${nrwro} -eq 0 ]] || \ 74 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 75 | done 76 | 77 | zonefs_umount 78 | 79 | exit 0 80 | -------------------------------------------------------------------------------- /tests/scripts/0517.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs seq files active after truncate to max (default)" 12 | exit 0 13 | fi 14 | 15 | require_sysfs 16 | 17 | zonefs_mkfs "$1" 18 | zonefs_mount "$1" 19 | 20 | i=0 21 | maxact=$(get_max_active_zones "$1") 22 | if [ ${maxact} -eq 0 ]; then 23 | maxact=4 24 | fi 25 | 26 | # Write 4K in maxact files 27 | n=0 28 | for((i=0; i<${maxact}; i++)); do 29 | echo "Writing seq file ${i}" 30 | 31 | dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ 32 | count=1 oflag=direct || \ 33 | exit_failed " --> Write seq file ${i} FAILED" 34 | 35 | n=$(( n + 1 )) 36 | 37 | nract=$(sysfs_nr_active_seq_files "$1") 38 | [[ ${nract} -eq ${n} ]] || \ 39 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" 40 | 41 | nrwro=$(sysfs_nr_wro_seq_files "$1") 42 | [[ ${nrwro} -eq 0 ]] || \ 43 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 44 | done 45 | 46 | # Remount and check again 47 | zonefs_umount 48 | zonefs_mount "$1" 49 | 50 | nract=$(sysfs_nr_active_seq_files "$1") 51 | [[ ${nract} -eq ${maxact} ]] || \ 52 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${maxact})" 53 | 54 | nrwro=$(sysfs_nr_wro_seq_files "$1") 55 | [[ ${nrwro} -eq 0 ]] || \ 56 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 57 | 58 | # Fill-up the files using truncate: the active count should go to 0 59 | n=${maxact} 60 | for((i=0; i<${maxact}; i++)); do 61 | echo "Filling seq file ${i}" 62 | 63 | fsize=$(file_max_size "${zonefs_mntdir}/seq/${i}") 64 | truncate_file "${zonefs_mntdir}/seq/${i}" ${fsize} || \ 65 | exit_failed " --> Truncate seq file ${i} to max size FAILED" 66 | 67 | n=$(( n - 1 )) 68 | 69 | nract=$(sysfs_nr_active_seq_files "$1") 70 | [[ ${nract} -eq ${n} ]] || \ 71 | exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" 72 | 73 | nrwro=$(sysfs_nr_wro_seq_files "$1") 74 | [[ ${nrwro} -eq 0 ]] || \ 75 | exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" 76 | done 77 | 78 | zonefs_umount 79 | 80 | exit 0 81 | -------------------------------------------------------------------------------- /tests/scripts/0518.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs conv files write-open" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_sysfs 17 | 18 | zonefs_mkfs "$1" 19 | zonefs_mount "$1" 20 | 21 | echo "Check write open" 22 | 23 | # Check that opening a conv file does not change the write open count 24 | tools/zopen --nrfiles="$nr_cnv_files" --fflag=read --pause "${zonefs_mntdir}/cnv" & 25 | zopid=$! 26 | sleep 1 27 | 28 | nract=$(sysfs_nr_active_seq_files "$1") 29 | [[ ${nract} -eq 0 ]] || \ 30 | exit_failed "nr_active_seq_files is ${nract} after read open (should be 0)" 31 | 32 | nrwro=$(sysfs_nr_wro_seq_files "$1") 33 | [[ ${nrwro} -eq 0 ]] || \ 34 | exit_failed "nr_wro_seq_files is ${nrwro} after read open (should be 0)" 35 | 36 | kill ${zopid} 37 | wait ${zopid} 38 | 39 | nract=$(sysfs_nr_active_seq_files "$1") 40 | [[ ${nract} -eq 0 ]] || \ 41 | exit_failed "nr_active_seq_files is ${nract} after read close (should be 0)" 42 | 43 | nrwro=$(sysfs_nr_wro_seq_files "$1") 44 | [[ ${nrwro} -eq 0 ]] || \ 45 | exit_failed "nr_wro_seq_files is ${nrwro} after read close (should be 0)" 46 | 47 | # Same with write open 48 | tools/zopen --nrfiles="$nr_cnv_files" --fflag=write --pause "${zonefs_mntdir}/cnv" & 49 | zopid=$! 50 | sleep 1 51 | 52 | nract=$(sysfs_nr_active_seq_files "$1") 53 | [[ ${nract} -eq 0 ]] || \ 54 | exit_failed "nr_active_seq_files is ${nract} after write open (should be 0)" 55 | 56 | nrwro=$(sysfs_nr_wro_seq_files "$1") 57 | [[ ${nrwro} -eq 0 ]] || \ 58 | exit_failed "nr_wro_seq_files is ${nrwro} after write open (should be 0)" 59 | 60 | kill ${zopid} 61 | wait ${zopid} 62 | 63 | nract=$(sysfs_nr_active_seq_files "$1") 64 | [[ ${nract} -eq 0 ]] || \ 65 | exit_failed "nr_active_seq_files is ${nract} after write close (should be 0)" 66 | 67 | nrwro=$(sysfs_nr_wro_seq_files "$1") 68 | [[ ${nrwro} -eq 0 ]] || \ 69 | exit_failed "nr_wro_seq_files is ${nrwro} after write close (should be 0)" 70 | 71 | zonefs_umount 72 | 73 | exit 0 74 | -------------------------------------------------------------------------------- /tests/scripts/0519.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sysfs conv files active after write" 12 | exit 0 13 | fi 14 | 15 | require_cnv_files 16 | require_sysfs 17 | 18 | zonefs_mkfs "$1" 19 | zonefs_mount "$1" 20 | 21 | i=0 22 | maxact=$(get_max_active_zones "$1") 23 | if [ ${maxact} -eq 0 ]; then 24 | maxact=4 25 | fi 26 | maxact=$(min ${maxact} ${nr_cnv_files}) 27 | 28 | # Write 4K in maxact conv files 29 | for((i=0; i<${maxact}; i++)); do 30 | echo "Writing conv file ${i}" 31 | 32 | dd if=/dev/zero of="${zonefs_mntdir}/cnv/${i}" bs=4096 \ 33 | count=1 oflag=direct conv=nocreat,notrunc || \ 34 | exit_failed "Write cnv file ${i} failed" 35 | 36 | nract=$(sysfs_nr_active_seq_files "$1") 37 | [[ ${nract} -eq 0 ]] || \ 38 | exit_failed "nr_active_seq_files is ${nract} (should be 0)" 39 | 40 | nrwro=$(sysfs_nr_wro_seq_files "$1") 41 | [[ ${nrwro} -eq 0 ]] || \ 42 | exit_failed "nr_wro_seq_files is ${nrwro} after close (should be 0)" 43 | done 44 | 45 | zonefs_umount 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/scripts/0600.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=remount-ro, sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try writing seq file 0" 32 | write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 33 | 34 | # Truncate should also fail 35 | echo "Try file truncate to 0 (zone reset)" 36 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 37 | exit_failed " --> truncate SUCCESS (should FAIL)" 38 | check_file_size "${zonefs_mntdir}/seq/0" 4096 39 | 40 | # File permission should not have changed but the entire file system 41 | # should now be read-only 42 | echo "Check permissions" 43 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 44 | check_fs_is_readonly 45 | 46 | # Evicting the inode should not change anything 47 | echo "Check file size and permissions after eviction" 48 | drop_inode_cache 49 | check_file_size "${zonefs_mntdir}/seq/0" 4096 50 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 51 | 52 | # We should still be able to read the file 53 | echo "Try reading seq file 0" 54 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 55 | exit_failed " --> read FAILED" 56 | 57 | # We should not be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file_err "${zonefs_mntdir}/seq/1" 4096 0 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0601.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=remount-ro, async)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "$1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try async writing seq file 0" 32 | write_file_async_err "${zonefs_mntdir}/seq/0" 4096 4096 33 | 34 | # Truncate should also fail 35 | echo "Try file truncate to 0 (zone reset)" 36 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 37 | exit_failed " --> truncate SUCCESS (should FAIL)" 38 | check_file_size "${zonefs_mntdir}/seq/0" 4096 39 | 40 | # File permission should not have changed but the entire file system 41 | # should now be read-only 42 | echo "Check permissions" 43 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 44 | check_fs_is_readonly 45 | 46 | # Evicting the inode should not change anything 47 | echo "Check file size and permissions after eviction" 48 | drop_inode_cache 49 | check_file_size "${zonefs_mntdir}/seq/0" 4096 50 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 51 | 52 | # We should still be able to read the file 53 | echo "Try reading seq file 0" 54 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 55 | exit_failed " --> read FAILED" 56 | 57 | # We should not be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file_err "${zonefs_mntdir}/seq/1" 4096 0 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0602.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=zone-ro, sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "-o errors=zone-ro $1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try writing seq file 0" 32 | write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 33 | 34 | # Truncate should also fail 35 | echo "Try file truncate to 0 (zone reset)" 36 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 37 | exit_failed " --> truncate SUCCESS (should FAIL)" 38 | check_file_size "${zonefs_mntdir}/seq/0" 4096 39 | 40 | # File permission should have changed and the file system 41 | # should still be usable 42 | echo "Check permissions" 43 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 44 | check_fs_is_writable 45 | 46 | # Evicting the inode should not change anything 47 | echo "Check file size and permissions after eviction" 48 | drop_inode_cache 49 | check_file_size "${zonefs_mntdir}/seq/0" 4096 50 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 51 | 52 | # We should still be able to read the file 53 | echo "Try reading seq file 0" 54 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 55 | exit_failed " --> read FAILED" 56 | 57 | # We should be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file "${zonefs_mntdir}/seq/1" 4096 4096 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0603.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=zone-ro, async)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "-o errors=zone-ro $1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try async writing seq file 0" 32 | write_file_async_err "${zonefs_mntdir}/seq/0" 4096 4096 33 | 34 | # Truncate should also fail 35 | echo "Try file truncate to 0 (zone reset)" 36 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 37 | exit_failed " --> truncate SUCCESS (should FAIL)" 38 | check_file_size "${zonefs_mntdir}/seq/0" 4096 39 | 40 | # File permission should have changed and the file system 41 | # should still be usable 42 | echo "Check permissions" 43 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 44 | check_fs_is_writable 45 | 46 | # Evicting the inode should not change anything 47 | echo "Check file size and permissions after eviction" 48 | drop_inode_cache 49 | check_file_size "${zonefs_mntdir}/seq/0" 4096 50 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 51 | 52 | # We should still be able to read the file 53 | echo "Try reading seq file 0" 54 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 55 | exit_failed " --> read FAILED" 56 | 57 | # We should be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file "${zonefs_mntdir}/seq/1" 4096 4096 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0604.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=zone-offline, sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "-o errors=zone-offline $1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try writing seq file 0" 32 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 33 | 34 | # Truncate should also fail 35 | echo "Try file truncate to 0 (zone reset)" 36 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 37 | exit_failed " --> truncate SUCCESS (should FAIL)" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | 40 | # File permission should have changed and the file system 41 | # should still be usable 42 | echo "Check permissions" 43 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 44 | check_fs_is_writable 45 | 46 | # Evicting the inode should not change anything 47 | echo "Check file size and permissions after eviction" 48 | drop_inode_cache 49 | check_file_size "${zonefs_mntdir}/seq/0" 0 50 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 51 | 52 | # We should not be able to read the file 53 | echo "Try reading seq file 0" 54 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 && \ 55 | exit_failed " --> read SUCCESS (should FAIL)" 56 | 57 | # We should be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file "${zonefs_mntdir}/seq/1" 4096 4096 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0605.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=zone-offline, async)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "-o errors=zone-offline $1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try async writing seq file 0" 32 | write_file_async_err "${zonefs_mntdir}/seq/0" 4096 0 33 | 34 | # Truncate should also fail 35 | echo "Try file truncate to 0 (zone reset)" 36 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 37 | exit_failed " --> truncate SUCCESS (should FAIL)" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | 40 | # File permission should have changed and the file system 41 | # should still be usable 42 | echo "Check permissions" 43 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 44 | check_fs_is_writable 45 | 46 | # Evicting the inode should not change anything 47 | echo "Check file size and permissions after eviction" 48 | drop_inode_cache 49 | check_file_size "${zonefs_mntdir}/seq/0" 0 50 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 51 | 52 | # We should not be able to read the file 53 | echo "Try reading seq file 0" 54 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 && \ 55 | exit_failed " --> read SUCCESS (should FAIL)" 56 | 57 | # We should be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file "${zonefs_mntdir}/seq/1" 4096 4096 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0606.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=repair, sync)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "-o errors=repair $1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail. For the expected file size, there are 2 cases: 31 | # 1) zonefs is doing regular writes: the expected file size is 4K x 2 as 32 | # the write will fail. 33 | # 2) zonefs is doing zone append writes: the expected file size is 4K x 3 as 34 | # the write will succeed. 35 | echo "Try writing seq file 0" 36 | write_file_err "${zonefs_mntdir}/seq/0" 4096 8192 12288 37 | 38 | # File permission should not have changed and the file system 39 | # should still be usable 40 | echo "Check permissions" 41 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 42 | check_fs_is_writable 43 | 44 | # Evicting the inode should not change anything 45 | echo "Check file size and permissions after eviction" 46 | drop_inode_cache 47 | check_file_size "${zonefs_mntdir}/seq/0" 8192 12288 48 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 49 | 50 | # We should still be able to read the file 51 | echo "Try reading seq file 0" 52 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 53 | exit_failed " --> read FAILED" 54 | 55 | # Truncate should be OK 56 | echo "Try file truncate to 0 (zone reset)" 57 | truncate_file "${zonefs_mntdir}/seq/0" 0 || \ 58 | exit_failed " --> truncate FAILED" 59 | check_file_size "${zonefs_mntdir}/seq/0" 0 60 | 61 | # We should be able to write another file 62 | echo "Try writing seq file 1" 63 | write_file "${zonefs_mntdir}/seq/1" 4096 4096 64 | 65 | zonefs_umount 66 | 67 | exit 0 68 | -------------------------------------------------------------------------------- /tests/scripts/0607.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file write IO error (errors=repair, async)" 12 | exit 0 13 | fi 14 | 15 | echo "Check handling of sequential file write IO error" 16 | 17 | require_write_mounted_dev "$1" 18 | 19 | zonefs_mkfs "$1" 20 | zonefs_mount "-o errors=repair $1" 21 | 22 | # Writing should be OK 23 | echo "Write seq file 0" 24 | write_file "${zonefs_mntdir}/seq/0" 4096 25 | 26 | # Move the zone write pointer without the FS knowing about it 27 | echo "Write seq file 0 zone directly" 28 | write_file_zone "$1" "${zonefs_mntdir}/seq/0" 29 | 30 | # Now, writing should fail 31 | echo "Try writing seq file 0" 32 | write_file_async_err "${zonefs_mntdir}/seq/0" 4096 8192 33 | 34 | # File permission should not have changed and the file system 35 | # should still be usable 36 | echo "Check permissions" 37 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 38 | check_fs_is_writable 39 | 40 | # Evicting the inode should not change anything 41 | echo "Check file size and permissions after eviction" 42 | drop_inode_cache 43 | check_file_size "${zonefs_mntdir}/seq/0" 8192 44 | check_file_perm "${zonefs_mntdir}/seq/0" "640" 45 | 46 | # We should still be able to read the file 47 | echo "Try reading seq file 0" 48 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 49 | exit_failed " --> read FAILED" 50 | 51 | # Truncate should be OK 52 | echo "Try file truncate to 0 (zone reset)" 53 | truncate_file "${zonefs_mntdir}/seq/0" 0 || \ 54 | exit_failed " --> truncate FAILED" 55 | check_file_size "${zonefs_mntdir}/seq/0" 0 56 | 57 | # We should be able to write another file 58 | echo "Try writing seq file 1" 59 | write_file "${zonefs_mntdir}/seq/1" 4096 4096 60 | 61 | zonefs_umount 62 | 63 | exit 0 64 | -------------------------------------------------------------------------------- /tests/scripts/0610.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=remount-ro, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at mount time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone readonly and remount 30 | echo "Remounting FS with seq file 0 zone as read-only" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_readonly "${nulldev}" 33 | zonefs_mount "${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing the readonly file should fail 43 | echo "Try writing readonly seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Try writing to seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0611.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=remount-ro, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at io-error time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone readonly 30 | set_nullb_first_seq_zone_readonly "${nulldev}" 31 | 32 | # Writing should now fail 33 | echo "Try writing readonly seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 35 | 36 | # Truncate should also fail 37 | echo "Try file truncate to 0 (zone reset)" 38 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 39 | exit_failed " --> truncate SUCCESS (should FAIL)" 40 | check_file_size "${zonefs_mntdir}/seq/0" 4096 41 | 42 | # File permission should have changed and the entire file system 43 | # should now be read-only 44 | echo "Check permissions" 45 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 46 | check_fs_is_readonly 47 | 48 | # Evicting the inode should not change anything 49 | echo "Check file size and permissions after eviction" 50 | drop_inode_cache 51 | check_file_size "${zonefs_mntdir}/seq/0" 4096 52 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 53 | 54 | # We should still be able to read the file 55 | echo "Try reading seq file 0" 56 | dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ 57 | exit_failed " --> read FAILED" 58 | 59 | # We should not be able to write another file 60 | echo "Try writing seq file 1" 61 | write_file_err "${zonefs_mntdir}/seq/1" 4096 0 62 | 63 | zonefs_umount 64 | 65 | destroy_nullb ${nulldev} 66 | 67 | exit 0 68 | -------------------------------------------------------------------------------- /tests/scripts/0612.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=zone-ro, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at mount time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone readonly and remount 30 | echo "Remounting FS with seq file 0 zone as read-only" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_readonly "${nulldev}" 33 | zonefs_mount "-o errors=zone-ro ${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "Check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing to he readonly file should fail 43 | echo "Try writing readonly seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Write seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0613.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=zone-ro, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at io-error time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "-o errors=zone-ro ${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone readonly 30 | set_nullb_first_seq_zone_readonly ${nulldev} 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 35 | 36 | # Truncate should also fail 37 | echo "Try file truncate to 0 (zone reset)" 38 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 39 | exit_failed " --> truncate SUCCESS (should FAIL)" 40 | check_file_size "${zonefs_mntdir}/seq/0" 4096 41 | 42 | # File permission should have changed and the file system should 43 | # still be writable 44 | echo "Check permissions" 45 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 46 | check_fs_is_writable 47 | 48 | # Evicting the inode should not change anything 49 | echo "Check file size and permissions after eviction" 50 | drop_inode_cache 51 | check_file_size "${zonefs_mntdir}/seq/0" 4096 52 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 53 | 54 | # We should be able to write another file 55 | echo "Write seq file 1" 56 | write_file "${zonefs_mntdir}/seq/1" 4096 57 | 58 | zonefs_umount 59 | 60 | destroy_nullb ${nulldev} 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0614.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=zone-offline, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at mount time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone readonly and remount 30 | echo "Remounting FS with seq file 0 zone as read-only" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_readonly "${nulldev}" 33 | zonefs_mount "-o errors=zone-offline ${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "Check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing to the file should fail 43 | echo "Try writing seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Write seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0615.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=zone-offline, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at io-error time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "-o errors=zone-offline ${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone readonly 30 | set_nullb_first_seq_zone_readonly ${nulldev} 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 35 | 36 | # The file permission must have changed and the file size should be 0. 37 | # The fs should be writable 38 | echo "Check file size and permissions" 39 | check_file_size "${zonefs_mntdir}/seq/0" 0 40 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 41 | check_fs_is_writable 42 | 43 | # Evicting the inode should not change anything 44 | echo "Check file size and permissions after eviction" 45 | drop_inode_cache 46 | check_file_size "${zonefs_mntdir}/seq/0" 0 47 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 48 | 49 | # We should be able to write another file 50 | echo "Write seq file 1" 51 | write_file "${zonefs_mntdir}/seq/1" 4096 52 | 53 | zonefs_umount 54 | 55 | destroy_nullb ${nulldev} 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/scripts/0616.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=repair, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at mount time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone readonly and remount 30 | echo "Remounting FS with seq file 0 zone as read-only" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_readonly "${nulldev}" 33 | zonefs_mount "-o errors=repair ${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "Check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing to he readonly file should fail 43 | echo "Try writing readonly seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Write seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0617.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file readonly zone (errors=repair, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on a read-only zone at io-error time" 16 | 17 | require_nullb_readonly 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "-o errors=repair ${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone readonly 30 | set_nullb_first_seq_zone_readonly ${nulldev} 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 35 | 36 | # Truncate should also fail 37 | echo "Try file truncate to 0 (zone reset)" 38 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 39 | exit_failed " --> truncate SUCCESS (should FAIL)" 40 | check_file_size "${zonefs_mntdir}/seq/0" 4096 41 | 42 | # File permission should have changed and the file system should 43 | # still be writable 44 | echo "Check permissions" 45 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 46 | check_fs_is_writable 47 | 48 | # Evicting the inode should not change anything 49 | echo "Check file size and permissions after eviction" 50 | drop_inode_cache 51 | check_file_size "${zonefs_mntdir}/seq/0" 4096 52 | check_file_perm "${zonefs_mntdir}/seq/0" "440" 53 | 54 | # We should be able to write another file 55 | echo "Write seq file 1" 56 | write_file "${zonefs_mntdir}/seq/1" 4096 57 | 58 | zonefs_umount 59 | 60 | destroy_nullb ${nulldev} 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0620.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=remount-ro, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at mount time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone offline and remount 30 | echo "Remounting FS with seq file 0 zone as offline" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_offline "${nulldev}" 33 | zonefs_mount "${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing the file should fail 43 | echo "Try writing seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Try writing to seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0621.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=remount-ro, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at io-error time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone offline 30 | set_nullb_first_seq_zone_offline "${nulldev}" 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 35 | 36 | # Truncate should also fail 37 | echo "Try file truncate to 0 (zone reset)" 38 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 39 | exit_failed " --> truncate SUCCESS (should FAIL)" 40 | check_file_size "${zonefs_mntdir}/seq/0" 0 41 | 42 | # File permission should have changed and the entire file system 43 | # should now be read-only 44 | echo "Check permissions" 45 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 46 | check_fs_is_readonly 47 | 48 | # Evicting the inode should not change anything 49 | echo "Check file size and permissions after eviction" 50 | drop_inode_cache 51 | check_file_size "${zonefs_mntdir}/seq/0" 0 52 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 53 | 54 | # We should not be able to write another file 55 | echo "Try writing seq file 1" 56 | write_file_err "${zonefs_mntdir}/seq/1" 4096 0 57 | 58 | zonefs_umount 59 | 60 | destroy_nullb ${nulldev} 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0622.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=zone-ro, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at mount time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone offline and remount 30 | echo "Remounting FS with seq file 0 zone as offline" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_offline "${nulldev}" 33 | zonefs_mount "-o errors=zone-ro ${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "Check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing to the file should fail 43 | echo "Try writing readonly seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Write seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0623.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=zone-ro, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at io-error time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "-o errors=zone-ro ${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone offline 30 | set_nullb_first_seq_zone_offline ${nulldev} 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 35 | 36 | # Truncate should also fail 37 | echo "Try file truncate to 0 (zone reset)" 38 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 39 | exit_failed " --> truncate SUCCESS (should FAIL)" 40 | check_file_size "${zonefs_mntdir}/seq/0" 0 41 | 42 | # File permission should have changed and the file system should 43 | # still be writable 44 | echo "Check permissions" 45 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 46 | check_fs_is_writable 47 | 48 | # Evicting the inode should not change anything 49 | echo "Check file size and permissions after eviction" 50 | drop_inode_cache 51 | check_file_size "${zonefs_mntdir}/seq/0" 0 52 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 53 | 54 | # We should be able to write another file 55 | echo "Write seq file 1" 56 | write_file "${zonefs_mntdir}/seq/1" 4096 57 | 58 | zonefs_umount 59 | 60 | destroy_nullb ${nulldev} 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/scripts/0624.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=zone-offline, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at mount time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone offline and remount 30 | echo "Remounting FS with seq file 0 zone as offline" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_offline "${nulldev}" 33 | zonefs_mount "-o errors=zone-offline ${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "Check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing to the file should fail 43 | echo "Try writing seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Write seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0625.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=zone-offline, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at io-error time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "-o errors=zone-offline ${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone offline 30 | set_nullb_first_seq_zone_offline ${nulldev} 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 35 | 36 | # The file permission must have changed and the file size should be 0. 37 | # The fs should be writable 38 | echo "Check file size and permissions" 39 | check_file_size "${zonefs_mntdir}/seq/0" 0 40 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 41 | check_fs_is_writable 42 | 43 | # Evicting the inode should not change anything 44 | echo "Check file size and permissions after eviction" 45 | drop_inode_cache 46 | check_file_size "${zonefs_mntdir}/seq/0" 0 47 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 48 | 49 | # We should be able to write another file 50 | echo "Write seq file 1" 51 | write_file "${zonefs_mntdir}/seq/1" 4096 52 | 53 | zonefs_umount 54 | 55 | destroy_nullb ${nulldev} 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /tests/scripts/0626.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=repair, mount)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at mount time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Unmount, set the first seq file zone offline and remount 30 | echo "Remounting FS with seq file 0 zone as offline" 31 | zonefs_umount "${dev}" 32 | set_nullb_first_seq_zone_offline "${nulldev}" 33 | zonefs_mount "-o errors=repair ${dev}" 34 | 35 | # The file permission must have changed and the file size should be 0. 36 | # The fs should be writable 37 | echo "Check file size and permissions" 38 | check_file_size "${zonefs_mntdir}/seq/0" 0 39 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 40 | check_fs_is_writable 41 | 42 | # Writing the file should fail 43 | echo "Try writing seq file 0" 44 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 45 | 46 | # We should be able to write another file 47 | echo "Write seq file 1" 48 | write_file "${zonefs_mntdir}/seq/1" 4096 49 | 50 | zonefs_umount 51 | 52 | destroy_nullb ${nulldev} 53 | 54 | exit 0 55 | -------------------------------------------------------------------------------- /tests/scripts/0627.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2023 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | . scripts/test_lib 9 | 10 | if [ $# == 0 ]; then 11 | echo "Sequential file offline zone (errors=repair, io-err)" 12 | exit 0 13 | fi 14 | 15 | echo "Check sequential file on an offline zone at io-error time" 16 | 17 | require_nullb_offline 18 | 19 | nulldev=$(create_zoned_nullb) 20 | dev="/dev/nullb${nulldev}" 21 | 22 | zonefs_mkfs "${dev}" 23 | zonefs_mount "-o errors=repair ${dev}" 24 | 25 | # Writing should be OK 26 | echo "Write seq file 0" 27 | write_file "${zonefs_mntdir}/seq/0" 4096 28 | 29 | # Set the first seq file zone offline 30 | set_nullb_first_seq_zone_offline ${nulldev} 31 | 32 | # Writing should now fail 33 | echo "Try writing seq file 0" 34 | write_file_err "${zonefs_mntdir}/seq/0" 4096 0 35 | 36 | # Truncate should also fail 37 | echo "Try file truncate to 0 (zone reset)" 38 | truncate_file "${zonefs_mntdir}/seq/0" 0 && \ 39 | exit_failed " --> truncate SUCCESS (should FAIL)" 40 | check_file_size "${zonefs_mntdir}/seq/0" 0 41 | 42 | # File permission should have changed and the file system should 43 | # still be writable 44 | echo "Check permissions" 45 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 46 | check_fs_is_writable 47 | 48 | # Evicting the inode should not change anything 49 | echo "Check file size and permissions after eviction" 50 | drop_inode_cache 51 | check_file_size "${zonefs_mntdir}/seq/0" 0 52 | check_file_perm "${zonefs_mntdir}/seq/0" "000" 53 | 54 | # We should be able to write another file 55 | echo "Write seq file 1" 56 | write_file "${zonefs_mntdir}/seq/1" 4096 57 | 58 | zonefs_umount 59 | 60 | destroy_nullb ${nulldev} 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/tools/Makefile.am: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: CC0-1.0 2 | # 3 | # Copyright (C) 2021 Western Digital Corporation or its affiliates. 4 | 5 | AM_CFLAGS = -O2 -Wall -Wextra -Wno-unused-parameter 6 | 7 | noinst_PROGRAMS = zio zopen 8 | 9 | zio_SOURCES = zio.c 10 | zio_LDADD = 11 | zio_LDFLAGS = 12 | 13 | zopen_SOURCES = zopen.c 14 | zopen_LDADD = 15 | zopen_LDFLAGS = 16 | -------------------------------------------------------------------------------- /tests/tools/zopen.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | * Copyright (C) 2022 Western Digital Corporation or its affiliates. 4 | * Author: Damien Le Moal 5 | */ 6 | 7 | #ifndef _GNU_SOURCE 8 | #define _GNU_SOURCE 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define ZOPEN_MAX_FILES 1024 22 | 23 | struct zopen_params { 24 | bool verbose; 25 | bool pause; 26 | 27 | const char *base_path; 28 | int fflags; 29 | 30 | int first_file; 31 | int nr_files; 32 | int fd[ZOPEN_MAX_FILES]; 33 | }; 34 | 35 | static void zopen_sigcatcher(int sig) 36 | { 37 | return; 38 | } 39 | 40 | #define zopen_vprintf(zo,fmt,args...) \ 41 | if ((zo)->verbose) { \ 42 | printf(fmt, ## args); \ 43 | } 44 | 45 | static int zopen(struct zopen_params *zo, int idx) 46 | { 47 | char path[PATH_MAX]; 48 | 49 | if (idx >= zo->nr_files) { 50 | fprintf(stderr, "Invalid file index %d/%d\n", 51 | idx, zo->nr_files); 52 | return -1; 53 | } 54 | 55 | /* Generate the file path */ 56 | snprintf(path, sizeof(path) - 1, "%s/%d", 57 | zo->base_path, zo->first_file + idx); 58 | 59 | zopen_vprintf(zo, "Opening %s\n", path); 60 | 61 | /* Open file */ 62 | zo->fd[idx] = open(path, zo->fflags, 0); 63 | if (zo->fd[idx] < 0) { 64 | fprintf(stderr, "Open %s failed %d (%s)\n", 65 | path, errno, strerror(errno)); 66 | return -1; 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | static void zopen_usage(char *cmd) 73 | { 74 | printf("Usage: %s [options] \n", 75 | cmd); 76 | printf("Options:\n" 77 | " -h | --help : print usage and exit\n" 78 | " --v : Verbose output\n" 79 | " --start= : First file to open (default: 0)\n" 80 | " --nrfiles= : Number of files to open (default: 1)\n" 81 | " --fflag= : Use O_XXX to open files. can be:\n" 82 | " - read (default)\n" 83 | " - write\n" 84 | " - direct\n" 85 | " - trunc\n" 86 | " This option can be used multiple times.\n" 87 | " --pause : Do not exit immediately and wait" 88 | " for a signal\n"); 89 | } 90 | 91 | int main(int argc, char **argv) 92 | { 93 | struct zopen_params zo; 94 | const char *val; 95 | struct sigaction act; 96 | int i; 97 | 98 | /* Setup signal handler */ 99 | act.sa_flags = 0; 100 | act.sa_handler = zopen_sigcatcher; 101 | sigemptyset(&act.sa_mask); 102 | (void)sigaction(SIGPIPE, &act, NULL); 103 | (void)sigaction(SIGINT, &act, NULL); 104 | (void)sigaction(SIGTERM, &act, NULL); 105 | 106 | /* Set default values */ 107 | memset(&zo, 0, sizeof(struct zopen_params)); 108 | zo.nr_files = 1; 109 | zo.fflags = O_LARGEFILE | O_RDONLY; 110 | for (i = 0; i < ZOPEN_MAX_FILES; i++) 111 | zo.fd[i] = -1; 112 | 113 | if (argc <= 1) { 114 | zopen_usage(argv[0]); 115 | return 1; 116 | } 117 | 118 | /* Parse command line */ 119 | for (i = 1; i < argc; i++) { 120 | 121 | if (strcmp(argv[i], "-h") == 0 || 122 | strcmp(argv[i], "--help") == 0) { 123 | zopen_usage(argv[0]); 124 | return 0; 125 | } 126 | 127 | if (strcmp(argv[i], "--v") == 0) { 128 | 129 | zo.verbose = true; 130 | 131 | } else if (strncmp(argv[i], "--start=", 8) == 0) { 132 | 133 | zo.first_file = atoi(argv[i] + 8); 134 | if (zo.first_file < 0) { 135 | fprintf(stderr, "Invalid start file\n"); 136 | return 1; 137 | } 138 | 139 | } else if (strncmp(argv[i], "--nrfiles=", 10) == 0) { 140 | 141 | zo.nr_files = atoi(argv[i] + 10); 142 | if (zo.nr_files <= 0 || zo.nr_files > ZOPEN_MAX_FILES) { 143 | fprintf(stderr, "Invalid number of files\n"); 144 | return 1; 145 | } 146 | 147 | } else if (strncmp(argv[i], "--fflag=", 8) == 0) { 148 | 149 | val = argv[i] + 8; 150 | if (strcmp(val, "read") == 0) { 151 | zo.fflags |= O_RDONLY; 152 | } else if (strcmp(val, "write") == 0) { 153 | zo.fflags |= O_WRONLY; 154 | } else if (strcmp(val, "direct") == 0) { 155 | zo.fflags |= O_DIRECT; 156 | } else if (strcmp(val, "trunc") == 0) { 157 | zo.fflags |= O_TRUNC; 158 | } else { 159 | fprintf(stderr, "Invalid file open flag\n"); 160 | return 1; 161 | } 162 | 163 | } else if (strcmp(argv[i], "--pause") == 0) { 164 | 165 | zo.pause = true; 166 | 167 | } else if (argv[i][0] == '-') { 168 | 169 | fprintf(stderr, "Invalid option \"%s\"\n", argv[i]); 170 | return 1; 171 | 172 | } else { 173 | 174 | break; 175 | 176 | } 177 | } 178 | 179 | if (i != argc - 1) { 180 | zopen_usage(argv[0]); 181 | return 0; 182 | } 183 | 184 | zo.base_path = realpath(argv[i], NULL); 185 | if (!zo.base_path) { 186 | fprintf(stderr, "Generate base path for %s failed\n", argv[i]); 187 | return 1; 188 | } 189 | 190 | /* Open files */ 191 | for (i = 0; i < zo.nr_files; i++) { 192 | if (zopen(&zo, i)) 193 | return 1; 194 | } 195 | 196 | printf("Opened %d file%s from file %d\n", 197 | zo.nr_files, zo.nr_files > 1 ? "s" : "", 198 | zo.first_file); 199 | 200 | if (zo.pause) { 201 | /* Wait for a signal */ 202 | pause(); 203 | } 204 | 205 | for (i = 0; i < zo.nr_files; i++) 206 | close(zo.fd[i]); 207 | 208 | printf("Closed %d file%s from file %d\n", 209 | zo.nr_files, zo.nr_files > 1 ? "s" : "", 210 | zo.first_file); 211 | 212 | return 0; 213 | } 214 | -------------------------------------------------------------------------------- /tests/zonefs-tests-nullblk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | # Zone size in MB 9 | zone_size=32 10 | zone_capacity=$zone_size 11 | 12 | # Max open and active limits 13 | declare -i zone_max_open=0 14 | declare -i zone_max_active=0 15 | 16 | # Device total capacity (MB) 17 | capacity=2048 18 | 19 | # Device block size 20 | blocksize="512" 21 | 22 | # Default number of conventional zones to test 23 | nr_conv=10 24 | 25 | function usage() { 26 | echo "Usage: $0 [options]" 27 | echo "Options:" 28 | echo " -h | --help : Display help" 29 | echo " -n | --nr_conv : Specify the number of conventional zones to use." 30 | echo " -s | --sectsz : Test with device block size set to bytes (default: 512 B)" 31 | echo " -t : Test to execute. Can be specified multiple times." 32 | echo " If used, only the first nullb config is used" 33 | echo " -r : Repeat the selected test cases times" 34 | echo " (default: num=1)" 35 | } 36 | 37 | # Check credentials 38 | if [ $(id -u) -ne 0 ]; then 39 | echo "Root credentials are needed to run tests." 40 | exit 1 41 | fi 42 | 43 | testopts="" 44 | 45 | # Check options 46 | while [[ $# -gt 0 ]]; do 47 | case "$1" in 48 | "-h" | "--help") 49 | usage "$0" 50 | exit 0 51 | ;; 52 | "-n" | "--nr_conv") 53 | shift 54 | nr_conv=($1) 55 | shift 56 | ;; 57 | "-s" | "--sectsz") 58 | shift 59 | blocksize=($1) 60 | shift 61 | ;; 62 | "-t") 63 | shift 64 | testopts+=" -t $1" 65 | shift 66 | ;; 67 | "-r") 68 | shift 69 | testopts+=" -r $1" 70 | shift 71 | ;; 72 | *) 73 | echo "Invalid option $1" 74 | exit 1 75 | ;; 76 | esac 77 | done 78 | 79 | if [ $blocksize != 512 ] && [ $blocksize != 4096 ]; then 80 | echo "Invalid sector size" 81 | exit 1 82 | fi 83 | 84 | # trap ctrl-c interruptions 85 | aborted=0 86 | trap ctrl_c INT 87 | 88 | function ctrl_c() { 89 | aborted=1 90 | } 91 | 92 | scriptdir="$(cd "$(dirname "$0")" && pwd)" 93 | 94 | modprobe null_blk nr_devices=0 95 | 96 | nr_configs=6 97 | 98 | function set_config() 99 | { 100 | case "$1" in 101 | "0") 102 | zone_max_open=0 103 | zone_max_active=0 104 | ;; 105 | "1") 106 | zone_max_open=$(( capacity / zone_size / 8 )) 107 | zone_max_active=0 108 | ;; 109 | "2") 110 | zone_max_open=0 111 | zone_max_active=$(( capacity / zone_size / 8 + 1 )) 112 | ;; 113 | "3") 114 | zone_max_open=$(( capacity / zone_size / 8 )) 115 | zone_max_active=$(( capacity / zone_size / 8 + 1 )) 116 | ;; 117 | "4") 118 | capacity=$(( capacity + zone_size / 2 + 1 )) 119 | nr_conv=0 120 | zone_max_open=$(( capacity / zone_size / 8 )) 121 | zone_max_active=$(( capacity / zone_size / 8 + 1 )) 122 | ;; 123 | "5") 124 | capacity=2048 125 | zone_capacity=$(( zone_size - 1 )) 126 | zone_max_open=$(( capacity / zone_size / 8 )) 127 | zone_max_active=$(( capacity / zone_size / 8 + 1 )) 128 | ;; 129 | *) 130 | echo "Invalid configuration" 131 | exit 1 132 | ;; 133 | esac 134 | } 135 | 136 | # Create a zoned null_blk disk 137 | function create_zoned_nullb() 138 | { 139 | local n=0 140 | 141 | while [ 1 ]; do 142 | if [ ! -b "/dev/nullb$n" ]; then 143 | break 144 | fi 145 | n=$(( n + 1 )) 146 | done 147 | 148 | dev="/sys/kernel/config/nullb/nullb$n" 149 | mkdir "$dev" 150 | 151 | if [ $zone_capacity != $zone_size ] && [ ! -w "$dev"/zone_capacity ]; then 152 | echo "Zone capacity is not supported by nullblk" 153 | exit 1 154 | fi 155 | 156 | echo "$blocksize" > "$dev"/blocksize 157 | echo 2 > "$dev"/queue_mode 158 | echo 2 > "$dev"/irqmode 159 | echo 2000 > "$dev"/completion_nsec 160 | 161 | echo $capacity > "$dev"/size 162 | echo 1024 > "$dev"/hw_queue_depth 163 | echo 1 > "$dev"/memory_backed 164 | 165 | echo 1 > "$dev"/zoned 166 | echo "$zone_size" > "$dev"/zone_size 167 | if [ $zone_capacity != $zone_size ]; then 168 | echo "$zone_capacity" > "$dev"/zone_capacity 169 | fi 170 | echo "$nr_conv" > "$dev"/zone_nr_conv 171 | 172 | if [ -f "$dev"/zone_max_open ]; then 173 | echo "$zone_max_open" > "$dev"/zone_max_open 174 | fi 175 | 176 | if [ -f "$dev"/zone_max_active ]; then 177 | echo "$zone_max_active" > "$dev"/zone_max_active 178 | fi 179 | 180 | echo 1 > "$dev"/power 181 | 182 | echo "nullb$n" 183 | } 184 | 185 | function destroy_zoned_nullb() 186 | { 187 | local ndev="$1" 188 | 189 | if [ -e "/sys/kernel/config/nullb/$ndev" ]; then 190 | echo "0" > /sys/kernel/config/nullb/$ndev/power 191 | fi 192 | rmdir /sys/kernel/config/nullb/$ndev > /dev/null 2>&1 193 | } 194 | 195 | declare -i rc=0 196 | declare -i nrtests=0 197 | declare -i passed=0 198 | declare -i skipped=0 199 | declare -i failed=0 200 | 201 | # Run all open/active configurations 202 | for (( m=0; m<$nr_configs; m++ )); do 203 | 204 | set_config "$m" 205 | 206 | ndev=$(create_zoned_nullb) 207 | if [ ! -b "/dev/${ndev}" ]; then 208 | echo "Create null block device failed" 209 | exit 1 210 | fi 211 | 212 | moz=$(cat /sys/block/"$ndev"/queue/max_open_zones) 213 | maz=$(cat /sys/block/"$ndev"/queue/max_active_zones) 214 | nrz=$(blkzone report "/dev/$ndev" | wc -l) 215 | nrc=$(blkzone report "/dev/$ndev" | grep -c CONVENTIONAL) 216 | 217 | echo "" 218 | echo "Config ${m}:" 219 | echo " Zone size: $zone_size MB, zone capacity: $zone_capacity MB" 220 | echo " $nrz zones, $nrc conventional zones" 221 | echo " $moz max open zones ($zone_max_open)" 222 | echo " $maz max active zones ($zone_max_active)" 223 | echo "" 224 | 225 | logdir="logs/${ndev}-conv${nr_conv}-moz${zone_max_open}-maz${zone_max_active}" 226 | 227 | if ! ./zonefs-tests.sh ${testopts} "-g" "$logdir" "/dev/$ndev"; then 228 | rc=1 229 | fi 230 | 231 | sleep 1 232 | destroy_zoned_nullb "$ndev" 233 | 234 | val=$(tail -1 "${logdir}/zonefs-tests.log" | cut -f1 -d' ') 235 | passed=$(( passed + val )) 236 | 237 | val=$(tail -1 "${logdir}/zonefs-tests.log" | cut -f3 -d' ') 238 | nrtests=$(( nrtests + val )) 239 | 240 | val=$(tail -1 "${logdir}/zonefs-tests.log" | cut -f2 -d'(' | cut -f1 -d' ') 241 | skipped=$(( skipped + val )) 242 | 243 | val=$(tail -1 "${logdir}/zonefs-tests.log" | cut -f8 -d' ') 244 | failed=$(( failed + val )) 245 | 246 | if [ "$aborted" == 1 ] || [ "$testopts" != "" ]; then 247 | break 248 | fi 249 | 250 | done 251 | 252 | rmmod null_blk > /dev/null 2>&1 253 | 254 | echo "" 255 | echo "Overall results:" 256 | echo "${passed} / ${nrtests} tests passed (${skipped} skipped, ${failed} failures)" 257 | 258 | if [ "$rc" != 0 ]; then 259 | echo "Failures detected" 260 | exit 1 261 | fi 262 | 263 | echo "All tests passed" 264 | exit 0 265 | -------------------------------------------------------------------------------- /tests/zonefs-tests-scsi-debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2022 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | # Zone size in MB 9 | zone_size=64 10 | zone_capacity=$zone_size 11 | 12 | # Device total capacity (MB) 13 | capacity=2048 14 | 15 | # Sector size 16 | sect_size=512 17 | 18 | # Number of conventional zones 19 | nr_conv=3 20 | 21 | function usage() { 22 | echo "Usage: $0 [options]" 23 | echo "Options:" 24 | echo " -h | --help : Display help" 25 | echo " -c | --cap : Test with zone capacity < zone size (default: off)" 26 | echo " -n | --nr_conv : Specify the number of conventional zones to use." 27 | echo " -t : Test to execute. Can be specified multiple times." 28 | echo " -r : Repeat the selected test cases times" 29 | echo " (default: num=1)" 30 | } 31 | 32 | # Check credentials 33 | if [ $(id -u) -ne 0 ]; then 34 | echo "Root credentials are needed to run tests." 35 | exit 1 36 | fi 37 | 38 | testopts="" 39 | 40 | # Check options 41 | while [[ $# -gt 0 ]]; do 42 | case "$1" in 43 | "-h" | "--help") 44 | usage "$0" 45 | exit 0 46 | ;; 47 | "-c" | "--cap") 48 | zone_capacity=$(( zone_size - 1 )) 49 | shift 50 | ;; 51 | "-n" | "--nr_conv") 52 | shift 53 | nr_conv="$1" 54 | shift 55 | ;; 56 | "-t") 57 | shift 58 | testopts+=" -t $1" 59 | shift 60 | ;; 61 | "-r") 62 | shift 63 | testopts+=" -r $1" 64 | shift 65 | ;; 66 | *) 67 | echo "Invalid option $1" 68 | exit 1 69 | ;; 70 | esac 71 | done 72 | 73 | # trap ctrl-c interruptions 74 | aborted=0 75 | trap ctrl_c INT 76 | 77 | function ctrl_c() { 78 | aborted=1 79 | } 80 | 81 | scriptdir="$(cd "$(dirname "$0")" && pwd)" 82 | 83 | # Create the scsi_debug device 84 | modprobe scsi_debug max_luns=1 sector_size="$sect_size" \ 85 | delay=0 dev_size_mb="$capacity" zbc=managed \ 86 | zone_size_mb="$zone_size" zone_cap_mb="$zone_capacity" \ 87 | zone_nr_conv="$nr_conv" 88 | 89 | sdev="$(lsscsi | grep scsi_debug | awk -F' ' '{print $NF}')" 90 | sbdev="$(basename $sdev)" 91 | zone_max_open=$(cat /sys/block/"$sbdev"/queue/max_open_zones) 92 | zone_max_active=$(cat /sys/block/"$sbdev"/queue/max_active_zones) 93 | nr_zones=$(blkzone report "$sdev" | wc -l) 94 | nr_conv=$(blkzone report "$sdev" | grep -c CONVENTIONAL) 95 | 96 | echo "" 97 | echo "Run tests against $sdev..." 98 | echo " Zone size: $zone_size MB, zone capacity: $zone_capacity MB" 99 | echo " $nr_zones zones, $nr_conv conventional zones" 100 | echo " $zone_max_open max open zones" 101 | echo " $zone_max_active max active zones" 102 | echo "" 103 | 104 | declare -i rc=0 105 | if ! ./zonefs-tests.sh ${testopts} "$sdev"; then 106 | rc=1 107 | fi 108 | 109 | sleep 1 110 | rmmod scsi_debug 111 | 112 | echo "" 113 | if [ "$rc" != 0 ]; then 114 | echo "Failures detected" 115 | exit 1 116 | fi 117 | 118 | echo "All tests passed" 119 | exit 0 120 | -------------------------------------------------------------------------------- /tests/zonefs-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SPDX-License-Identifier: GPL-2.0-or-later 4 | # 5 | # Copyright (C) 2019 Western Digital Corporation or its affiliates. 6 | # 7 | 8 | # Run everything from the tests directory 9 | cd $(dirname "$0") 10 | 11 | . scripts/test_lib 12 | 13 | # trap ctrl-c interruptions 14 | aborted=0 15 | trap ctrl_c INT 16 | 17 | function test_num() 18 | { 19 | basename "$1" .sh 20 | } 21 | 22 | function ctrl_c() { 23 | aborted=1 24 | } 25 | 26 | function usage() 27 | { 28 | echo "Usage: $(basename "$0") [Options] " 29 | echo "Options:" 30 | echo " -l : List all tests" 31 | echo " -g : Use this directory to save log files." 32 | echo " default: logs/" 33 | echo " -t [-] : Execute only the specified test ." 34 | echo " If a second case is specified after a hyphen," 35 | echo " all test cases from to will be" 36 | echo " executed. This option can be specified" 37 | echo " multiple times." 38 | echo " -s : Short test (do not execute tests that take a" 39 | echo " long time)" 40 | echo " -r : Repeat the selected test cases times" 41 | echo " (default: num=1)" 42 | echo " -h, --help : This help message" 43 | } 44 | 45 | # Check configuration 46 | [[ $(modinfo null_blk) ]] || 47 | { 48 | echo "null_blk module is not available." 49 | exit 1 50 | } 51 | 52 | [[ $(type -P "tools/zio") && $(type -P "tools/zopen") ]] || 53 | { 54 | echo "Test tools not found." 55 | echo "Run \"./configure --with-tests\" and recompile." 56 | exit 1 57 | } 58 | 59 | [[ $(type -P "fio") ]] || 60 | { 61 | echo "fio not found." 62 | echo "Installing fio is required to run tests." 63 | exit 1 64 | } 65 | 66 | [[ $(type -P "mkzonefs") ]] || 67 | { 68 | echo "mkzonefs not found." 69 | echo "Installing zonefs-tools is required to run tests." 70 | exit 1 71 | } 72 | 73 | # Parse command line 74 | declare -a tests 75 | declare list=false 76 | logdir="" 77 | export short=false 78 | declare nrloops=1 79 | 80 | # Get full test list 81 | declare -a testlist 82 | for f in scripts/*.sh; do 83 | testlist+=("$(test_num $f)") 84 | done 85 | 86 | function get_test_range() 87 | { 88 | local case="$1" 89 | local tstart=$(echo "${case}" | cut -f1 -d'-') 90 | local tend=$(echo "${case}" | cut -f2 -d'-') 91 | local add=0 92 | declare -a trange 93 | 94 | for t in "${testlist[@]}"; do 95 | 96 | if [ "$t" == "$tstart" ]; then 97 | add=1 98 | fi 99 | 100 | if [ "$add" == "1" ]; then 101 | trange+=("scripts/$t.sh") 102 | fi 103 | 104 | if [ "$t" == "$tend" ]; then 105 | add=0 106 | fi 107 | done 108 | 109 | if [ "${#trange[@]}" == "0" ]; then 110 | echo "Invalid test range $1" 111 | exit 1; 112 | fi 113 | 114 | tests+=( "${trange[@]}" ) 115 | } 116 | 117 | while [ "${1#-}" != "$1" ]; do 118 | case "$1" in 119 | -h | --help) 120 | usage 121 | exit 0 122 | ;; 123 | -t) 124 | get_test_range "$2" 125 | shift 126 | shift 127 | ;; 128 | -l) 129 | list=true 130 | shift 131 | ;; 132 | -g) 133 | shift 134 | logdir="$1" 135 | shift 136 | ;; 137 | -s) 138 | short=true 139 | shift 140 | ;; 141 | -r) 142 | nrloops="$2" 143 | shift 144 | shift 145 | ;; 146 | -*) 147 | echo "unknow option $1" 148 | exit 1 149 | ;; 150 | esac 151 | done 152 | 153 | if [ ! $list ] && [ $# -lt 1 ]; then 154 | usage 155 | exit 1 156 | fi 157 | 158 | # Get list of tests 159 | if [ "${#tests[@]}" == "0" ]; then 160 | for f in scripts/*.sh; do 161 | tests+=("$f") 162 | done 163 | fi 164 | 165 | # Handle -l option (list tests) 166 | if $list; then 167 | for t in "${tests[@]}"; do 168 | echo " Test $(test_num "$t"): $( $t )" 169 | done 170 | exit 0 171 | fi 172 | 173 | # Check number of loops 174 | if [ ${nrloops} -eq 0 ]; then 175 | echo "Invalid number of repetitions" 176 | exit 1 177 | fi 178 | 179 | dev="$1" 180 | if [ -z "$dev" ]; then 181 | usage 182 | exit 1 183 | fi 184 | 185 | if [ ! -b "$dev" ]; then 186 | echo "Invalid block device" 187 | exit 1 188 | fi 189 | 190 | # Check credentials 191 | if [ $(id -u) -ne 0 ]; then 192 | echo "Root credentials are needed to run tests." 193 | exit 1 194 | fi 195 | 196 | realdev=$(readlink -f "$dev") 197 | bdev=$(basename "$realdev") 198 | major=$((0x$(stat -L -c '%t' "$realdev"))) 199 | minor=$((0x$(stat -L -c '%T' "$realdev"))) 200 | 201 | # When the target is a partition device, get basename of its holder device to 202 | # access sysfs path of the holder device 203 | if [[ -r "/sys/dev/block/$major:$minor/partition" ]]; then 204 | realsysfs=$(readlink "/sys/dev/block/$major:$minor") 205 | bdev=$(basename "${realsysfs%/*}") 206 | fi 207 | 208 | dev="/dev/$bdev" 209 | 210 | if [ "$(<"/sys/class/block/$bdev/queue/zoned")" == "none" ]; then 211 | echo "/dev/$dev is not a zoned block device" 212 | exit 1 213 | fi 214 | 215 | if ! blkzone_has_zone_capacity "$dev"; then 216 | echo "blkzone utility is not reporting zone capacity." 217 | echo "util-linux update needed." 218 | exit 1 219 | fi 220 | 221 | export zonefs_mntdir="${PWD}/$bdev-mnt" 222 | mkdir -p "$zonefs_mntdir" 223 | 224 | if [ "$logdir" == "" ]; then 225 | logdir="logs/${bdev}" 226 | fi 227 | 228 | mkdir -p "$logdir" || \ 229 | exit_failed "Create log directory ${logdir} failed" 230 | rm -rf "${logdir}/*" > /dev/null 2>&1 231 | export logdir 232 | 233 | passed=0 234 | skipped=0 235 | failed=0 236 | 237 | # Drive parameters 238 | echo "Gathering information on $dev..." 239 | export nr_zones=$(get_nr_zones "$dev") 240 | export zone_sectors=$(get_zone_sectors "$dev") 241 | export zone_bytes=$(( zone_sectors * 512 )) 242 | export nr_cnv_zones=$(get_nr_cnv_zones "$dev") 243 | export nr_seq_zones=$(get_nr_seq_zones "$dev") 244 | export total_usable_sectors=$(get_total_zone_capacity_sectors "$dev") 245 | export iosize=$((4096 * 64)) 246 | 247 | # Expected number of files 248 | if [ "$nr_cnv_zones" == 0 ]; then 249 | nr_cnv_files=0 250 | nr_seq_files=$(( nr_seq_zones - 1 )) 251 | seq_file_0_zone_start_sector=$zone_sectors 252 | elif [ "$nr_cnv_zones" == 1 ]; then 253 | nr_cnv_files=0 254 | nr_seq_files=$nr_seq_zones 255 | seq_file_0_zone_start_sector=$zone_sectors 256 | else 257 | nr_cnv_files=$(( nr_cnv_zones - 1 )) 258 | nr_seq_files=$nr_seq_zones 259 | seq_file_0_zone_start_sector=$(( nr_cnv_zones * zone_sectors )) 260 | fi 261 | export nr_cnv_files 262 | export nr_seq_files 263 | export seq_file_0_zone_start_sector 264 | export seq_file_0_max_size=$(get_zone_capacity_bytes "$dev" $seq_file_0_zone_start_sector) 265 | 266 | export zone_cap_sectors=$(( seq_file_0_max_size / 512 )) 267 | export zone_cap_bytes=${seq_file_0_max_size} 268 | 269 | # zonefs features 270 | zonefs_module=$(modprobe -c | grep -c zonefs) 271 | if [ $zonefs_module != 0 ]; then 272 | modprobe zonefs 273 | else 274 | have_zonefs=$(cat /proc/filesystems | grep -c zonefs) 275 | if [ $have_zonefs -eq 0 ]; then 276 | exit_failed "The kernel does not support zonefs" 277 | fi 278 | fi 279 | export zonefs_module 280 | 281 | if [ -d "/sys/fs/zonefs" ]; then 282 | zonefs_has_sysfs=1 283 | else 284 | zonefs_has_sysfs=0 285 | fi 286 | export zonefs_has_sysfs 287 | if [ $zonefs_module != 0 ]; then 288 | rmmod zonefs 289 | fi 290 | 291 | # Set IO scheduler 292 | set_io_scheduler "${bdev}" "mq-deadline" || \ 293 | exit_failed "Set ${bdev} scheduler to mq-deadline failed" 294 | 295 | function kmsg_log() 296 | { 297 | if [ -e /dev/kmsg ]; then 298 | echo "$1" > /dev/kmsg 299 | fi 300 | } 301 | 302 | function kmsg_log_start() 303 | { 304 | kmsg_log "++++ zonefs-test case $1 start ++++" 305 | } 306 | 307 | function kmsg_log_end() 308 | { 309 | kmsg_log "---- zonefs-test case $1 end ----" 310 | } 311 | 312 | function run_test() 313 | { 314 | local tnum="$(test_num $1)" 315 | local ret=0 316 | 317 | kmsg_log_start ${tnum} 318 | 319 | if [ $zonefs_module != 0 ]; then 320 | modprobe zonefs || (echo "FAILED (modprobe)"; return 1) 321 | fi 322 | 323 | echo "## Test ${tnum}: $( $1 )" 324 | echo "" 325 | 326 | "$1" "$2" 327 | ret=$? 328 | if [ "$ret" == 0 ]; then 329 | echo "PASS" 330 | elif [ "$ret" == 2 ]; then 331 | echo "skip" 332 | else 333 | echo "FAILED" 334 | fi 335 | echo "" 336 | 337 | umount "$zonefs_mntdir" >> /dev/null 2>&1 338 | if [ $zonefs_module != 0 ]; then 339 | rmmod zonefs || if [ $ret == 0 ]; then echo "FAILED (rmmod)"; ret=1; fi 340 | fi 341 | 342 | kmsg_log_end ${tnum} 343 | 344 | return $ret 345 | } 346 | 347 | runlog="${logdir}/zonefs-tests.log" 348 | 349 | # Start logging the run 350 | { 351 | 352 | echo "zonefs-tests on $dev:" 353 | echo " $nr_zones zones ($nr_cnv_zones conventional zones, $nr_seq_zones sequential zones)" 354 | echo " $zone_sectors 512B sectors zone size ($(( zone_bytes / 1048576 )) MiB)" 355 | echo " $zone_cap_sectors 512B sectors zone capacity ($(( zone_cap_bytes / 1048576 )) MiB)" 356 | echo " $(get_max_open_zones $dev) max open zones" 357 | echo " $(get_max_active_zones $dev) max active zones" 358 | 359 | if [ ${nrloops} -eq 1 ]; then 360 | echo "Running tests" 361 | else 362 | echo "Running tests ${nrloops} times" 363 | fi 364 | 365 | nrtests=0 366 | 367 | for ((r=1; r<=${nrloops}; r++)); do 368 | 369 | if [ ${nrloops} -ne 1 ]; then 370 | echo "" 371 | echo "Run ${r}/${nrloops}:" 372 | fi 373 | 374 | nrtests=$(( nrtests + ${#tests[@]})) 375 | 376 | for t in "${tests[@]}"; do 377 | tnum="$(test_num $t)" 378 | 379 | echo -n " Test ${tnum}: " 380 | printf "%-60s ... " "$( $t )" 381 | 382 | run_test "$t" "$1" > "${logdir}/${tnum}.log" 2>&1 383 | ret=$? 384 | if [ "$ret" == 0 ]; then 385 | status="\e[92mPASS\e[0m" 386 | ((passed++)) 387 | elif [ "$ret" == 2 ]; then 388 | status="skip" 389 | ((skipped++)) 390 | else 391 | status="\e[31mFAIL\e[0m" 392 | ((failed++)) 393 | fi 394 | 395 | echo -e "$status" 396 | 397 | if [ -f "${logdir}/.zonefs_test_nullbn" ]; then 398 | destroy_nullb "$(cat ${logdir}/.zonefs_test_nullbn)" 399 | fi 400 | 401 | if [ "$aborted" == 1 ]; then 402 | break 403 | fi 404 | 405 | na=0 406 | done 407 | 408 | if [ "$aborted" == 1 ]; then 409 | break 410 | fi 411 | done 412 | 413 | echo "" 414 | echo "${passed} / ${nrtests} tests passed (${skipped} skipped, ${failed} failures)" 415 | 416 | # End logging the run 417 | } | tee -i "${runlog}" 2>&1 418 | 419 | failed=$(grep -Po "skipped, \K[0-9]*" "${runlog}") 420 | 421 | umount "$zonefs_mntdir" >> /dev/null 2>&1 422 | rm -rf "$zonefs_mntdir" >> /dev/null 2>&1 423 | rm -f local-* >> /dev/null 2>&1 424 | 425 | # cleanup env 426 | unset short 427 | unset zonefs_mntdir 428 | unset logdir 429 | unset nr_zones 430 | unset zone_sectors 431 | unset zone_bytes 432 | unset zone_cap_sectors 433 | unset zone_cap_bytes 434 | unset nr_cnv_zones 435 | unset nr_seq_zones 436 | unset total_usable_sectors 437 | unset iosize 438 | unset nr_cnv_files 439 | unset nr_seq_files 440 | unset seq_file_0_zone_start_sector 441 | unset seq_file_0_max_size 442 | unset zonefs_has_sysfs 443 | 444 | if [ ${failed} -ne 0 ]; then 445 | exit 1 446 | fi 447 | 448 | exit 0 449 | 450 | -------------------------------------------------------------------------------- /zonefs-tools.spec: -------------------------------------------------------------------------------- 1 | Name: %{pkg_name} 2 | Version: %{pkg_version} 3 | Release: 1%{?dist} 4 | Summary: Provides user utilities for the zonefs file system 5 | 6 | License: GPLv2+ 7 | URL: https://github.com/westerndigitalcorporation/%{name} 8 | Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz 9 | 10 | BuildRequires: libblkid-devel 11 | BuildRequires: libuuid-devel 12 | BuildRequires: autoconf 13 | BuildRequires: automake 14 | BuildRequires: libtool 15 | BuildRequires: make 16 | BuildRequires: gcc 17 | 18 | %description 19 | This package provides the mkzonefs (and mkfs.zonefs) user utility 20 | to format zoned block devices for use with the zonefs file system. 21 | 22 | %prep 23 | %autosetup 24 | 25 | %build 26 | sh autogen.sh 27 | %configure 28 | %make_build 29 | 30 | %install 31 | %make_install 32 | 33 | %files 34 | %{_sbindir}/* 35 | %{_mandir}/man8/* 36 | 37 | %license COPYING.GPL 38 | %doc README.md CONTRIBUTING 39 | 40 | %changelog 41 | * Tue Jan 31 2023 Damien Le Moal 1.6.0-1 42 | - Version 1.6.0 initial package 43 | --------------------------------------------------------------------------------