2009-07-01

ZFS as whole has 2 main ways it can be accessed. The first is ZVOL and the second is ZPL. In my first status update I said that I had ported ZVOL layer to NetBSD, and I was able to create and use ZFS Zpools and Zvols (Logical partitions exported from one disk storage pool called zpool).

Over the last few weeks I have worked on a ZPL port. ZPL is ZFS file system layer. I have ported zfs_vfsops.c file and zfs_vnops.c file to NetBSD. Today I have ZFS to state where I can mount ZFS data set, copy whole kernel source tree there and finally build NetBSD kernel on it.

$ su 
# modload /mod/solaris.kmod                                                                                                                       
# modload /mod/zfs.kmod                                                                                                                           
# zfs mount test/zfs
 # mount 
/dev/wd0a on / type ffs (local)
kernfs on /kern type kernfs (local)
ptyfs on /dev/pts type ptyfs (local)
/dev/zvol/dsk/test/zfs on /test/zfs type zfs (local)
# zfs list 
NAME        USED  AVAIL  REFER  MOUNTPOINT
test        391M  1.57G    18K  /test
test/tank    40M  1.61G    16K  -
test/zfs    351M  1.57G   351M  /test/zfs
test/zfs1    18K  1.57G    18K  /test/zfs1
# cd /test/zfs/src/sys/arch/i386/compile/GENERIC/
# make           
making sure the compat library is up to date...
`libcompat.a' is up to date.
making sure the kern library is up to date...
`libkern.o' is up to date.
#   compile  GENERIC/init_main.o
cc -ffreestanding -fno-zero-initialized-in-bss -O2 -std=gnu99 -fno-strict-aliasing -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -Wextra -Wno-unused-parameter -Werror -Di386 -I. -I../../../../../common/include -I../../../../arch -I../../../.. -nostdinc -DMAXUSERS=64 -D_KERNEL -D_KERNEL_OPT -I../../../../lib/libkern/../../../common/lib/libc/quad -I../../../../lib/libkern/../../../common/lib/libc/string -I../../../../lib/libkern/../../../common/lib/libc/arch/i386/string -I../../../../dist/ipf -I../../../../external/isc/atheros_hal/dist -I../../../../external/isc/atheros_hal/ic -I../../../../../common/include -c ../../../../kern/init_main.c
#    create  vers.c
sh ../../../../conf/newvers.sh 
#   compile  GENERIC/vers.o
cc  -ffreestanding -fno-zero-initialized-in-bss  -O2 -std=gnu99 -fno-strict-aliasing   -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -Wextra -Wno-unused-parameter  -Werror   -Di386 -I.  -I../../../../../common/include -I../../../../arch  -I../../../.. -nostdinc  -DMAXUSERS=64 -D_KERNEL -D_KERNEL_OPT -I../../../../lib/libkern/../../../common/lib/libc/quad -I../../../../lib/libkern/../../../common/lib/libc/string -I../../../../lib/libkern/../../../common/lib/libc/arch/i386/string   -I../../../../dist/ipf -I../../../../external/isc/atheros_hal/dist -I../../../../external/isc/atheros_hal/ic -I../../../../../common/include  -c vers.c
#      link  GENERIC/netbsd
ld -Map netbsd.map --cref -T ../../../../arch/i386/conf/kern.ldscript -Ttext c0100000 -e start -X -o netbsd ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
NetBSD 5.99.14 (GENERIC) #1: Tue Jun 30 20:00:37 UTC 2009
   text    data     bss     dec     hex filename
8554455  407284  538396 9500135  90f5e7 netbsd

I tried to boot build kernel and it worked like a charm. There is still much work to do port ZFS snapshot support, properly implement security policies for ZFS access, test ZFS ACL support etc.

My work is accessible in my git repository at git://rachael.ziaspace.com/src.git in a branch called haad-zfs. You can easily clone this repo with command git clone git://rachael.ziaspace.com/src.git. To get haad-zfs branch checkout you need to use command git checkout -b haad-zfs origin/haad-zfs from src directory.

About the project

The GUID Partition Table is a new standard for disk partitioning. The GPT layout provides a set of advanced partitioning features including, but not limited to:

  • modern logical block addressing (LBA)
  • 64-bit LBA pointers, allowing partitions up to 8 Zbytes in size, and even bigger
  • suitable for disks with sector size, other than 512 bytes
  • by default up to 128 partitions per disk
  • backup partition table.

The NetBSD already has support for GPT disks via dkwedges, but can't boot off a GPT partitioned disk. My GSoC project is to implement a GPT aware bootloader for the NetBSD operating system by extending its existing MBR/disklabel BIOS-based multistaged kernel loader.

Please note, although GPT comes from the EFI world and the loader somewhat mimics EFI bootstrap behavior, the project is not about writing a pure EFI loader. Instead, it will be based on BIOS interface and will technically look like an arbitrary MBR loader but with GPT parsing. Such an approach should allow the use of GPT partitioned disks on non-EFI systems as well. On EFI systems NetBSD can be bootstrapped via the Compatibility Support Module.

Current status

The project assumes development of MBR (or LBA0), Partition Boot Record, and adopting of 1st stage and 2nd stage loaders.

Currently, the MBR (LBA0) loader which parses GPT is in a beta stage. It implements the following features:

  • locating GPT headers by looking at LBA1 and the last LBA of boot disk
  • checking the GPT header for its signature and validating the CRC32
  • walking through the partition table looking for a bootable partition
  • reading the PBR from a bootable partition, testing its boot capability, and passing control to it if the test was successful.

Code cleanup and CRC32 calculation of GUID partition array (which wasn't included due to space constraints, but likely can be enabled after optimisation) are still required.

It was decided to store the primary loader on an EFI System Partition (which is FAT formatted by convention), and not use NetBSD partitions for bootstrapping. Such behavior will be similar to what EFI bootstrapping does, and the boot path will be as follows:

BIOS → LBA0 → PBR on EFI syspart → /boot → NetBSD kernel.

Fortunately, the "fatboot" (or bootxx_fat16) loader can do almost all of the required things in place of the PBR and 1st stage loader. The only missing thing is FAT lookup at an arbitrary offset on the disk (right now it assumes LBA0). It was easily implemented by having partition offset passed from GPT MBR or from any other loader through the ecx:ebx register pair. As we can't rely on all other loaders using this mechanism, the offset could be embedded into the PBR itself by installboot(8).

My current efforts are focused on getting gpt.S and fatboot.S (and corresponding management tools) in shape and ready to publish for beta testing. So the future work in terms of the GSoC project will include the following:

  • code cleanup for gpt.S (LBA0) and fatboot.S
  • review of bootloader installation tools and updating documentation
  • adding GPT support into boot(8)
  • more documentation updates and getting code in shape for CVS merge

Some additional information (including development schedule) can be found at the project home page at: http://netbsd-soc.sourceforge.net/projects/gpt/

Karolina Lesisska sent out a cry for help: apparently the Polish BSD magazine will be closed unless sales go up really soon (by monday, worst). So be sure to go and get a copy from your nearest book store right now!

What, you're still there?! Well, as a reaser on what you'll get, there are a bunch of articles available in PDF format, which include an article on Installing NetBSD by Patrick Pippen, and an interview with Simon Burge, Antti Kantee and Greg Oster by Federico Biancuzzi. Get your subscription today!

2009-06-30

Three new security advisories were published, covering OpenSSH, ntpd, ntpq and hack:

You can find more information about them on the Security and NetBSD page.

Project Description

The utility resize_ffs is a program intended to resize Berkeley Fast File Systems (FFS) by either growing or shrinking them. This filesystem is the standard filesystem for the NetBSD operating system -- a free, fast, secure, and highly portable Unix-like Open Source operating system.

There is already a preliminary utility in the NetBSD source tree, and this project will first and primarily thoroughly test it with a regression test suite and code review, and correct and fix any bugs encountered. After this is accomplished, and the utility is stable, this project will attempt to extend the utility with features such as "live" resizing, that is the ability to dynamically resize the filesystem without first having to unmount it.

More information is available on the project website.

Status Update

After a little bit of a slow start, the project is back on track. I am moving from the "just testing" phase to using that test information to hunt down bugs and also improve the program. One addition I have already added is the ability to choose the new filesystem size in kilo-, mega-, or gigabytes - as well as the default of sectors. However, it does currently assume a sector size of 512 KB in the conversion. I have identified several potential bugs, the worst of which is data corruption which seems limited to when the filesystem is growing.

At USENIX 2009 I talked about rump file systems. The paper (pdf, html) and slides are available. Additionally, USENIX members can view a video of the presentation.

paper abstract

When kernel functionality is desired in userspace, the common approach is to reimplement it for userspace interfaces. We show that use of existing kernel file systems in userspace programs is possible without modifying the kernel file system code base. Two different operating modes are explored: 1) a transparent mode, in which the file system is mounted in the typical fashion by using the kernel code as a userspace server, and 2) a standalone mode, in which applications can use a kernel file system as a library. The first mode provides isolation from the trusted computing base and a secure way for mounting untrusted file systems on a monolithic kernel. The second mode is useful for file system utilities and applications, such as populating an image or viewing the contents without requiring host operating system kernel support. Additional uses for both modes include debugging, development and testing.

