Source string Read only

(itstool) path: sect2/para
138/1380
Context English State
debug.debugger_on_panic=1
Kernel panics will happen, so care should be taken with the filesystem cache. In particular, having softupdates might mean the latest file version could be lost if a panic occurs before it is committed to storage. Disabling softupdates yields a great performance hit, and still does not guarantee data consistency. Mounting filesystem with the <quote>sync</quote> option is needed for that. For a compromise, the softupdates cache delays can be shortened. There are three sysctl's that are useful for this (best to be set in <filename>/etc/sysctl.conf</filename>):
kern.filedelay=5
kern.dirdelay=4
kern.metadelay=3
The numbers represent seconds.
For debugging kernel panics, kernel core dumps are required. Since a kernel panic might make filesystems unusable, this crash dump is first written to a raw partition. Usually, this is the swap partition. This partition must be at least as large as the physical RAM in the machine. On the next boot, the dump is copied to a regular file. This happens after filesystems are checked and mounted, and before swap is enabled. This is controlled with two <filename>/etc/rc.conf</filename> variables:
dumpdev="/dev/ad0s4b"
dumpdir="/usr/core
The <varname>dumpdev</varname> variable specifies the swap partition and <varname>dumpdir</varname> tells the system where in the filesystem to relocate the core dump on reboot.
Writing kernel core dumps is slow and takes a long time so if you have lots of memory (&gt;256M) and lots of panics it could be frustrating to sit and wait while it is done (twice — first to write it to swap, then to relocate it to filesystem). It is convenient then to limit the amount of RAM the system will use via a <filename>/boot/loader.conf</filename> tunable:
hw.physmem="256M"
If the panics are frequent and filesystems large (or you simply do not trust softupdates+background fsck) it is advisable to turn background fsck off via <filename>/etc/rc.conf</filename> variable:
background_fsck="NO"
This way, the filesystems will always get checked when needed. Note that with background fsck, a new panic could happen while it is checking the disks. Again, the safest way is not to have many local filesystems by using another computer as an NFS server.
Starting the Project
For the purpose of creating a new GEOM class, an empty subdirectory has to be created under an arbitrary user-accessible directory. You do not have to create the module directory under <filename>/usr/src</filename>.
The Makefile
It is good practice to create <filename>Makefile</filename>s for every nontrivial coding project, which of course includes kernel modules.
Creating the <filename>Makefile</filename> is simple thanks to an extensive set of helper routines provided by the system. In short, here is how a minimal <filename>Makefile</filename> looks for a kernel module:
SRCS=g_journal.c
KMOD=geom_journal

.include &lt;bsd.kmod.mk&gt;
This <filename>Makefile</filename> (with changed filenames) will do for any kernel module, and a GEOM class can reside in just one kernel module. If more than one file is required, list it in the <envar>SRCS</envar> variable, separated with whitespace from other filenames.
On FreeBSD Kernel Programming
Memory Allocation
See <citerefentry><refentrytitle>malloc</refentrytitle><manvolnum>9</manvolnum></citerefentry>. Basic memory allocation is only slightly different than its userland equivalent. Most notably, <function>malloc</function>() and <function>free</function>() accept additional parameters as is described in the man page.
A <quote>malloc type</quote> must be declared in the declaration section of a source file, like this:
static MALLOC_DEFINE(M_GJOURNAL, "gjournal data", "GEOM_JOURNAL Data");
To use this macro, <filename>sys/param.h</filename>, <filename>sys/kernel.h</filename> and <filename>sys/malloc.h</filename> headers must be included.
There is another mechanism for allocating memory, the UMA (Universal Memory Allocator). See <citerefentry><refentrytitle>uma</refentrytitle><manvolnum>9</manvolnum></citerefentry> for details, but it is a special type of allocator mainly used for speedy allocation of lists comprised of same-sized items (for example, dynamic arrays of structs).
Lists and Queues
See <citerefentry><refentrytitle>queue</refentrytitle><manvolnum>3</manvolnum></citerefentry>. There are a LOT of cases when a list of things needs to be maintained. Fortunately, this data structure is implemented (in several ways) by C macros included in the system. The most used list type is TAILQ because it is the most flexible. It is also the one with largest memory requirements (its elements are doubly-linked) and also the slowest (although the speed variation is on the order of several CPU instructions more, so it should not be taken seriously).
If data retrieval speed is very important, see <citerefentry><refentrytitle>tree</refentrytitle><manvolnum>3</manvolnum></citerefentry> and <citerefentry><refentrytitle>hashinit</refentrytitle><manvolnum>9</manvolnum></citerefentry>.
BIOs
Structure <varname remap="structname">bio</varname> is used for any and all Input/Output operations concerning GEOM. It basically contains information about what device ('provider') should satisfy the request, request type, offset, length, pointer to a buffer, and a bunch of <quote>user-specific</quote> flags and fields that can help implement various hacks.

Loading…

No matching activity found.

Browse all component changes

Glossary

English English
No related strings found in the glossary.

Source information

Source string comment
(itstool) path: sect2/para
Flags
read-only
Source string location
article.translate.xml:250
String age
a year ago
Source string age
a year ago
Translation file
articles/geom-class.pot, string 49