Why kernel tasks for each MTD partition?

Thilo Fromm fromm at dresearch-fe.de
Tue May 8 09:13:02 EDT 2012


Hello me,

just in case anyone else is ever riddled about this (like I was);
here's what I found out.

> while playing around with mtdblock and blockrom (see my other mail[1])
> I noticed that a separate kernel process is active for each "mtdblock"
> partition (e.g. ps shows "[mtdblock0]", "[mtdblock1]" kernel processes
> if you have two MTD partitions and you use mtdblock). These also exist
> for my blockrom device nodes. Since I see comparable processes for all
> storage on my Linux workstation I suppose the Linux storage stack runs
> these. Can somebody please fill me in on what they are?

It turns out the generic mtd block device subsystem starts one kernel
process for each mtd block device added. Each kernel process is an
endpoint for the corresponding mtd block device's I/O queue. The
kernel process will call the mtd block device readsect / writesect
implementation on incoming requests.

The process is implemented in drivers/mtd/mtd_blkdevs.c; the function
is "static int mtd_blktrans_thread(void *arg)". It is started directly
by add_mtd_blktrans_dev().

> Also, more importantly, I notice accesses on all my device nodes (the
> "blockrom" ones) upon system start originating from the corresponding
> kernel process. However, the "mtdblock" nodes are not touched by their
> kernel processes. How come?

This is UDEV doing some generic block dev initialisation. udev already
has default rules for mtd* (amongst lots of other things), so MTD
devices are not handled like other persistent storage devices
(actually they're just skipped for udev). The corresponding udev rules
file is "rules/60-persistent-storage.rules" and is part of the udev
sources (see e.g.
<http://git.kernel.org/?p=linux/hotplug/udev.git;a=blob;f=rules/60-persistent-storage.rules;h=b74821edd4764d4a353b67f5365b9c783b32c5c4;hb=HEAD>).

The mtd* exception does of course not cover my newly introduced
blockrom* device nodes. However, changing the corresponding line in
60-persistent-storage.rules

-KERNEL=="fd*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*", GOTO="persistent_storage_end"
+KERNEL=="fd*|blockrom*|mtd*|nbd*|gnbd*|btibm*|dm-*|md*",
GOTO="persistent_storage_end"

does the trick.

Regards,
Thilo

-- 
Dipl.-Ing (FH) Thilo Fromm, MSc., Embedded Systems Architect
DResearch Fahrzeugelektronik GmbH
Otto-Schmirgal-Str. 3, D-10319 Berlin, Germany
Tel: +49 (30) 515 932 228   mailto:fromm at dresearch-fe.de
Fax: +49 (30) 515 932 77    http://www.dresearch.de
Amtsgericht: Berlin Charlottenburg, HRB 130120 B
Ust.-IDNr. DE273952058
Geschäftsführer: Dr. M. Weber, W. Mögle



More information about the linux-mtd mailing list