pax_global_header00006660000000000000000000000064143661365240014524gustar00rootroot0000000000000052 comment=224ff786e387d3022ce333bf2b7f5ea0cd2102c8 zonefs-tools-1.6.0/000077500000000000000000000000001436613652400141725ustar00rootroot00000000000000zonefs-tools-1.6.0/.gitignore000066400000000000000000000015021436613652400161600ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (c) 2019 Western Digital Corporation or its affiliates. # Object files *.o *.lo *.ko *.obj *.elf *.mod.c .*.o.cmd .*.ko.cmd *.lib *.a *.la # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex src/mkzonefs tests/log* tests/tools/zio tests/tools/zopen # Kernel compile files *.symvers modules.order .tmp_versions # Dependency files .depfile .depend # Windows-specific files Thumbs.db desktop.ini # Mac-specific things .DS_Store ._.DS_Store # Editors temporary files *~ # Autotools stuff m4/*.m4 aclocal.m4 autom4te.cache/ build-aux/ configure Makefile.in Makefile config.log config.status src/stamp-h1 config.h config.h.in .deps libtool .libs .dirstamp # Built RPMs *.rpm # Tests files tests/*.state tests/*.log zonefs-tools-1.6.0/CODE_OF_CONDUCT.md000066400000000000000000000127011436613652400167720ustar00rootroot00000000000000 # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [Open Source Inquiries][contact]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html [Mozilla CoC]: https://github.com/mozilla/diversity [FAQ]: https://www.contributor-covenant.org/faq [translations]: https://www.contributor-covenant.org/translations [contact]: https://www.westerndigital.com/contact/contact-open-source zonefs-tools-1.6.0/CONTRIBUTING000066400000000000000000000036631436613652400160340ustar00rootroot00000000000000SPDX-License-Identifier: CC0-1.0 Copyright (C) 2019 Western Digital Corporation or its affiliates. This project embraces the Developer Certificate of Origin (DCO) for contributions. This means you must agree to the following prior to submitting patches, if you agree with this developer certificate you acknowledge this by adding a Signed-off-by tag to your patch commit log. Every submitted patch must have this. The source for the DCO: http://developercertificate.org/ ----------------------------------------------------------------------- Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. zonefs-tools-1.6.0/COPYING.GPL000066400000000000000000000433621436613652400156560ustar00rootroot00000000000000Copyright (C) 2019, Western Digital Corporation or its affiliates. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. zonefs-tools-1.6.0/LICENSES/000077500000000000000000000000001436613652400153775ustar00rootroot00000000000000zonefs-tools-1.6.0/LICENSES/CC0-1.0.txt000066400000000000000000000156101436613652400170040ustar00rootroot00000000000000Creative Commons Legal Code CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; ii. moral rights retained by the original author(s) and/or performer(s); iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; v. rights protecting the extraction, dissemination, use and reuse of data in a Work; vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. zonefs-tools-1.6.0/LICENSES/GPL-2.0-or-later.txt000066400000000000000000000433621436613652400206120ustar00rootroot00000000000000Copyright (C) 2019, Western Digital Corporation or its affiliates. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. zonefs-tools-1.6.0/Makefile.am000066400000000000000000000015631436613652400162330ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2019 Western Digital Corporation or its affiliates. ACLOCAL_AMFLAGS = -I m4 SUBDIRS = src man if BUILD_TESTS SUBDIRS += tests/tools endif EXTRA_DIST = autogen.sh README.md COPYING.GPL CONTRIBUTING if BUILD_RPM rpmdir = $(abs_top_builddir)/rpmbuild EXTRA_DIST += zonefs-tools.spec tests RPMARCH=`$(RPM) --eval %_target_cpu` rpm: dist @echo "Building RPM package..." @mkdir -p $(rpmdir) $(RPMBUILD) -ta --clean -D "_topdir $(rpmdir)" zonefs-tools-$(PACKAGE_VERSION).tar.gz @mv -f $(rpmdir)/RPMS/$(RPMARCH)/*.rpm $(abs_top_builddir) @mv -f $(rpmdir)/SRPMS/*.rpm $(abs_top_builddir) @rm -rf $(rpmdir) @rm -f zonefs-tools-$(PACKAGE_VERSION).tar.gz else rpm: @echo "Building RPM packages requires rpmbuild and rpm utilities" exit 1 endif CLEANFILES = *.rpm *.tar.gz DISTCLEANFILES = *.rpm *.tar.gz configure configure~ zonefs-tools-1.6.0/README.md000066400000000000000000000234151436613652400154560ustar00rootroot00000000000000Copyright (C) 2019, Western Digital Corporation or its affiliates. #

zonefs tools