The design and implementation of the Runnable Userspace Meta Program file system (rump fs) framework for NetBSD is presented. Using rump, ten disk-based file systems, a memory file system, a network file system and a userspace framework file system have been tested to be functional. File system performance for an estimated typical workload is found to be ±5% of kernel performance. The prototype of a similar framework for Linux was also implemented and portability was verified: Linux file systems work on NetBSD and NetBSD file systems work on Linux. Finally, the implementation is shown to be maintainable by examining the 1.5 year period it has been a part of NetBSD.

2009-06-29

During this year’s Google Summer of Code I’m improving the performance of NetBSD’s regular expression library and adding support to it for wide characters.

NetBSD’s current regular expression library was initially written by Henry Spencer in 1986, when ASCII was the de facto standard. Moreover, Spencer described it as slow. So it makes real sense to replace it and seek for alternatives.

I decided to develop a new regular expression library at first. It seemed rather easy in the beginning, but turned out to be more difficult in all its details than I expected (everyone who read the regular expression specification in the POSIX standard will agree). Therefore, I was really happy when Ville Laurikari offered to release his regular expression library tre, which he wrote his master thesis about, under a 2-clause BSD licence, so that tre can become part of libc.

tre is a mature, strictly POSIX-conforming regular expression library with additional features, such as approximate matching, matching on binary data, thread safety, ABI compatibility and wide character support. tre also includes agrep, an approximate version of grep, which will be imported into NetBSD.

At the moment I’m preparing a performance benchmark, which is based on realistic regular expressions and data, to ensure that tre is verifiably efficient. If the benchmark reveals that tre is less efficient than NetBSD’s current regular expression library, I will try to address the performance issues. Afterwards tre will be integrated in libc.

Moreover, Glenn Fowler from AT&T Research developed a regression testing framework for regular expressions, which I will integrate with the atf to test and ensure POSIX-compliance.

2009-06-28

Postfix 2.6.2, the latest stable version of the popular mail transport agent, was imported into NetBSD-current recently. The following features have been added since version 2.5.4:

  • Multi-instance support introduces a new postmulti(1) command to create/add/remove/etc. additional Postfix instances. The familiar "postfix start" etc. commands now automatically start multiple Postfix instances. The good news: nothing changes when you use only one Postfix instance. See MULTI_INSTANCE_README for details.
  • Multi-instance support required that some files be moved from the non-shared $config_directory to the shared $daemon_directory. The affected files are postfix-script, postfix-files and post-install.
  • TLS (SSL) support was updated for elliptic curve encryption. This requires OpenSSL version 0.9.9 or later. The SMTP client no longer uses the SSLv2 protocol by default. See TLS_README for details.
  • The Milter client now supports all Sendmail 8.14 Milter requests, including requests for rejected recipient addresses, and requests to replace the envelope sender address. See MILTER_README for details.
  • Postfix no longer adds (Resent-) From:, Date:, Message-ID: or To: headers to email messages with "remote" origins (these are origins that don't match $local_header_rewrite_clients). Adding such headers breaks DKIM signatures that explicitly cover non-present headers. For compatibility with existing logfile processing software, Postfix will log ``message-id='' for email messages that have no Message-Id header.
  • Stress-adaptive behavior is now enabled by default. This allows the Postfix SMTP server to temporarily reduce time limits and error-count limits under conditions of overload, such as a malware attack or backscatter flood. See STRESS_README for details.

Enjoy!

2009-06-26

wake is a new command to send Wake-on-LAN frames over an ethernet to Wake-on-LAN capable machines, remote powering them up. This functionality is generally enabled in a machine's BIOS and can be used to power on machines from a remote system without having physical access to them.

wake is available in NetBSD-current. See the wake(8) manual page for details.

2009-06-25

One might be tempted to think that, while parsing can be a complex task involving various competing models, printing is straightforward and should be the easy part of the job. This is not quite true however, as David and I have been in disagreement for some time already over the exact semantics and syntax of a potential XML printing subsystem of xmltools.

This post is all about the design of the printing language in xmltools and the underlying model. I also present at the end my latest hybrid proposal, that I’ve submitted to David for approval earlier today, and which I hope will bring satisfaction to all parties. If you have some opinion on this topic, do not hesitate to e-mail me! (My e-mail is my first name followed by my last name with all spaces replaced by dots; it’s written in French in the footer so you might not be able to decode it.)

The basic problem can be described as follows: we have a source tree, the input document and we want to transform it by adding or removing nodes in some places. Simple? Not quite.

Select & transform

The first design I proposed is based on sed(1): we select some node in the tree using a tree pattern (same as in my xmlgrep) and then transform it using some actions: insert, append, replace, etc. Only these needed to be adapted to XML.

My idea was then to use PYX/ESIS-inspired actions, which also happen to model closely my internal API. These consisted of a one-character prefix indicating the thing to print, followed by contents (depending on the prefix). Prefixes were:

( opening tag
) closing tag
@ attribute
. text
! comment
? junk

This is a very simple approach but David objected that it was unnatural to write XML using some language which was not XML.

Advantages
  • Very simple and straightforward.
  • Completely symmetrical to the way patterns are matched.
Disadvantages
  • Code used to write XML does not look like the output.
  • Not intuitive to read as data.

Decorate & pull

Another approach, which is used most notably by XSLT, is to have a template, which itself is written as XML, in which some elements from the source document are pulled.

Let me say it upfront in case anybody is not clear on this: pulling is not a stream technique, so this model as is cannot be implemented easily (some subsets of XSLT as stream transformations have been researched, but since it is from the start not a stream-oriented technique, it’s complex and IMHO not worth it).

David first suggested using a template as a way of having printing-heavy script actually look like their output. He observed plain XML could be written directly while some special elements, e.g. xmlsed:addattr could be used to print things that cannot be represented directly in XML. Indeed, there is no XML syntax to write just an attribute without the surrounding tag, yet there are cases where we might want to add an attribute to an existing element.

I criticized this idea based on the fact that reserving a namespace was intrusive and that using XML to represent scripting elements was too verbose.

But the main point was that pull-style transformation was never an option.

Advantages
  • XML in script remains in output.
  • Very intuitive and easy to read.
Disadvantages
  • Model is not adapted to streaming.
  • Too verbose.

Towards a hybrid model: XML syntax for select & transform

Given the stream-unfriendly nature of the template-based model, David came up with the idea to represent actions of the select & transform model as XML: XML opening and closing tags could be used to represent the corresponding printing actions (respectively ( and )) but for the rest, we were still stuck with the way-too-verbose XSLT-like <xmlsed:whatever> elements.

I was still very dissatisfied with the verbosity of having to write <xmlsed:whatever/> just to add an attribute or specify where to insert the current node (before, after, inside the plain XML part), but the concept itself, of using a template, was quite nice.

Advantages
  • XML in script remains in output.
  • Very intuitive and easy to read.
  • Still reasonably simple to implement.
Disadvantages
  • Still too verbose.

A hybrid model

Today, after more brainstorming, I finally decided on the following model, and unless David is really against it (which I seriously doubt), I think it will make it into xmlsed one way or the other: the idea is the same as that of the previous attempt, use a template which actually describes actions inferred from the structure of XML itself.

Only, this time, we do not use special elements to indicate actions anymore, everything is inferred from the structure. The trick to do this is to have a virtual element represent the current node; it can have any name (it will be user-settable), let’s call it : by default. We can place it wherever we want in the template. And to add an attribute (resp. a child), we just have to add an attribute (resp. a child) to that virtual element. The syntax remains reasonably compact (even optimally compact given we’re using XML as the basis for our template) and the script now very closely models the output, even more than XSLT scripts!

The idea was inspired from xargs(1) and its -I option. Again, Unix saved the day… well, not quite, but still, I think it is a nice and practical compromise. :)

A couple of weeks ago, Guillaume Lasmayous and I threw the idea of interviewing NetBSD developers through our website, NetBSDfr, to promote the NetBSD Project, and to make their work known to the widest possible audience.

Today, we are discussing with Soren Jacobsen, snj@, NetBSD 5.0 release engineer.

