xref: /freebsd/sys/contrib/openzfs/.github/CONTRIBUTING.md (revision f3087bef11543b42e0d69b708f367097a4118d24)
1# Contributing to OpenZFS
2<p align="center">
3  <img alt="OpenZFS Logo"
4    src="https://openzfs.github.io/openzfs-docs/_static/img/logo/480px-Open-ZFS-Secondary-Logo-Colour-halfsize.png"/>
5</p>
6
7*First of all, thank you for taking the time to contribute!*
8
9By using the following guidelines, you can help us make OpenZFS even better.
10
11## Table Of Contents
12[What should I know before I get
13started?](#what-should-i-know-before-i-get-started)
14
15  * [Get ZFS](#get-zfs)
16  * [Debug ZFS](#debug-zfs)
17  * [Where can I ask for help?](#where-can-I-ask-for-help)
18
19[How Can I Contribute?](#how-can-i-contribute)
20
21  * [Reporting Bugs](#reporting-bugs)
22  * [Suggesting Enhancements](#suggesting-enhancements)
23  * [Pull Requests](#pull-requests)
24  * [Testing](#testing)
25
26[Style Guides](#style-guides)
27
28  * [Coding Conventions](#coding-conventions)
29  * [Commit Message Formats](#commit-message-formats)
30    * [New Changes](#new-changes)
31    * [OpenZFS Patch Ports](#openzfs-patch-ports)
32    * [Coverity Defect Fixes](#coverity-defect-fixes)
33    * [Signed Off By](#signed-off-by)
34
35Helpful resources
36
37  * [OpenZFS Documentation](https://openzfs.github.io/openzfs-docs/)
38  * [OpenZFS Developer Resources](http://open-zfs.org/wiki/Developer_resources)
39  * [Git and GitHub for beginners](https://openzfs.github.io/openzfs-docs/Developer%20Resources/Git%20and%20GitHub%20for%20beginners.html)
40
41## What should I know before I get started?
42
43### Get ZFS
44You can build zfs packages by following [these
45instructions](https://openzfs.github.io/openzfs-docs/Developer%20Resources/Building%20ZFS.html),
46or install stable packages from [your distribution's
47repository](https://openzfs.github.io/openzfs-docs/Getting%20Started/index.html).
48
49### Debug ZFS
50A variety of methods and tools are available to aid ZFS developers.
51It's strongly recommended that when developing a patch the `--enable-debug`
52configure option should be set. This will enable additional correctness
53checks and all the ASSERTs to help quickly catch potential issues.
54
55In addition, there are numerous utilities and debugging files which
56provide visibility into the inner workings of ZFS.  The most useful
57of these tools are discussed in detail on the [Troubleshooting
58page](https://openzfs.github.io/openzfs-docs/Basic%20Concepts/Troubleshooting.html).
59
60### Where can I ask for help?
61The [zfs-discuss mailing
62list](https://openzfs.github.io/openzfs-docs/Project%20and%20Community/Mailing%20Lists.html)
63or IRC are the best places to ask for help. Please do not file
64support requests on the GitHub issue tracker.
65
66## How Can I Contribute?
67
68### Reporting Bugs
69*Please* contact us via the [zfs-discuss mailing
70list](https://openzfs.github.io/openzfs-docs/Project%20and%20Community/Mailing%20Lists.html)
71or IRC if you aren't certain that you are experiencing a bug.
72
73If you run into an issue, please search our [issue
74tracker](https://github.com/openzfs/zfs/issues) *first* to ensure the
75issue hasn't been reported before. Open a new issue only if you haven't
76found anything similar to your issue.
77
78You can open a new issue and search existing issues using the public [issue
79tracker](https://github.com/openzfs/zfs/issues).
80
81#### When opening a new issue, please include the following information at the top of the issue:
82* What distribution (with version) you are using.
83* The spl and zfs versions you are using, installation method (repository
84or manual compilation).
85* Describe the issue you are experiencing.
86* Describe how to reproduce the issue.
87* Including any warning/errors/backtraces from the system logs.
88
89When a new issue is opened, it is not uncommon for developers to request
90additional information.
91
92In general, the more detail you share about a problem the quicker a
93developer can resolve it. For example, providing a simple test case is always
94exceptionally helpful.
95
96Be prepared to work with the developers investigating your issue. Your
97assistance is crucial in providing a quick solution. They may ask for
98information like:
99
100* Your pool configuration as reported by `zdb` or `zpool status`.
101* Your hardware configuration, such as
102  * Number of CPUs.
103  * Amount of memory.
104  * Whether your system has ECC memory.
105  * Whether it is running under a VMM/Hypervisor.
106  * Kernel version.
107  * Values of the spl/zfs module parameters.
108* Stack traces which may be logged to `dmesg`.
109
110### Suggesting Enhancements
111OpenZFS is a widely deployed production filesystem which is under active
112development. The team's primary focus is on fixing known issues, improving
113performance, and adding compelling new features.
114
115You can view the list of proposed features
116by filtering the issue tracker by the ["Type: Feature"
117label](https://github.com/openzfs/zfs/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature%22).
118If you have an idea for a feature first check this list. If your idea already
119appears then add a +1 to the top most comment, this helps us gauge interest
120in that feature.
121
122Otherwise, open a new issue and describe your proposed feature.  Why is this
123feature needed?  What problem does it solve?
124
125### Pull Requests
126
127#### General
128
129* All pull requests, except backports and releases, must be based on the current master branch
130and should apply without conflicts.
131* Please attempt to limit pull requests to a single commit which resolves
132one specific issue.
133* Make sure your commit messages are in the correct format. See the
134[Commit Message Formats](#commit-message-formats) section for more information.
135* When updating a pull request squash multiple commits by performing a
136[rebase](https://git-scm.com/docs/git-rebase) (squash).
137* For large pull requests consider structuring your changes as a stack of
138logically independent patches which build on each other.  This makes large
139changes easier to review and approve which speeds up the merging process.
140* Try to keep pull requests simple. Simple code with comments is much easier
141to review and approve.
142* All proposed changes must be approved by an OpenZFS organization member.
143* If you have an idea you'd like to discuss or which requires additional testing, consider opening it as a draft pull request.
144Once everything is in good shape and the details have been worked out you can remove its draft status.
145Any required reviews can then be finalized and the pull request merged.
146
147#### Tests and Benchmarks
148* Every pull request is tested using a GitHub Actions workflow on multiple platforms by running the [zfs-tests.sh and zloop.sh](
149https://openzfs.github.io/openzfs-docs/Developer%20Resources/Building%20ZFS.html#running-zloop-sh-and-zfs-tests-sh) test suites.
150`.github/workflows/scripts/generate-ci-type.py` is used to determine whether the pull request is nonbehavior, i.e., not introducing behavior changes of any code, configuration or tests. If so, the CI will run on fewer platforms and only essential sanity tests will run. You can always override this by adding `ZFS-CI-Type` line to your commit message:
151  * If your last commit (or `HEAD` in git terms) contains a line `ZFS-CI-Type: quick`, quick mode is forced regardless of what files are changed.
152  * Otherwise, if any commit in a PR contains a line `ZFS-CI-Type: full`, full mode is forced.
153* To verify your changes conform to the [style guidelines](
154https://github.com/openzfs/zfs/blob/master/.github/CONTRIBUTING.md#style-guides
155), please run `make checkstyle` and resolve any warnings.
156* Code analysis is performed by [CodeQL](https://codeql.github.com/) for each pull request.
157* Test cases should be provided when appropriate.  This includes making sure new features have adequate code coverage.
158* If your pull request improves performance, please include some benchmarks.
159* The pull request must pass all CI checks before being accepted.
160
161### Testing
162All help is appreciated! If you're in a position to run the latest code
163consider helping us by reporting any functional problems, performance
164regressions or other suspected issues. By running the latest code to a wide
165range of realistic workloads, configurations and architectures we're better
166able quickly identify and resolve potential issues.
167
168Users can also run the [ZFS Test
169Suite](https://github.com/openzfs/zfs/tree/master/tests) on their systems
170to verify ZFS is behaving as intended.
171
172## Style Guides
173
174### Repository Structure
175
176OpenZFS uses a standardised branching structure.
177- The "development and main branch", is the branch all development should be based on.
178- "Release branches" contain the latest released code for said version.
179- "Staging branches" contain selected commits prior to being released.
180
181**Branch Names:**
182- Development and Main branch: `master`
183- Release branches: `zfs-$VERSION-release`
184- Staging branches: `zfs-$VERSION-staging`
185
186`$VERSION` should be replaced with the `major.minor` version number.
187_(This is the version number without the `.patch` version at the end)_
188
189### Coding Conventions
190We currently use [C  Style  and  Coding  Standards  for
191SunOS](http://www.cis.upenn.edu/%7Elee/06cse480/data/cstyle.ms.pdf) as our
192coding convention.
193
194This repository has an `.editorconfig` file. If your editor [supports
195editorconfig](https://editorconfig.org/#download), it will
196automatically respect most of this project's whitespace preferences.
197
198Additionally, Git can help warn on whitespace problems as well:
199
200```
201git config --local core.whitespace trailing-space,space-before-tab,indent-with-non-tab,-tab-in-indent
202```
203
204### Commit Message Formats
205#### New Changes
206Commit messages for new changes must meet the following guidelines:
207* In 72 characters or less, provide a summary of the change as the
208first line in the commit message.
209* A body which provides a description of the change. If necessary,
210please summarize important information such as why the proposed
211approach was chosen or a brief description of the bug you are resolving.
212Each line of the body must be 72 characters or less.
213* The last line must be a `Signed-off-by:` tag. See the
214[Signed Off By](#signed-off-by) section for more information.
215
216An example commit message for new changes is provided below.
217
218```
219This line is a brief summary of your change
220
221Please provide at least a couple sentences describing the
222change. If necessary, please summarize decisions such as
223why the proposed approach was chosen or what bug you are
224attempting to solve.
225
226Signed-off-by: Contributor <contributor@email.com>
227```
228
229#### Coverity Defect Fixes
230If you are submitting a fix to a
231[Coverity defect](https://scan.coverity.com/projects/zfsonlinux-zfs),
232the commit message should meet the following guidelines:
233* Provides a subject line in the format of
234`Fix coverity defects: CID dddd, dddd...` where `dddd` represents
235each CID fixed by the commit.
236* Provides a body which lists each Coverity defect and how it was corrected.
237* The last line must be a `Signed-off-by:` tag. See the
238[Signed Off By](#signed-off-by) section for more information.
239
240An example Coverity defect fix commit message is provided below.
241```
242Fix coverity defects: CID 12345, 67890
243
244CID 12345: Logically dead code (DEADCODE)
245
246Removed the if(var != 0) block because the condition could never be
247satisfied.
248
249CID 67890: Resource Leak (RESOURCE_LEAK)
250
251Ensure free is called after allocating memory in function().
252
253Signed-off-by: Contributor <contributor@email.com>
254```
255
256#### Signed Off By
257A line tagged as `Signed-off-by:` must contain the developer's
258name followed by their email. This is the developer's certification
259that they have the right to submit the patch for inclusion into
260the code base and indicates agreement to the [Developer's Certificate
261of Origin](https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin).
262Code without a proper signoff cannot be merged.
263
264Git can append the `Signed-off-by` line to your commit messages. Simply
265provide the `-s` or `--signoff` option when performing a `git commit`.
266For more information about writing commit messages, visit [How to Write
267a Git Commit Message](https://chris.beams.io/posts/git-commit/).
268
269#### Co-authored By
270If someone else had part in your pull request, please add the following to the commit:
271`Co-authored-by: Name <gitregistered@email.address>`
272This is useful if their authorship was lost during squashing, rebasing, etc.,
273but may be used in any situation where there are co-authors.
274
275The email address used here should be the same as on the GitHub profile of said user.
276If said user does not have their email address public, please use the following instead:
277`Co-authored-by: Name <[username]@users.noreply.github.com>`
278