Skip to content

Commit e6ea76b

Browse files
kmoore134mattmacy
authored andcommitted
Add FreeBSD support to ZoL
- Refactor tree in to os specific parts - Import FreeBSD SPL - update tests to work on FreeBSD Signed-off-by: Matt Macy <[email protected]>
1 parent 02fad92 commit e6ea76b

File tree

722 files changed

+105792
-2125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

722 files changed

+105792
-2125
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ cscope.*
6363
*.log
6464
venv
6565

66+
*.so
67+
*.so.debug
68+
*.so.full
69+
*.tmp
70+
*.log
71+
module/export_syms
72+
module/machine
73+
module/x86
74+
module/zfs.ko.debug
75+
module/zfs.ko.full

COPYRIGHT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ notable exceptions and their respective licenses include:
1919
* AES Implementation: module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman
2020
* AES Implementation: module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl
2121
* PBKDF2 Implementation: lib/libzfs/THIRDPARTYLICENSE.openssl
22-
* SPL Implementation: module/spl/THIRDPARTYLICENSE.gplv2
22+
* SPL Implementation: module/os/linux/spl/THIRDPARTYLICENSE.gplv2
2323

2424
This product includes software developed by the OpenSSL Project for use
2525
in the OpenSSL Toolkit (http://www.openssl.org/)

Makefile.am

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,28 @@ include config/rpm.am
44
include config/deb.am
55
include config/tgz.am
66

7-
SUBDIRS = include rpm
7+
SUBDIRS = include
8+
if BUILD_LINUX
9+
SUBDIRS+= rpm
10+
endif
11+
812
if CONFIG_USER
9-
SUBDIRS += udev etc man scripts lib tests cmd contrib
13+
SUBDIRS += etc man scripts lib tests cmd contrib
14+
if BUILD_LINUX
15+
SUBDIRS+= udev
16+
endif
1017
endif
1118
if CONFIG_KERNEL
1219
SUBDIRS += module
1320

1421
extradir = $(prefix)/src/zfs-$(VERSION)
1522
extra_HEADERS = zfs.release.in zfs_config.h.in
1623

24+
if BUILD_LINUX
1725
kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION)
1826
nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS)
1927
endif
28+
endif
2029

2130
AUTOMAKE_OPTIONS = foreign
2231
EXTRA_DIST = autogen.sh copy-builtin
@@ -25,11 +34,16 @@ EXTRA_DIST += META AUTHORS COPYRIGHT LICENSE NEWS NOTICE README.md
2534
EXTRA_DIST += CODE_OF_CONDUCT.md
2635

2736
# Include all the extra licensing information for modules
28-
EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE module/icp/algs/skein/THIRDPARTYLICENSE.descrip
29-
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip
30-
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip
31-
EXTRA_DIST += module/spl/THIRDPARTYLICENSE.gplv2 module/spl/THIRDPARTYLICENSE.gplv2.descrip
32-
EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash module/zfs/THIRDPARTYLICENSE.cityhash.descrip
37+
EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE
38+
EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE.descrip
39+
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman
40+
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip
41+
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl
42+
EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip
43+
EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2
44+
EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2.descrip
45+
EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash
46+
EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip
3347

3448
@CODE_COVERAGE_RULES@
3549

@@ -39,7 +53,7 @@ gitrev:
3953

4054
BUILT_SOURCES = gitrev
4155

42-
distclean-local::
56+
distclean-local:
4357
-$(RM) -R autom4te*.cache
4458
-find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
4559
-o -name .pc -o -name .hg -o -name .git \) -prune -o \
@@ -57,9 +71,10 @@ all-local:
5771

5872
dist-hook: gitrev
5973
cp ${top_srcdir}/include/zfs_gitrev.h $(distdir)/include; \
60-
sed -i 's/Release:[[:print:]]*/Release: $(RELEASE)/' \
74+
sed -i.bak -e 's/Release:[[:print:]]*/Release: $(RELEASE)/' \
6175
$(distdir)/META
6276

77+
if BUILD_LINUX
6378
# For compatibility, create a matching spl-x.y.z directly which contains
6479
# symlinks to the updated header and object file locations. These
6580
# compatibility links will be removed in the next major release.
@@ -76,6 +91,7 @@ install-data-hook:
7691
ln -fs zfs_config.h spl_config.h && \
7792
ln -fs zfs.release spl.release
7893
endif
94+
endif
7995

8096
codecheck: cstyle shellcheck flake8 mancheck testscheck vcscheck
8197

@@ -88,15 +104,18 @@ commitcheck:
88104

89105
cstyle:
90106
@find ${top_srcdir} -name '*.[hc]' ! -name 'zfs_config.*' \
91-
! -name '*.mod.c' -type f \
107+
! -name '*.mod.c' ! -name '*_if.h' ! -path "*/os/freebsd/*" \
108+
-type f \
92109
-exec ${top_srcdir}/scripts/cstyle.pl -cpP {} \+
93110