This project provides the *mkzonefs* command line utility which allows formatting zoned block devices for use with the *zonefs* file system. ## The *zonefs* File System *zonefs* is a very simple file system exposing each zone of a zoned block device as a file. *zonefs* does not have complex on-disk metadata. Its implementation relies solely on a super block stored at LBA 0 of the device. On mount, *zonefs* uses zone configuration information obtained directly from the device to populate the mount point with files representing the device zones. By default, the files created have the following characteristics. 1) The files mapped to zones of the same type are grouped together under a directory. * For conventional zones, the directory "cnv" is used. * For all sequential write zones, the directory "seq" is used. 2) The name of each file is by default the number of the file, corresponding to the number of the backing zone for the file. 3) The size of conventional zone files is fixed to the zone size. Conventional zone files cannot be truncated. 4) The size of sequential zone files represent the zones write pointer position relative to the zone start sector. Truncating these files is allowed only down to a 0 size, in wich case, the zone is reset to rewind its write pointer position to the start of the zone. 5) All read and write operations to files are not allowed beyond the file zone size. 6) Creating, deleting, renaming etc files and directories is not allowed. 7) All files are by default owned by the root user with access permissions set to 640 ("-rw-r-----"). The on-disk super block allows specifying optional features which change the default file system operation: 1) File names: the start sector value of a file backing zone can be used as a file name. 2) File owner UID and GID and access permissions can be changed. 3) Contiguous conventional zones can be aggregated into a single file instead of the default one file per zone. ## License The *zonefs-tools* project source code is distributed under the terms of the GNU General Public License v2.0 or later ([GPL-v2](https://opensource.org/licenses/GPL-2.0)). A copy of this license with *zonefs-tools* copyright can be found in the files [LICENSES/GPL-2.0-or-later.txt](LICENSES/GPL-2.0-or-later.txt) and [COPYING.GPL](COPYING.GPL). All source files in *zonefs-tools* contain the SPDX short identifier for the GPL-2.0-or-later license in place of the full license text. ``` SPDX-License-Identifier: GPL-2.0-or-later ``` Some files such as the `Makefile.am` files and the `.gitignore` file are public domain specified by the [CC0 1.0 Universal (CC0 1.0) Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/). These files are identified with the following SPDX short identifier header. ``` SPDX-License-Identifier: CC0-1.0 ``` See [LICENSES/CC0-1.0.txt](LICENSES/CC0-1.0.txt) for the full text of this license. ## Requirements The following packages must be installed prior to compiling *mkzonefs*. * m4 * autoconf * automake * libtool * libuuid library and its development headers (*libuuid* and *libuuid-devel* packages) * libblkid library and its development headers (*libblkid* and *libblkid-devel* packages) The kernel header file `/usr/include/linux/blkzoned.h` must also be present. ## Compilation and Installation The following commands will compile the *mkzonefs* tool. ``` > sh ./autogen.sh > ./configure > make ``` To install the compiled executable files, simply execute as root the following command. ``` > sudo make install ``` The default installation directory is /usr/sbin. This default location can be changed using the configure script. Executing the following command displays the options used to control the installation path. ``` > ./configure --help ``` ## Building RPM Packages The *rpm* and *rpmbuild* utilities are necessary to build *zonefs-tools* RPM packages. Once these utilities are installed, the RPM packages can be built using the following command. ``` $ sh ./autogen.sh $ ./configure $ make rpm ``` Four RPM packages are built: a binary package providing *mkzonefs* executable and its documentation and license files, a source RPM package, a *debuginfo* RPM package and a *debugsource* RPM package. The source RPM package can be used to build the binary and debug RPM packages outside of *zonefs-tools* source tree using the following command. ``` $ rpmbuild --rebuild zonefs-tools-.src.rpm ``` ## Usage *mkzonefs* detailed usage is as follows: ``` > mkzonefs -h Usage: mkzonefs [options] Options: --help | -h : General help message -v : Verbose output -f : Force overwrite of existing content -o : Optional features See "man mkzonefs" for more information ``` To format a zoned block device for use with *zonefs* with all default settings, the following command can be used. ``` # mkzonefs /dev/ ``` Enabling optional features can be done with the *-o* option. For instance, to set the files owner UID and GID to user "1000", the following command can be used. ``` # mkzonefs -o uid=1000,gid=1000 /dev/ ``` Several optional features can be specified simultaneously as a comma separated list. The following features are defined. Feature | Description --------------|------------------------------------------------- aggr_cnv | Aggregate contiguous conventional zones as a single file (default: off) uid=*int* | Set zone files user owner ID (default: 0) gid=*int* | Set zone files user group ID (default: 0) perm=*octal* | Set zone files access permissions (default: 640) ## Running tests zonefs tools also provide a test suite for testing the correct operation of zonefs with any zoned block device. To enable the compilation of tools used for tests, zonefs-tools must be compiled as follows. ``` > sh ./autogen.sh > ./configure --with-tests > make ``` Running the tests for a particular device is done as follows. ``` > cd tests > ./zonefs-tests.sh /dev/XXX ``` Where */dev/XXX* is the device file for the target zoned block device to test with. The script *zonefs-tests-nullblk.sh* is also available to test a particular kernel against a *nullblk* device. The *zonefs-tests.sh* script has several options that can be listed using the *-h* or *--help* options or by not specifying any argument. ``` > ./zonefs-tests.sh -h Usage: zonefs-tests.sh [Options] Options: -l : List all tests -g : Use file name for the test log file. default: -zonefs-tests.log -t : Execute only the specified test case. Can be specified multiple times. -s : Short test (do not execute tests that take a long time) -h, --help : This help message ``` The lists of test cases executed can be listed with the *-l* option. ``` ./zonefs-tests.sh -l Test 0010: mkzonefs (options) Test 0011: mkzonefs (force format) Test 0012: mkzonefs (invalid device) Test 0013: mkzonefs (super block zone state) Test 0020: mount (default) Test 0021: mount (invalid device) Test 0022: mount (check mount directory sub-directories) Test 0023: mount (options) Test 0030: Number of files (default) Test 0031: Number of files (aggr_cnv) Test 0032: Number of files using stat (default) Test 0033: Number of files using stat (aggr_cnv) Test 0034: Number of blocks using stat (default) Test 0035: Number of blocks using stat (aggr_cnv) Test 0040: Files permissions (default) Test 0041: Files permissions (aggr_cnv) Test 0042: Files permissions (set value) Test 0043: Files permissions (set value + aggr_cnv) Test 0050: Files owner (default) Test 0051: Files owner (aggr_cnv) Test 0052: Files owner (set value) Test 0053: Files owner (set value + aggr_cnv) Test 0060: Files size (default) Test 0061: Files size (aggr_cnv) Test 0070: Conventional file truncate Test 0071: Conventional file truncate (aggr_cnv) Test 0072: Conventional file unlink Test 0073: Conventional file unlink (aggr_cnv) Test 0074: Conventional file random write Test 0075: Conventional file random write (direct) Test 0076: Conventional file random write (aggr_cnv) Test 0077: Conventional file random write (aggr_cnv, direct) Test 0078: Conventional file mmap read/write Test 0079: Conventional file mmap read/write (aggr_cnv) Test 0080: Sequential file truncate Test 0081: Sequential file unlink Test 0082: Sequential file buffered write IO Test 0083: Sequential file overwrite Test 0084: Sequential file unaligned write (sync IO) Test 0085: Sequential file unaligned write (async IO) Test 0086: Sequential file append (sync) Test 0087: Sequential file append (async) Test 0088: Sequential file random read Test 0089: Sequential file mmap read/write Test 0090: sequential file 4K synchronous write Test 0091: Sequential file large synchronous write Test 0092: Sequential file explicit-open zone resources Test 0100: Swap file on conventional file Test 0101: Swap file on sequential file Test 0110: Sysfs attr after format Test 0111: Sysfs seq files active after mount (open zones) Test 0112: Sysfs seq files active after mount (active zones) Test 0113: Sysfs seq files write-open (default) Test 0114: Sysfs seq files write-open (explicit-open) Test 0115: Sysfs seq files active after write (default) Test 0116: Sysfs conv files write-open Test 0117: Sysfs conv files active after write ``` ## Contributing Read the [CONTRIBUTING](CONTRIBUTING) file and send patches to: Damien Le Moal If you believe your changes require kernel eyes or review, Cc the Linux kernel file system development mailing list: linux-fsdevel@vger.kernel.org zonefs-tools-1.6.0/autogen.sh000077500000000000000000000002141436613652400161700ustar00rootroot00000000000000#!/bin/sh # # SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2019 Western Digital Corporation or its affiliates. exec autoreconf -f -i zonefs-tools-1.6.0/configure.ac000066400000000000000000000033461436613652400164660ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2019 Western Digital Corporation or its affiliates. AC_INIT([zonefs tools], [1.6.0], [damien.lemoal@wdc.com]) AC_PREFIX_DEFAULT(/usr) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) AM_SILENT_RULES([yes]) AC_USE_SYSTEM_EXTENSIONS AC_SYS_LARGEFILE m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) m4_pattern_allow([AM_PROG_AR]) LT_INIT # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O AC_PROG_LN_S # Checks for header files. AC_CHECK_HEADER(libgen.h, [], [AC_MSG_ERROR([Couldn't find libgen.h])]) AC_CHECK_HEADER(mntent.h, [], [AC_MSG_ERROR([Couldn't find mntent.h])]) AC_CHECK_HEADER(linux/fs.h, [], [AC_MSG_ERROR([Couldn't find linux/fs.h])]) AC_CHECK_HEADER(blkid/blkid.h, [], [AC_MSG_ERROR([Couldn't find blkid/blkid.h])]) AC_CHECK_HEADER(linux/blkzoned.h, [], [AC_MSG_ERROR([Couldn't find linux/blkzoned.h])]) # Checks for libraries. AC_SEARCH_LIBS([blkid_do_fullprobe], [blkid], [], [AC_MSG_ERROR([Couldn't find libblkid])]) AC_SEARCH_LIBS([uuid_generate], [uuid], [], [AC_MSG_ERROR([Couldn't find libuuid])]) # Checks for rpm package builds AC_PATH_PROG([RPMBUILD], [rpmbuild], [notfound]) AC_PATH_PROG([RPM], [rpm], [notfound]) AM_CONDITIONAL([BUILD_RPM], [test "x$RPMBUILD" != xnotfound && test "x$RPM" != xnotfound]) # Build tests AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [Build test suite [default=no]])], [AM_CONDITIONAL([BUILD_TESTS], true) AC_CHECK_HEADER(linux/aio_abi.h, [], [AC_MSG_ERROR([Couldn't find linux/aio_abi.h])])], [AM_CONDITIONAL([BUILD_TESTS], false)]) AC_CONFIG_FILES([ Makefile man/Makefile src/Makefile tests/tools/Makefile ]) AC_OUTPUT zonefs-tools-1.6.0/m4/000077500000000000000000000000001436613652400145125ustar00rootroot00000000000000zonefs-tools-1.6.0/m4/dontremove000066400000000000000000000002531436613652400166170ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2019 Western Digital Corporation or its affiliates. the only purpose of this file is to keep the m4 directory in git zonefs-tools-1.6.0/man/000077500000000000000000000000001436613652400147455ustar00rootroot00000000000000zonefs-tools-1.6.0/man/Makefile.am000066400000000000000000000005371436613652400170060ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2019 Western Digital Corporation or its affiliates. dist_man_MANS = mkzonefs.8 install-data-hook: (cd $(DESTDIR)${mandir}/man8; rm -f mkfs.zonefs.8.gz) (cd $(DESTDIR)${mandir}/man8; $(LN_S) mkzonefs.8.gz mkfs.zonefs.8.gz) uninstall-hook: (cd $(DESTDIR)${mandir}/man8; rm -f mkfs.zonefs.8.gz) zonefs-tools-1.6.0/man/mkzonefs.8000066400000000000000000000030121436613652400166660ustar00rootroot00000000000000.\" SPDX-License-Identifier: GPL-2.0-or-later .\" .\" Copyright (C) 2019, Western Digital Corporation or its affiliates. .\" Written by Damien Le Moal .\" .TH mkzonefs 8 .SH NAME mkzonefs \- Create a zonefs file system on a zoned block device .SH SYNOPSIS .B mkzonefs [ .B \-h|\-\-help ] [ .B \-v ] [ .B \-f ] [ .B \-L .I label ] [ .B \-o .I features ] .I device .SH DESCRIPTION .B mkzonefs is used to create a zonefs file system on a zoned block device. .SH OPTIONS .TP \fB\-h\fR, \fB\-\-help\fR Display a short usage message and return .TP .BI \-v Verbose output .TP .BI \-f Overwrite existing file system format on the device .TP .BI \-L " label" Specify a label (volume name). A label must not exceed 32 characters. .TP .BI \-o " features" .RS Specify optional features. Features are comma separated and may take an argument using the equal ("=") sign. The following features are supported. .TP .BR aggr_cnv Aggregate contiguous conventional zones into a single file. Default: off (create one file per zone). .TP .BR uid =\fIUID\fR Create files with \fIUID\fR as owner user. The default is "root" user (UID 0). .TP .BR gid =\fIGID\fR Create files with \fIGID\fR as group owner. The default is "root" group (GID 0). .TP .BR perm =\fIpermissions\fR Create files with \fIpermissions\fR as access rights. The default is "640". .RE .SH AUTHOR This version of \fBmkzonefs\fR was written by Damien Le Moal. .SH AVAILABILITY .B mkzonefs is available from https://github.com/westerndigitalcorporation/zonefs-tools/ zonefs-tools-1.6.0/src/000077500000000000000000000000001436613652400147615ustar00rootroot00000000000000zonefs-tools-1.6.0/src/Makefile.am000066400000000000000000000010051436613652400170110ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2019 Western Digital Corporation or its affiliates. AM_CFLAGS = -O2 -Wall -Wextra -Wno-unused-parameter sbin_PROGRAMS = mkzonefs CFILES = zonefs_dev.c \ mkzonefs.c HFILES = zonefs.h mkzonefs_SOURCES = ${CFILES} ${HFILES} mkzonefs_LDADD = mkzonefs_LDFLAGS = -luuid -lblkid install-exec-hook: (cd $(DESTDIR)${sbindir}; rm -f mkfs.zonefs) (cd $(DESTDIR)${sbindir}; $(LN_S) mkzonefs mkfs.zonefs) uninstall-hook: (cd $(DESTDIR)${sbindir}; rm -f mkfs.zonefs) zonefs-tools-1.6.0/src/mkzonefs.c000066400000000000000000000157031436613652400167670ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-or-later /* * This file is part of zonefs tools. * Copyright (c) 2019 Western Digital Corporation or its affiliates. * * Authors: Damien Le Moal (damien.lemoal@wdc.com) */ #include #include #include #include #include #include #include #include #include #include "zonefs.h" /* * For super block checksum (CRC32) */ #define CRCPOLY_LE 0xedb88320 __u32 zonefs_crc32(__u32 crc, const void *buf, size_t length) { unsigned char *p = (unsigned char *)buf; int i; while (length--) { crc ^= *p++; for (i = 0; i < 8; i++) crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); } return crc; } /* * Fill and write a super block. */ static int zonefs_write_super(struct zonefs_dev *dev) { struct zonefs_super *super; __u32 crc; int ret; ret = posix_memalign((void **)&super, sysconf(_SC_PAGESIZE), sizeof(*super)); if (ret) { fprintf(stderr, "Not enough memory\n"); return -1; } memset(super, 0, sizeof(*super)); super->s_magic = __cpu_to_le32(ZONEFS_MAGIC); uuid_copy(super->s_uuid, dev->uuid); strcpy(super->s_label, dev->label); super->s_features = __cpu_to_le64(dev->features); super->s_uid = __cpu_to_le32(dev->uid); super->s_gid = __cpu_to_le32(dev->gid); super->s_perm = __cpu_to_le32(dev->perm); crc = zonefs_crc32(~0U, super, sizeof(*super)); super->s_crc = __cpu_to_le32(crc); ret = pwrite(dev->fd, super, sizeof(*super), 0); free(super); if (ret < 0) { fprintf(stderr, "%s: Write super block failed %d (%s)\n", dev->name, errno, strerror(errno)); return -1; } return zonefs_finish_zone(dev, &dev->zones[0]); } /* * Parse features string. */ static int zonefs_parse_features(struct zonefs_dev *dev, char *features) { char *ef, *f = features; while (*f) { if (strncmp(f, "aggr_cnv", 8) == 0) { dev->features |= ZONEFS_F_AGGRCNV; f += 8; } else if (strncmp(f, "uid=", 4) == 0) { dev->features |= ZONEFS_F_UID; f += 4; dev->uid = strtol(f, &ef, 10); if (errno == ERANGE) { fprintf(stderr, "Invalid UID\n"); return -1; } f = ef; } else if (strncmp(f, "gid=", 4) == 0) { dev->features |= ZONEFS_F_GID; f += 4; dev->gid = strtol(f, &ef, 10); if (errno == ERANGE) { fprintf(stderr, "Invalid GID\n"); return -1; } f = ef; } else if (strncmp(f, "perm=", 5) == 0) { dev->features |= ZONEFS_F_PERM; f += 5; dev->perm = strtol(f, &ef, 8); if (errno == ERANGE) { fprintf(stderr, "Invalid file permissions\n"); return -1; } f = ef; } if (*f) { if (*f != ',') { fprintf(stderr, "Invalid feature string\n"); return -1; } f++; } } return 0; } /* * Print usage. */ static void mkzonefs_usage(void) { printf("Usage: mkzonefs [options] \n"); printf("Options:\n" " --version : Print version number and exit\n" " --help | -h : General help message\n" " -v : Verbose output\n" " -f : Force overwrite of existing content\n" " -o : Optional features\n"); } /* * Main function. */ int main(int argc, char **argv) { unsigned int nr_zones; struct zonefs_dev dev; char uuid_str[UUID_STR_LEN]; int i, ret; /* Compile time checks */ ZONEFS_STATIC_ASSERT(sizeof(struct zonefs_super) == ZONEFS_SUPER_SIZE); ZONEFS_STATIC_ASSERT(sizeof(uuid_t) == ZONEFS_UUID_SIZE); /* Initialize */ memset(&dev, 0, sizeof(dev)); dev.fd = -1; /* Defaults */ dev.uid = 0; /* root */ dev.gid = 0; /* root */ dev.perm = S_IRUSR | S_IWUSR | S_IRGRP; /* 0640 */ /* Parse options */ for (i = 1; i < argc; i++) { if (strcmp(argv[i], "--version") == 0) { printf("mkzonefs, version %s\n", PACKAGE_VERSION); printf("Copyright (C) 2019, Western Digital Corporation" " or its affiliates.\n"); return 0; } if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { mkzonefs_usage(); printf("See \"man mkzonefs\" for more information\n"); return 0; } if (strcmp(argv[i], "-f") == 0) { dev.flags |= ZONEFS_OVERWRITE; } else if (strcmp(argv[i], "-v") == 0) { dev.flags |= ZONEFS_VERBOSE; } else if (strcmp(argv[i], "-L") == 0) { i++; if (i >= argc - 1) { fprintf(stderr, "Invalid command line\n"); return 1; } if (strlen(argv[i]) > ZONEFS_LABEL_LEN) { fprintf(stderr, "Label too long (%d chars allowed)\n", ZONEFS_LABEL_LEN); return 1; } memcpy(dev.label, argv[i], strlen(argv[i])); } else if (strcmp(argv[i], "-o") == 0) { i++; if (i >= argc - 1) { fprintf(stderr, "Invalid command line\n"); return 1; } if (zonefs_parse_features(&dev, argv[i]) < 0) return 1; } else if (argv[i][0] == '-') { fprintf(stderr, "Invalid option '%s'\n", argv[i]); return 1; } else { break; } } if (i != argc - 1) { fprintf(stderr, "No device specified\n"); return 1; } /* Get device path */ dev.path = realpath(argv[i], NULL); if (!dev.path) { fprintf(stderr, "Failed to get device real path\n"); return 1; } /* Open the device */ if (zonefs_open_dev(&dev, true) < 0) return 1; printf("%s: %llu 512-byte sectors (%llu GiB)\n", dev.path, dev.capacity, (dev.capacity << 9) / (1024ULL * 1024ULL * 1024ULL)); printf(" Host-%s device\n", (dev.model == ZONEFS_DEV_HM) ? "managed" : "aware"); nr_zones = dev.capacity / dev.zone_nr_sectors; printf(" %u zones of %zu 512-byte sectors (%zu MiB)\n", nr_zones, dev.zone_nr_sectors, (dev.zone_nr_sectors << 9) / (1024 * 1024)); if (nr_zones < dev.nr_zones) { size_t runt_sectors = dev.capacity & (dev.zone_nr_sectors - 1); printf(" 1 runt zone of %zu 512-byte sectors (%zu MiB)\n", runt_sectors, (runt_sectors << 9) / (1024 * 1024)); } printf(" %u conventional zones, %u sequential zones\n", dev.nr_conv_zones, dev.nr_seq_zones); printf(" %u read-only zones, %u offline zones\n", dev.nr_ro_zones, dev.nr_ol_zones); if (dev.nr_ol_zones >= dev.nr_zones - 1) { fprintf(stderr, "No useable zones\n"); ret = 1; goto out; } printf("Format:\n"); printf(" %u usable zones\n", dev.nr_zones - dev.nr_ol_zones - 1); printf(" Aggregate conventional zones: %s\n", dev.features & ZONEFS_F_AGGRCNV ? "enabled" : "disabled"); printf(" File UID: %u\n", dev.uid); printf(" File GID: %u\n", dev.gid); printf(" File access permissions: %o\n", dev.perm); if (strlen(dev.label)) printf(" FS label: %s\n", dev.label); uuid_generate(dev.uuid); uuid_unparse(dev.uuid, uuid_str); printf(" FS UUID: %s\n", uuid_str); ret = 1; printf("Resetting sequential zones\n"); if (zonefs_reset_zones(&dev) < 0) goto out; printf("Writing super block\n"); if (zonefs_write_super(&dev) < 0) goto out; /* Sync */ if (zonefs_sync_dev(&dev) < 0) goto out; ret = 0; out: zonefs_close_dev(&dev); return ret; } zonefs-tools-1.6.0/src/zonefs.h000066400000000000000000000053321436613652400164410ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-or-later /* * This file is part of zonefs tools. * Copyright (c) 2019 Western Digital Corporation or its affiliates. * * Authors: Damien Le Moal (damien.lemoal@wdc.com) */ #ifndef ZONEFS_H #define ZONEFS_H #define _LARGEFILE64_SOURCE #include "config.h" #include #include #include #include #include #include /* * On-disk super block magic. */ #ifndef ZONEFS_MAGIC #define ZONEFS_MAGIC 0x5a4f4653 /* 'Z' 'O' 'F' 'S' */ #endif /* * Feature flags. */ #define ZONEFS_F_AGGRCNV (1ULL << 0) #define ZONEFS_F_UID (1ULL << 1) #define ZONEFS_F_GID (1ULL << 2) #define ZONEFS_F_PERM (1ULL << 3) /* * Volume label and UUID size. */ #define ZONEFS_LABEL_LEN 64 #define ZONEFS_UUID_SIZE 16 /* * On disk super block. * This uses a full 4KB block. */ #define ZONEFS_SUPER_SIZE 4096U struct zonefs_super { /* Magic number */ __le32 s_magic; /* 4 */ /* Checksum */ __le32 s_crc; /* 8 */ /* Volume label */ char s_label[ZONEFS_LABEL_LEN]; /* 72 */ /* 128-bit uuid */ __u8 s_uuid[ZONEFS_UUID_SIZE]; /* 88 */ /* Features */ __le64 s_features; /* 96 */ /* UID/GID to use for files */ __le32 s_uid; /* 100 */ __le32 s_gid; /* 104 */ /* File permissions */ __le32 s_perm; /* 108 */ /* Padding to ZONEFS_SUPER_SIZE bytes */ __u8 s_reserved[3988]; /* 4096 */ } __attribute__ ((packed)); /* * Device descriptor. */ struct zonefs_dev { /* Device file path and basename */ char *path; char *name; /* Flags and features */ unsigned int flags; unsigned long long features; unsigned int uid; unsigned int gid; unsigned int perm; char label[ZONEFS_LABEL_LEN]; uuid_t uuid; /* Device info */ unsigned int model; unsigned long long capacity; size_t zone_nr_sectors; unsigned int nr_zones; unsigned int nr_conv_zones; unsigned int nr_seq_zones; unsigned int nr_ro_zones; unsigned int nr_ol_zones; struct blk_zone *zones; /* Device file descriptor */ int fd; }; /* * Device model. */ #define ZONEFS_DEV_HM 1 #define ZONEFS_DEV_HA 2 /* * Device flags. */ #define ZONEFS_VERBOSE (1 << 0) #define ZONEFS_OVERWRITE (1 << 1) #define zonefs_zone_id(dev, z) \ (unsigned int)((z)->start / (dev)->zone_nr_sectors) int zonefs_open_dev(struct zonefs_dev *dev, bool check_overwrite); void zonefs_close_dev(struct zonefs_dev *dev); int zonefs_sync_dev(struct zonefs_dev *dev); int zonefs_finish_zone(struct zonefs_dev *dev, struct blk_zone *zone); int zonefs_reset_zones(struct zonefs_dev *dev); /* * For compile time checks */ #define ZONEFS_STATIC_ASSERT(cond) \ void zonefs_static_assert(int dummy[(cond) ? 1 : -1]) #endif /* ZONEFS_H */ zonefs-tools-1.6.0/src/zonefs_dev.c000066400000000000000000000334001436613652400172670ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-or-later /* * This file is part of zonefs tools. * Copyright (c) 2019 Western Digital Corporation or its affiliates. * * Authors: Damien Le Moal (damien.lemoal@wdc.com) */ #include "zonefs.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Test if the device is mounted. */ static int zonefs_dev_mounted(struct zonefs_dev *dev) { struct mntent *mnt = NULL; FILE *file = NULL; file = setmntent("/proc/mounts", "r"); if (file == NULL) return 0; while ((mnt = getmntent(file)) != NULL) { if (strcmp(dev->path, mnt->mnt_fsname) == 0) break; } endmntent(file); return mnt ? 1 : 0; } /* * Test if the device is already used as a target backend. */ static int zonefs_dev_busy(struct zonefs_dev *dev) { char path[128]; struct dirent **namelist; int n, ret = 0; snprintf(path, sizeof(path), "/sys/block/%s/holders", dev->name); n = scandir(path, &namelist, NULL, alphasort); if (n < 0) { fprintf(stderr, "scandir %s failed\n", path); return -1; } while (n--) { if (strcmp(namelist[n]->d_name, "..") != 0 && strcmp(namelist[n]->d_name, ".") != 0) ret = 1; free(namelist[n]); } free(namelist); return ret; } /* * Check that the device supports reset all zones operation. * For now, simply exclude DM devices as that operation is never * supported on these devices. */ static bool zonefs_dev_has_reset_all(struct zonefs_dev *dev) { char path[PATH_MAX]; struct stat st; int len; /* Check if this is a DM device */ len = snprintf(path, sizeof(path), "/sys/block/%s/dm/name", dev->name); if (len >= PATH_MAX) { fprintf(stderr, "name %s failed: %s\n", path, strerror(ENAMETOOLONG)); return false; } return stat(path, &st) != 0; } /* * Check that the device is a zoned block device. */ static bool zonefs_dev_is_zoned(struct zonefs_dev *dev) { char str[PATH_MAX]; FILE *file; int res; int len; /* Check that this is a zoned block device */ len = snprintf(str, sizeof(str), "/sys/block/%s/queue/zoned", dev->name); /* Indicates truncation */ if (len >= PATH_MAX) { fprintf(stderr, "name %s failed: %s\n", str, strerror(ENAMETOOLONG)); return false; } file = fopen(str, "r"); if (!file) { fprintf(stderr, "Open %s failed\n", str); return false; } memset(str, 0, sizeof(str)); res = fscanf(file, "%s", str); fclose(file); if (res != 1) { fprintf(stderr, "Invalid file %s format\n", str); return false; } if (strcmp(str, "host-aware") == 0) { dev->model = ZONEFS_DEV_HA; return true; } if (strcmp(str, "host-managed") == 0) { dev->model = ZONEFS_DEV_HM; return true; } return false; } /* * Get device capacity and zone size. */ static int zonefs_get_dev_capacity(struct zonefs_dev *dev) { char str[128]; FILE *file; int res; /* Get capacity */ if (ioctl(dev->fd, BLKGETSIZE64, &dev->capacity) < 0) { fprintf(stderr, "%s: Get capacity failed %d (%s)\n", dev->path, errno, strerror(errno)); return -1; } dev->capacity >>= 9; /* Get zone size */ snprintf(str, sizeof(str), "/sys/block/%s/queue/chunk_sectors", dev->name); file = fopen(str, "r"); if (!file) { fprintf(stderr, "Open %s failed\n", str); return -1; } memset(str, 0, sizeof(str)); res = fscanf(file, "%s", str); fclose(file); if (res != 1) { fprintf(stderr, "Invalid file %s format\n", str); return -1; } dev->zone_nr_sectors = atol(str); if (!dev->zone_nr_sectors) { fprintf(stderr, "%s: Invalid zone size\n", dev->path); return -1; } return 0; } /* * Convert zone type to a string. */ static inline const char *zonefs_zone_type_str(struct blk_zone *zone) { switch (zone->type) { case BLK_ZONE_TYPE_CONVENTIONAL: return( "Conventional" ); case BLK_ZONE_TYPE_SEQWRITE_REQ: return( "Sequential-write-required" ); case BLK_ZONE_TYPE_SEQWRITE_PREF: return( "Sequential-write-preferred" ); } return( "Unknown-type" ); } /* * Convert zone condition to a string. */ static inline const char *zonefs_zone_cond_str(struct blk_zone *zone) { switch (zone->cond) { case BLK_ZONE_COND_NOT_WP: return "Not-write-pointer"; case BLK_ZONE_COND_EMPTY: return "Empty"; case BLK_ZONE_COND_IMP_OPEN: return "Implicit-open"; case BLK_ZONE_COND_EXP_OPEN: return "Explicit-open"; case BLK_ZONE_COND_CLOSED: return "Closed"; case BLK_ZONE_COND_READONLY: return "Read-only"; case BLK_ZONE_COND_FULL: return "Full"; case BLK_ZONE_COND_OFFLINE: return "Offline"; } return "Unknown-condition"; } /* * Print a device zone information. */ static void zonefs_print_zone(struct zonefs_dev *dev, struct blk_zone *zone) { if (zone->cond == BLK_ZONE_COND_READONLY) { printf("Zone %05u: readonly %s zone\n", zonefs_zone_id(dev, zone), zonefs_zone_type_str(zone)); return; } if (zone->cond == BLK_ZONE_COND_OFFLINE) { printf("Zone %05u: offline %s zone\n", zonefs_zone_id(dev, zone), zonefs_zone_type_str(zone)); return; } if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) { printf("Zone %05u: Conventional, sector %llu, %llu sectors\n", zonefs_zone_id(dev, zone), zone->start, zone->len); return; } printf("Zone %05u: type 0x%x (%s), cond 0x%x (%s), " "sector %llu, %llu sectors, wp sector %llu\n", zonefs_zone_id(dev, zone), zone->type, zonefs_zone_type_str(zone), zone->cond, zonefs_zone_cond_str(zone), zone->start, zone->len, zone->wp); } #define ZONEFS_REPORT_ZONES_BUFSZ 524288 /* * Get a device zone configuration. */ static int zonefs_get_dev_zones(struct zonefs_dev *dev) { struct blk_zone_report *rep = NULL; unsigned int rep_max_zones; struct blk_zone *blkz; unsigned int i, nr_zones; __u64 sector; int ret = -1; /* This will ignore an eventual last smaller zone */ nr_zones = dev->capacity / dev->zone_nr_sectors; if (dev->capacity % dev->zone_nr_sectors) nr_zones++; /* Allocate zone array */ dev->zones = calloc(nr_zones, sizeof(struct blk_zone)); if (!dev->zones) { fprintf(stderr, "Not enough memory\n"); return -1; } /* Get a buffer for zone report */ rep = malloc(ZONEFS_REPORT_ZONES_BUFSZ); if (!rep) { fprintf(stderr, "Not enough memory\n"); goto out; } rep_max_zones = (ZONEFS_REPORT_ZONES_BUFSZ - sizeof(struct blk_zone_report)) / sizeof(struct blk_zone); sector = 0; while (sector < dev->capacity) { /* Get zone information */ memset(rep, 0, ZONEFS_REPORT_ZONES_BUFSZ); rep->sector = sector; rep->nr_zones = rep_max_zones; ret = ioctl(dev->fd, BLKREPORTZONE, rep); if (ret != 0) { fprintf(stderr, "%s: Get zone information failed %d (%s)\n", dev->name, errno, strerror(errno)); goto out; } if (!rep->nr_zones) break; blkz = (struct blk_zone *)(rep + 1); for (i = 0; i < rep->nr_zones && sector < dev->capacity; i++) { if (dev->flags & ZONEFS_VERBOSE) zonefs_print_zone(dev, blkz); /* Check zone size */ if (blkz->len != dev->zone_nr_sectors && blkz->start + blkz->len != dev->capacity) { fprintf(stderr, "%s: Invalid zone %u size\n", dev->name, zonefs_zone_id(dev, blkz)); ret = -1; goto out; } dev->zones[dev->nr_zones] = *blkz; dev->nr_zones++; if (blkz->cond == BLK_ZONE_COND_READONLY) dev->nr_ro_zones++; else if (blkz->cond == BLK_ZONE_COND_OFFLINE) dev->nr_ol_zones++; if (blkz->type == BLK_ZONE_TYPE_CONVENTIONAL) dev->nr_conv_zones++; else dev->nr_seq_zones++; sector = blkz->start + blkz->len; blkz++; } } if (sector != dev->capacity) { fprintf(stderr, "%s: Invalid zones (last sector reported is %llu, " "expected %llu)\n", dev->name, sector, dev->capacity); ret = -1; goto out; } if (dev->nr_zones != nr_zones) { fprintf(stderr, "%s: Invalid number of zones (expected %u, got %u)\n", dev->name, nr_zones, dev->nr_zones); ret = -1; goto out; } out: free(rep); return ret; } /* * Get a device information. */ static int zonefs_get_dev_info(struct zonefs_dev *dev) { if (!zonefs_dev_is_zoned(dev)) { fprintf(stderr, "%s: Not a zoned block device\n", dev->name); return -1; } if (zonefs_get_dev_capacity(dev) < 0) return -1; if (zonefs_get_dev_zones(dev) < 0) return -1; return 0; } /* * Use libblkid to check for existing file systems on the device. * Return -1 on error, 0 if something valid is detected on the device * and 1 if the device appears to be unused. */ static int zonefs_check_overwrite(struct zonefs_dev *dev) { const char *type; blkid_probe pr; int ret = -1; pr = blkid_new_probe(); if (!pr) goto out; ret = blkid_probe_set_device(pr, dev->fd, 0, 0); if (ret < 0) goto out; ret = blkid_probe_enable_superblocks(pr, 1); if (ret < 0) goto out; ret = blkid_probe_enable_partitions(pr, 1); if (ret < 0) goto out; ret = blkid_do_fullprobe(pr); if (ret < 0 || ret == 1) { /* 1 means that nothing was found */ goto out; } /* Analyze what was found on the device */ ret = blkid_probe_lookup_value(pr, "TYPE", &type, NULL); if (ret == 0) { fprintf(stderr, "%s appears to contain an existing filesystem (%s)\n", dev->path, type); goto out; } ret = blkid_probe_lookup_value(pr, "PTTYPE", &type, NULL); if (ret == 0) { fprintf(stderr, "%s appears to contain a partition table (%s)\n", dev->path, type); goto out; } fprintf(stderr, "%s appears to contain something according to blkid\n", dev->path); ret = 0; out: if (pr) blkid_free_probe(pr); if (ret == 0) fprintf(stderr, "Use the option '-f' to overwrite\n"); else if (ret < 0) fprintf(stderr, "%s: probe failed, cannot detect existing filesystem\n", dev->name); return ret; } /* * Open a device. */ int zonefs_open_dev(struct zonefs_dev *dev, bool check_overwrite) { struct stat st; int ret; dev->name = basename(dev->path); /* Check that this is a block device */ if (stat(dev->path, &st) < 0) { fprintf(stderr, "Get %s stat failed %d (%s)\n", dev->path, errno, strerror(errno)); return -1; } if (!S_ISBLK(st.st_mode)) { fprintf(stderr, "%s is not a block device\n", dev->path); return -1; } if (zonefs_dev_mounted(dev)) { fprintf(stderr, "%s is mounted\n", dev->path); return -1; } if (zonefs_dev_busy(dev)) { fprintf(stderr, "%s is in use\n", dev->path); return -1; } /* Open device */ dev->fd = open(dev->path, O_RDWR | O_EXCL); if (dev->fd < 0) { fprintf(stderr, "Open %s failed %d (%s)\n", dev->path, errno, strerror(errno)); return -1; } if (check_overwrite && !(dev->flags & ZONEFS_OVERWRITE)) { /* Check for existing valid content */ ret = zonefs_check_overwrite(dev); if (ret <= 0) goto err; } /* We need direct writes */ ret = fcntl(dev->fd, F_SETFL, O_DIRECT); if (ret) { fprintf(stderr, "Set O_DIRECT failed %d (%s)\n", errno, strerror(errno)); goto err; } /* Get device capacity and zone configuration */ if (zonefs_get_dev_info(dev) < 0) goto err; return 0; err: zonefs_close_dev(dev); return -1; } /* * Close an open device. */ void zonefs_close_dev(struct zonefs_dev *dev) { if (dev->fd >= 0) { close(dev->fd); dev->fd = -1; } free(dev->zones); dev->zones = NULL; } /* * Write a metadata block. */ int zonefs_sync_dev(struct zonefs_dev *dev) { blkid_cache cache; int ret; ret = fsync(dev->fd); if (ret < 0) { fprintf(stderr, "%s: fsync failed %d (%s)\n", dev->name, errno, strerror(errno)); return -1; } /* * Make sure udev notices the uuid and label changes so that blkid * cache and by-uuid/by-label device links all get updated. */ ret = blkid_get_cache(&cache, NULL); if (ret >= 0) { blkid_get_dev(cache, dev->path, BLKID_DEV_NORMAL); blkid_put_cache(cache); } blkid_send_uevent(dev->path, "change"); return 0; } /* * Finish a zone (requires Linux kernel v5.5 and above). */ #ifdef BLKFINISHZONE int zonefs_finish_zone(struct zonefs_dev *dev, struct blk_zone *zone) { struct blk_zone_range range; if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) return 0; /* Sequential zone: transition it to full state */ range.sector = zone->start; range.nr_sectors = zone->len; if (ioctl(dev->fd, BLKFINISHZONE, &range) < 0) { fprintf(stderr, "%s: Finish zone %u failed %d (%s)\n", dev->name, zonefs_zone_id(dev, zone), errno, strerror(errno)); return -1; } return 0; } #else int zonefs_finish_zone(struct zonefs_dev *dev, struct blk_zone *zone) { return 0; } #endif /* BLKFINISHZONE */ /* * Reset a zone. */ static int zonefs_reset_zone(struct zonefs_dev *dev, struct blk_zone *zone) { struct blk_zone_range range; if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL) return 0; /* Sequential zone: reset */ range.sector = zone->start; range.nr_sectors = zone->len; if (ioctl(dev->fd, BLKRESETZONE, &range) < 0) { fprintf(stderr, "%s: Reset zone %u failed %d (%s)\n", dev->name, zonefs_zone_id(dev, zone), errno, strerror(errno)); return -1; } zone->wp = zone->start; return 0; } /* * Reset all zones of a device. */ int zonefs_reset_zones(struct zonefs_dev *dev) { struct blk_zone_range range; unsigned int i; int ret; /* * Try to reset all zones. This does not work on all devices so if * this fails, fall back to resetting zones one at a time. */ if (zonefs_dev_has_reset_all(dev)) { range.sector = 0; range.nr_sectors = dev->capacity; ret = ioctl(dev->fd, BLKRESETZONE, &range); if (!ret) { for (i = 0; i < dev->nr_zones; i++) dev->zones[i].wp = dev->zones[i].start; return 0; } } /* Fallback to zone reset zones one at a time */ for (i = 0; i < dev->nr_zones; i++) { ret = zonefs_reset_zone(dev, &dev->zones[i]); if (ret) return ret; } return 0; } zonefs-tools-1.6.0/tests/000077500000000000000000000000001436613652400153345ustar00rootroot00000000000000zonefs-tools-1.6.0/tests/scripts/000077500000000000000000000000001436613652400170235ustar00rootroot00000000000000zonefs-tools-1.6.0/tests/scripts/0001.sh000077500000000000000000000015461436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mkzonefs (options)" exit 0 fi # Test various good mkzonefs options OPTS_OK=("" "-h" "--help" "--help" "-v" "-f" "-o aggr_cnv" "-o uid=0" "-o gid=0" "-o perm=777" "-o aggr_cnv,uid=0,gid=0,perm=777") for ((i = 0; i < ${#OPTS_OK[@]}; i++)); do clear_sb "$1" cmd="mkzonefs ${OPTS_OK[$i]} $1" echo "Check mkzonefs command: $cmd" $cmd || exit_failed " --> FAILED" done # Test various bad mkzonefs options OPTS_BAD=("-bad-option" "-o" "-o invalid_feature" "-o invalid,,list") for ((i = 0; i < ${#OPTS_BAD[@]}; i++)); do cmd="mkzonefs ${OPTS_BAD[$i]} $1" echo "Check mkzonefs command: $cmd" $cmd && exit_failed " --> SUCCESS (should FAIL)" done exit 0 zonefs-tools-1.6.0/tests/scripts/0002.sh000077500000000000000000000010631436613652400177430ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # if [ $# == 0 ]; then echo "mkzonefs (force format)" exit 0 fi require_program mkfs.f2fs # Format with f2fs mkfs.f2fs -m "$1" || exit_failed " --> f2fs format FAILED" # This should fail echo "Check mkzonefs with used super block and not forced" mkzonefs "$1" && exit_failed " --> FAILED" # And pass if -f is specified echo "Check mkzonefs with used super block and forced" mkzonefs -f "$1" || exit_failed " --> FAILED" exit 0 zonefs-tools-1.6.0/tests/scripts/0003.sh000077500000000000000000000010521436613652400177420ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mkzonefs (invalid device)" exit 0 fi # Not a block device echo "# Trying /dev/console" mkzonefs /dev/console && exit_failed " --> SUCCESS (should FAIL)" # Regular block device nulldev=$(create_regular_nullb) echo "# Trying regular block device /dev/nullb$nulldev" mkzonefs "/dev/nullb$nulldev" && exit_failed " --> SUCCESS (should FAIL)" destroy_nullb $nulldev exit 0 zonefs-tools-1.6.0/tests/scripts/0004.sh000077500000000000000000000007331436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mkzonefs (super block zone state)" exit 0 fi if zone_is_conventional "$1" "0"; then # The super block is in a conventional zone: nothing to do echo "conventional zone" exit 0 fi zonefs_mkfs "$1" zone_is_full "$1" "0" || exit_failed " --> Super block zone is not in full state" exit 0 zonefs-tools-1.6.0/tests/scripts/0020.sh000077500000000000000000000004541436613652400177460ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mount (default)" exit 0 fi echo "Check default mount" zonefs_mkfs "$1" zonefs_mount "$1" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0021.sh000077500000000000000000000007341436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mount (invalid device)" exit 0 fi # Invalid device echo "Check mount with invalid device" zonefs_mount_err /dev/console # Regular device echo "Check mount with non-zoned block device" nulldev=$(create_regular_nullb) zonefs_mount_err "/dev/nullb$nulldev" destroy_nullb $nulldev exit 0 zonefs-tools-1.6.0/tests/scripts/0022.sh000077500000000000000000000012411436613652400177430ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mount (check mount directory sub-directories)" exit 0 fi zonefs_mkfs "$1" zonefs_mount "$1" if [ "$nr_cnv_zones" -le 1 ]; then if [ -d "$zonefs_mntdir/cnv/" ]; then echo "$zonefs_mntdir/cnv/ exits (should not exist)" exit 1 fi else if [ ! -d "$zonefs_mntdir/cnv/" ]; then echo "$zonefs_mntdir/cnv/ does not exit (should exist)" exit 1 fi fi if [ ! -d "$zonefs_mntdir/seq/" ]; then echo "$zonefs_mntdir/seq/ does not exit (should exit)" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0023.sh000077500000000000000000000012461436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "mount (options)" exit 0 fi zonefs_mkfs "$1" # Test good mount options OPTS=("-o errors=repair" "-o errors=remount-ro" "-o errors=zone-ro" "-o errors=zone-offline") for ((i = 0; i < ${#OPTS[@]}; i++)); do zonefs_mount "${OPTS[$i]} $1" zonefs_umount "$1" done # Test invalid mount options OPTS=("-o errors=continue" "-o errors=panic" "-o foo=bar" "-o bad_option") for ((i = 0; i < ${#OPTS[@]}; i++)); do zonefs_mount_err "${OPTS[$i]} $1" done exit 0 zonefs-tools-1.6.0/tests/scripts/0040.sh000077500000000000000000000022631436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Number of files (default)" exit 0 fi echo "Check for number of files: $nr_cnv_files cnv, $nr_seq_files seq" zonefs_mkfs "$1" zonefs_mount "$1" if [ "$nr_cnv_files" != 0 ]; then nr_files=$(ls_nr_files "$zonefs_mntdir/cnv/") if [ "$nr_files" != "$nr_cnv_files" ]; then echo " --> Invalid number of conventional zones file:" echo " --> Expected $nr_cnv_files, got $nr_files" exit 1 fi nr_files=$(file_size "$zonefs_mntdir/cnv") if [ "$nr_files" != "$nr_cnv_files" ]; then echo " --> Invalid cnv directory size:" echo " --> Expected $nr_cnv_files, got $nr_files" exit 1 fi fi nr_files=$(ls_nr_files "$zonefs_mntdir/seq/") if [ "$nr_files" != "$nr_seq_files" ]; then echo " --> Invalid number of sequential zones file:" echo " --> Expected $nr_seq_files, got $nr_files" exit 1 fi nr_files=$(file_size "$zonefs_mntdir/seq/") if [ "$nr_files" != "$nr_seq_files" ]; then echo " --> Invalid seq directory size:" echo " --> Expected $nr_seq_files, got $nr_files" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0041.sh000077500000000000000000000021421436613652400177450ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Number of files (aggr_cnv)" exit 0 fi require_cnv_files echo "Check for number of files: 1 cnv, $nr_seq_files seq" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" nr_files=$(ls_nr_files "$zonefs_mntdir/cnv/") if [ "$nr_files" != 1 ]; then echo " --> Invalid number of conventional zones file:" echo " --> Expected 1, got $nr_files" exit 1 fi nr_files=$(file_size "$zonefs_mntdir/cnv") if [ "$nr_files" != 1 ]; then echo " --> Invalid cnv directory size:" echo " --> Expected 1, got $nr_files" exit 1 fi nr_files=$(ls_nr_files "$zonefs_mntdir/seq/") if [ "$nr_files" != "$nr_seq_files" ]; then echo " --> Invalid number of sequential zones file:" echo " --> Expected $nr_seq_files, got $nr_files" exit 1 fi nr_files=$(file_size "$zonefs_mntdir/seq") if [ "$nr_files" != "$nr_seq_files" ]; then echo " --> Invalid seq directory size:" echo " --> Expected $nr_seq_files, got $nr_files" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0042.sh000077500000000000000000000015171436613652400177530ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Number of files using stat (default)" exit 0 fi echo "Check for number of files: $nr_cnv_files cnv, $nr_seq_files seq" zonefs_mkfs "$1" zonefs_mount "$1" nr_s_files=$nr_seq_files if [ "$nr_seq_files" != 0 ]; then nr_s_files=$(( nr_s_files + 1 )) fi nr_c_files=$nr_cnv_files if [ "$nr_cnv_files" != 0 ]; then nr_c_files=$(( nr_c_files + 1 )) fi nr_expected_files=$(( nr_s_files + nr_c_files )) nr_files=$(stat_nr_files "$zonefs_mntdir") if [ "$nr_files" != "$nr_expected_files" ]; then echo " --> Invalid total number of zone files:" echo " --> Expected $nr_expected_files, got $nr_files" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0043.sh000077500000000000000000000015151436613652400177520ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Number of files using stat (aggr_cnv)" exit 0 fi require_cnv_files echo "Check for number of files: 1 aggr_cnv, $num_seq_files seq" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" nr_s_files=$nr_seq_files if [ "$nr_seq_files" != 0 ]; then nr_s_files=$(( nr_s_files + 1 )) fi if [ $nr_cnv_files != 0 ]; then nr_c_files=2 else nr_c_files=0 fi nr_expected_files=$(( nr_s_files + nr_c_files )) nr_files=$(stat_nr_files "$zonefs_mntdir") if [ "$nr_files" != "$nr_expected_files" ]; then echo " --> Invalid total number of zone files:" echo " --> Expected $nr_expected_files, got $nr_files" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0044.sh000077500000000000000000000013321436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Number of blocks using stat (default)" exit 0 fi echo "Check for number of blocks for the file system" zonefs_mkfs "$1" zonefs_mount "$1" nr_blocks=$(block_number "$zonefs_mntdir") sz_blocks=$(block_size "$zonefs_mntdir") capacity_bytes=$(( total_usable_sectors * 512)) nr_expected_blocks=$(( capacity_bytes / sz_blocks )) if [ "$nr_blocks" != "$nr_expected_blocks" ]; then echo " --> Invalid total number of blocks:" echo " --> Expected $nr_expected_blocks, got $nr_blocks" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0045.sh000077500000000000000000000013471436613652400177570ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Number of blocks using stat (aggr_cnv)" exit 0 fi echo "Check for number of blocks of the file system" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" nr_blocks=$(block_number "$zonefs_mntdir") sz_blocks=$(block_size "$zonefs_mntdir") capacity_bytes=$(( total_usable_sectors * 512)) nr_expected_blocks=$(( capacity_bytes / sz_blocks )) if [ "$nr_blocks" != "$nr_expected_blocks" ]; then echo " --> Invalid total number of blocks:" echo " --> Expected $nr_expected_blocks, got $nr_blocks" exit 1 fi zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0060.sh000077500000000000000000000005241436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files permissions (default)" exit 0 fi echo "Check for files permission 640" zonefs_mkfs "$1" zonefs_mount "$1" check_perm "640" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0061.sh000077500000000000000000000005771436613652400177610ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files permissions (aggr_cnv)" exit 0 fi require_cnv_files echo "Check for files permission 640 (aggr_cnv)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" check_perm "640" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0062.sh000077500000000000000000000005501436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files permissions (format set value)" exit 0 fi echo "Check for files permission 770" zonefs_mkfs "-o perm=770 $1" zonefs_mount "$1" check_perm "770" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0063.sh000077500000000000000000000006331436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files permissions (format set value + aggr_cnv)" exit 0 fi require_cnv_files echo "Check for files permission 770 (aggr_cnv)" zonefs_mkfs "-o aggr_cnv,perm=770 $1" zonefs_mount "$1" check_perm "770" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0064.sh000077500000000000000000000014721436613652400177570ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files permissions (user set value)" exit 0 fi echo "Check for files permission persistence" zonefs_mkfs "$1" zonefs_mount "$1" if [ "$nr_cnv_files" != 0 ]; then check_file_perm "$zonefs_mntdir/cnv/0" "640" chmod 770 "$zonefs_mntdir"/cnv/0 check_file_perm "$zonefs_mntdir/cnv/0" "770" # Drop inode cache and check again drop_inode_cache check_file_perm "$zonefs_mntdir/cnv/0" "770" fi check_file_perm "$zonefs_mntdir/seq/0" "640" chmod 770 "$zonefs_mntdir"/seq/0 check_file_perm "$zonefs_mntdir/seq/0" "770" # Drop inode cache and check again drop_inode_cache check_file_perm "$zonefs_mntdir/seq/0" "770" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0065.sh000077500000000000000000000014551436613652400177610ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files permissions (user set value + aggr_cnv)" exit 0 fi require_cnv_files echo "Check for files permission persistence" zonefs_mkfs "$1" zonefs_mount "$1" check_file_perm "$zonefs_mntdir/cnv/0" "640" chmod 770 "$zonefs_mntdir"/cnv/0 check_file_perm "$zonefs_mntdir/cnv/0" "770" # Drop inode cache and check again drop_inode_cache check_file_perm "$zonefs_mntdir/cnv/0" "770" check_file_perm "$zonefs_mntdir/seq/0" "640" chmod 770 "$zonefs_mntdir"/seq/0 check_file_perm "$zonefs_mntdir/seq/0" "770" # Drop inode cache and check again drop_inode_cache check_file_perm "$zonefs_mntdir/seq/0" "770" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0080.sh000077500000000000000000000005261436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files owner (default)" exit 0 fi echo "Check for default UID 0 and GID 0" zonefs_mkfs "$1" zonefs_mount "$1" check_uid_gid "0" "0" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0081.sh000077500000000000000000000006001436613652400177460ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files owner (aggr_cnv)" exit 0 fi require_cnv_files echo "Check for default UID 0 and GID 0, aggr_cnv" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" check_uid_gid "0" "0" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0082.sh000077500000000000000000000011471436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files owner (format set value)" exit 0 fi echo "Check for UID 1000, GID 0" zonefs_mkfs "-o uid=1000 $1" zonefs_mount "$1" check_uid_gid "1000" "0" zonefs_umount echo "Check for UID 0, GID 1000" zonefs_mkfs "-o gid=1000 $1" zonefs_mount "$1" check_uid_gid "0" "1000" zonefs_umount echo "Check for UID 1000, GID 2000" zonefs_mkfs "-o uid=1000,gid=2000 $1" zonefs_mount "$1" check_uid_gid "1000" "2000" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0083.sh000077500000000000000000000012761436613652400177620ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files owner (format set value + aggr_cnv)" exit 0 fi require_cnv_files echo "Check for UID 1000, GID 0, aggr_cnv" zonefs_mkfs "-o aggr_cnv,uid=1000 $1" zonefs_mount "$1" check_uid_gid "1000" "0" zonefs_umount echo "Check for UID 0, GID 1000, aggr_cnv" zonefs_mkfs "-o aggr_cnv,gid=1000 $1" zonefs_mount "$1" check_uid_gid "0" "1000" zonefs_umount echo "Check for UID 1000, GID 2000, aggr_cnv" zonefs_mkfs "-o aggr_cnv,uid=1000,gid=2000 $1" zonefs_mount "$1" check_uid_gid "1000" "2000" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0084.sh000077500000000000000000000015471436613652400177640ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files owner (user set value)" exit 0 fi echo "Check for files UID/GID persistence" zonefs_mkfs "$1" zonefs_mount "$1" if [ "$nr_cnv_files" != 0 ]; then check_file_uid_gid "$zonefs_mntdir/cnv/0" "0 0" chown 1000:1000 "$zonefs_mntdir"/cnv/0 check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" # Drop inode cache and check again drop_inode_cache check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" fi check_file_uid_gid "$zonefs_mntdir/seq/0" "0 0" chown 1000:1000 "$zonefs_mntdir"/seq/0 check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" # Drop inode cache and check again drop_inode_cache check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0085.sh000077500000000000000000000015321436613652400177570ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files owner (user set value + aggr_cnv)" exit 0 fi require_cnv_files echo "Check for files UID/GID persistence" zonefs_mkfs "$1" zonefs_mount "$1" check_file_uid_gid "$zonefs_mntdir/cnv/0" "0 0" chown 1000:1000 "$zonefs_mntdir"/cnv/0 check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" # Drop inode cache and check again drop_inode_cache check_file_uid_gid "$zonefs_mntdir/cnv/0" "1000 1000" check_file_uid_gid "$zonefs_mntdir/seq/0" "0 0" chown 1000:1000 "$zonefs_mntdir"/seq/0 check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" # Drop inode cache and check again drop_inode_cache check_file_uid_gid "$zonefs_mntdir/seq/0" "1000 1000" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0100.sh000077500000000000000000000005201436613652400177370ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files size (default)" exit 0 fi echo "Check for $zone_bytes B file size" zonefs_mkfs "$1" zonefs_mount "$1" check_size false zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0101.sh000077500000000000000000000006121436613652400177420ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Files size (aggr_cnv)" exit 0 fi require_cnv_files echo "Check for $(( zone_bytes * (nr_cnv_zones - 1) )) B file size" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" check_size true zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0110.sh000077500000000000000000000022301436613652400177400ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "File names and inode numbers (default)" exit 0 fi echo "Check file names and their inode numbers" zonefs_mkfs "$1" zonefs_mount "$1" echo "Checking root inode $zonefs_mntdir" check_dir_ino "$zonefs_mntdir" ${nr_zones} if [ "$nr_cnv_files" != "0" ]; then echo "Checking conventional files" if $short; then nrfiles=$(min ${nr_cnv_files} 500) else nrfiles=${nr_cnv_files} fi echo "Checking cnv directory inode number" check_dir_ino "$zonefs_mntdir/cnv" $(( nr_zones + 1 )) echo "Checking cnv directory files inode number" check_files_ino "$zonefs_mntdir/cnv" ${nrfiles} 1 fi echo "Checking sequential files" if $short; then nrfiles=$(min ${nr_seq_files} 2000) else nrfiles=${nr_seq_files} fi echo "Checking seq directory inode number" check_dir_ino "$zonefs_mntdir/seq" $(( nr_zones + 2 )) echo "Checking seq directory files inode number" check_files_ino "$zonefs_mntdir/seq" \ ${nrfiles} \ $(( seq_file_0_zone_start_sector / zone_sectors )) zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0111.sh000077500000000000000000000017601436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "File names and inode numbers (aggr_cnv)" exit 0 fi require_cnv_files echo "Check file names and their inode numbers" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" echo "Checking root inode $zonefs_mntdir" check_dir_ino "$zonefs_mntdir" ${nr_zones} echo "Checking cnv directory inode number" check_dir_ino "$zonefs_mntdir/cnv" $(( nr_zones + 1 )) echo "Checking cnv directory files inode number" check_files_ino "$zonefs_mntdir/cnv" ${nr_cnv_files} 1 if $short; then nrfiles=$(min ${nr_seq_files} 2000) else nrfiles=${nr_seq_files} fi echo "Checking seq directory inode number" check_dir_ino "$zonefs_mntdir/seq" $(( nr_zones + 2 )) echo "Checking seq directory files inode number" check_files_ino "$zonefs_mntdir/seq" \ ${nrfiles} \ $(( seq_file_0_zone_start_sector / zone_sectors )) zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0200.sh000077500000000000000000000007001436613652400177400ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file truncate" exit 0 fi require_cnv_files echo "Check conventional file truncate" zonefs_mkfs "$1" zonefs_mount "$1" truncate --no-create --size=0 "$zonefs_mntdir"/cnv/0 && \ exit_failed " --> SUCCESS (should FAIL)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0201.sh000077500000000000000000000007411436613652400177460ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file truncate (aggr_cnv)" exit 0 fi require_cnv_files echo "Check conventional file truncate, aggr_cnv" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" truncate --no-create --size=0 "$zonefs_mntdir"/cnv/0 && \ exit_failed " --> SUCCESS (should FAIL)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0202.sh000077500000000000000000000006441436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file unlink" exit 0 fi require_cnv_files echo "Check conventional file unlink" zonefs_mkfs "$1" zonefs_mount "$1" rm -f "$zonefs_mntdir"/cnv/0 && \ exit_failed " --> SUCCESS (should FAIL)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0203.sh000077500000000000000000000007051436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file unlink (aggr_cnv)" exit 0 fi require_cnv_files echo "Check conventional file unlink, aggr_cnv" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" rm -f "$zonefs_mntdir"/cnv/0 && \ exit_failed " --> SUCCESS (should FAIL)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0204.sh000077500000000000000000000011341436613652400177460ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file random write" exit 0 fi require_cnv_files require_program fio echo "Check conventional file random write" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=libaio --iodepth=8 \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0205.sh000077500000000000000000000017341436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file random write (direct)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file random write, direct IO (sync)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=psync \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file random write, direct IO (async)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=libaio --iodepth=64 \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0206.sh000077500000000000000000000020221436613652400177450ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file random write (aggr_cnv)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file random write, aggr_cnv (sync)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=psync --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file random write, aggr_cnv (async)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0207.sh000077500000000000000000000021001436613652400177430ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file random write (aggr_cnv, direct)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file random write, aggr_cnv, direct (sync)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=psync --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file random write, aggr_cnv, direct (async)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_rndwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0208.sh000077500000000000000000000021241436613652400177520ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file mmap read/write" exit 0 fi require_cnv_files require_program fio echo "Check conventional file mmap write" zonefs_mkfs "$1" zonefs_mount "$1" maxsize=$(file_max_size "$zonefs_mntdir"/cnv/0) fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ --bs="${iosize}" --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file mmap read" zonefs_mount "$1" fio --name=cnv_mmaprd --filename="$zonefs_mntdir"/cnv/0 \ --rw=randread --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ --bs="${iosize}" --verify=md5 --do_verify=1 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0209.sh000077500000000000000000000021521436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file mmap read/write (aggr_cnv)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file mmap write (aggr_cnv)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" maxsize=$(aggr_cnv_size) fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=randwrite --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ --bs="${iosize}" --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file mmap read (aggr_cnv)" zonefs_mount "$1" fio --name=cnv_mmaprd --filename="$zonefs_mntdir"/cnv/0 \ --rw=randread --ioengine=mmap --size="$maxsize" \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ --bs="${iosize}" --verify=md5 --do_verify=1 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0210.sh000077500000000000000000000016261436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq write" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq write (sync)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=psync \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq write (async)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=libaio --iodepth=64 \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0211.sh000077500000000000000000000017131436613652400177470ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq write (direct)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq write, direct IO (sync)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=psync \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq write, direct IO (async)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=libaio --iodepth=64 \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0212.sh000077500000000000000000000020011436613652400177370ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq write (aggr_cnv)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq write, aggr_cnv (sync)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=psync --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq write, aggr_cnv (async)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0213.sh000077500000000000000000000020571436613652400177530ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq write (aggr_cnv, direct)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq write, aggr_cnv, direct (sync)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=psync --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq write, aggr_cnv, direct (async)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqwr --filename="$zonefs_mntdir"/cnv/0 \ --rw=write --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ --bs=131072 --verify=md5 --do_verify=1 --overwrite=1 \ --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0214.sh000077500000000000000000000014111436613652400177450ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq write (large IOs)" exit 0 fi require_cnv_files require_program dd echo "Check conventional file seq write (large IOs, buffered)" zonefs_mkfs "$1" zonefs_mount "$1" bs=$(file_size "$zonefs_mntdir"/cnv/0) dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ bs="$bs" count=1 conv=notrunc || \ exit_failed " --> FAILED" sync || exit_failed " --> FAILED" echo "Check conventional file seq write (large_IOs, direct)" dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ bs="$bs" count=1 conv=notrunc oflag=direct || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0215.sh000077500000000000000000000017321436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq write (aggr_cnv, large IOs)" exit 0 fi require_cnv_files require_program dd zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fsz=$(aggr_cnv_size) bs=$(( 16 * 1024 * 1024 )) if [ $bs -gt $fsz ]; then bs="$fsz" fi count=$(( fsz / bs )) echo "Check conventional file seq write (aggr_cnv, large IOs, buffered)" echo "bs: $bs, count: $count, fsz: $fsz" dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ bs="$bs" count="$count" conv=notrunc || \ exit_failed " --> FAILED" sync || exit_failed " --> FAILED" echo "Check conventional file seq write (aggr_cnv, large_IOs, direct)" echo "bs: $bs, count: $count, fsz: $fsz" dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 \ bs="$bs" count="$count" conv=notrunc oflag=direct || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0216.sh000077500000000000000000000014631436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq read" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq read (sync)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=psync \ --bs=131072 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq read (async)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=libaio --iodepth=64 \ --bs=131072 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0217.sh000077500000000000000000000015501436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq read (direct)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq read, direct IO (sync)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=psync \ --bs=131072 --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq read, direct IO (async)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=libaio --iodepth=64 \ --bs=131072 --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0218.sh000077500000000000000000000016361436613652400177620ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq read (aggr_cnv)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq read, aggr_cnv (sync)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=psync --size="$(aggr_cnv_size)" \ --bs=131072 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq read, aggr_cnv (async)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ --bs=131072 --continue_on_error=none || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0219.sh000077500000000000000000000017141436613652400177600ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq read (aggr_cnv, direct)" exit 0 fi require_cnv_files require_program fio echo "Check conventional file seq read, aggr_cnv, direct (sync)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=psync --size="$(aggr_cnv_size)" \ --bs=131072 --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount echo "Check conventional file seq read, aggr_cnv, direct (async)" zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fio --name=cnv_seqrd --filename="$zonefs_mntdir"/cnv/0 \ --rw=read --ioengine=libaio --iodepth=64 --size="$(aggr_cnv_size)" \ --bs=131072 --continue_on_error=none --direct=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0220.sh000077500000000000000000000013541436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq read (large IOs)" exit 0 fi require_cnv_files require_program dd echo "Check conventional file seq read (large IOs, buffered)" zonefs_mkfs "$1" zonefs_mount "$1" bs=$(file_size "$zonefs_mntdir"/cnv/0) dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ bs="$bs" count=1 || \ exit_failed " --> FAILED" sync || exit_failed " --> FAILED" echo "Check conventional file seq read (large_IOs, direct)" dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ bs="$bs" count=1 iflag=direct || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0221.sh000077500000000000000000000020001436613652400177360ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file seq read (aggr_cnv, large IOs)" exit 0 fi require_cnv_files require_program dd zonefs_mkfs "-o aggr_cnv $1" zonefs_mount "$1" fsz=$(aggr_cnv_size) bs=$(( 16 * 1024 * 1024 )) if [ $bs -gt $fsz ]; then bs="$fsz" fi count=$(( fsz / bs )) if [ $(( count * bs )) -ne $fsz ]; then count=$(( count + 1 )) fi echo "Check conventional file seq read (aggr_cnv, large IOs, buffered)" echo "bs: $bs, count: $count, fsz: $fsz" dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ bs="$bs" count="$count" || \ exit_failed " --> FAILED" sync || exit_failed " --> FAILED" echo "Check conventional file seq read (aggr_cnv, large_IOs, direct)" echo "bs: $bs, count: $count, fsz: $fsz" dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ bs="$bs" count="$count" iflag=direct || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0222.sh000077500000000000000000000011721436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file readahead" exit 0 fi require_cnv_files require_program dd echo "Check conventional file readahead" zonefs_mkfs "$1" zonefs_mount "$1" bs=$(block_size "$zonefs_mntdir"/cnv/0) dd if=/dev/zero of="$zonefs_mntdir"/cnv/0 conv=notrunc \ oflag=direct bs="$bs" count=1 || \ exit_failed " --> FAILED" dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ bs="$bs" count=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0223.sh000077500000000000000000000011431436613652400177470ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Conventional file read beyond eof" exit 0 fi require_cnv_files require_program dd echo "Check conventional file read beyond eof" zonefs_mkfs "$1" zonefs_mount "$1" bs=$(block_size "$zonefs_mntdir"/seq/0) sz=$(file_size "$zonefs_mntdir"/cnv/0) ofst=$(( ($sz - 512) / 512 )) dd if="$zonefs_mntdir"/cnv/0 of=/dev/null \ bs="$(( bs * 2 ))" count=1 seek="$ofst" || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0300.sh000077500000000000000000000025761436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file truncate" exit 0 fi echo "Check sequential file truncate" zonefs_mkfs "$1" zonefs_mount "$1" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "4096" ] && \ exit_failed " --> Invalid file size $sz B, expected 4096 B" echo "## file truncate to 0 (zone reset)" truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "0" ] && \ exit_failed " --> Invalid file size $sz B, expected 0 B" echo "## file truncate to after zone wp (e.g. 4096B)" truncate --no-create --size=4096 "$zonefs_mntdir"/seq/0 && \ exit_failed " --> SUCCESS (should FAIL)" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "0" ] && \ exit_failed " --> Invalid file size $sz B, expected 0 B" echo "## file truncate to zone size (zone finish)" maxsize=$(file_max_size "$zonefs_mntdir"/seq/0) truncate --no-create --size=$maxsize "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$maxsize" ] && \ exit_failed " --> Invalid file size $sz B, expected $maxsize B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0301.sh000077500000000000000000000006121436613652400177440ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file unlink" exit 0 fi echo "Check sequential file unlink" zonefs_mkfs "$1" zonefs_mount "$1" rm -f "$zonefs_mntdir"/seq/0 && \ exit_failed " --> SUCCESS (should FAIL)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0302.sh000077500000000000000000000010651436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file buffered write IO" exit 0 fi echo "Check sequential file buffered write IO" zonefs_mkfs "$1" zonefs_mount "$1" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 bs=4096 count=1 && \ exit_failed " --> SUCCESS (should FAIL)" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "0" ] && \ exit_failed " --> Invalid file size $sz B, expected 0 B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0303.sh000077500000000000000000000017711436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file overwrite" exit 0 fi echo "Check sequential file overwrite" zonefs_mkfs "$1" zonefs_mount "$1" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "4096" ] && \ exit_failed " --> Invalid file size $sz B, expected 4096 B" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 conv=notrunc && \ exit_failed " --> SUCCESS (should FAIL)" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "4096" ] && \ exit_failed " --> Invalid file size $sz B, expected 4096 B" truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "0" ] && \ exit_failed " --> Invalid file size $sz B, expected 0 B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0304.sh000077500000000000000000000011111436613652400177420ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file unaligned write (sync)" exit 0 fi echo "Check sequential file unaligned write (sync IO)" zonefs_mkfs "$1" zonefs_mount "$1" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 bs=4096 count=1 seek=1 && \ exit_failed " --> SUCCESS (should FAIL)" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "0" ] && \ exit_failed " --> Invalid file size $sz B, expected 0 B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0305.sh000077500000000000000000000014411436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file unaligned write (async)" exit 0 fi require_program fio echo "Check sequential file unaligned write (async IO)" zonefs_mkfs "$1" zonefs_mount "$1" fio --name=seq_wr --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=8 \ --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 --offset=4096 && \ exit_failed " --> SUCCESS (should FAIL)" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "0" ] && \ exit_failed " --> Invalid file size $sz B, expected 0 B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0306.sh000077500000000000000000000027051436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file append (sync)" exit 0 fi echo "Check sequential file append (sync)" zonefs_mkfs "$1" zonefs_mount "$1" # Check with O_APPEND file open echo "Check sync append writes with O_APPEND" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "4096" ] && \ exit_failed " --> Invalid file size $sz B, expected 4096 B" tools/zio --write --fflag=direct --fflag=append \ --size=135168 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" # Test with RWF_APPEND I/O flag echo "Check sync append writes with RWF_APPEND" truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" tools/zio --write --fflag=direct --ioflag=append \ --size=135168 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0307.sh000077500000000000000000000027201436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file append (async)" exit 0 fi echo "Check sequential file append (async)" zonefs_mkfs "$1" zonefs_mount "$1" # Test with O_APPEND file open echo "Check append writes with O_APPEND" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "4096" ] && \ exit_failed " --> Invalid file size $sz B, expected 4096 B" tools/zio --write --fflag=direct --fflag=append \ --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" # Test with RWF_APPEND I/O flag echo "Check append writes with RWF_APPEND" truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs=4096 count=1 || \ exit_failed " --> FAILED" tools/zio --write --fflag=direct --ioflag=append \ --size=135168 --async=8 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0309.sh000077500000000000000000000036721436613652400177650ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file mmap read/write" exit 0 fi require_program fio echo "Check sequential file mmap write (should fail)" zonefs_mkfs "$1" zonefs_mount "$1" # Fill the file for mmap maxsize=$(file_max_size "$zonefs_mntdir"/seq/0) truncate --no-create --size=$maxsize "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$maxsize" ] && \ exit_failed " --> Invalid file size $sz B, expected $maxsize B" # mmpa(MAP_WRITE) should fail fio --name=cnv_mmapwr --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=0 --unlink=0 \ --rw=randwrite --ioengine=mmap --size="$sz" --max-jobs=8 \ --bs=4096 --continue_on_error=none && \ exit_failed " --> FAILED" # Reset the file truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" # Fill file fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=64 --max-jobs=8 \ --bs="${iosize}" --size="$maxsize" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount echo "Check sequential file mmap read" zonefs_mount "$1" fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=randread --ioengine=mmap --max-jobs=8 \ --create_on_open=0 --allow_file_create=0 --unlink=0 \ --bs="${iosize}" --size="$maxsize" --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio mmap rand read FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0310.sh000077500000000000000000000015031436613652400177440ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2020 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "sequential file 4K synchronous write" exit 0 fi set -x require_program fio echo "Check sequential file 4K sync write" zonefs_mkfs "$1" zonefs_mount "$1" sz=$(file_max_size "$zonefs_mntdir"/seq/0) truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=psync --iodepth=64 --max-jobs=8 \ --bs=4096 --size="$sz" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" zonefs_umount set +x exit 0 zonefs-tools-1.6.0/tests/scripts/0311.sh000077500000000000000000000017251436613652400177530ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2020 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file large synchronous write" exit 0 fi require_program fio echo "Check sequential file sync write bigger than max-append size" zonefs_mkfs "$1" zonefs_mount "$1" sz=$(file_max_size "$zonefs_mntdir"/seq/0) truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" pbs=$(block_size "$1") mask=$(($pbs - 1)) bs=$(get_zone_append_max_bytes "$1") bs=$(($bs + $pbs)) bs=$((($bs + $mask & ~$mask))) fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=psync --iodepth=64 --max-jobs=8 \ --bs="$bs" --size="$sz" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0312.sh000077500000000000000000000033151436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2020 Western Digital Corporation or its affiliates. # . scripts/test_lib generate_fio() { local nseq="$1" filesize=$(file_max_size "$zonefs_mntdir"/seq/0) if $short; then filesize=$((zone_sectors * 512 / 64)) fi cat > 0312.fio << EOF [global] create_on_open=0 allow_file_create=0 file_append=1 unlink=0 rw=write ioengine=psync bs=${iosize} filesize=${filesize} continue_on_error=none direct=1 [writefiles] EOF for (( i=0; i<$nseq; i++ )); do truncate -s 0 "$zonefs_mntdir/seq/$i" echo "filename=$zonefs_mntdir/seq/$i" >> 0312.fio done } function cleanup { rm -f 0312.fio > /dev/null 2>&1 } trap cleanup EXIT if [ $# == 0 ]; then echo "Sequential file explicit-open zone resources" exit 0 fi require_program fio echo "Check explicit-open mounts" max_open_zones=$(get_max_open_zones "$1") if [ "$max_open_zones" == 0 ]; then exit_skip "No maximum open zone limit" fi zonefs_mkfs "$1" zonefs_mount "-o explicit-open $1" # fio write with less than $max_open_zones must succeed echo "Check write in less than $max_open_zones max open files" if [ "$max_open_zones" -gt "1" ]; then generate_fio "$(( max_open_zones - 1 ))" fio 0312.fio || exit_failed "fio write failed" fi # fio write with $max_open_zones must succeed echo "Check write in exactly $max_open_zones max open files" generate_fio "$max_open_zones" fio 0312.fio || exit_failed "fio write failed" # fio write with 2 * $max_open_zones must fail echo "Check write in double $max_open_zones max open files" nrfiles=$(min $(( max_open_zones * 2 )) $nr_seq_files) generate_fio "$nrfiles" fio 0312.fio && exit_failed "fio write succeeded (should fail)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0320.sh000077500000000000000000000030221436613652400177430ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file random read (buffered)" exit 0 fi require_program fio zonefs_mkfs "$1" zonefs_mount "$1" echo "Fill sequential file" # Fill file fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount echo "Check sequential file random read (sync)" zonefs_mount "$1" # Sync buffered random read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=randread --ioengine=psync --max-jobs=8 \ --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio sync rand read FAILED" zonefs_umount zonefs_mount "$1" echo "Check sequential file random read (async)" # Async buffered random read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=randread --ioengine=libaio --iodepth=8 --max-jobs=8 \ --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio async rand read FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0321.sh000077500000000000000000000030571436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file random read (direct)" exit 0 fi require_program fio zonefs_mkfs "$1" zonefs_mount "$1" echo "Fill sequential file" # Fill file fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount echo "Check sequential file random read (sync)" zonefs_mount "$1" # Sync direct random read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=randread --ioengine=psync --max-jobs=8 \ --direct=1 --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio sync direct rand read FAILED" zonefs_umount zonefs_mount "$1" echo "Check sequential file random read (async)" # Async direct random read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=randread --ioengine=libaio --iodepth=8 --max-jobs=8 \ --direct=1 --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio async direct rand read FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0322.sh000077500000000000000000000030101436613652400177420ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file seq read (buffered)" exit 0 fi require_program fio zonefs_mkfs "$1" zonefs_mount "$1" echo "Fill sequential file" # Fill file fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount echo "Check sequential file sequential read (sync)" zonefs_mount "$1" # Sync buffered sequential read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=read --ioengine=psync \ --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio sync sequential read FAILED" zonefs_umount zonefs_mount "$1" echo "Check sequential file sequential read (async)" # Async buffered sequential read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=read --ioengine=libaio --iodepth=8 \ --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio async sequential read FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0323.sh000077500000000000000000000030421436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file seq read (direct)" exit 0 fi require_program fio zonefs_mkfs "$1" zonefs_mount "$1" echo "Fill sequential file" # Fill file fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount echo "Check sequential file sequential read (sync)" zonefs_mount "$1" # Sync direct sequential read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=read --ioengine=psync --direct=1 \ --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio sync direct sequential read FAILED" zonefs_umount zonefs_mount "$1" echo "Check sequential file random read (async)" # Async direct sequential read fio --name=seq_rndrd --filename="$zonefs_mntdir"/seq/0 \ --rw=read --ioengine=libaio --iodepth=8 \ --direct=1 --bs=131072 --verify=md5 --do_verify=1 \ --continue_on_error=none || \ exit_failed "fio async direct sequential read FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0324.sh000077500000000000000000000012551436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readahead" exit 0 fi echo "Check sequential file readahead" zonefs_mkfs "$1" zonefs_mount "$1" bs=$(block_size "$zonefs_mntdir"/seq/0) dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs="$bs" count=1 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$bs" ] && \ exit_failed " --> Invalid file size $sz B, expected $bs B" dd if="$zonefs_mntdir"/seq/0 of=/dev/null bs="$bs" count=1 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0325.sh000077500000000000000000000026601436613652400177570ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file read beyond eof" exit 0 fi echo "Check sequential file read beyond eof" zonefs_mkfs "$1" zonefs_mount "$1" bs=$(block_size "$zonefs_mntdir"/seq/0) dd if=/dev/zero of="$zonefs_mntdir"/seq/0 oflag=direct bs="$bs" count=1 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$bs" ] && \ exit_failed " --> Invalid file size $sz B, expected $bs B" dd if="$zonefs_mntdir"/seq/0 of=/dev/null bs="$(( bs * 2 ))" count=1 || \ exit_failed " --> FAILED" echo "Check sequential file read beyond max size" # Fill file fio --name=seqwrite --filename="$zonefs_mntdir"/seq/0 \ --create_on_open=0 --allow_file_create=0 --file_append=1 --unlink=0 \ --rw=write --ioengine=libaio --iodepth=8 --max-jobs=8 \ --bs=131072 --size="$seq_file_0_max_size" --verify=md5 --do_verify=1 \ --continue_on_error=none --direct=1 || \ exit_failed "fio write FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" ofst=$(( ($seq_file_0_max_size - 512) / 512 )) dd if="$zonefs_mntdir"/seq/0 of=/dev/null \ bs="$(( bs * 2 ))" count=1 seek="$ofst" || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0326.sh000077500000000000000000000022021436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file dsync write (sync)" exit 0 fi echo "Check sequential file dsync write (sync)" zonefs_mkfs "$1" zonefs_mount "$1" # Check with O_DSYNC file open echo "Check writes with O_DSYNC" tools/zio --write --fflag=direct --fflag=dsync \ --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" # Test with RWF_DSYNC I/O flag echo "Check writes with RWF_APPEND" truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" tools/zio --write --fflag=direct --ioflag=dsync \ --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0327.sh000077500000000000000000000022361436613652400177600ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file dsync write (async)" exit 0 fi echo "Check sequential file dsync write (async)" zonefs_mkfs "$1" zonefs_mount "$1" # Check with O_DSYNC file open echo "Check async writes with O_DSYNC" tools/zio --write --fflag=direct --fflag=dsync --async=8 \ --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" # Test with RWF_DSYNC I/O flag echo "Check writes with RWF_APPEND" truncate --no-create --size=0 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" tools/zio --write --fflag=direct --ioflag=dsync --async=8 \ --size=$((2 * 1024 * 1024 )) "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" sz=$(file_size "$zonefs_mntdir"/seq/0) [ "$sz" != "$seq_file_0_max_size" ] && \ exit_failed " --> Invalid file size $sz B, expected $seq_file_0_max_size B" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0400.sh000077500000000000000000000011371436613652400177470ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2021 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Swap file on conventional file" exit 0 fi require_cnv_files echo "Check swap file on conventional file" zonefs_mkfs "$1" zonefs_mount "$1" chmod 600 "$zonefs_mntdir"/cnv/0 || \ exit_failed " --> FAILED" mkswap "$zonefs_mntdir"/cnv/0 || \ exit_failed " --> FAILED" swapon "$zonefs_mntdir"/cnv/0 || \ exit_failed " --> FAILED" swapoff "$zonefs_mntdir"/cnv/0 || \ exit_failed " --> FAILED" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0401.sh000077500000000000000000000021541436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2021 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Swap file on sequential file" exit 0 fi echo "Check swap file on sequential file" zonefs_mkfs "$1" zonefs_mount "$1" # Fill the file tools/zio --write --fflag=direct \ --size=131072 --async=8 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" chmod 600 "$zonefs_mntdir"/seq/0 || \ exit_failed " --> FAILED" # mkswap should fail (cannot write swap file header) mkswap "$zonefs_mntdir"/seq/0 && \ exit_failed " --> SUCCESS (should FAIL)" # Create a swap file and copy it to a sequential file to check # the kernel side zonefs swap activate check. sudo fallocate -l "$seq_file_0_max_size" /tmp/swapfile chmod 600 /tmp/swapfile || \ exit_failed " --> FAILED" mkswap /tmp/swapfile || \ exit_failed " --> FAILED" dd if=/tmp/swapfile of="$zonefs_mntdir"/seq/0 \ bs=131072 oflag=direct || exit_failed " --> FAILED" swapon "$zonefs_mntdir"/seq/0 && \ exit_failed " --> SUCCESS (should FAIL)" zonefs_umount rm -f /tmp/swapfile exit 0 zonefs-tools-1.6.0/tests/scripts/0510.sh000077500000000000000000000021241436613652400177460ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs attr after format" exit 0 fi require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" echo "Check max write open seq files" dev_val=$(get_max_open_zones "$1") sysfs_val=$(sysfs_max_wro_seq_files "$1") [[ ${sysfs_val} -eq ${dev_val} ]] || \ exit_failed "max_wro_seq_files is ${sysfs_val} (should be ${dev_val})" echo "Check max active seq files" dev_val=$(get_max_active_zones "$1") sysfs_val=$(sysfs_max_active_seq_files "$1") [[ ${sysfs_val} -eq ${dev_val} ]] || \ exit_failed "max_active_seq_files is ${sysfs_val} (should be ${dev_val})" echo "Check write open seq files count" sysfs_val=$(sysfs_nr_wro_seq_files "$1") [[ ${sysfs_val} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${sysfs_val} (should be 0)" echo "Check active seq files count" sysfs_val=$(sysfs_nr_active_seq_files "$1") [[ ${sysfs_val} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${sysfs_val} (should be 0)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0511.sh000077500000000000000000000013611436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files active after mount (open zones)" exit 0 fi require_sysfs # Format and then write the first file seq zone to activate it # (emulate an EPO event after a file was open) zonefs_mkfs "$1" zstart=$(( (nr_cnv_zones + 1) * zone_sectors )) blkzone open -o ${zstart} -l ${zone_sectors} "$1" || \ exit_failed "Explicit open zone failed" echo "Check active seq files count" zonefs_mount "$1" sysfs_val=$(sysfs_nr_active_seq_files "$1") [[ ${sysfs_val} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${sysfs_val} (should be 0)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0512.sh000077500000000000000000000016071436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files active after mount (active zones)" exit 0 fi require_sysfs # Check that the number of active files matches the number of # active zones. zonefs_mkfs "$1" i=0 nract=$(get_max_open_zones "$1") if [ ${nract} -eq 0 ]; then nract=4 fi echo "Writing 4K in ${nract} zones" for((i=1; i<=${nract}; i++)); do zstart=$(( (nr_cnv_zones + i) * zone_bytes / 4096 )) dd if=/dev/zero of="$1" bs=4096 seek=${zstart} count=1 oflag=direct || exit_failed "write seq zone failed" done echo "Check active seq files count" zonefs_mount "$1" sysfs_val=$(sysfs_nr_active_seq_files "$1") [[ ${sysfs_val} -eq ${nract} ]] || \ exit_failed "nr_active_seq_files is ${sysfs_val} (should be 4)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0513.sh000077500000000000000000000027141436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files write-open (default)" exit 0 fi require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" i=0 maxopen=$(get_max_open_zones "$1") if [ ${maxopen} -eq 0 ]; then maxopen=4 fi echo "Check read open" # Check that any number of file can be read-open for((i=1; i<=$(( maxopen + 1 )); i++)); do echo "Opening ${i} files for reading" tools/zopen --nrfiles="$i" --fflag=read --pause "${zonefs_mntdir}/seq" & zopid=$! sleep 1 nract=$(sysfs_nr_active_seq_files "$1") nrwro=$(sysfs_nr_wro_seq_files "$1") kill ${zopid} wait ${zopid} [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} (should be 0)" [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} (should be 0)" done echo "Check write open" # Check that any number of file can be write-open for((i=1; i<=$(( maxopen + 1 )); i++)); do echo "Opening ${i} files for writing" tools/zopen --nrfiles="$i" --fflag=write --pause "${zonefs_mntdir}/seq" & zopid=$! sleep 1 nract=$(sysfs_nr_active_seq_files "$1") nrwro=$(sysfs_nr_wro_seq_files "$1") kill ${zopid} wait ${zopid} [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} (should be 0)" [[ ${nrwro} -eq ${i} ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} (should be $i)" done zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0514.sh000077500000000000000000000054021436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files write-open (explicit-open)" exit 0 fi require_sysfs zonefs_mkfs "$1" zonefs_mount "-o explicit-open $1" i=0 devmaxopen=$(get_max_open_zones "$1") devmaxactive=$(get_max_active_zones "$1") maxopen=${devmaxopen} if [ ${maxopen} -eq 0 ]; then maxopen=${devmaxactive} if [ ${maxopen} -eq 0 ]; then maxopen=4 fi fi echo "Check read open" # Check that any number of file can be read-open for((i=1; i<=$(( maxopen + 1 )); i++)); do echo "Opening ${i} files for reading" tools/zopen --nrfiles="$i" --fflag=read --pause "${zonefs_mntdir}/seq" & zopid=$! sleep 1 nract=$(sysfs_nr_active_seq_files "$1") nrwro=$(sysfs_nr_wro_seq_files "$1") kill ${zopid} wait ${zopid} [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} (should be 0)" [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} (should be 0)" done echo "Check write open" function exit_error() { local zopid="$1" # Close the files kill ${zopid} wait ${zopid} exit_failed "$2" } # Check that any number of file can be write-open for((i=1; i<=${maxopen}; i++)); do echo "Opening ${i} files for writing" tools/zopen --nrfiles="$i" --fflag=write --pause "${zonefs_mntdir}/seq" & zopid=$! sleep 1 if [ ${devmaxopen} -ne 0 ]; then nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${i} ]] || \ exit_error ${zopid} "nr_active_seq_files is ${nract} (should be ${i})" fi nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq ${i} ]] || \ exit_error ${zopid} "nr_wro_seq_files is ${nrwro} (should be ${i})" # Close the files kill ${zopid} wait ${zopid} # Now all counters should be back to 0 since the files where not written nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} after close (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after close (should be 0)" done if [ ${devmaxopen} -ne 0 ]; then # Opening one more file than max-open should fail echo "Opening $(( maxopen + 1 )) files for writing (failure expected)" tools/zopen --nrfiles="$(( maxopen + 1 ))" \ --fflag=write "${zonefs_mntdir}/seq" && \ exit_failed "Write-opening $(( maxopen + 1 )) > ${maxopen} files succedded (should fail)" fi sleep 1 nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} after close (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after close (should be 0)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0515.sh000077500000000000000000000036661436613652400177670ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files active after write (default)" exit 0 fi require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" i=0 maxact=$(get_max_active_zones "$1") if [ ${maxact} -eq 0 ]; then maxact=4 fi # Write 4K in maxact files n=0 for((i=0; i<${maxact}; i++)); do echo "Writing seq file ${i}" dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ count=1 oflag=direct || \ exit_failed " --> Write seq file ${i} FAILED" n=$(( n + 1 )) nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${n} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" done # Remount and check again zonefs_umount zonefs_mount "$1" nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${maxact} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${maxact})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" # Fill-up the files: the active count should go to 0 n=${maxact} for((i=0; i<${maxact}; i++)); do echo "Filling seq file ${i}" fsize=$(file_max_size "${zonefs_mntdir}/seq/${i}") wcount=$(( fsize / 1048576 - 1 )) dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ seek=1 count=${wcount} oflag=direct conv=notrunc || \ exit_failed " --> Fill seq file ${i} FAILED" n=$(( n - 1 )) nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${n} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" done zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0516.sh000077500000000000000000000035001436613652400177530ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files active after truncate to 0 (default)" exit 0 fi require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" i=0 maxact=$(get_max_active_zones "$1") if [ ${maxact} -eq 0 ]; then maxact=4 fi # Write 4K in maxact files n = 0 for((i=0; i<${maxact}; i++)); do echo "Writing seq file ${i}" dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ count=1 oflag=direct || \ exit_failed " --> Write seq file ${i} FAILED" n=$(( n + 1 )) nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${n} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" done # Remount and check again zonefs_umount zonefs_mount "$1" nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${maxact} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${maxact})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" # Truncate the files: the active count should go to 0 n=${maxact} for((i=0; i<${maxact}; i++)); do echo "Truncating seq file ${i}" truncate_file "${zonefs_mntdir}/seq/${i}" 0 || \ exit_failed " --> Truncate seq file ${i} to 0 FAILED" n=$(( n - 1 )) nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${n} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" done zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0517.sh000077500000000000000000000035771436613652400177720ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs seq files active after truncate to max (default)" exit 0 fi require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" i=0 maxact=$(get_max_active_zones "$1") if [ ${maxact} -eq 0 ]; then maxact=4 fi # Write 4K in maxact files n=0 for((i=0; i<${maxact}; i++)); do echo "Writing seq file ${i}" dd if=/dev/zero of="${zonefs_mntdir}/seq/${i}" bs=1048576 \ count=1 oflag=direct || \ exit_failed " --> Write seq file ${i} FAILED" n=$(( n + 1 )) nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${n} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" done # Remount and check again zonefs_umount zonefs_mount "$1" nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${maxact} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${maxact})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" # Fill-up the files using truncate: the active count should go to 0 n=${maxact} for((i=0; i<${maxact}; i++)); do echo "Filling seq file ${i}" fsize=$(file_max_size "${zonefs_mntdir}/seq/${i}") truncate_file "${zonefs_mntdir}/seq/${i}" ${fsize} || \ exit_failed " --> Truncate seq file ${i} to max size FAILED" n=$(( n - 1 )) nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq ${n} ]] || \ exit_failed " --> nr_active_seq_files is ${nract} (should be ${n})" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed " --> nr_wro_seq_files is ${nrwro} after close (should be 0)" done zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0518.sh000077500000000000000000000034531436613652400177640ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs conv files write-open" exit 0 fi require_cnv_files require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" echo "Check write open" # Check that opening a conv file does not change the write open count tools/zopen --nrfiles="$nr_cnv_files" --fflag=read --pause "${zonefs_mntdir}/cnv" & zopid=$! sleep 1 nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} after read open (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after read open (should be 0)" kill ${zopid} wait ${zopid} nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} after read close (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after read close (should be 0)" # Same with write open tools/zopen --nrfiles="$nr_cnv_files" --fflag=write --pause "${zonefs_mntdir}/cnv" & zopid=$! sleep 1 nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} after write open (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after write open (should be 0)" kill ${zopid} wait ${zopid} nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} after write close (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after write close (should be 0)" zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0519.sh000077500000000000000000000017121436613652400177610ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sysfs conv files active after write" exit 0 fi require_cnv_files require_sysfs zonefs_mkfs "$1" zonefs_mount "$1" i=0 maxact=$(get_max_active_zones "$1") if [ ${maxact} -eq 0 ]; then maxact=4 fi maxact=$(min ${maxact} ${nr_cnv_files}) # Write 4K in maxact conv files for((i=0; i<${maxact}; i++)); do echo "Writing conv file ${i}" dd if=/dev/zero of="${zonefs_mntdir}/cnv/${i}" bs=4096 \ count=1 oflag=direct conv=nocreat,notrunc || \ exit_failed "Write cnv file ${i} failed" nract=$(sysfs_nr_active_seq_files "$1") [[ ${nract} -eq 0 ]] || \ exit_failed "nr_active_seq_files is ${nract} (should be 0)" nrwro=$(sysfs_nr_wro_seq_files "$1") [[ ${nrwro} -eq 0 ]] || \ exit_failed "nr_wro_seq_files is ${nrwro} after close (should be 0)" done zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0600.sh000077500000000000000000000031501436613652400177460ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=remount-ro, sync)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "$1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should not have changed but the entire file system # should now be read-only echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "640" check_fs_is_readonly # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "640" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # We should not be able to write another file echo "Try writing seq file 1" write_file_err "${zonefs_mntdir}/seq/1" 4096 0 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0601.sh000077500000000000000000000031651436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=remount-ro, async)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "$1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try async writing seq file 0" write_file_async_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should not have changed but the entire file system # should now be read-only echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "640" check_fs_is_readonly # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "640" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # We should not be able to write another file echo "Try writing seq file 1" write_file_err "${zonefs_mntdir}/seq/1" 4096 0 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0602.sh000077500000000000000000000031461436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=zone-ro, sync)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "-o errors=zone-ro $1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should have changed and the file system # should still be usable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "440" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "440" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # We should be able to write another file echo "Try writing seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 4096 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0603.sh000077500000000000000000000031631436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=zone-ro, async)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "-o errors=zone-ro $1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try async writing seq file 0" write_file_async_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should have changed and the file system # should still be usable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "440" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "440" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # We should be able to write another file echo "Try writing seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 4096 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0604.sh000077500000000000000000000031641436613652400177570ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=zone-offline, sync)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "-o errors=zone-offline $1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 0 # File permission should have changed and the file system # should still be usable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should not be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 && \ exit_failed " --> read SUCCESS (should FAIL)" # We should be able to write another file echo "Try writing seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 4096 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0605.sh000077500000000000000000000032011436613652400177500ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=zone-offline, async)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "-o errors=zone-offline $1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try async writing seq file 0" write_file_async_err "${zonefs_mntdir}/seq/0" 4096 0 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 0 # File permission should have changed and the file system # should still be usable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should not be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 && \ exit_failed " --> read SUCCESS (should FAIL)" # We should be able to write another file echo "Try writing seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 4096 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0606.sh000077500000000000000000000031241436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=repair, sync)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "-o errors=repair $1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 12288 # File permission should not have changed and the file system # should still be usable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "640" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 12288 check_file_perm "${zonefs_mntdir}/seq/0" "640" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # Truncate should be OK echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 || \ exit_failed " --> truncate FAILED" check_file_size "${zonefs_mntdir}/seq/0" 0 # We should be able to write another file echo "Try writing seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 4096 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0607.sh000077500000000000000000000031311436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file write IO error (errors=repair, async)" exit 0 fi echo "Check handling of sequential file write IO error" zonefs_mkfs "$1" zonefs_mount "-o errors=repair $1" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Move the zone write pointer without the FS knowing about it echo "Write seq file 0 zone directly" write_file_zone "$1" "${zonefs_mntdir}/seq/0" # Now, writing should fail echo "Try writing seq file 0" write_file_async_err "${zonefs_mntdir}/seq/0" 4096 8192 # File permission should not have changed and the file system # should still be usable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "640" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 8192 check_file_perm "${zonefs_mntdir}/seq/0" "640" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # Truncate should be OK echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 || \ exit_failed " --> truncate FAILED" check_file_size "${zonefs_mntdir}/seq/0" 0 # We should be able to write another file echo "Try writing seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 4096 zonefs_umount exit 0 zonefs-tools-1.6.0/tests/scripts/0610.sh000077500000000000000000000024051436613652400177510ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=remount-ro, mount)" exit 0 fi echo "Check sequential file on a read-only zone at mount time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone readonly and remount echo "Remounting FS with seq file 0 zone as read-only" zonefs_umount "${dev}" set_nullb_first_seq_zone_readonly "${nulldev}" zonefs_mount "${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing the readonly file should fail echo "Try writing readonly seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Try writing to seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0611.sh000077500000000000000000000032571436613652400177600ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=remount-ro, io-err)" exit 0 fi echo "Check sequential file on a read-only zone at io-error time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone readonly set_nullb_first_seq_zone_readonly "${nulldev}" # Writing should now fail echo "Try writing readonly seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should have changed and the entire file system # should now be read-only echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "440" check_fs_is_readonly # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "440" # We should still be able to read the file echo "Try reading seq file 0" dd of=/dev/null if="${zonefs_mntdir}/seq/0" iflag=direct bs=4096 count=1 || \ exit_failed " --> read FAILED" # We should not be able to write another file echo "Try writing seq file 1" write_file_err "${zonefs_mntdir}/seq/1" 4096 0 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0612.sh000077500000000000000000000024151436613652400177540ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=zone-ro, mount)" exit 0 fi echo "Check sequential file on a read-only zone at mount time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone readonly and remount echo "Remounting FS with seq file 0 zone as read-only" zonefs_umount "${dev}" set_nullb_first_seq_zone_readonly "${nulldev}" zonefs_mount "-o errors=zone-ro ${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing to he readonly file should fail echo "Try writing readonly seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0613.sh000077500000000000000000000027451436613652400177630ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=zone-ro, io-err)" exit 0 fi echo "Check sequential file on a read-only zone at io-error time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "-o errors=zone-ro ${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone readonly set_nullb_first_seq_zone_readonly ${nulldev} # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should have changed and the file system should # still be writable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "440" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "440" # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0614.sh000077500000000000000000000024061436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=zone-offline, mount)" exit 0 fi echo "Check sequential file on a read-only zone at mount time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone readonly and remount echo "Remounting FS with seq file 0 zone as read-only" zonefs_umount "${dev}" set_nullb_first_seq_zone_readonly "${nulldev}" zonefs_mount "-o errors=zone-offline ${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing to the file should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0615.sh000077500000000000000000000025311436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=zone-offline, io-err)" exit 0 fi echo "Check sequential file on a read-only zone at io-error time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "-o errors=zone-offline ${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone readonly set_nullb_first_seq_zone_readonly ${nulldev} # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0616.sh000077500000000000000000000024131436613652400177560ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=repair, mount)" exit 0 fi echo "Check sequential file on a read-only zone at mount time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone readonly and remount echo "Remounting FS with seq file 0 zone as read-only" zonefs_umount "${dev}" set_nullb_first_seq_zone_readonly "${nulldev}" zonefs_mount "-o errors=repair ${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing to he readonly file should fail echo "Try writing readonly seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0617.sh000077500000000000000000000027431436613652400177650ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file readonly zone (errors=repair, io-err)" exit 0 fi echo "Check sequential file on a read-only zone at io-error time" require_nullb_readonly nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "-o errors=repair ${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone readonly set_nullb_first_seq_zone_readonly ${nulldev} # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 4096 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 4096 # File permission should have changed and the file system should # still be writable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "440" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 4096 check_file_perm "${zonefs_mntdir}/seq/0" "440" # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0620.sh000077500000000000000000000023541436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=remount-ro, mount)" exit 0 fi echo "Check sequential file on an offline zone at mount time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone offline and remount echo "Remounting FS with seq file 0 zone as offline" zonefs_umount "${dev}" set_nullb_first_seq_zone_offline "${nulldev}" zonefs_mount "${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing the file should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Try writing to seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0621.sh000077500000000000000000000027401436613652400177550ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=remount-ro, io-err)" exit 0 fi echo "Check sequential file on an offline zone at io-error time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone offline set_nullb_first_seq_zone_offline "${nulldev}" # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 0 # File permission should have changed and the entire file system # should now be read-only echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_readonly # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should not be able to write another file echo "Try writing seq file 1" write_file_err "${zonefs_mntdir}/seq/1" 4096 0 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0622.sh000077500000000000000000000023761436613652400177630ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=zone-ro, mount)" exit 0 fi echo "Check sequential file on an offline zone at mount time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone offline and remount echo "Remounting FS with seq file 0 zone as offline" zonefs_umount "${dev}" set_nullb_first_seq_zone_offline "${nulldev}" zonefs_mount "-o errors=zone-ro ${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing to the file should fail echo "Try writing readonly seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0623.sh000077500000000000000000000027271436613652400177640ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=zone-ro, io-err)" exit 0 fi echo "Check sequential file on an offline zone at io-error time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "-o errors=zone-ro ${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone offline set_nullb_first_seq_zone_offline ${nulldev} # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 0 # File permission should have changed and the file system should # still be writable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0624.sh000077500000000000000000000023771436613652400177660ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=zone-offline, mount)" exit 0 fi echo "Check sequential file on an offline zone at mount time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone offline and remount echo "Remounting FS with seq file 0 zone as offline" zonefs_umount "${dev}" set_nullb_first_seq_zone_offline "${nulldev}" zonefs_mount "-o errors=zone-offline ${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing to the file should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0625.sh000077500000000000000000000025241436613652400177610ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=zone-offline, io-err)" exit 0 fi echo "Check sequential file on an offline zone at io-error time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "-o errors=zone-offline ${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone offline set_nullb_first_seq_zone_offline ${nulldev} # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0626.sh000077500000000000000000000023601436613652400177600ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=repair, mount)" exit 0 fi echo "Check sequential file on an offline zone at mount time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Unmount, set the first seq file zone offline and remount echo "Remounting FS with seq file 0 zone as offline" zonefs_umount "${dev}" set_nullb_first_seq_zone_offline "${nulldev}" zonefs_mount "-o errors=repair ${dev}" # The file permission must have changed and the file size should be 0. # The fs should be writable echo "Check file size and permissions" check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Writing the file should fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/0627.sh000077500000000000000000000027251436613652400177660ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2023 Western Digital Corporation or its affiliates. # . scripts/test_lib if [ $# == 0 ]; then echo "Sequential file offline zone (errors=repair, io-err)" exit 0 fi echo "Check sequential file on an offline zone at io-error time" require_nullb_offline nulldev=$(create_zoned_nullb) dev="/dev/nullb${nulldev}" zonefs_mkfs "${dev}" zonefs_mount "-o errors=repair ${dev}" # Writing should be OK echo "Write seq file 0" write_file "${zonefs_mntdir}/seq/0" 4096 # Set the first seq file zone offline set_nullb_first_seq_zone_offline ${nulldev} # Writing should now fail echo "Try writing seq file 0" write_file_err "${zonefs_mntdir}/seq/0" 4096 0 # Truncate should also fail echo "Try file truncate to 0 (zone reset)" truncate_file "${zonefs_mntdir}/seq/0" 0 && \ exit_failed " --> truncate SUCCESS (should FAIL)" check_file_size "${zonefs_mntdir}/seq/0" 0 # File permission should have changed and the file system should # still be writable echo "Check permissions" check_file_perm "${zonefs_mntdir}/seq/0" "000" check_fs_is_writable # Evicting the inode should not change anything echo "Check file size and permissions after eviction" drop_inode_cache check_file_size "${zonefs_mntdir}/seq/0" 0 check_file_perm "${zonefs_mntdir}/seq/0" "000" # We should be able to write another file echo "Write seq file 1" write_file "${zonefs_mntdir}/seq/1" 4096 zonefs_umount destroy_nullb ${nulldev} exit 0 zonefs-tools-1.6.0/tests/scripts/test_lib000066400000000000000000000313721436613652400205610ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # blkzone=$(type -p blkzone 2>/dev/null) function drop_inode_cache() { echo 2 > /proc/sys/vm/drop_caches } function devname() { basename "$(realpath $1)" } function sysfs_max_active_seq_files() { cat "/sys/fs/zonefs/$(devname $1)/max_active_seq_files" } function sysfs_nr_active_seq_files() { cat "/sys/fs/zonefs/$(devname $1)/nr_active_seq_files" } function sysfs_max_wro_seq_files() { cat "/sys/fs/zonefs/$(devname $1)/max_wro_seq_files" } function sysfs_nr_wro_seq_files() { cat "/sys/fs/zonefs/$(devname $1)/nr_wro_seq_files" } function get_nr_zones() { ${blkzone} report "$1" | wc -l || exit 0 } function get_nr_cnv_zones() { ${blkzone} report "$1" | grep -c "CONVENTIONAL" || exit 0 } function get_nr_seq_zones() { ${blkzone} report "$1" | grep -c "SEQ_WRITE_" || exit 0 } function get_zone_sectors() { cat "/sys/class/block/$(devname $1)/queue/chunk_sectors" } function get_zone_append_max_bytes() { cat "/sys/class/block/$(devname $1)/queue/zone_append_max_bytes" } function get_max_open_zones() { local bdev="$(devname $1)" if [ -f "/sys/class/block/$bdev/queue/max_open_zones" ]; then cat "/sys/class/block/$bdev/queue/max_open_zones" else echo "0" fi } function get_max_active_zones() { local bdev="$(devname $1)" if [ -f "/sys/class/block/$bdev/queue/max_active_zones" ]; then cat "/sys/class/block/$bdev/queue/max_active_zones" else echo "0" fi } function zone_info() { ${blkzone} report --count 1 --offset "$2" "$1" || exit 0 } function zone_is_conventional() { echo "$(zone_info $1 $2)" | grep -q "CONVENTIONAL" && return 0 || return 1 } function zone_is_full() { echo "$(zone_info $1 $2)" | grep -q "zcond:14(fu)" && return 0 || return 1 } function blkzone_has_zone_capacity() { echo "$(zone_info $1 0)" | grep -q "cap " && return 0 || return 1 } function get_zone_capacity_sectors() { c=$(echo "$(zone_info $1 $2)" | cut -d "," -f3 | cut -d" " -f3) echo $((c)) } function get_zone_capacity_bytes() { echo $(( $(get_zone_capacity_sectors "$1" "$2") * 512 )) } function get_total_zone_capacity_sectors() { local total_cap=0 # Skip the first zone as it contains the super block while read -r c_hex; do c=$((c_hex)) total_cap=$(( total_cap + c )) done < <(blkzone report -o "$zone_sectors" "$1" | cut -d "," -f3 | cut -d" " -f3) echo $total_cap } function exit_skip() { echo " --> skipped: $1" exit 2 } function exit_failed() { echo "$1" exit 1 } function clear_sb() { local nrcnv=$(get_nr_cnv_zones "$1") # Clear super block for -f tests if [ $nrcnv == 0 ]; then blkzone reset --offset 0 -c 1 "$1" || (echo "Reset super block zone failed"; exit 1) # Resetting a zone does not clear the page cache of cached zone data # pages. Take a big hammer and clear the page cache to avoid access # to stale data. echo 1 > /proc/sys/vm/drop_caches else dd if=/dev/zero of="$1" bs=4096 oflag=direct count=1 || (echo "Clear super block failed"; exit 1) fi } function zonefs_mkfs() { IFS=' '; read -r -a args <<< "$1" mkzonefs -f "${args[@]}" || \ exit_failed " --> mkzonefs FAILED with arguments \"${args[*]}\"" } function zonefs_mount() { IFS=' '; read -r -a args <<< "$1" mount -t zonefs "${args[@]}" "$zonefs_mntdir" || \ exit_failed " --> mount FAILED with arguments \"${args[*]} $zonefs_mntdir\"" } function zonefs_mount_err() { IFS=' '; read -r -a args <<< "$1" mount -t zonefs "${args[@]}" "$zonefs_mntdir" && \ exit_failed " --> mount SUCCESS with arguments \"${args[*]} $zonefs_mntdir\" (should FAIL)" } function zonefs_umount() { # Make sure udev is not looking at the FS udevadm settle >> /dev/null 2>&1 umount "$zonefs_mntdir" || \ exit_failed " --> umount FAILED" } function get_perm() { stat -c "%a" "$1" } function check_file_perm() { perm="$(get_perm "$1")" if [ "$perm" == "0" ]; then perm="000" fi if [ "$perm" != "$2" ]; then echo "file $1: invalid permission $perm (expected $2)" exit 1 fi } function get_ino() { stat -c "%i" "$1" || \ exit_failed " --> Failed to get inode number of file $1" } function check_dir_ino() { local dir="$1" local expected_ino=$2 local ino ino=$(get_ino "${dir}") if [ ${ino} != ${expected_ino} ]; then echo " --> Invalid inode number for directory ${dir}" echo " --> Expected ${expected_ino}, got ${ino}" exit 1 fi } function check_files_ino() { local dir="$1" local nrfiles=$2 local expected_ino=$3 local ino local f # # Note: this needs to be improved as this assumes that files under # a zone type directory are all from contiguous zones. This may not # be the case for all devices as conventional zones can be anywhere. # In practice, this is not an issue though. # for (( f=0; f<${nrfiles}; f++ )); do ino=$(get_ino "${dir}/$f") if [ ${ino} != ${expected_ino} ]; then echo " --> Invalid inode number for file ${dir}/$f" echo " --> Expected ${expected_ino}, got ${ino}" exit 1 fi expected_ino=$(( expected_ino + 1 )) done } function check_perm() { if [ -d "$zonefs_mntdir/cnv/" ]; then list=$(stat -c "%n %a" "$zonefs_mntdir"/cnv/[0-9]*) while read -r line; do fp=(${line}) f=${fp[0]##*/} perm=${fp[1]} if [ "$perm" != "$1" ]; then echo "cnv file $f: invalid permission $perm (expected $1)" exit 1 fi done <<< "$list" fi pushd "$zonefs_mntdir" > /dev/null 2>&1 || exit list=$(stat -c "%n %a" seq/[0-9]*) popd > /dev/null 2>&1 || exit while read -r line; do fp=(${line}) f=${fp[0]##*/} perm=${fp[1]} if [ "$perm" != "$1" ]; then echo "seq file $f: invalid permission $perm (expected $1)" exit 1 fi done <<< "$list" } function get_uid_gid() { stat -c "%u %g" "$1" } function check_file_uid_gid() { ug="$(get_uid_gid "$1")" if [ "$ug" != "$2" ]; then echo "file $1: invalid UID/GID $ug (expected $2)" exit 1 fi } function check_uid_gid() { if [ -d "$zonefs_mntdir/cnv/" ]; then list=$(stat -c "%n %u %g" "$zonefs_mntdir"/cnv/[0-9]*) while read -r line; do fug=(${line}) f=${fug[0]##*/} uid=${fug[1]} gid=${fug[2]} if [ "$uid" != "$1" ]; then echo "cnv file $f: invalid UID $uid (expected $1)" exit 1 fi if [ "$gid" != "$2" ]; then echo "cnv file $f: invalid GID $gid (expected $2)" exit 1 fi done <<< "$list" fi pushd "$zonefs_mntdir" > /dev/null 2>&1 || exit list=$(stat -c "%n %u %g" seq/[0-9]*) popd > /dev/null 2>&1 || exit while read -r line; do fug=(${line}) f=${fug[0]##*/} uid=${fug[1]} gid=${fug[2]} if [ "$uid" != "$1" ]; then echo "seq file $f: invalid UID $uid (expected $1)" exit 1 fi if [ "$gid" != "$2" ]; then echo "seq file $f: invalid GID $gid (expected $2)" exit 1 fi done <<< "$list" } function truncate_file() { truncate --no-create --size="$2" "$1" } function file_size() { stat -c "%s" "$1" } function check_file_size() { local file="$1" local expected_fsz="$2" local fsz fsz=$(file_size "${file}") [[ "${fsz}" == "${expected_fsz}" ]] || \ exit_failed " --> Invalid file size ${fsz} B, expected ${expected_fsz} B" } function file_max_size() { nr_blocks=$(stat -c "%b" "$1") block_size=$(stat -c "%B" "$1") echo "$(( nr_blocks * block_size ))" } function aggr_cnv_size() { size=$(file_max_size "$zonefs_mntdir"/cnv/0) two_zones_size=$((zone_sectors * 2 * 512)) if $short && ((two_zones_size < size)); then size="${two_zones_size}" fi echo "${size}" } function check_size() { aggr_cnv=$1 if [ -d "$zonefs_mntdir/cnv/" ]; then # Note: conventional zone capacity is always equal to the zone size if $aggr_cnv; then expected_sz=$(( zone_bytes * (nr_cnv_zones - 1) )) else expected_sz=$zone_bytes fi list=$(stat -c "%n %s" "$zonefs_mntdir"/cnv/[0-9]*) while read -r line; do fsz=(${line}) f=${fsz[0]##*/} sz=${fsz[1]} if [ "$sz" != "$expected_sz" ]; then echo "cnv file $f: invalid size $sz B (expected $expected_sz B)" exit 1 fi done <<< "$list" fi pushd "$zonefs_mntdir" > /dev/null 2>&1 || exit list=$(stat -c "%n %s" seq/[0-9]*) popd > /dev/null 2>&1 || exit while read -r line; do fsz=(${line}) f=${fsz[0]##*/} sz=${fsz[1]} if [ "$sz" != "0" ]; then echo "seq file $f: invalid size $sz B (expected 0 B)" exit 1 fi done <<< "$list" } function create_nullb() { local zoned=$1 local n=0 modprobe null_blk nr_devices=0 while [ 1 ]; do if [ ! -b "/dev/nullb$n" ]; then break fi n=$(( n + 1 )) done cfg="/sys/kernel/config/nullb/nullb$n" mkdir "$cfg" || exit_failed "Create test null_blk device failed" echo 1 > "${cfg}/zoned" echo 2 > "${cfg}/queue_mode" echo 2 > "${cfg}/irqmode" echo 2000 > "${cfg}/completion_nsec" echo 2048 > "${cfg}/size" echo 1024 > "${cfg}/hw_queue_depth" echo 1 > "${cfg}/memory_backed" echo ${zoned} > "${cfg}/zoned" if [ "${zoned}" == "1" ]; then echo 32 > "${cfg}/zone_size" echo 10 > "${cfg}/zone_nr_conv" echo 8 > "${cfg}/zone_max_open" echo 8 > "${cfg}/zone_max_active" fi echo 1 > "${cfg}/power" || exit_failed "Start null_blk device $n failed" echo "$n" > "${logdir}/.zonefs_test_nullbn" echo "$n" } function create_regular_nullb() { create_nullb 0 || \ exit_failed " --> Create regular null_blk device failed" } function create_zoned_nullb() { create_nullb 1 || \ exit_failed " --> Create zoned null_blk device failed" } function destroy_nullb() { local cfg="/sys/kernel/config/nullb/nullb$1" echo 0 > "${cfg}/power" rmdir "${cfg}" rmmod null_blk > /dev/null 2>&1 rm -f "${logdir}/.zonefs_test_nullbn" } function ls_nr_files() { ls -U "$1" | wc -l || exit_failed " --> ls FAILED" } function stat_nr_files() { stat -f -c "%c" "$1" } function block_number() { stat -f -c "%b" "$1" } function block_size() { stat -f -c "%S" "$1" } function require_program() { type -p "$1" 2> /dev/null || exit_skip "program $1 not available" } function require_cnv_files() { [[ ${nr_cnv_files} -ne 0 ]] || exit_skip "no conventional files" } function require_sysfs() { [[ ${zonefs_has_sysfs} -eq 1 ]] || exit_skip "sysfs attributes not supported" } function require_null_blk() { modinfo null_blk || exit_failed "null_blk module is not available" } function require_nullb_readonly() { modprobe null_blk nr_devices=0 || exit_failed "Failed to load null_blk module" have_zone_readonly=$(grep -c "zone_readonly" "/sys/kernel/config/nullb/features") rmmod null_blk > /dev/null 2>&1 [[ ${have_zone_readonly} -eq 0 ]] && exit_skip "null_blk does not support zone_readonly config" } function require_nullb_offline() { modprobe null_blk nr_devices=0 || exit_failed "Failed to load null_blk module" have_zone_offline=$(grep -c "zone_offline" "/sys/kernel/config/nullb/features") rmmod null_blk > /dev/null 2>&1 [[ ${have_zone_offline} -eq 0 ]] && exit_skip "null_blk does not support zone_offline config" } function set_nullb_first_seq_zone_readonly() { local cfg="/sys/kernel/config/nullb/nullb$1" echo $(( 10 * 32 * 1048576 / 512 )) > "${cfg}/zone_readonly" } function set_nullb_first_seq_zone_offline() { local cfg="/sys/kernel/config/nullb/nullb$1" echo $(( 10 * 32 * 1048576 / 512 )) > "${cfg}/zone_offline" } function fs_ro() { grep "${zonefs_mntdir}" "/proc/mounts" | grep -c "ro," } function check_fs_is_readonly() { [[ $(fs_ro) -eq 1 ]] || exit_failed "File system is not readonly" } function check_fs_is_writable() { [[ $(fs_ro) -eq 0 ]] || exit_failed "File system is readonly" } function write_file() { local file="$1" local sz=$2 local fsz=$(file_size "${file}") dd if=/dev/zero of="${file}" \ oflag=direct,append bs=${sz} count=1 \ conv=nocreat,notrunc || \ exit_failed " --> write ${sz} B to ${file} FAILED" check_file_size "${file}" $(( fsz + sz )) } function write_file_err() { local file="$1" local sz=$2 local expected_fsz=$3 dd if=/dev/zero of="${file}" \ oflag=direct,append bs=${sz} count=1 \ conv=nocreat,notrunc && \ exit_failed " --> write ${sz} B to ${file} SUCCESS (should FAIL)" check_file_size "${file}" ${expected_fsz} } function write_file_async_err() { local file="$1" local sz=$2 local expected_fsz=$3 tools/zio --write --fflag=direct --ofst=$(file_size "${file}") \ --async=1 --size=${sz} --nio=1 "${file}" && \ exit_failed " --> async write ${sz} B to ${file} SUCCESS (should FAIL)" check_file_size "${file}" ${expected_fsz} } function write_file_zone() { local dev="$1" local file="$2" local ofst local fino local fsz fino=$(get_ino "${file}") fsz=$(file_size "${file}") ofst=$(( (fino * zone_bytes + fsz) / 4096 )) dd if=/dev/zero of="${dev}" \ oflag=direct bs=4096 count=1 seek=${ofst} \ conv=nocreat,notrunc || \ exit_failed " --> write 4096 B to ${dev} in zone at $(( fino * zone_sectors )) FAILED" } function min() { local a=$1 local b=$2 echo $((a < b ? a : b)) } function max() { local a=$1 local b=$2 echo $((a > b ? a : b)) } zonefs-tools-1.6.0/tests/tools/000077500000000000000000000000001436613652400164745ustar00rootroot00000000000000zonefs-tools-1.6.0/tests/tools/Makefile.am000066400000000000000000000004411436613652400205270ustar00rootroot00000000000000# SPDX-License-Identifier: CC0-1.0 # # Copyright (C) 2021 Western Digital Corporation or its affiliates. AM_CFLAGS = -O2 -Wall -Wextra -Wno-unused-parameter noinst_PROGRAMS = zio zopen zio_SOURCES = zio.c zio_LDADD = zio_LDFLAGS = zopen_SOURCES = zopen.c zopen_LDADD = zopen_LDFLAGS = zonefs-tools-1.6.0/tests/tools/zio.c000066400000000000000000000307011436613652400174420ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2019 Western Digital Corporation or its affiliates. * Author: Damien Le Moal */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * IO descriptor. */ struct zio { int nr; void *buf; struct iocb iocb; }; /* * Run parameters. */ struct zio_params { bool verbose; int fd; bool read; bool async; int fflags; bool append; loff_t fsize; loff_t fmaxsize; size_t iosize; loff_t ioofst; unsigned int ionum; int ioflags; unsigned int iodepth; struct zio *io; aio_context_t ioctx; struct iocb **iocbs; unsigned int nr_ios; }; /* * Utilities. */ #define zio_vprintf(zio,format,args...) \ if ((zio)->verbose) { \ printf(format, ## args); \ } static inline unsigned long long zio_usec(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000000ULL + tv.tv_usec; } /* * System call wrappers. */ ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) { return syscall(SYS_preadv2, fd, iov, iovcnt, offset, 0, flags); } ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) { return syscall(SYS_pwritev2, fd, iov, iovcnt, offset, 0, flags); } static inline int io_setup(unsigned int nr, aio_context_t *ctxp) { return syscall(__NR_io_setup, nr, ctxp); } static inline int io_destroy(aio_context_t ctx) { return syscall(__NR_io_destroy, ctx); } static inline int io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp) { return syscall(__NR_io_submit, ctx, nr, iocbpp); } static inline int io_getevents(aio_context_t ctx, long min_nr, long max_nr, struct io_event *events, struct timespec *timeout) { return syscall(__NR_io_getevents, ctx, min_nr, max_nr, events, timeout); } static inline bool zio_done(struct zio_params *zio) { if (zio->ionum) return zio->nr_ios >= zio->ionum; return (zio->read && zio->ioofst >= zio->fsize) || (!zio->read && zio->ioofst >= zio->fmaxsize); } /* * Sync IO run. */ static int zio_run_sync(struct zio_params *zio) { ssize_t ret; loff_t ofst; struct iovec iov = { .iov_base = zio->io[0].buf, .iov_len = zio->iosize, }; while (!zio_done(zio)) { if (zio->read) { ofst = zio->ioofst; ret = preadv2(zio->fd, &iov, 1, ofst, zio->ioflags); } else { if (zio->append) ofst = 0; else ofst = zio->ioofst; ret = pwritev2(zio->fd, &iov, 1, ofst, zio->ioflags); } if (ret <= 0) { fprintf(stderr, "%05u: %s %zu B at %ld failed %d (%s)\n", zio->nr_ios, zio->read ? "READ" : "WRITE", zio->iosize, zio->ioofst, errno, strerror(errno)); return errno; } zio_vprintf(zio, "%05u: %s %zu B at %ld\n", zio->nr_ios, zio->read ? "READ" : "WRITE", zio->iosize, zio->ioofst); zio->nr_ios++; zio->ioofst += ret; } return 0; } /* * Async IO run. */ static int zio_submit_async(struct zio_params *zio) { struct iocb *iocb; struct zio *io; unsigned int i, n = 0; int ret; for (i = 0; i < zio->iodepth; i++) { if (zio_done(zio)) break; io = &zio->io[i]; if (io->nr >= 0) continue; iocb = &io->iocb; memset(iocb, 0, sizeof(struct iocb)); iocb->aio_fildes = zio->fd; if (zio->read) { iocb->aio_lio_opcode = IOCB_CMD_PREAD; iocb->aio_offset = zio->ioofst; } else { iocb->aio_lio_opcode = IOCB_CMD_PWRITE; if (zio->append) iocb->aio_offset = 0; else iocb->aio_offset = zio->ioofst; } iocb->aio_buf = (unsigned long)io->buf; iocb->aio_nbytes = zio->iosize; iocb->aio_rw_flags = zio->ioflags; iocb->aio_data = (unsigned long)io; io->nr = zio->nr_ios; zio_vprintf(zio, "%05d: %s %zu B at %ld issued\n", io->nr, zio->read ? "READ" : "WRITE", zio->iosize, zio->ioofst); zio->iocbs[n] = iocb; n++; zio->nr_ios++; zio->ioofst += zio->iosize; } if (!n) return 0; ret = io_submit(zio->ioctx, n, zio->iocbs); if (ret < 0) { fprintf(stderr, "io_submit failed %d (%s)\n", errno, strerror(errno)); return -1; } return n; } static int zio_check_async(struct zio_params *zio, int submitted, int in_flight) { struct io_event ioevent; struct iocb *iocb; struct zio *io; int ret, min_nr, n = 0; while (n < in_flight) { if (!submitted || (in_flight - n) >= (int)zio->iodepth) min_nr = 1; else min_nr = 0; ret = io_getevents(zio->ioctx, min_nr, 1, &ioevent, NULL); if (!ret) break; if (ret != 1) { fprintf(stderr, "io_getevents failed %d (%s)\n", ret, strerror(ret)); return -1; } iocb = (struct iocb *) ioevent.obj; io = (struct zio *)ioevent.data; if (ioevent.res < 0) { ret = -ioevent.res; fprintf(stderr, "%05d: %s %llu B at %lld failed %d (%s)\n", io->nr, zio->read ? "READ" : "WRITE", iocb->aio_nbytes, iocb->aio_offset, ret, strerror(ret)); return -1; } zio_vprintf(zio, "%05d: %s %llu B at %lld completed\n", io->nr, zio->read ? "READ" : "WRITE", iocb->aio_nbytes, iocb->aio_offset); io->nr = -1; n++; } return n; } static int zio_run_async(struct zio_params *zio) { struct io_event ioevent; int n, in_flight = 0; ssize_t ret; /* Setup IO context */ memset(&zio->ioctx, 0, sizeof(aio_context_t)); memset(&ioevent, 0, sizeof(struct io_event)); ret = io_setup(zio->iodepth, &zio->ioctx); if (ret < 0) { fprintf(stderr, "io_setup failed %d (%s)\n", errno, strerror(errno)); return -1; } /* Do IOs until submission stops */ while (1) { n = zio_submit_async(zio); if (n < 0) { ret = -1; break; } if (!n && !in_flight) break; in_flight += n; n = zio_check_async(zio, n, in_flight); if (n < 0) { ret = -1; break; } in_flight -= n; } io_destroy(zio->ioctx); return ret; } static void zio_cleanup(struct zio_params *zio) { unsigned int i; if (!zio->io) return; for (i = 0; i < zio->iodepth; i++) free(zio->io[i].buf); free(zio->io); zio->io = NULL; free(zio->iocbs); zio->iocbs = NULL; if (zio->fd > 0) { close(zio->fd); zio->fd = -1; } } static int zio_init(struct zio_params *zio, char *path) { struct stat st; unsigned int i; int ret; /* Allocate and initialize IO array */ zio->io = calloc(zio->iodepth, sizeof(struct zio)); if (!zio->io) { fprintf(stderr, "No memory for IO array\n"); return -1; } for (i = 0; i < zio->iodepth; i++) { zio->io[i].nr = -1; ret = posix_memalign((void **) &zio->io[i].buf, sysconf(_SC_PAGESIZE), zio->iosize); if (ret != 0) { fprintf(stderr, "Allocate IO buffer failed %d (%s)\n", -ret, strerror(-ret)); goto err; } } zio->iocbs = calloc(zio->iodepth, sizeof(struct iocb *)); if (!zio->iocbs) { fprintf(stderr, "No memory for async IO array\n"); goto err; } /* Open file */ zio->fd = open(path, zio->fflags, 0); if (zio->fd < 0) { fprintf(stderr, "Open %s failed %d (%s)\n", path, errno, strerror(errno)); goto err; } ret = fstat(zio->fd, &st); if (ret) { fprintf(stderr, "Stat %s failed %d (%s)\n", path, errno, strerror(errno)); goto err; } zio->fsize = st.st_size; zio->fmaxsize = st.st_blocks << 9; /* If we do append writes, set offset to EOF */ if (!zio->read) { zio->append = ((zio->fflags & O_APPEND) == O_APPEND) || (zio->ioflags & RWF_APPEND) == RWF_APPEND; if (zio->append) zio->ioofst = zio->fsize; } return 0; err: zio_cleanup(zio); return -1; } static void zio_usage(char *cmd) { printf("Usage: %s [options] \n", cmd); printf("Options:\n" " -h | --help : print usage and exit\n" " --v : Verbose output (stats)\n" " --vv : Very verbose output (IOs)\n" " --read : do read (default)\n" " --write : do write\n" " --size= : Do sized IOs (default: 4096)\n" " --ofst= : Start IOs at (default: 0)\n" " --nio= : Do IOs and exit\n" " (default: IOs until EOF)\n" " --async= : Do asynchronous IOs, issuing at most\n" " IOs at a time\n" " --fflag= : Use O_ to open file.\n" " can be:\n" " - direct\n" " - append\n" " - ndelay\n" " - sync\n" " - dsync\n" " - trunc\n" " This option can be used multiple times.\n" " --ioflag= : Use RWF_ for IOs. can be:\n" " - nowait\n" " - hipri\n" " - append\n" " - dsync\n" " This option can be used multiple times.\n"); } int main(int argc, char **argv) { struct zio_params zio; unsigned long long start; long long arg; int ret, i; /* Set default values */ memset(&zio, 0, sizeof(struct zio_params)); zio.fd = -1; zio.read = true; zio.async = false; zio.append = false; zio.fflags = O_LARGEFILE; zio.iosize = 4096; zio.iodepth = 1; zio.verbose = false; if (argc <= 1) { zio_usage(argv[0]); return 1; } /* Parse command line */ for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { zio_usage(argv[0]); return 0; } if (strcmp(argv[i], "--v") == 0) { zio.verbose = true; } else if (strcmp(argv[i], "--read") == 0) { zio.read = true; zio.fflags |= O_RDONLY; } else if (strcmp(argv[i], "--write") == 0) { zio.read = false; zio.fflags |= O_WRONLY; } else if (strncmp(argv[i], "--size=", 7) == 0) { arg = atol(argv[i] + 7); if (arg <= 0) { fprintf(stderr, "Invalid IO size\n"); return 1; } zio.iosize = arg; } else if (strncmp(argv[i], "--ofst=", 7) == 0) { arg = atoll(argv[i] + 7); if (arg < 0) { fprintf(stderr, "Invalid IO offset\n"); return 1; } zio.ioofst = arg; } else if (strncmp(argv[i], "--nio=", 6) == 0) { arg = atoi(argv[i] + 6); if (arg <= 0) { fprintf(stderr, "Invalid number of IOs\n"); return 1; } zio.ionum = arg; } else if (strncmp(argv[i], "--async=", 8) == 0) { zio.async = true; arg = atoi(argv[i] + 8); if (arg <= 0) { fprintf(stderr, "Invalid async IO depth\n"); return 1; } zio.iodepth = arg; } else if (strncmp(argv[i], "--fflag=", 8) == 0) { if (strcmp(argv[i] + 8, "direct") == 0) { zio.fflags |= O_DIRECT; } else if (strcmp(argv[i] + 8, "append") == 0) { zio.fflags |= O_APPEND; } else if (strcmp(argv[i] + 8, "ndelay") == 0) { zio.fflags |= O_NDELAY; } else if (strcmp(argv[i] + 8, "sync") == 0) { zio.fflags |= O_SYNC; } else if (strcmp(argv[i] + 8, "dsync") == 0) { zio.fflags |= O_DSYNC; } else if (strcmp(argv[i] + 8, "trunc") == 0) { zio.fflags |= O_TRUNC; } else { fprintf(stderr, "Invalid file open flag\n"); return 1; } } else if (strncmp(argv[i], "--ioflag=", 9) == 0) { if (strcmp(argv[i] + 9, "append") == 0) { zio.ioflags |= RWF_APPEND; } else if (strcmp(argv[i] + 9, "nowait") == 0) { zio.ioflags |= RWF_NOWAIT; } else if (strcmp(argv[i] + 9, "hipri") == 0) { zio.ioflags |= RWF_HIPRI; } else if (strcmp(argv[i] + 9, "dsync") == 0) { zio.ioflags |= RWF_DSYNC; } else { fprintf(stderr, "Invalid IO flag\n"); return 1; } } else if (argv[i][0] == '-') { fprintf(stderr, "Invalid option \"%s\"\n", argv[i]); return 1; } } ret = zio_init(&zio, argv[argc - 1]); if (ret != 0) return 1; start = zio_usec(); if (zio.async) ret = zio_run_async(&zio); else ret = zio_run_sync(&zio); if (ret != 0) ret = 1; if (ret == 0) { unsigned long long elapsed = zio_usec() - start; unsigned long long bw, iops; iops = zio.nr_ios * 1000000ULL / elapsed; bw = zio.nr_ios * zio.iosize * 1000000ULL / elapsed; printf("%u IOs done in %llu ms (%llu us)\n", zio.nr_ios, elapsed / 1000, elapsed); printf(" %llu IOPS, %llu.%03llu MB/s\n", iops, bw / 1000000, (bw % 1000000) / 1000); } zio_cleanup(&zio); return ret; } zonefs-tools-1.6.0/tests/tools/zopen.c000066400000000000000000000110041436613652400177670ustar00rootroot00000000000000// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (C) 2022 Western Digital Corporation or its affiliates. * Author: Damien Le Moal */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #define ZOPEN_MAX_FILES 1024 struct zopen_params { bool verbose; bool pause; const char *base_path; int fflags; int first_file; int nr_files; int fd[ZOPEN_MAX_FILES]; }; static void zopen_sigcatcher(int sig) { return; } #define zopen_vprintf(zo,fmt,args...) \ if ((zo)->verbose) { \ printf(fmt, ## args); \ } static int zopen(struct zopen_params *zo, int idx) { char path[PATH_MAX]; if (idx >= zo->nr_files) { fprintf(stderr, "Invalid file index %d/%d\n", idx, zo->nr_files); return -1; } /* Generate the file path */ snprintf(path, sizeof(path) - 1, "%s/%d", zo->base_path, zo->first_file + idx); zopen_vprintf(zo, "Opening %s\n", path); /* Open file */ zo->fd[idx] = open(path, zo->fflags, 0); if (zo->fd[idx] < 0) { fprintf(stderr, "Open %s failed %d (%s)\n", path, errno, strerror(errno)); return -1; } return 0; } static void zopen_usage(char *cmd) { printf("Usage: %s [options] \n", cmd); printf("Options:\n" " -h | --help : print usage and exit\n" " --v : Verbose output\n" " --start= : First file to open (default: 0)\n" " --nrfiles= : Number of files to open (default: 1)\n" " --fflag= : Use O_XXX to open files. can be:\n" " - read (default)\n" " - write\n" " - direct\n" " - trunc\n" " This option can be used multiple times.\n" " --pause : Do not exit immediately and wait" " for a signal\n"); } int main(int argc, char **argv) { struct zopen_params zo; const char *val; struct sigaction act; int i; /* Setup signal handler */ act.sa_flags = 0; act.sa_handler = zopen_sigcatcher; sigemptyset(&act.sa_mask); (void)sigaction(SIGPIPE, &act, NULL); (void)sigaction(SIGINT, &act, NULL); (void)sigaction(SIGTERM, &act, NULL); /* Set default values */ memset(&zo, 0, sizeof(struct zopen_params)); zo.nr_files = 1; zo.fflags = O_LARGEFILE | O_RDONLY; for (i = 0; i < ZOPEN_MAX_FILES; i++) zo.fd[i] = -1; if (argc <= 1) { zopen_usage(argv[0]); return 1; } /* Parse command line */ for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { zopen_usage(argv[0]); return 0; } if (strcmp(argv[i], "--v") == 0) { zo.verbose = true; } else if (strncmp(argv[i], "--start=", 8) == 0) { zo.first_file = atoi(argv[i] + 8); if (zo.first_file < 0) { fprintf(stderr, "Invalid start file\n"); return 1; } } else if (strncmp(argv[i], "--nrfiles=", 10) == 0) { zo.nr_files = atoi(argv[i] + 10); if (zo.nr_files <= 0 || zo.nr_files > ZOPEN_MAX_FILES) { fprintf(stderr, "Invalid number of files\n"); return 1; } } else if (strncmp(argv[i], "--fflag=", 8) == 0) { val = argv[i] + 8; if (strcmp(val, "read") == 0) { zo.fflags |= O_RDONLY; } else if (strcmp(val, "write") == 0) { zo.fflags |= O_WRONLY; } else if (strcmp(val, "direct") == 0) { zo.fflags |= O_DIRECT; } else if (strcmp(val, "trunc") == 0) { zo.fflags |= O_TRUNC; } else { fprintf(stderr, "Invalid file open flag\n"); return 1; } } else if (strcmp(argv[i], "--pause") == 0) { zo.pause = true; } else if (argv[i][0] == '-') { fprintf(stderr, "Invalid option \"%s\"\n", argv[i]); return 1; } else { break; } } if (i != argc - 1) { zopen_usage(argv[0]); return 0; } zo.base_path = realpath(argv[i], NULL); if (!zo.base_path) { fprintf(stderr, "Generate base path for %s failed\n", argv[i]); return 1; } /* Open files */ for (i = 0; i < zo.nr_files; i++) { if (zopen(&zo, i)) return 1; } printf("Opened %d file%s from file %d\n", zo.nr_files, zo.nr_files > 1 ? "s" : "", zo.first_file); if (zo.pause) { /* Wait for a signal */ pause(); } for (i = 0; i < zo.nr_files; i++) close(zo.fd[i]); printf("Closed %d file%s from file %d\n", zo.nr_files, zo.nr_files > 1 ? "s" : "", zo.first_file); return 0; } zonefs-tools-1.6.0/tests/zonefs-tests-nullblk.sh000077500000000000000000000114001436613652400217740ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # # Zone size in MB zone_size=32 zone_capacity=$zone_size # Max open and active limits declare -i zone_max_open=0 declare -i zone_max_active=0 # Device total capacity (MB) capacity=2048 # Device block size blocksize="512" # Default number of conventional zones to test nr_conv=10 function usage() { echo "Usage: $0 [options]" echo "Options:" echo " -h | --help : Display help" echo " -c | --cap : Test with zone capacity < zone size (default: off)" echo " -n | --nr_conv : Specify the number of conventional zones to use." echo " -s | --sectsz : Test with device block size set to bytes (default: 512 B)" echo " -t : Test to execute. Can be specified multiple times." echo " If used, only the first nullb config is used" } # Check credentials if [ $(id -u) -ne 0 ]; then echo "Root credentials are needed to run tests." exit 1 fi testopts="" # Check options while [[ $# -gt 0 ]]; do case "$1" in "-h" | "--help") usage "$0" exit 0 ;; "-c" | "--cap") zone_capacity=$(( zone_size - 1 )) shift ;; "-n" | "--nr_conv") shift nr_conv=($1) shift ;; "-s" | "--sectsz") shift blocksize=($1) shift ;; "-t") shift testopts+=" -t $1" shift ;; *) echo "Invalid option $1" exit 1 ;; esac done if [ $blocksize != 512 ] && [ $blocksize != 4096 ]; then echo "Invalid sector size" exit 1 fi # trap ctrl-c interruptions aborted=0 trap ctrl_c INT function ctrl_c() { aborted=1 } scriptdir="$(cd "$(dirname "$0")" && pwd)" modprobe null_blk nr_devices=0 nr_configs=5 function set_config() { case "$1" in "0") zone_max_open=0 zone_max_active=0 ;; "1") zone_max_open=$(( $capacity / $zone_size / 8 )) zone_max_active=0 ;; "2") zone_max_open=0 zone_max_active=$(( $capacity / $zone_size / 8 + 1 )) ;; "3") zone_max_open=$(( $capacity / $zone_size / 8 )) zone_max_active=$(( $capacity / $zone_size / 8 + 1 )) ;; "4") capacity=$(( capacity + zone_size / 2 + 1 )) nr_conv=0 zone_max_open=$(( $capacity / $zone_size / 8 )) zone_max_active=$(( $capacity / $zone_size / 8 + 1 )) ;; *) echo "Invalid configuration" exit 1 ;; esac } # Create a zoned null_blk disk function create_zoned_nullb() { local n=0 while [ 1 ]; do if [ ! -b "/dev/nullb$n" ]; then break fi n=$(( n + 1 )) done dev="/sys/kernel/config/nullb/nullb$n" mkdir "$dev" if [ $zone_capacity != $zone_size ] && [ ! -w "$dev"/zone_capacity ]; then echo "Zone capacity is not supported by nullblk" exit 1 fi echo "$blocksize" > "$dev"/blocksize echo 2 > "$dev"/queue_mode echo 2 > "$dev"/irqmode echo 2000 > "$dev"/completion_nsec echo $capacity > "$dev"/size echo 1024 > "$dev"/hw_queue_depth echo 1 > "$dev"/memory_backed echo 1 > "$dev"/zoned echo "$zone_size" > "$dev"/zone_size if [ $zone_capacity != $zone_size ]; then echo "$zone_capacity" > "$dev"/zone_capacity fi echo "$nr_conv" > "$dev"/zone_nr_conv if [ -f "$dev"/zone_max_open ]; then echo "$zone_max_open" > "$dev"/zone_max_open fi if [ -f "$dev"/zone_max_active ]; then echo "$zone_max_active" > "$dev"/zone_max_active fi echo 1 > "$dev"/power echo "nullb$n" } function destroy_zoned_nullb() { local ndev="$1" echo 0 > /sys/kernel/config/nullb/$ndev/power rmdir /sys/kernel/config/nullb/$ndev } declare -i rc=0 # Run all open/active configurations (3 by default) for (( m=0; m<$nr_configs; m++ )); do set_config "$m" ndev=$(create_zoned_nullb) moz=$(cat /sys/block/"$ndev"/queue/max_open_zones) maz=$(cat /sys/block/"$ndev"/queue/max_active_zones) nrz=$(blkzone report "/dev/$ndev" | wc -l) nrc=$(blkzone report "/dev/$ndev" | grep -c CONVENTIONAL) echo "" echo "Config ${m}:" echo " Zone size: $zone_size MB, zone capacity: $zone_capacity MB" echo " $nrz zones, $nrc conventional zones" echo " $moz max open zones ($zone_max_open)" echo " $maz max active zones ($zone_max_active)" echo "" logdir="logs/${ndev}-conv${nr_conv}-moz${zone_max_open}-maz${zone_max_active}" if ! ./zonefs-tests.sh ${testopts} "-g" "$logfile" "/dev/$ndev"; then rc=1 fi sleep 1 destroy_zoned_nullb "$ndev" if [ "$aborted" == 1 ] || [ "$testopts" != "" ]; then break fi done rmmod null_blk > /dev/null 2>&1 echo "" if [ "$rc" != 0 ]; then echo "Failures detected" exit 1 fi echo "All tests passed" exit 0 zonefs-tools-1.6.0/tests/zonefs-tests-scsi-debug.sh000077500000000000000000000046421436613652400223700ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2022 Western Digital Corporation or its affiliates. # # Zone size in MB zone_size=64 zone_capacity=$zone_size # Device total capacity (MB) capacity=1024 # Sector size sect_size=512 # Number of conventional zones nr_conv=3 function usage() { echo "Usage: $0 [options]" echo "Options:" echo " -h | --help : Display help" echo " -c | --cap : Test with zone capacity < zone size (default: off)" echo " -n | --nr_conv : Specify the number of conventional zones to use." echo " -t : Test to execute. Can be specified multiple times." } # Check credentials if [ $(id -u) -ne 0 ]; then echo "Root credentials are needed to run tests." exit 1 fi testopts="" # Check options while [[ $# -gt 0 ]]; do case "$1" in "-h" | "--help") usage "$0" exit 0 ;; "-c" | "--cap") zone_capacity=$(( zone_size - 1 )) shift ;; "-n" | "--nr_conv") shift nr_conv="$1" shift ;; "-t") shift testopts+=" -t $1" shift ;; *) echo "Invalid option $1" exit 1 ;; esac done # trap ctrl-c interruptions aborted=0 trap ctrl_c INT function ctrl_c() { aborted=1 } scriptdir="$(cd "$(dirname "$0")" && pwd)" # Create the scsi_debug device modprobe scsi_debug max_luns=1 sector_size="$sect_size" \ delay=0 dev_size_mb="$capacity" zbc=managed \ zone_size_mb="$zone_size" zone_cap_mb="$zone_capacity" \ zone_nr_conv="$nr_conv" sdev="$(lsscsi | grep scsi_debug | awk -F' ' '{print $NF}')" sbdev="$(basename $sdev)" zone_max_open=$(cat /sys/block/"$sbdev"/queue/max_open_zones) zone_max_active=$(cat /sys/block/"$sbdev"/queue/max_active_zones) nr_zones=$(blkzone report "$sdev" | wc -l) nr_conv=$(blkzone report "$sdev" | grep -c CONVENTIONAL) echo "" echo "Run tests against $sdev..." echo " Zone size: $zone_size MB, zone capacity: $zone_capacity MB" echo " $nr_zones zones, $nr_conv conventional zones" echo " $zone_max_open max open zones" echo " $zone_max_active max active zones" echo "" declare -i rc=0 if ! ./zonefs-tests.sh ${testopts} "$sdev"; then rc=1 fi sleep 1 rmmod scsi_debug echo "" if [ "$rc" != 0 ]; then echo "Failures detected" exit 1 fi echo "All tests passed" exit 0 zonefs-tools-1.6.0/tests/zonefs-tests.sh000077500000000000000000000166231436613652400203470ustar00rootroot00000000000000#!/bin/bash # # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright (C) 2019 Western Digital Corporation or its affiliates. # # Run everything from the tests directory cd $(dirname "$0") . scripts/test_lib # trap ctrl-c interruptions aborted=0 trap ctrl_c INT function test_num() { basename "$1" .sh } function ctrl_c() { aborted=1 } function usage() { echo "Usage: $(basename "$0") [Options] " echo "Options:" echo " -l : List all tests" echo " -g : Use this directory to save log files." echo " default: logs/" echo " -t [-] : Execute only the specified test ." echo " If a second case is specified after a hyphen," echo " all test cases from to will be" echo " executed. This option can be specified" echo " multiple times." echo " -s : Short test (do not execute tests that take a" echo " long time)" echo " -h, --help : This help message" } # Check configuration [[ $(modinfo null_blk) ]] || { echo "null_blk module is not available." exit 1 } [[ $(type -P "tools/zio") && $(type -P "tools/zopen") ]] || { echo "Test tools not found." echo "Run \"./configure --with-tests\" and recompile." exit 1 } [[ $(type -P "fio") ]] || { echo "fio not found." echo "Installing fio is required to run tests." exit 1 } [[ $(type -P "mkzonefs") ]] || { echo "mkzonefs not found." echo "Installing zonefs-tools is required to run tests." exit 1 } # Parse command line declare -a tests declare list=false logdir="" export short=false # Get full test list declare -a testlist for f in scripts/*.sh; do testlist+=("$(test_num $f)") done function get_test_range() { local case="$1" local tstart=$(echo "${case}" | cut -f1 -d'-') local tend=$(echo "${case}" | cut -f2 -d'-') local add=0 declare -a trange for t in "${testlist[@]}"; do if [ "$t" == "$tstart" ]; then add=1 fi if [ "$add" == "1" ]; then trange+=("scripts/$t.sh") fi if [ "$t" == "$tend" ]; then add=0 fi done if [ "${#trange[@]}" == "0" ]; then echo "Invalid test range $1" exit 1; fi tests+=( "${trange[@]}" ) } while [ "${1#-}" != "$1" ]; do case "$1" in -h | --help) usage exit 0 ;; -t) get_test_range "$2" shift shift ;; -l) list=true shift ;; -g) shift logdir="$1" shift ;; -s) short=true shift ;; -*) echo "unknow option $1" exit 1 ;; esac done if [ ! $list ] && [ $# -lt 1 ]; then usage exit 1 fi # Get list of tests if [ "${#tests[@]}" == "0" ]; then for f in scripts/*.sh; do tests+=("$f") done fi # Handle -l option (list tests) if $list; then for t in "${tests[@]}"; do echo " Test $(test_num "$t"): $( $t )" done exit 0 fi dev="$1" if [ -z "$dev" ]; then usage exit 1 fi if [ ! -b "$dev" ]; then echo "Invalid block device" exit 1 fi # Check credentials if [ $(id -u) -ne 0 ]; then echo "Root credentials are needed to run tests." exit 1 fi realdev=$(readlink -f "$dev") bdev=$(basename "$realdev") major=$((0x$(stat -L -c '%t' "$realdev"))) minor=$((0x$(stat -L -c '%T' "$realdev"))) # When the target is a partition device, get basename of its holder device to # access sysfs path of the holder device if [[ -r "/sys/dev/block/$major:$minor/partition" ]]; then realsysfs=$(readlink "/sys/dev/block/$major:$minor") bdev=$(basename "${realsysfs%/*}") fi dev="/dev/$bdev" if [ "$(<"/sys/class/block/$bdev/queue/zoned")" == "none" ]; then echo "/dev/$dev is not a zoned block device" exit 1 fi if ! blkzone_has_zone_capacity "$dev"; then echo "blkzone utility is not reporting zone capacity." echo "util-linux update needed." exit 1 fi export zonefs_mntdir="${PWD}/$bdev-mnt" mkdir -p "$zonefs_mntdir" if [ "$logdir" == "" ]; then logdir="logs/${bdev}" fi mkdir -p "$logdir" || \ exit_failed "Create log directory ${logdir} failed" rm -rf "${logdir}/*" > /dev/null 2>&1 export logdir passed=0 total=0 rc=0 # Drive parameters echo "Gathering information on $dev..." export nr_zones=$(get_nr_zones "$dev") export zone_sectors=$(get_zone_sectors "$dev") export zone_bytes=$(( zone_sectors * 512 )) export nr_cnv_zones=$(get_nr_cnv_zones "$dev") export nr_seq_zones=$(get_nr_seq_zones "$dev") export total_usable_sectors=$(get_total_zone_capacity_sectors "$dev") export iosize=$((4096 * 64)) # Expected number of files if [ "$nr_cnv_zones" == 0 ]; then nr_cnv_files=0 nr_seq_files=$(( nr_seq_zones - 1 )) seq_file_0_zone_start_sector=$zone_sectors elif [ "$nr_cnv_zones" == 1 ]; then nr_cnv_files=0 nr_seq_files=$nr_seq_zones seq_file_0_zone_start_sector=$zone_sectors else nr_cnv_files=$(( nr_cnv_zones - 1 )) nr_seq_files=$nr_seq_zones seq_file_0_zone_start_sector=$(( nr_cnv_zones * zone_sectors )) fi export nr_cnv_files export nr_seq_files export seq_file_0_zone_start_sector export seq_file_0_max_size=$(get_zone_capacity_bytes "$dev" $seq_file_0_zone_start_sector) # zonefs features modprobe zonefs if [ -d "/sys/fs/zonefs" ]; then zonefs_has_sysfs=1 else zonefs_has_sysfs=0 fi export zonefs_has_sysfs rmmod zonefs # Set IO scheduler echo mq-deadline > "/sys/block/$bdev/queue/scheduler" || \ exit_failed "Failed to set scheduler to mq-deadline" function kmsg_log() { if [ -e /dev/kmsg ]; then echo "$1" > /dev/kmsg fi } function kmsg_log_start() { kmsg_log "++++ zonefs-test case $1 start ++++" } function kmsg_log_end() { kmsg_log "---- zonefs-test case $1 end ----" } function run_test() { local tnum="$(test_num $1)" local ret=0 kmsg_log_start ${tnum} modprobe zonefs || (echo "FAILED (modprobe)"; return 1) echo "## Test ${tnum}: $( $1 )" echo "" "$1" "$2" ret=$? if [ "$ret" == 0 ]; then echo "PASS" elif [ "$ret" == 2 ]; then echo "skip" else echo "FAILED" fi echo "" umount "$zonefs_mntdir" >> /dev/null 2>&1 rmmod zonefs || if [ $ret == 0 ]; then echo "FAILED (rmmod)"; ret=1; fi kmsg_log_end ${tnum} return $ret } echo "zonefs-tests on $dev:" echo " $nr_zones zones ($nr_cnv_zones conventional zones, $nr_seq_zones sequential zones)" echo " $zone_sectors 512B sectors zone size ($(( zone_bytes / 1048576 )) MiB)" echo " $(get_max_open_zones $dev) max open zones" echo " $(get_max_active_zones $dev) max active zones" echo "Running tests" for t in "${tests[@]}"; do tnum="$(test_num $t)" echo -n " Test ${tnum}: " printf "%-60s ... " "$( $t )" run_test "$t" "$1" > "${logdir}/${tnum}.log" 2>&1 ret=$? if [ "$ret" == 0 ]; then status="\e[92mPASS\e[0m" rc=0 elif [ "$ret" == 2 ]; then status="skip" rc=0 else status="\e[31mFAIL\e[0m" rc=1 fi if [ "$rc" == 0 ]; then ((passed++)) fi ((total++)) echo -e "$status" if [ -f "${logdir}/.zonefs_test_nullbn" ]; then destroy_nullb "$(cat ${logdir}/.zonefs_test_nullbn)" fi if [ "$aborted" == 1 ]; then break fi na=0 done echo "" echo "$passed / $total tests passed" umount "$zonefs_mntdir" >> /dev/null 2>&1 rm -rf "$zonefs_mntdir" >> /dev/null 2>&1 rm -f local-* >> /dev/null 2>&1 # cleanup env unset short unset zonefs_mntdir unset logdir unset nr_zones unset zone_sectors unset zone_bytes unset nr_cnv_zones unset nr_seq_zones unset total_usable_sectors unset iosize unset nr_cnv_files unset nr_seq_files unset seq_file_0_zone_start_sector unset seq_file_0_max_size unset zonefs_has_sysfs if [ "$passed" != "$total" ]; then exit 1 fi exit 0 zonefs-tools-1.6.0/zonefs-tools.spec000066400000000000000000000015271436613652400175150ustar00rootroot00000000000000Name: zonefs-tools Version: 1.6.0 Release: 1%{?dist} Summary: Provides user utilities for the zonefs file system License: GPLv2+ URL: https://github.com/westerndigitalcorporation/%{name} Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz BuildRequires: libblkid-devel BuildRequires: libuuid-devel BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool BuildRequires: make BuildRequires: gcc %description This package provides the mkzonefs (and mkfs.zonefs) user utility to format zoned block devices for use with the zonefs file system. %prep %autosetup %build sh autogen.sh %configure %make_build %install %make_install %files %{_sbindir}/* %{_mandir}/man8/* %license COPYING.GPL %doc README.md CONTRIBUTING %changelog * Tue Jan 31 2023 Damien Le Moal 1.6.0-1 - Version 1.6.0 initial package