NetBSDfr: First of all, let me thank you for this interview. We plan to run
several interviews of NetBSD developers, I think one every one or 2
months or so. You've been chosen as the first one. Thanks for accepting
to answer our questions.

snj: Thanks for asking me, and thanks for your efforts to strengthen the
community.  It's great to see efforts like this.
Sorry it took so long to get back to you.  I wanted to take some time to
think over my answers.  Please let me know if you think anything needs
clarification.

NetBSDfr: For the readers who don't know you, can you shortly introduce
yourself ?

snj: My name is Soren Jacobsen and I am a NetBSD developer and
release engineer.  I've been part of releng since late 2005, and was the
lead release engineer for the 5.0 release.

NetBSDfr: Why did you choose to run NetBSD ? How long have you been
using it ?

snj: My first experience with NetBSD was 1.5.3, which I guess was
around the second half of 2002.  Compared to a lot of people, I was a bit
late to the party.  At the time, I was frustrated with Linux in a number of
ways, and NetBSD was a solid operating system with a philosophy that
 made sense to me.  There wasn't any one particular thing about
NetBSD that grabbed my attention.  It was more that there was nothing
that bothered me.  It just seemed right.

NetBSDfr: Do you have an idea of the time you spend working on the
NetBSD project daily, weekly, monthly ?

snj: Like most volunteers, the amount I'm able to spend on NetBSD
depends on real life and my motivation level.  A year ago, at most I was
doing 8 hours a week.  More recently, 8 hours a day wasn't uncommon.
The week leading up to the release was especially hectic; I put in a
couple 16 hour days there.

NetBSDfr: How did you become a NetBSD developer ?

snj: When I started using NetBSD full time as my primary operating
system, I became heavily dependent on pkgsrc, our framework for
third-party packages.  There were a number of packages I wanted to
see updated, and I started sending patches against pkgsrc and various
small things in the base system.  At the end of 2003, I was offered an
account, and became a developer in January of 2004.

To anyone out there who is interested in helping the project: pkgsrc
is a great way to get involved.  There are so many packages out there,
and only a finite number of developers to import and maintain them.
Consider submitting PRs against pkgsrc and joining the pkgsrc-wip
project.  We can use all the help we can get in this area.

NetBSDfr: How did you become member of NetBSD release engineering
team ?
Are the members of the releng team elected ? chosen among
developers ? Does this require specific skills ?

snj: The release engineering team is rather informal.  There is no
election process, and no strictly defined leader of the group, although
people do step up to fill this position.  When we feel understaffed, we
 put out a call for volunteers, and usually a person or two will join.  

Release engineering is not as glorious as a lot of other activities, so we
don't normally have people begging to join releng.
It's hard to say about specific skills.  Like in most other areas, having
sound judgment and a good sense of perspective is essential.  These are
the only strictly required skills.  Plenty of others are useful, though:
patience, caution, attention to detail, etc.  Pretty basic stuff, for the
most part.  Of course, the more technical knowledge, the better, but this
is not as big of a deal as it might seem.  I'll explain below.

NetBSDfr: Can you explain us more in details how does NetBSD release
engineering process work ?

snj: There are two basic tasks:
- Pulling up changes into branches.
- Releasing.

The first one is rather straightforward, and it is something we do
constantly.  Developers request that certain changes be pulled up to a
given branch.  If we agree that the changes should be pulled up, we commit
them to the branch.  To help track the status of a branch, we maintain a
record of every change made to a branch over its lifetime.

Putting together a release is a much more complicated task requiring
coordination with a large number of people.  The main task is to decide
the point at which the remaining bugs can safely be ignored.  There are
lots of other tasks involved here, of course: managing the build cluster,
pulling up changes, preparing information about the release, testing,
making sure that important fixes find their way to the branch, begging
people to work on certain things, paying very close attention to the
mailing lists, etc.

NetBSDfr: How does the quality assurance process works ? Who decides
to include this or that patch to a branch ?  This is also linked I think to
the following question: how does the releng team decide how many
betas, RCs versions are required before declaring a branch is stable ?

snj: No one person can have thorough technical knowledge in all areas
of the source tree.  Therefore, it's sometimes hard for a person (or
small group) to be able to say for sure whether a particular change
should be pulled up to the release branch.  This is where one of the
most important qualities of a release engineer comes into place: the
ability to get sound advice from the right people.  To some extent, we
trust that developers submitting changes for pullup have carefully
considered the implications of the change.  But at the same time, we
try to be very cautious, and being able to effectively consult with other
developers is of vital importance. 

We start the release process when we think the tree is in pretty good
shape.  At this point, the branch is known as, e.g., 5.0_BETA.  At this
point, more users start running the code, and we are constantly watching
for feedback (positive and negative).  Intrusive changes are avoided
during all stages of the release process, but they are most acceptable at
this point.  The general rule is that the further along in the release
process we are, the more restrictive we are about changes.  Unfortunately,
it is impossible to have many hard rules about this.  If big nasty bug
comes up, you're faced with a choice between ignoring the problem or
taking a risk on an intrusive change.  Sometimes we take the risk,
sometimes we don't.  This is another case where no one particular person
can have all the answers.  To avoid one person making a bad judgment call,
members of releng discuss these issues with each other and with other
developers.

A release candidate, by definition, occurs when it is felt that the tree
is good enough to release.  In practice, this rarely happens.  There is
almost always a good reason to do at least one more release candidate.  In
some respects, they're more psychological than anything else.  I admit I
rushed a couple release candidates out with full knowledge that 5.0 could
not be released without further fixes.  But when important last-minute
changes are made, putting out a release candidate is a great way to get
those changes tested.  Take 5.0_RC3, for example.  At the time, we were
aware of a few show-stopping bugs, but there were significant WAPBL
changes that needed wider testing, so we felt that RC3 was justified.

In the end, deciding when to declare a release stable comes down to
compromise.  You have a hard list of requirements that the release must
meet.  Beyond that, you just have to get to a point where you feel that
the remaining bugs are outweighed by all the positives in the new release.
This is a hard thing to do, because when you've been tracking every
problem raised for months, you tend to be focused on negatives and can
easily forget about all the people who are having wonderful experiences.
Eventually you have to let go and realize that you'll never have a
bug-free release.  When you get to that point, you tag the final release
and hope that you haven't made a horrible mistake  :) 

NetBSDfr: As a conclusion, can you tell us how you imagine the future
of NetBSD?

snj: We've made a massive jump with 5.0, and 6.0 should continue this
trend.
NetBSD has been ignored by many people for years, but this is changing.
As for more specific predictions, I think we're going to see NetBSD usage
increase greatly in the server and embedded worlds.  I don't envision any
radical shifts in direction, but this is not a problem.  NetBSD has always
been a great operating system; we just need to get out there and introduce
more people to it.

Many thanks to Guillaume for his hard work on preparing, conducting and translating this interview and rendez-vous in a few weeks for the next one. In the meantime, any names of developers to interview, or questions you'd like to ask, are more than welcome.

Original post at NetBSDfr.

Read the following for security issues:
June, 2009 security advisories

Then if you're reading this on http://netbsd.gw.com/ you might have noticed that Nhat Minh Lê has been posting about parsing my blog's atom feed in reply to an email I sent trying to do the same thing. Crazy meta fun. :)

2009-06-23

My work thusfar has consisted of updating the system to work on NetBSD 5.0 i386. I've updated the scripts given to me by my mentor, Phil Nelson of Western Washington University, and made the system's documentation more extensive as well as clarified some ambiguous parts. I've committed a "skeleton" for the system to the NetBSD Summer of Code repositories which at this time must be filled in by the user with packages and configuration files by hand as per the documentation.

The next step in my work is to make an interactive program to automatically fill in the skeleton system based on a question and answer style format. I will use the BSD curses library to create a type of simplistic, intuitive GUI for this process.

I will then expand the project to include support for the x64, spark, and shark architectures, and hopefully towards the end of the summer I will have support for automatically upgrading to the latest versions of installation packages as per a system administrator's request.

For more information regarding this project please visit the project's page here.

To follow the project as it progresses please subscribe to the blog here.

Four new security advisories were published:

You can find more information about them on the Security and NetBSD page.

2009-06-22

Netbsd 5.0 has been successfully installed with specified packages on i386 machines! I will be posting these results as well as committing what I have so far at http://blog.netbsd.org/ later today!

Edited 22.06. Incompatible syntax changes and more examples.

Since Matthew Sporleder on tech-userlevel has (implicitly) suggested that xmlgrep could be used to dissect Atom feeds, but was a bit lost at how to do it exactly, I thought I’d post a little demo of a console session playing with an Atom file and xmlgrep (as well as some other command-line tools).