111+
filter_executable = -exec test -x '{}' \; -print
112+
94113
shellcheck:
95114
@if type shellcheck > /dev/null 2>&1; then \
96-
shellcheck --exclude=SC1090 --format=gcc \
115+
shellcheck --exclude=SC1090 --exclude=SC1117 --format=gcc \
97116
$$(find ${top_srcdir}/scripts/*.sh -type f) \
98117
$$(find ${top_srcdir}/cmd/zed/zed.d/*.sh -type f) \
99-
$$(find ${top_srcdir}/cmd/zpool/zpool.d/* -executable); \
118+
$$(find ${top_srcdir}/cmd/zpool/zpool.d/* -type f ${filter_executable}); \
100119
else \
101120
echo "skipping shellcheck because shellcheck is not installed"; \
102121
fi
@@ -111,13 +130,19 @@ mancheck:
111130
echo "skipping mancheck because mandoc is not installed"; \
112131
fi
113132

133+
if BUILD_LINUX
134+
stat_fmt = -c '%A %n'
135+
else
136+
stat_fmt = -f '%Sp %N'
137+
endif
138+
114139
testscheck:
115140
@find ${top_srcdir}/tests/zfs-tests -type f \
116-
\( -name '*.ksh' -not -executable \) -o \
117-
\( -name '*.kshlib' -executable \) -o \
118-
\( -name '*.shlib' -executable \) -o \
119-
\( -name '*.cfg' -executable \) | \
120-
xargs -r stat -c '%A %n' | \
141+
\( -name '*.ksh' -not ${filter_executable} \) -o \
142+
\( -name '*.kshlib' ${filter_executable} \) -o \
143+
\( -name '*.shlib' ${filter_executable} \) -o \
144+
\( -name '*.cfg' ${filter_executable} \) | \
145+
xargs -r stat ${stat_fmt} | \
121146
awk '{c++; print} END {if(c>0) exit 1}'
122147

123148
vcscheck:

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
![img](http://zfsonlinux.org/images/zfs-linux.png)
1+
![img](https://github.com/zfsonfreebsd/ZoF/raw/master/zof-logo.png)
22

33
ZFS on Linux is an advanced file system and volume manager which was originally
4-
developed for Solaris and is now maintained by the OpenZFS community.
4+
developed for Solaris and is now maintained by the OpenZFS community. ZoF is the work
5+
to bring FreeBSD support into the ZoL repo.
56

67
[![codecov](https://codecov.io/gh/zfsonlinux/zfs/branch/master/graph/badge.svg)](https://codecov.io/gh/zfsonlinux/zfs)
78
[![coverity](https://scan.coverity.com/projects/1973/badge.svg)](https://scan.coverity.com/projects/zfsonlinux-zfs)
89

910
# Official Resources
1011

11-
* [Site](http://zfsonlinux.org)
12-
* [Wiki](https://github.com/zfsonlinux/zfs/wiki)
13-
* [Mailing lists](https://github.com/zfsonlinux/zfs/wiki/Mailing-Lists)
12+
* [ZoF GitHub Site](https://zfsonfreebsd.github.io/ZoF/)
13+
* [ZoL Site](http://zfsonlinux.org)
14+
* [ZoL Wiki](https://github.com/zfsonlinux/zfs/wiki)
15+
* [ZoL Mailing lists](https://github.com/zfsonlinux/zfs/wiki/Mailing-Lists)
1416
* [OpenZFS site](http://open-zfs.org/)
17+
* [HEAD Snapshots](http://pkg.trueos.org/iso/freebsd-pkgbase/)
1518

1619
# Installation
1720

18-
Full documentation for installing ZoL on your favorite Linux distribution can
19-
be found at [our site](http://zfsonlinux.org/).
21+
[FreeBSD HEAD Snapshot Images](http://pkg.trueos.org/iso/freebsd-pkgbase/) are available from the [TrueOS Project](https://www.trueos.org).
2022

21-
# Contribute & Develop
23+
Legacy ZFS is disabled in the src build (While enabled for the boot-loader) and ZoF is included automatically via the ports system as sysutils/zol and sysutils/zol-kmod.
2224

23-
We have a separate document with [contribution guidelines](./.github/CONTRIBUTING.md).
25+
# Issues
2426

25-
# Release
27+
Issues can be reported via GitHub's [Issue Tracker](https://github.com/zfsonfreebsd/ZoF).
2628

27-
ZFS on Linux is released under a CDDL license.
28-
For more details see the NOTICE, LICENSE and COPYRIGHT files; `UCRL-CODE-235197`
29-
30-
# Supported Kernels
31-
* The `META` file contains the officially recognized supported kernel versions.

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-slate

cmd/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ if USING_PYTHON
55
SUBDIRS += arcstat arc_summary dbufstat
66
endif
77

8+
if BUILD_LINUX
89
SUBDIRS += mount_zfs zed zvol_id
10+
endif

cmd/arc_summary/Makefile.am

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
EXTRA_DIST = arc_summary2 arc_summary3
22

3+
transform = $(program_transform_name)
4+
35
if USING_PYTHON_2
46
dist_bin_SCRIPTS = arc_summary2
57
install-exec-hook:
6-
mv $(DESTDIR)$(bindir)/arc_summary2 $(DESTDIR)$(bindir)/arc_summary
8+
before=$$(echo arc_summary2 | sed '$(transform)'); \
9+
after=$$(echo arc_summary | sed '$(transform)'); \
10+
mv "$(DESTDIR)$(bindir)/$$before" "$(DESTDIR)$(bindir)/$$after"
711
else
812
dist_bin_SCRIPTS = arc_summary3
913
install-exec-hook:
10-
mv $(DESTDIR)$(bindir)/arc_summary3 $(DESTDIR)$(bindir)/arc_summary
14+
before=$$(echo arc_summary3 | sed '$(transform)'); \
15+
after=$$(echo arc_summary | sed '$(transform)'); \
16+
mv "$(DESTDIR)$(bindir)/$$before" "$(DESTDIR)$(bindir)/$$after"
1117
endif

cmd/arc_summary/arc_summary2

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ import errno
5454
from subprocess import Popen, PIPE
5555
from decimal import Decimal as D
5656

57+
#Requires py27-sysctl on FreeBSD
58+
if sys.platform.startswith('freebsd'):
59+
import sysctl
60+
5761
show_tunable_descriptions = False
5862
alternate_tunable_layout = False
5963

@@ -79,12 +83,18 @@ def get_Kstat():
7983
def load_proc_kstats(fn, namespace):
8084
"""Collect information on a specific subsystem of the ARC"""
8185

82-
kstats = [line.strip() for line in open(fn)]
83-
del kstats[0:2]
84-
for kstat in kstats:
85-
kstat = kstat.strip()
86-
name, _, value = kstat.split()
87-
Kstat[namespace + name] = D(value)
86+
if sys.platform.startswith('freebsd'):
87+
kstats = sysctl.filter(namespace)
88+
for kstat in kstats:
89+
name, value = kstat.name, kstat.value
90+
Kstat[name] = D(value)
91+
else:
92+
kstats = [line.strip() for line in open(fn)]
93+
del kstats[0:2]
94+
for kstat in kstats:
95+
kstat = kstat.strip()
96+
name, _, value = kstat.split()
97+
Kstat[namespace + name] = D(value)
8898

8999
Kstat = {}
90100
load_proc_kstats('/proc/spl/kstat/zfs/arcstats',
@@ -921,13 +931,16 @@ def _tunable_summary(Kstat):
921931
global show_tunable_descriptions
922932
global alternate_tunable_layout
923933

924-
names = os.listdir("/sys/module/zfs/parameters/")
934+
if sys.platform.startswith('freebsd'):
935+
ctls = sysctl.filter('vfs.zfs')
936+
else:
937+
names = os.listdir("/sys/module/zfs/parameters/")
925938

926-
values = {}
927-
for name in names:
928-
with open("/sys/module/zfs/parameters/" + name) as f:
929-
value = f.read()
930-
values[name] = value.strip()
939+
values = {}
940+
for name in names:
941+
with open("/sys/module/zfs/parameters/" + name) as f:
942+
value = f.read()
943+
values[name] = value.strip()
931944

932945
descriptions = {}
933946

@@ -966,22 +979,31 @@ def _tunable_summary(Kstat):
966979
sys.stderr.write("Tunable descriptions will be disabled.\n")
967980

968981
sys.stdout.write("ZFS Tunables:\n")
969-
names.sort()
982+
if not sys.platform.startswith('freebsd'):
983+
names.sort()
970984

971985
if alternate_tunable_layout:
972986
fmt = "\t%s=%s\n"
973987
else:
974988
fmt = "\t%-50s%s\n"
975989

976-
for name in names:
990+
if sys.platform.startswith('freebsd'):
991+
for ctl in ctls:
992+
993+
if show_tunable_descriptions and ctl.name in descriptions:
994+
sys.stdout.write("\t# %s\n" % descriptions[ctl.name])
995+
996+
sys.stdout.write(fmt % (ctl.name, ctl.value))
997+
else:
998+
for name in names:
977999

978-
if not name:
979-
continue
1000+
if not name:
1001+
continue
9801002

981-
if show_tunable_descriptions and name in descriptions:
982-
sys.stdout.write("\t# %s\n" % descriptions[name])
1003+
if show_tunable_descriptions and name in descriptions:
1004+
sys.stdout.write("\t# %s\n" % descriptions[name])
9831005

984-
sys.stdout.write(fmt % (name, values[name]))
1006+
sys.stdout.write(fmt % (name, values[name]))
9851007

9861008

9871009
unSub = [

0 commit comments

Comments
 (0)