Re: [dm-devel] NetBSD libdevmapper port

If you are rewriting it --- have you somehow thought about avoiding
suspend?

A big source of problems in Linux is, that when you suspend a device, you
can do only a limited set of calls --- basically, you must avoid anything
that could possibly wait for I/O or allocate memory --- or you might end
up waiting for the suspended device and deadlock. And I know still about 3
places in kernel that have this error possibility.

A Linux LVM does something like: suspend old table, write to disk with
direct i/o, resume new table. I'd suggest that you invent some method how
to batch these operations into single syscall --- or you run into a
several years of deadlock problems on NetBSD --- basically, on Linux, we
have to preallocate a stack and heap (so that running LVM process won't
cause a page fault --- the question --- how to do it portably on all
NetBSD architectures?), mlock the process, make sure that we don't open
files or write anything to terminal while suspended, make sure that the
ioctl syscall doesn't allocate anything (currently false, it won't
deadlock but it could randomly fail), make sure that O_DIRECT write
syscall doesn't allocate anything or wait for other I/O (currently it
false, there is a deadlock possibility) ... etc.

--- if you port lvm2 as it is, you'll have to audit (and maybe rewrite)
many parts of NetBSD kernel for not waiting for I/O. If you do it badly,
you'll get deadlocks.

This suspend thing was a big misdesign and if you are writing it from
scratch, try to avoid it.

Mikulas

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,

*** Please keep me on CC when you replying from dm-devel list I'm not
currently subscribed there. ***

My name is Adam Hamsik and this summer I'm working on GSOC project Write and
improve LVM driver. As my task I have rewritten (We can't include GPL
software into NetBSD kernel therefore I have rewritten it from scratch)dm
like driver for NetBSD and ported libdevmapper + lvm2tools to NetBSD. There
are some small differences between

After the first implementation of dm-driver my mentor suggested to
rewrite/clean dm-ioctl interface to be more NetBSD-like. I have implemented
new interface based on proplib library [1] it is based on work

lib/ioctl/libdm-nbsd-iface.c -> this is copied/changed libdm-iface.c I found
that number of NetBSD specific changes is
bigger than I can easily #ifdef them, therefore I have added new

NetBSD interface file.

I have created patch against latest release of libdevmapper, it would be
great if we will be able to manage
commiting of this patch to libdevmapper main repo. My patch is currently not
ready to commit, it needs major cleanup, but I thought that it would be good
to let dm developers know about my effort and show my work to them.

My patch is located here [3], I have uploaded patch against lvm2tools, too.
But it is patch against 2.02.28.
Because there were quite massive changes to lvm2tools in latest releases I
will report lvm2tools again and