First, let’s fetch the feed:

$ ftp http://mspo.com/blog/atom.xml
[...]

As a side effect of xmlgrep, we might want to indent the XML file to make it human-readable:
$ xmlgrep '*' atom.xml | more

List all posts in the NetBSD category with their IDs:
$ xmlgrep -x 'entry[category/@term=NetBSD]/(title|id)/.' atom.xml
tag:blogger.com,1999:blog-6347225410141611306.post-1131641169617411392
NetBSD quotas - quickstart
tag:blogger.com,1999:blog-6347225410141611306.post-1939815769827620970
NetBSD device drivers - easier than you might think
[...]

Those of you yet unfamiliar with the syntax might have some trouble understanding. The previous pattern could be read "select a text child of an id or title element, itself a child of an entry element, which contains a category element which has an attribute child term equal to NetBSD." Step by step, you should notice that a[b] is read "a such that b", | stands for "or", / for "child of", @ for "attribute", . for "text", and the braces are used for grouping purposes.

Now, let’s select a post by ID:

$ xmlgrep -x 'entry[id/.~"post-1939"]#' atom.xml

Or, select a post by title and view its contents using w3m:
$ xmlgrep -x 'entry[title/.~"device drivers"]/content/.' atom.xml |
> sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' |
> w3m -T text/html

As a side note, I should mention that up to now we have used subpatterns quite a lot. This is because the Atom feed specification does not force an order (or does it?) on the children of entry elements. With more precise knowledge of the order of elements relative to each other, we could have optimized the pattern to use % and %% where possible. Subpatterns are costly, but for data sets this size, we probably don’t care much.

Let’s print all entry titles which date from March 2009 using the fact that we know the updated element comes before the title one:

$ xmlgrep -x 'entry/updated[.~"^2009-03"]%%title/.' atom.xml

A friend of mine told me it would be useful to have arithmetic predicates. I think they will feature in xmltools sooner or later, but even without them, it is still possible to do some simple statistics, by combining the results with awk(1), for example. The following one-liner counts the number of posts that have no older than March:
$ xmlgrep -x 'entry/updated/.' atom.xml | awk -F - '$2>=3' | wc -l

That’s it; I hope this will help people who want to get started with xmlgrep. If you have other good examples you’d want me to elaborate, do not hesitate to send me a mail!

Summary

A NetBSD system, in order to tolerate disk failures, can use the software RAID driver raid(4). Currently, if that system is shut down uncleanly (e.g., loses power or crashes), then when it comes back up it will have to check the entire RAID set's redundancy information. This process can take many hours, during which it imposes a substantial load on the system. It is also a distinct disadvantage to using NetBSD in server applications, and the inclusion of a journaling filesystem in NetBSD 5 makes it all the more prominent.

The goal of my Summer of Code project is to shorten that check from hours to minutes.

More Detail

The problem is due to a fundamental limitation of RAID: if the system is abruptly halted in the middle of writing to several independent disks, there is no way to tell afterwards which of those write operations were actually performed short of reading the actual data involved. This is especially problematic for RAID-5 and similar, where a mismatch between data and parity will result in garbling part of that data when (not if) it has to be reconstructed after a disk failure.

The solution taken in the RAIDframe codebase used by NetBSD is simple: while a RAID device is configured and in use, the entire thing is marked as needing a parity rewrite — even though only a small part, or perhaps none at all, has write operations in progress at any given time.

Thus, my fix is to record a better approximation of what parts of the RAID are being written to at any given time. Except that now the RAID driver has to update that record as writes are done, rather than just once on boot and once at shutdown, and if this approximation is too fine-grained then that will noticeably reduce performance — all of the time, not just after unplanned reboots.

Status

At the time of this writing, I have a prototype implementation of just such a parity map; it's not fit for general consumption at this point, but the basics are working. Next up is more testing and performance evaluation, to refine the parity map algorithm. Eventually there will need to be an interface for the system administrator to configure this feature, and the code will need to correctly handle a RAID set being moved between kernels with and without parity map support, but these should be relatively straightforward and are scheduled for later in the summer.

Some additional minor improvements to the RAID system are also planned, time permitting, pertaining in particular to the handling of spare disks and reconstruction after a disk failure. In any case, by the end of the summer, a notable weakness of NetBSD will have been corrected.

2009-06-21

Generic file system mounting introduction

File systems have their own "proprietary" mount protocol. Those protocols are defined as opaque containers called struct <fs>_args which contain different things from one file system to another. These need to be treated differently, as each addition of a file system implies adding specific code on every program which wants to use it.

The aim of this project is to replace them by a generic protocol, which could be used for every file system. Doing so, it could be possible for instance to mount a device without having to specify the file system type. To do this, I am using a prop_dictionary instead of the struct <fs>_args.

Deliverables

Mandatory (must-have) components:

  • mount_generic command
  • patches for in-tree file systems
  • patch to add a new vfs operation
Optional (would-be-nice) components:
  • up-to-date manpages

Status

A proof of concept has been written. It contains the conversion of some file systems so as to use a properties dictionary, the new vfs_probe function and some applications which use them. It was tested with rump(3) which allows to do the tests without having to rebuild a kernel and to debug as easily as if it were a userland application. I converted fs-utils applications to make them use rump syscalls instead of the ukfs library. Then I wrote a new mounting library which uses the properties library. This library will be used to write the mount_generic program.
The code of these applications, the patch of the file systems and the vfs layer are available here.

Remaining work

  • Asking on tech-kern for comments
  • Adding support for remaining file systems
  • Completing the mount_generic command

How to test it

Building the patched rump :

# cd /usr/src/sys
# patch < ~/genfsmount.patch
# cd rump
# make && make install
Building fs-utils libraries and applications :
# cd fsu_rsprop/lib
# make includes
# cd ..
# make && make install

Examples

Usage

$ fsu_ls -o ro -w ffs.xml ~/ffs.img
Trying ffs: probing success, mount succeed
CVS             Makefile.rump   TODO            include         net
Makefile        README.dirs     fs              librump

$ cat ffs.xml 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>fspec</key>
        <string>/home/stacktic/ffs.img</string>
</dict>
</plist>

$ fsu_cat -f ffs.xml Makefile
Trying ffs: probing success, mount succeed
#       $NetBSD: Makefile,v 1.4 2008/11/17 10:21:44 pooka Exp $
#

SUBDIR= include librump fs net

.include <bsd.subdir.mk>

$ fsu_ls -o ro ~/i386cd.iso 
Trying ffs: probing failed (22)
Trying cd9660: probing success, mount succeed
bin             dev             lib             mnt2            stand           sysinstmsgs.es  targetroot
boot            etc             libexec         netbsd          sysinst         sysinstmsgs.fr  tmp
boot.cfg        i386            mnt             sbin            sysinstmsgs.de  sysinstmsgs.pl  usr

Using specific options

$ fsu_ls ~/msdos.img               
Trying ffs: probing failed (22)
Trying cd9660: probing failed (22)
Trying msdos: probing succeeded, mount succeeded
CVS             Makefile.rump   TODO            include         net
Makefile        README.dirs     fs              librump

$ fsu_ls -s shortname,uid=stacktic,gid=users ~/msdos.img -l
Adding: shortname = true
Adding: uid = 1000
Adding: gid = 100
Trying ffs: probing failed (22)
Trying cd9660: probing failed (22)
Trying msdos: probing succeeded, mount succeeded
total 288
d---------  1 stacktic  users  16384 Jun 12 11:30 cvs
d---------  1 stacktic  users  16384 Jun 12 11:30 fs
d---------  1 stacktic  users  16384 Jun 12 11:30 include
d---------  1 stacktic  users  16384 Jun 12 11:30 librump
----------  1 stacktic  users    118 Jun 12 11:30 makefile
----------  1 stacktic  users   2377 Jun 12 11:30 makefi~1.rum
d---------  1 stacktic  users  16384 Jun 12 11:30 net
----------  1 stacktic  users   1525 Jun 12 11:30 readme~1.dir
----------  1 stacktic  users    530 Jun 12 11:30 todo

Links

Those who have been keeping an eye on my Git repository have surely noticed the recent update of the bitvopt branch, which contains alternate implementations of the core routines of the matching engine (match.c): followsibling and followparent. The bitvopt code replaces the direct tests and propagation entirely with bit vector operations (masking, shifting, etc.).

