I'm going to send as reply to this message a set of patches I am
applying to the upcoming Debian packages for zfs-fuse. For those
interested, the package is mostly in shape, but not uploaded yet, as I
want to fix a few issues before pushing the first release. For the
moment, all that is publicly available is a git repository, which is
cloneable from git://git.debian.org/~glandium/zfs-fuse.git and should
soon be http-browsable from
http://git.debian.org/?p=users/glandium/zfs-fuse.git;a=summary
Kudos have to go to Brian Donlan for his first set of packages for
Debian, which I used as a base for these upcoming packages.
Cheers,
Mike
Scons doesn't clean up the cache file it creates. The file must be removed
by hand.
---
src/SConstruct | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/SConstruct b/src/SConstruct
index f0a0a5d..3d060f1 100644
--- a/src/SConstruct
+++ b/src/SConstruct
@@ -88,3 +88,5 @@ env.Install(install_dir, 'cmd/zfs/zfs')
env.Install(install_dir, 'zfs-fuse/zfs-fuse')
env.Alias('install', install_dir)
+
+Clean('clean', ['.sconsign.dblite'])
--
1.6.1.149.g7bbd8
This option can be used to set the level of optimization one wants when
building zfs-fuse.
This allows to run, e.g. "scons optim=-O0" to have a debug=1 build without
optimization.
---
src/SConstruct | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/SConstruct b/src/SConstruct
index f0a0a5d..28d3d0a 100644
--- a/src/SConstruct
+++ b/src/SConstruct
@@ -14,15 +14,16 @@ env['LINKFLAGS'] = Split('-pipe -Wall -Werror')
env['CCFLAGS'] = Split('-pipe -Wall -Werror -std=c99 -Wno-switch -Wno-unused -Wno-missing-braces -Wno-parentheses -Wno-uninitialized -fno-strict-aliasing -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DTEXT_DOMAIN=\\"zfs-fuse\\" -DLINUX_AIO')
debug = int(ARGUMENTS.get('debug', '1'))
+optim = ARGUMENTS.get('optim', '-O2')
if not debug:
env.Append(LINKFLAGS = ['-s'])
- env.Append(CCFLAGS = Split('-s -O2 -DNDEBUG'))
+ env.Append(CCFLAGS = Split('-s %s -DNDEBUG' % optim))
else:
env.Append(LINKFLAGS = ['-ggdb'])
env.Append(CCFLAGS = ['-ggdb'])
if debug == 1:
- env.Append(CCFLAGS = ['-O2'])
+ env.Append(CCFLAGS = [optim])
elif debug == 2:
env.Append(CCFLAGS = ['-DDEBUG'])
elif debug == 3:
--
1.6.1.149.g7bbd8
The /etc/zfs/zpool.cache file is not a configuration file, but a (binary)
cache file. Such files should live in /var/lib/zfs if we follow the FHS.
---
src/lib/libzfscommon/include/sys/fs/zfs.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lib/libzfscommon/include/sys/fs/zfs.h b/src/lib/libzfscommon/include/sys/fs/zfs.h
index 99688e7..29e1890 100644
--- a/src/lib/libzfscommon/include/sys/fs/zfs.h
+++ b/src/lib/libzfscommon/include/sys/fs/zfs.h
@@ -378,7 +378,7 @@ typedef enum zfs_cache_type {
* The location of the pool configuration repository, shared between kernel and
* userland.
*/
-#define ZPOOL_CACHE "/etc/zfs/zpool.cache"
+#define ZPOOL_CACHE "/var/lib/zfs/zpool.cache"
/*
* vdev states are ordered from least to most healthy.
--
1.6.1.149.g7bbd8
---
src/lib/libumem/sol_compat.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/lib/libumem/sol_compat.h b/src/lib/libumem/sol_compat.h
index 4b7e6cf..687090c 100644
--- a/src/lib/libumem/sol_compat.h
+++ b/src/lib/libumem/sol_compat.h
@@ -164,8 +164,14 @@ static INLINE uint_t ec_atomic_inc(uint_t *mem)
#define ISP2(x) (((x) & ((x) - 1)) == 0)
/* beware! umem only uses these atomic adds for incrementing by 1 */
+#if defined(_WIN32) || (defined(__GNUC__) && \
+ (defined(__i386__) || defined(__x86_64__) || defined(__sparc__)))
#define atomic_add_64(lvalptr, delta) ec_atomic_inc64(lvalptr)
#define atomic_add_32_nv(a, b) ec_atomic_inc(a)
+#else
+extern uint32_t atomic_add_32_nv(volatile uint32_t *, int32_t);
+extern void atomic_add_64(volatile uint64_t *, int64_t);
+#endif
#ifndef NANOSEC
#define NANOSEC 1000000000
--
1.6.1.149.g7bbd8
Derived from opensolaris_atomic.c from FreeBSD, implement generic atomic
operations based on a global mutex for architectures where assembly is
not provided.
---
Note the src/lib/libsolkerncompat/generic is actually a symbolic link.
src/SConstruct | 7 +--
src/lib/libsolcompat/SConscript | 4 +-
src/lib/libsolcompat/generic/atomic.c | 155 +++++++++++++++++++++++++++++++++
src/lib/libsolkerncompat/SConscript | 4 +-
src/lib/libsolkerncompat/generic | 1 +
5 files changed, 163 insertions(+), 8 deletions(-)
create mode 100644 src/lib/libsolcompat/generic/atomic.c
create mode 120000 src/lib/libsolkerncompat/generic
diff --git a/src/SConstruct b/src/SConstruct
index f0a0a5d..a192f00 100644
--- a/src/SConstruct
+++ b/src/SConstruct
@@ -44,15 +44,10 @@ def getarch(arch):
if re.compile('i\d86').match(arch):
return 'i386'
- return None
+ return 'generic'
myarch = getarch(arch)
-if not myarch:
- print
- print 'Sorry, only the x86, amd64 and sparc64 hardware architectures are supported'
- sys.exit(1)
-
if myarch == 'sparc64':
env.Append(CCFLAGS = '-mcpu=ultrasparc')
env.Append(ASFLAGS = '-mcpu=ultrasparc')
diff --git a/src/lib/libsolcompat/SConscript b/src/lib/libsolcompat/SConscript
index 9561082..8810242 100644
--- a/src/lib/libsolcompat/SConscript
+++ b/src/lib/libsolcompat/SConscript
@@ -1,8 +1,10 @@
Import('env')
+import glob
subst = {'arch': env['ARCH']}
-objects = Split('getmntany.c mkdirp.c strlcpy.c strlcat.c u8_textprep.c zone.c %(arch)s/atomic.S' % subst)
+objects = Split('getmntany.c mkdirp.c strlcpy.c strlcat.c u8_textprep.c zone.c')
+objects += glob.glob('%(arch)s/atomic.[cS]' % subst)
cpppath = Split('./include ./include/%(arch)s' % subst)
env.StaticLibrary('libsolcompat', objects, CPPPATH = env['CPPPATH'] + cpppath)
diff --git a/src/lib/libsolcompat/generic/atomic.c b/src/lib/libsolcompat/generic/atomic.c
new file mode 100644
index 0000000..435ae3e
--- /dev/null
+++ b/src/lib/libsolcompat/generic/atomic.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2008 Mike Hommey <glan...@debian.org>
+ *
+ * Derived from opensolaris_atomic.c
+ * Copyright (c) 2007 Pawel Jakub Dawidek <p...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+
+#include <pthread.h>
+
+static pthread_mutex_t atomic_mtx;
+
+static __attribute__((constructor)) void
+atomic_init(void)
+{
+ pthread_mutex_init(&atomic_mtx, NULL);
+}
+
+void
+atomic_add_64(volatile uint64_t *target, int64_t delta)
+{
+ pthread_mutex_lock(&atomic_mtx);
+ *target += delta;
+ pthread_mutex_unlock(&atomic_mtx);
+}
+
+void
+atomic_inc_64(volatile uint64_t *target)
+{
+ pthread_mutex_lock(&atomic_mtx);
+ *target += 1;
+ pthread_mutex_unlock(&atomic_mtx);
+}
+
+void
+atomic_dec_64(volatile uint64_t *target)
+{
+
+ pthread_mutex_lock(&atomic_mtx);
+ *target -= 1;
+ pthread_mutex_unlock(&atomic_mtx);
+}
+
+uint64_t
+atomic_add_64_nv(volatile uint64_t *target, int64_t delta)
+{
+ uint64_t newval;
+
+ pthread_mutex_lock(&atomic_mtx);
+ newval = (*target += delta);
+ pthread_mutex_unlock(&atomic_mtx);
+ return (newval);
+}
+
+void
+atomic_add_32(volatile uint32_t *target, int32_t delta)
+{
+ pthread_mutex_lock(&atomic_mtx);
+ *target += delta;
+ pthread_mutex_unlock(&atomic_mtx);
+}
+
+void
+atomic_inc_32(volatile uint32_t *target)
+{
+ pthread_mutex_lock(&atomic_mtx);
+ *target += 1;
+ pthread_mutex_unlock(&atomic_mtx);
+}
+
+void
+atomic_dec_32(volatile uint32_t *target)
+{
+ pthread_mutex_lock(&atomic_mtx);
+ *target -= 1;
+ pthread_mutex_unlock(&atomic_mtx);
+}
+
+uint32_t
+atomic_add_32_nv(volatile uint32_t *target, int32_t delta)
+{
+ uint32_t newval;
+
+ pthread_mutex_lock(&atomic_mtx);
+ newval = (*target += delta);
+ pthread_mutex_unlock(&atomic_mtx);
+ return (newval);
+}
+
+uint32_t
+atomic_inc_32_nv(volatile uint32_t *target)
+{
+ uint32_t newval;
+
+ pthread_mutex_lock(&atomic_mtx);
+ newval = (*target += 1);
+ pthread_mutex_unlock(&atomic_mtx);
+ return (newval);
+}
+
+void *
+atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
+{
+ void *oldval, **trg;
+
+ pthread_mutex_lock(&atomic_mtx);
+ trg = ((void **)(uintptr_t)(volatile void *)(target));
+ oldval = *trg;
+ if (oldval == cmp)
+ *trg = newval;
+ pthread_mutex_unlock(&atomic_mtx);
+ return (oldval);
+}
+
+uint64_t
+atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval)
+{
+ uint64_t oldval;
+
+ pthread_mutex_lock(&atomic_mtx);
+ oldval = *target;
+ if (oldval == cmp)
+ *target = newval;
+ pthread_mutex_unlock(&atomic_mtx);
+ return (oldval);
+}
+
+void
+membar_producer(void)
+{
+ /* nothing */
+}
diff --git a/src/lib/libsolkerncompat/SConscript b/src/lib/libsolkerncompat/SConscript
index 3a47516..eff62aa 100644
--- a/src/lib/libsolkerncompat/SConscript
+++ b/src/lib/libsolkerncompat/SConscript
@@ -1,8 +1,10 @@
Import('env')
+import glob
subst = {'arch': env['ARCH']}
-objects = Split('main.c acl_common.c bitmap.c clock.c cmn_err.c condvar.c flock.c fs_subr.c kcf_random.c kmem.c kobj.c kobj_subr.c kstat.c move.c mutex.c pathname.c policy.c refstr.c rwlock.c strlcpy.c taskq.c thread.c u8_textprep.c vfs.c vnode.c zmod.c %(arch)s/atomic.S' % subst)
+objects = Split('main.c acl_common.c bitmap.c clock.c cmn_err.c condvar.c flock.c fs_subr.c kcf_random.c kmem.c kobj.c kobj_subr.c kstat.c move.c mutex.c pathname.c policy.c refstr.c rwlock.c strlcpy.c taskq.c thread.c u8_textprep.c vfs.c vnode.c zmod.c')
+objects += glob.glob('%(arch)s/atomic.[cS]' % subst)
cpppath = Split('. ./include ./include/%(arch)s #lib/libumem/include #lib/libavl/include' % subst)
ccflags = Split('-D_KERNEL')
diff --git a/src/lib/libsolkerncompat/generic b/src/lib/libsolkerncompat/generic
new file mode 120000
index 0000000..39647b4
--- /dev/null
+++ b/src/lib/libsolkerncompat/generic
@@ -0,0 +1 @@
+../libsolcompat/generic
\ No newline at end of file
--
1.6.1.149.g7bbd8
I also forgot to mention his work on the manual pages, that I merged
into the last set of opensolaris manpages, to make the man pages more
linux-aware (for examples, section numbers, and missing features).
They are attached here.
Mike
> Kudos have to go to Brian Donlan for his first set of packages for
> Debian, which I used as a base for these upcoming packages.
Hi,
Please note my name is spelled with a y there, not an i ;)
Thanks,
Bryan