The main advantage of this approach is vectorization. Such operations are easily done on a single unit (the type of which is defined in bitv.h and somewhat configurable with the USE_STDINT macro) and can be generalized to loops that carry no dependencies between iterations. These loops can then be auto-vectorized by a sufficiently smart compiler. The current code in bitvopt is understood and vectorized by both GCC 4 with -ftree-vectorize and ICC 10.1. Beware, ICC 10.0 fails because of the restrict qualifiers, which are necessary; also note that, on x86, you have to pass USE_STDINT in order to select a type bigger than unsigned char, or else, SIMD shift operations won’t be available. To see the vectorization reports, you can use -ftree-vectorizer-verbose=5 for GCC and -vec-report for ICC.

The results are not quite satisfactory and the branch was not merged into master:

GCC auto-vectorization not doing well…

On the chart, GCC has vectorization disabled by default while ICC always has vectorization (even though I have not specified -vect anywhere). The measurements have been done on my old Pentium 4, with -O2 and appropriate architecture flags, with GCC 4.1.2 and ICC 10.1. The values are averages computed over 100 runs of the following pattern on the same dictionary as before:

$ xmlgrep 'p[hw/?="Ab\"a*cus"]#'

I must say I can’t explain why operations on native integers (the -int builds) are slower than those on bytes. As for the relative gain of non-vectorized code over vectorized one, this is most probably because the pattern is not long enough (less than one base unit) to take advantage of SIMD so we lose in the overhead introduced with vectorization (all the more so as data may be unaligned on entry of these functions). Lastly, it seems auto-vectorization in GCC really is not advantageous right now, since the non-vectorized versions tend to outperform their vectorized counterparts when compiled with GCC (and this is not the case with ICC).

Anyway, this was just a side experiment of mine; work on the main tools continue: plans for more features in the matcher (on request, case insensitivity, arithmetic predicates, maybe some other things) as well as the introduction of xmlsed are underway.

2009-06-20

XML tools update NetBSD Blog 2009-06-20 21:43 UTC

My Google Summer of Code student, Nhat Minh Le, is working on a suite of simple, efficient, stream-oriented tools for processing XML on UNIX systems. Nhat Minh is making good progress on xmlgrep, a grep-alike program that understands XML syntax.

Read about Nhat Minh's progress on his blog.

Keep reading for my explanation of the niche where Nhat Minh's tools fit.

UNIX's versatile text-processing system consists of simple tools (awk, grep, join, sed, sort) that provide elementary text-processing functions, and tool-building facilities (pipelines and scripts) that let you assemble simple tools into more sophisticated tools. UNIX tools are well-suited to processing tables where there is one record per line and where each field in a record is delimited from the next by a reserved character or characters.

About a decade ago, XML began to show up on UNIX systems in the form of both configuration files and XHTML web pages. Some UNIX administrators grumbled about the introduction of XML, especially XML as a configuration file format. They were accustomed both to reading and writing configuration files, and to automating chores by processing configuration files with standard UNIX tools. Tabular configuration files were more suited to be processed with standard UNIX tools, and to be read and written by people, than XML files were. Some admins thought that the use of XML as a configuration file should stop and never be reconsidered. Others felt that while XML configuration files may have promise, to introduce them without elementary processing tools was premature; some of those admins waited for the analogues to awk, sed, et cetera for XML to appear.

And they waited, and waited. Today, there are no XML tools to equal the economy of implementation, flexibility, and ease of use of the UNIX text-processing tools. Complicated tools with weighty prerequisites, such as a Java virtual machine, are common.

Nhat Minh's XML tools project aims to deliver small, simple programs that can work together to perform sophisticated XML processing tasks, bringing UNIX text processing into the XML era. xmlgrep will extract text from XML documents. A tool called xmlsed will transform them. We are still discussing the merits of xmlsort and xmljoin, and a tool for "decorating" one XML tree with another that has no parallel in the traditional UNIX tools.

(A draft of this blog entry first appeared on an internal mailing list of OJC Technologies.)

2009-06-19

Of course NFS is done by now, and I'm almost done setting up a NetBSD 5.0 directory tree. I ran into a bit of a snag with fdisk, and I'm looking into it now.

2009-06-16

After spending some days fixing bugs in the xmlgrep matcher code, I took some time again to look at the performance issues. The previous measurements showed xmlgrep was slower than xmlstarlet, even on patterns without subpatterns, which are theoretically optimal for my implementation. That really bothered me.

Profiling seemed to show xmlgrep spent most of its time in bit vector operations – that much was expected. But my vain attempt (Git branch bitvopt) at replacing tests (the FOREACHVSTATE macro) with bit vector operations proved actually slower than the master version.

Then I had a talk with David Young, my mentor, and we concluded that both the input mechanism and the memory allocation pattern were suboptimal.

About the input problem, I’ve replaced the old input feeder, which used fgets(3), with direct read(2) calls, and this has indeed shaved some seconds off the counter. This is especially noticeable for patterns without subpatterns, since I/O accounts for more in that case.

The memory allocation issue was more serious. Basically, a lot of bit vectors and subcontext frames were needlessly allocated then almost immediately freed afterwards. This is due to the following construct commonly found in patterns (maybe I should optimize this one case specifically): patterns which start with an anchored subpattern, typically something like a[b] or {a%b}. This kind of patterns causes the matcher to try to match every node in the tree against the subpattern yet fail almost all the time (on all those nodes that do not match a). Such a failed subpattern match entails a call to pushsub followed by a call to popsub, which are responsible for the management of the subcontext stack.

I’ve switched to pool allocators for both internal tree nodes and bit vectors. This has drastically reduced the number of allocations made during a run. David also pointed out that I could use a pre-allocated vector instead of a linked list for the subcontext stack, and I remembered one of the nice properties of my implementation: the number of subcontext is bounded by the maximal nesting depth of subpatterns. He also suggested I should use copy-on-write bit vectors, but that proved unnecessary as I now use pointer swapping instead of copying then erasing (which was quite stupid in the first place, I agree).

All these changes were developed in the memopt2 branch overnight and are now in master. The same measurements as before show some exciting improvements, most notably the fact that we are now faster than libxml on patterns that do not use look-ahead! Basically, on this example, we are about 50% faster than before.

Revisited speed comparison

2009-06-13

I'm almost done with my NFS server, the final stage that will allow me to test my work on the guinea pig computers. It's been a rocky road, setting up this slew of servers, but I've learned a lot of applicable things. I'll be doing work over the weekend and hope to have everything ready to roll on Monday.

2009-06-12

As xmlgrep is approaching a pre-pre-alpha release (something that is still very experimental, but nonetheless working, somewhat :), I’ve been doing some basic tests on it, including one simple benchmark. The results are, IMHO, encouraging. The benchmark pits xmlgrep against equivalent existing software:

  • the selection tool from the xmlstarlet project (available in pkgsrc as textproc/xmlstarlet);
  • another xmlgrep from the Perl Twig package (textproc/p5-XML-Twig in pkgsrc);
  • and GNU grep, though it does not really accomplish the same, from the base NetBSD-5 distribution, as a reference.

Since each tool accepts its own patterns and treats them differently, I’ve tried my best to get meaningful results with each, but obviously, the behaviors obtained differ somewhat.

The tests/memplot script was used to make the sampling. The data were plotted using Gnuplot. The following commands were run:

$ xmlgrep 'hw/?="Ab\"a*cus"' d.xml
$ xmlgrep 'hw[?="Ab\"a*cus"]' d.xml
$ xml sel -t -c "//hw[text()='Ab&quot;a*cus']" d.xml
$ xml_grep "hw[string()='Ab\"a*cus']" d.xml
$ grep 'Ab"a\*cus' d.xml

The goal was to retrieve the <hw> element which contains the Ab"a*cus string from a 53M dictionary, retrieved from http://www.ibiblio.org/webster/ and merged into a single file.

The first two lines correspond to two different invocations of xmlgrep, which do not do exactly the same thing, and with the first being the good one, the other inefficiently abusing the look-ahead mechanism. Yet, it was included for comparison purposes and maybe to be fair to the XPath-based alternatives, which have to rely on a predicate.

Results follow; the second and third pictures are just zooms which omit one or another of the candidates.

I know these results don’t mean much, so don’t take them too seriously. I’ve only tested a single simple pattern. Actually, I didn’t really intend to make a comparison, at first, I just wanted to make sure xmlgrep doesn’t leak or otherwise misuse memory. But since the sampling code was there, I thought it’d be fun to do some additional measurements.

Overall benchmark
Low-memory candidates benchmark
Fast candidates benchmark

As expected, xmlstarlet, which uses a full DOM model requires a lot of memory to do its work (more than 400M!). But it is the fastest.

My xmlgrep, when used right, is still nearly 42% slower than xmlstarlet (from above 4s to below 6s), but I think the times remain reasonable; memory-wise, it is also the lightest, with a constant 2.9M in use throughout the whole run. Even GNU grep requires about 2.8M.

Surprisingly, the Twig xmlgrep is not too big a memory killer, though its memory usage increases over time, by steps (though it looks linear on the long run). This appears somewhat strange to me; why some nodes should be pruned from its internal DOM-like tree while others seem to remain for the duration of the program. However, on the speed side, Twig is predictably very slow; it takes nearly two minutes to produce the results comparable to those of its C counterparts.

That’s it for tonight; as one friend of mine told me, more interesting benchmarks will probably come from actual users.

2009-06-11

Having completed two Spring quarter finals today and one yesterday, I can finally put my entire effort into GSOC! I'm definitely looking forward to it.

2009-06-10

xmltools is a project whose ultimate goal is to bring Unix command-line efficiency to the XML world (and not, as many might think, to bring XML into the Unix world, which is being done already, though not by my fault). The idea is to treat XML as a generic tree representation format.

This seems very straightforward; in fact, one could argue that XML was designed from the start to be a generic tree representation. However, XML has a number of problems that make it hard to use in this role.

The first such problems is doctype declarations. While the bare XML structure, which we see most of the time, is very simple, doctype declarations and their semantics are both unneeded and unwanted in tree (syntax) manipulation programs. It would be fine if doctype support was optional for non-validating XML processors, but as I understand it, the XML standard mandates support for a portion of it: entity declarations and references, and default attribute values.

The second issue is with white space handling: XML does not include any default behavior regarding white space. XML parsers must pass all white space to the application, which is responsible for some sensible default processing. The xml:space attribute can give a hint to the application but as far as I know, it’s not in wide use.

This all led me to develop a set of compatibility rules which precisely describe what one should expect from xmltools, no matter which backend is used (in case we move away from expat, which I plan to do, eventually). This subset is sufficient to describe any tree-like data set.

The rules will be maintained in the doc/compatxml.text file, in the xmltools source tree. For convenience, I’ve reproduced the current version below:

  1. Do not use doctype declarations for any purpose other than validation. In particular, do not rely on doctype declarations to provide default attributes and do not use internal entities for arbitrary substitutions; if you wanted to save typing, you wouldn’t be using XML. Use of numeric and predefined entities is OK. Use of directly-encoded characters is preferred.

  2. Do not presuppose the XML processor has access to any resource beside your file: do not use external entities.

  3. Do not assume the XML processor is able to handle multiple character sets: all the documents and other data supplied to the program should use the same character set. Also, set your locale appropriately.

  4. Unless xml:space is set, assume all white-space only text elements are ignored by the XML processor.

  5. Set xml:space to preserve whenever white space not kept by the previous rule must be preserved. As stated in the first rule, do not rely on doctype declarations to implicitly set this attribute. Please note however that the fourth rule works well for most purposes, including processing of HTML pre elements which only contain verbatim text.

2009-06-09

My apologies for not having written in a while, I will be updating the site daily from now on.

I now have successfully set up a dhcpd, sshd, ipf, ipnat, and named server for my humble little subnet tucked neatly into the corner of wwu. I will be beginning the setup of an NFS server to allow me to use TFTP booting for the rest of today.

Recently, I’ve been working with expat extensively, as part of my Google Summer of Code project, and have come to the realization that there is, IMHO, no good well-maintained lightweight stream-oriented XML parser.

Of course, one would think expat, at this point, and I thought so too, when I started, only to find myself now locked with an expat-like design, which is both inefficient and unnecessarily complicated (for what I want to do).

So, what is this expat design I am talking about? It is the event-driven (callback-oriented) model, what the XML guys out there call push parsers, though I personally think it doesn’t make much sense to call it that way, so I won’t.

While event-driven parsing is good for some tasks — awk(1) is a really clever tool — it really fails on complex parsing tasks such as those required by my xmltools that rely on partial reprocessing of the document tree.

Reprocessing of the document tree basically means we have to keep an in-memory copy of the parts we want to traverse more than once. Of course, expat can (help us) do that. Using expat, the basic idea is to have two input sources which both call the event handlers. Then, whenever we need to reprocess some part of the tree, we just traverse our in-memory copy and feed the information to the handlers as if they were receiving these from expat.

Now, this seems good at first, but the fact is we now have two parsers: expat and our tree parser. Moreover, they don’t share an identical behavior: on the expat side, we may need to build new nodes to put in the partial tree (for future reprocessing), while in the in-memory tree parser, we may need to free some nodes which are no longer needed. But even in the expat handling code there may be nodes we have to keep (usually the current branch, from the root to the current node); this in turn implies we sometimes have to free some nodes as well. Now we have bits and pieces of the in-memory tree management code everywhere. Things start to look messy…

Besides, when do we call the surrogate parser? The issue here is we don’t want expat to feed new data while we are in the middle of (or more precisely before we can even start) a reprocessing operation. The expat manual points at the XML_StopParser and XML_ResumeParser functions. These seem to be exactly what we need, right? Wrong. Indeed, a more careful reading of the documentation reveals parsing does not stop immediately after the handler that called XML_StopParser; there may be an unspecified number of additional events between the end of that one and the moment the parser actually stops. This makes these routines pretty much useless. Actually, we need to use the secondary input system right on top of expat itself, in the middle of our callbacks, whenever we need this functionality. This is not pretty to say the least…

But there is a more elegant solution: the idea is to have the internal tree management module drive the process. It maintains the in-memory tree and calls the event code on its nodes whenever necessary, possibly going through loops or any patterns that suit its needs, for that matter. Then, when it requires a node that is not present in the tree, it calls upon the input module which returns the next node in the stream. This is the so-called pull method. There really is nothing special about it; in fact, it’s the way most I/O libraries out there are built. Why XML had to be different, I don’t know.

As I’ve said, to the extent of my knowledge, there is no lightweight and well-maintained (I mean not some two-year-old experiment by some obscure hacker, though I respect these things, I don’t have time right now to play with such codes) C library which implements the full XML standard and this pull metaphor. If anyone out there knows, do not hesitate to let me know.

2009-05-27


  1. "userquota" should be set in the options of /etc/fstab for the filesystem where you want you want quotas enabled.


  2. /dev/sd0a /usr/local ffs rw,userquota 1 1

  3. Make sure your quota-enabled filesystem is mounted

  4. Run /etc/rc.d/quota start to generate an automatic "quotacheck -a" command

  5. "edquota -f FILESYSTEM USER" will open up vi and have you fill out the quota file


  6. Quotas for user qtest:
    /usr/local: blocks in use: 0, limits (soft = 20, hard = 10)
    inodes in use: 0, limits (soft = 100, hard = 150)

  7. "quotaon -a" to turn quotas on for every filesystem with the userquota option

  8. Finally, try running repquota -a to see a report of all the quotas and test it out! Here's my attempting to exceed my quota of 100K


  9. Error: bar: Disc quota exceeded; bar: WARNING: FILE TRUNCATED.



Caveats


I found a few issues with quotas-

  • The userquota options and the log options are mutually exclusive, so WAPBL and quotas don't work together. (I think there is a plan to fix this)

  • After really using quotas, I was unable to umount my fs but fstat didn't show anything using it



quota(1) - check your own quota
repquota(8) - check everyone's quota
quotaon(8) - enable quotas
edquota(8) - edit the quota file
quotacheck(8) - see if a user is exceeding his quota

2009-05-24

Okay, so this is basically a post about procrastination as I avoid working on my first pseudo device. One thing that struck me was how accessible this part of the internal working of NetBSD were. I mean, seriously, if I can get a working device then anyone can.

NetBSD Documentation: Writing a pseudo device tells you everything you need to get started (well, mostly :) ) And studying other drivers shows that they mostly all look the same, use the same few conventions, and can offer a lot of hints on getting something functional fast.

A device-writing section in NetBSD Internals would be a very welcome addition and would give some nice background to the networking pseudo device chapter.

I guess it's time to get some reading in about config_attach_pseudo and friends but if you have an idea for adding a little this-or-that to NetBSD, I'll bet you can get a functional pseudo device in one day or less.

p.s.
Should I be doing this whole thing with rump?

2009-05-10

I spent some time today working out the kinks of making a directory tree for NetBSD 5.0 which only recently was released. Understanding scripts/importing packages comprised most of my day today.

I can't help but feel like it's been a slow start, but the excitement I feel when I get the smallest thing to work is incredible.

2009-05-09

Update! This whole article has proven mostly worthless thanks the following two entries in fstab:
/dev/wd0b /var/log2 mfs rw,-s10m 0 0
/var/log2 /var/log union rw - -

That creates a 10M /var/log2 and then union mounts it onto /var/log, which will auto-magically seed the filesystem as it is used.

Thanks, tech-embed


Install into /sbin/mount_seed_tmpfs

So I like to run my soekris read-mostly and one of the biggest weaknesses of the methods I describe in there is seeding your memory file systems with the correct files so daemons requiring those files will function properly. Basically, if /var/log/messages doesn't exist, syslog isn't going to create it for you!

So, I've written the following script which will populate a tmpfs with all the data currently on the disk before mounting it. I basically works by first mounting the tmpfs to a hidden location, copying everything from the seeddir, and then doing a null mount on-top of the destdir.

So the command:
mount -t seed_tmpfs -o -s10M /var/log /var/log
will create a (hidden to df) mount of a 10M tmpfs, copy everything from /var/log to it, and then null mount that on-top of it.

Using it in /etc/fstab is a two step process (mostly for safety)
/var/log /var/log2 seed_tmpfs noauto,rw,-s10M - -
And then in /etc/rc.conf:
critital_local_filesystems="/ /var/log2"

This is a workaround for a little bug where mount -a will always try to remount the filesystem, and putting the parent and target into critical_local_filesystems will explicitly mount them.

The other bug is that umount can't trigger to umount both systems that I know of so a manual umount requires two commands.

2009-05-04

The NetBSD Blog The Julipedia 2009-05-04 18:47 UTC

The NetBSD Project recently launched a new official blog for NetBSD. From here, I'd like to invite you to visit it and subscribe to it. It's only with your support (through reading and, specially, commenting) that developers will post more entries! Enjoy :-)

2009-05-03

So after re-installing NetBSD on my soekris I got to thinking about jumpstart for netbsd and about the whole pxe boot in general. After doing a little reading of the pretty excellent pxeboot man page (I mean, NetBSD really does have some great documentation) I wanted to give some of the more flexible options a try.

I didn't have to look much further than the bottom of the pxeboot man page, but I thought I would give a summary post about the booting process, and about how you can completely avoid using NFS for netboot if you want to. (let's hope the automated installer has a no-nfs option!)

The gist of what happens is is that NetBSD overloads the "filename" option in dhcpd.conf, depending on the request.

1) The first request, from the pxe bios is:
option vendor-class-identifier, 0, 20) = "PXEClient:Arch:00000" - pxeboot file


fun starts here - by default netbsd will look in next-server/root-path (dhcpd.conf config) for 'netbsd' and boot it, but you have more options at your disposal:

2) pxeboot then does a new request as:
option vendor-class-identifier, 0, 17) = "NetBSD:i386:libsa" looking for "boot.cfg"

3) pxeboot will then do request for 'netbsd' or whatever you tell it to do in boot.cfg!

The neat thing about #2 and #3 is that you can say "tftp:boot.cfg" OR "nfs:boot.cfg" and decide how you want to serve that file.

So if you want to say boot the netbsd kernel over tftp and turn off a troublesome piece of hardware, you can make your boot.cfg look like this:
menu=tftp boot userconf mode:boot netbsd -c

Or point to different kernels:
menu=tftp boot installer:boot netbsd-INSTALL

And then you just override the values in dhcpd.conf:
} else if filename = "netbsd" {
filename "tftp:netbsd-SOMETHINGELSE";



So I'm definitely interested to see how the above-mentioned summer of code project decides to use these options, if he decides to use MULTIBOOT to pass an arbitrary list of options into the boot sequence (my-ctrl-file=tftp:macaddress.xml) or who knows what.

Abandon CDROM booting! :)

(my dhcpd.conf is mostly from the pxeboot man page and I'm testing by connecting my eee to my powerbook with a normal patch cable because modern interfaces will automagically act like crossovers)

host eeepc {
hardware ethernet 00:1E:4D:5E:90:75 ;
# filename "/private/tftpboot/pxeboot_ia32.bin";
next-server 192.168.2.201;
option routers 192.168.2.201;
option domain-name-servers 4.2.2.1;
option root-path "/usr/local/soekris/";
fixed-address 192.168.2.203;
# This section allows dhcpd to respond with different answers
# for the different tftp requests for the bootloader and kernel.
if substring (option vendor-class-identifier, 0, 20)
= "PXEClient:Arch:00000" {
filename "pxeboot_ia32_vga.bin";
} elsif substring (option vendor-class-identifier, 0, 17)
= "NetBSD:i386:libsa" {
if filename = "boot.cfg" {
filename "tftp:boot.cfg";
} else if filename = "netbsd" {
filename "tftp:netbsd";
}
}
}

2009-05-02

Upgraded to NetBSD 5 mspo.com blog 2009-05-02 12:50 UTC

I just upgraded my soekris from NetBSD 3.1 to NetBSD 5.0. I actually did a fresh install following my own docs at soekris.html and am still working on getting all of my packages installed now. So far the systems seems fine, although I'm having a little more trouble fitting it onto 512MB. :)

Speaking of packages, I'm still waiting on the install of apache to finish (pkg_add seems stuck in select() or something) and I wanted to get this site back up, so I just fired up /usr/libexec/httpd (bozohttpd), which is now included in NetBSD, so I didn't have to wait for pkg_add at all.

NetBSD fester 5.0 NetBSD 5.0 (GENERIC) #0: Sun Apr 26 18:50:08 UTC 2009

2009-05-01

Today I moved some personal equipment into my workspace. Things will be going slowly until next Monday (May 4) due to a midterm project for my Game Programming class.

2009-04-29

Today I prepared the work area for the project. I installed the new NetBSD 5.0 on my x86 server machine as well as procured a couple of SPARC machines for use in testing.

In addition, I updated the project's official site, found here.

In the next couple of weeks I will be preparing by hand a PXE installation tree for NetBSD 5.0 in order to learn more about the inner workings of Dr. Nelson's current system.

2009-04-28

patch_* tools are announced in an email describing the beginnings of a tool which is like what mt_diff was supposed to be.

I personally look forward to single-command upgrades to my netbsd systems. :)

2009-04-27

First and foremost, I would like to express my excitement at having been selected to work with Google, NetBSD, and Dr. Philip Nelson. I feel extremely honored to have been given this opportunity. This blog will follow major project events for those interested in its completion.

I am jumping in without hesitation, and will be reading documentation so as to further familiarize myself with PXE Booting, dhcpd, NetBSD, and Dr. Nelson's existing system during the next few weeks. Below please find some links that contain information about the project and myself:

Official Site for the Project:
http://netbsd-soc.sourceforge.net/projects/pxebulk/

NetBSD Repository for its Google Summer of Code Projects:
http://sourceforge.net/projects/netbsd-soc/

My Resume:
http://maxhart.thruhere.net/

Dr. Philip Nelson's Site:
http://cs.wwu.edu/faculty/phil/

2009-04-19

As noted in another blog, wasabi systems has gone away. It would seem that they donated WAPBL to NetBSD in a final act of charity before being forced to close their doors. Now that they're gone, I wonder if they have any other technologies they would be able to give to NetBSD or even sell to the netbsd foundation. Old hardware is probably too easy to sell for bill-paying, or else that would probably be nice too.

Regardless, it's sad to see them go. Who will be the next big NetBSD-based company (other than microsoft via the sidekick, I mean) to give things a spin? On that note, microsoft donating Danger's work would also be nice. ;)

Edited for typos..

2009-04-13

pkgsrc-dashboard is now, basically, functionally complete for its initial goals:
If will take input from a single shell script on any pkgsrc client and create a website of reports telling you if the package is vulnerable, old according to a source repository, and/or old according to a binary repository.

There are tons of possibilities when you get into this sort of thing, but I think that base functionality is pretty good. The server requires one daily sync of the INDEX from your local source repository, perl, DBI, and DBD::SQLite, and occasional find -exec rm to cleanup old reports. The client only needs to run a shell script every once in a while (daily is the highest supported frequency).

pkgsrc-dashboard

2009-04-06

So in IRC I brought up the idea of a web dashboard for managing a network of pkgsrc servers and liked it so much I started a google code project for it.

http://code.google.com/p/pkgsrc-dashboard/

If you're a pkgsrc/netbsd person and have some input, ideas, or want to join the project then let me know!

So this weekend I actually got some code out on pkgsrc-dashboard and I'm pretty happy with it. Well.. almost. :)

Obviously, this first commit is just something to try out and see what happens, but basically the server-side of things is starting to take shape. (I'll add a simple client very soon)

It has shown some, in my opinion, weaknesses with the tools available and I'm hoping to be able to improve that situation, or at least highlight these weaknesses enough to where they are improved. One obvious example is that NetBSD doesn't include a very featured http client by default. ftp(1) can do http requests, but it lacks the ability to POST, set headers, and other things that would make simple web-based automation a little easier. For now, I've programming pkgsrc-dashboard to handle GET's with parameters, but it would have been easier with curl as a client target.

Regardless, I'm happy with the progress I made this weekend.

2009-04-02

The Google Summer of Code 2009 application deadline for students is tomorrow and NetBSD has got very few applications so far. If you have the interest in working on a cool operating system project, where almost any project idea can fit, take the time to read our proposals and apply! New, original ideas not listed there will also be considered.

It'd be a pity if the number of assigned slots to NetBSD was small due to the low number of applications! We did much better past year.

Note that there are a couple of ATF-related proposals in there. Help will be certainly welcome (by me ;-) in those areas!

2009-03-28

Normally I would do a whole How-To on this topic, but it was so easy that it really only qualifies as a blog post. Everything pretty much just works on my eeepc 701 so there isn't a whole lot to document. The main accomplishment was just figuring out how to turn off the screen.

I'm mostly using the GENERIC kernel with the following line added:

i915drm* at vga? # Intel i915, i945 DRM driver


My xorg.conf came from X -configure. I can't remember making any changes to it, but here are some snippets:

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "wsmouse"
Option "Device" "/dev/wsmouse"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Device"
Identifier "Card0"
Driver "intel"
VendorName "Intel Corporation"
BoardName "Mobile 915GM/GMS/910GML Express Graphics Controller"
BusID "PCI:0:2:0"
EndSection


To turn off the LCD backlight and get a completely dark screen:

startx
xset +dpms
xset dpms force suspend


The only problem is that you must be in X for that to work. I would like to simply leave it on the console, but I couldn't figure out a way to turn off the LCD with screenblank(1) using wscons, and I feel like vesa might have some options, but I couldn't find them.

2009-03-25

Jibbed The NetBSD livecd has been updated to a new version.

2009-03-20

Okay, so an email came through the mailing lists recently about systrace being removed and how to handle it. This got me thinking about kauth and secmodel. Two ideas came to mind:

1) Implement system calls as a kauth scope.
2) Create a tool called secmodelctl which allowed for manipulation on an overlay level of the security model.

The main use for systrace to come back, in my opinion, is for great projects like sysjail.

secmodelctl should be like pfctl where you can load a config file, manipulate rules, etc.



<priv type="priveleged_port" action="add">
<prog>/usr/libexec/ftpd</prog>
<sha1>e34da0a32eda829b4496370cc24987322d2e852d</sha1>
<user>ftpd_user</user>
<port>21</port>
</priv>

2009-03-14

We had an interesting discussion on EFNet/#netbsd this morning about some possible enhancements to acpi and some other facilities being improved/introduced in NetBSD 5. The main idea was this: given a set of criteria, could netbsd automatically turn off hardware components to save on power?

So, for a simple example, if I have a server with two cpu's and my system load is less than 1 for an extended period of time, why not step down my cpu speed and if my load continues to stay low, turn off one cpu?

What if I never use more than half of my ram? Or what if my network traffic could go from gig to 100M without any harm?

I've worked in some power and cooling-starved datacenters where we would never seriously consider trying to set all of this stuff up, while at the same time we had a lot of standby servers, or very idle systems. This tells me that power management is probably seen as risky, difficult, or both.

All of this stuff, of course, also applies to laptops which need extended battery performance, lid-closing sleeps, etc. It's one of the few places where laptop-driven technology could make a big impact in a datacenter.

Anyway, netbsd isn't really there yet to provide a lot of this, but it seems to have facilities which could be put together to almost solve the problem:
powerd
drvctl
envstat
cpuctl

And maybe something more like sar or a similar dtrace-type listener.

2009-03-10

I wanted to give a little press to mk-configure by Aleksey Cheusov because I think it's an interesting project and because the auto tools are a regular source of heartache for developers and users. (you might know them as the standard ./configure && make && make install cycle)

Having a BSD-based alternative to these tools is nice for someone making BSD software and pushing the use of NetBSD's flavor of make is also cool because it's very powerful and could do a lot of things (like the above project shows) that are currently achieved with many different and difficult to understand/learn tools. Make is magic-enough. :)

2009-03-07

Interview with Andrew Doran from the NetBSD Project. We talk about the upcoming 5.0 release. File Info: 22Min, 10MB. Ogg Link: http://cisx1.uma.maine.edu/~wbackman/bsdtalk/bsdtalk171.ogg

2009-02-27

tech-userlevel might not seem like the most exciting mailing list, but it usually has some good stuff.

It looks like Ian Hibbert has reworked bluetooth service discovery so it's easier for your headphone to tell your computer that they also have 256MB of storage. ;)

Message on tech-userlevel

2009-02-24

I'm not sure why this wasn't announced yet, but it looks like the desktop-gnome meta-pkg was added. This is a big step for the Desktop NetBSD project.

It looks like this package is mostly the normal gnome metapkg plus some stuff. Try it out!

2009-02-21

Mirroring NetBSD mspo.com blog 2009-02-21 19:11 UTC

Brian Seklecki just posted a new wiki page about how to run a netbsd source mirror. I have helped him with some of this stuff (although not very much), so I thought I would advertise the page here.

2009-01-02

I reinstalled NetBSD-current recently on my shark (Digital DNARD) and, out of curiosity, I wanted to see if the new-style kernel modules worked fine on this platform. To test that, I attempted to load the puffs module and failed with an error message saying something like "kobj_reloc: unexpected relocation type 1". Similarly, the same error appeared when running the simpler regression tests in /usr/tests/modules.

After seeing that error message, I tracked it down in the source code and ended in src/sys/arch/arm/arm32/kobj_machdep.c. A quick look at it and at src/sys/arch/arm/include/elf_machdep.h revealed that the kernel was lacking support for the R_ARM_PC24 relocation type. "It can't be too difficult to implement", I thought. Hah!

Based on documentation, I understood that R_ARM_PC24 is used in "short" jumps. This relocation is used to signal the runtime system that the offset to the target address of a branch instruction has to be relocated. This offset is a 24-bit number and, when loaded, it has to be shifted two bits to the left to accommodate for the fact that instructions are 32-bit aligned. Before the relocation, there is some addend encoded in the instruction that has to be loaded, sign-extended and shifted two bits to the left and, after all that, added to the calculated address.

I spent hours trying to implement support for the R_ARM_PC24 relocation type because it didn't want to work as expected. I even ended up looking at the Linux code to see how they dealt with it, and I found out that I was doing exactly the same as them. So what was the problem? A while later I realized that this whole thing wasn't working because the relocated address to be stored in the branch instruction didn't fit in the 24 bits! That makes things harder to solve.

At that point, I looked at the port-arm mailing list and found that several other people were looking at this same issue. Great, some time "wasted" but a lot of new stuff learnt. Anyway, it turns out there are basically two solutions to the problem described above. The first involves generating jump trampolines for the addresses that fall too far away. The second one is simpler: just change the kernel to load the modules closer to the kernel text, and thus make the jump offsets fit into the 24 bits of the instructions. Effectively, there is a guy that has got almost everything working already.

Let's see if they can get it working soon!

Feeds

Feed RSS Last fetched Next fetched after
#NetBSD Community Blog XML 2009-07-04 03:35 2009-07-04 05:35
bsdtalk XML 2009-07-04 03:35 2009-07-04 05:35
freshmeat.net announcements (Global) XML 2009-07-04 03:35 2009-07-04 05:35
hubertf's NetBSD blog XML 2009-07-04 03:35 2009-07-04 05:35
i summon one kim XML 2009-07-04 03:35 2009-07-04 05:35
Implementality XML 2009-07-04 05:05 2009-07-04 07:05
Jeremy C. Reed's blog XML 2009-07-04 03:35 2009-07-04 05:35
Latest Secunia Advisories XML 2009-07-04 03:35 2009-07-04 05:35
Lenh — le blog XML 2009-07-04 05:05 2009-07-04 07:05
mspo.com blog XML 2009-07-04 03:35 2009-07-04 05:35
NetBSD Blog XML 2009-07-04 03:35 2009-07-04 05:35
NetBSD PXE Bulk Install Project XML 2009-07-04 05:05 2009-07-04 07:05
NetBSD.org News XML 2009-07-04 03:35 2009-07-04 05:35
Nifelheim Tech-Blog XML 2009-07-04 03:35 2009-07-04 05:35
OSNews XML 2009-07-04 03:35 2009-07-04 05:35
Seebach Exhibit 7 XML 2009-07-04 03:35 2009-07-04 05:35
The Julipedia XML 2009-07-04 05:05 2009-07-04 07:05
unsigned long geek = random(); XML 2009-07-04 03:35 2009-07-04 05:35
What Do You Want? XML 2009-07-04 03:35 2009-07-04 05:35