From: Artem Bityutskiy <Artem.Bityutskiy@...>
Subject: [RFC PATCH] UBIFS - new flash file system
Date: Mar 27, 10:55 am 2008
Dear community,
here is a new flash file system developed by Nokia engineers with
help of the University of Szeged. The new file-system is called
UBIFS, which stands for UBI file system. UBI is the wear-leveling/
bad-block handling/volume management layer which is already in
mainline (see drivers/mtd/ubi).
The main objective of UBIFS is better performance and scalability
comparing to JFFS2 which is achieved by
a) implementing write-back (JFFS2 is write-through)
b) storing and maintaining the indexing file-system information
on the media (JFFS2 maintains it in RAM and builds it on each
mount, which requires full media scanning).
At the same time, UBIFS implements the nice features JFFS2 has -
compression and tolerance to unclean re-boots. Although UBIFS
borrowed basic ideas from JFFS2, it is completely different
file-system.
UBIFS is stable and very close to be production ready. It was
tested on OLPC and N810. The development was done on flash simulator
on a 2-way x86 machine. However, UBIFS needs a good review.
Note, UBIFS works on top of UBI, not on top of bare flash devices.
It delegates crucial things like garbage-collection and bad
eraseblock handling to UBI. One important thing to note is MLC
NAND flashes which tend to have very small eraseblock lifetime -
just few thousand erase-cycles (some have even about 3000 or less).
This makes JFFS2 random wear-leveling algorithm to be not good
enough. In opposite, UBI provides good wear-leveling based on
saved erase-counters.
There is also mkfs.ubifs user-space utility, so it is possible to
prepare UBIFS images. Please, see the URLs given at the end of this
letter.
UBIFS performs quite well - it gives very good write performance
because of write-back (write tests gave us ~100 times faster
performance which is clearly because of the caching) while giving
about the same performance as JFFS2 gives on synchronous operations.
Obviously, it is extremely difficult to compete with JFFS2 on
synchronous operations because it maintains the FS index in RAM,
while UBIFS maintains it on the flash media. However, because of
many tricks and optimization implemented in UBIFS (wandering
and multi-headed journal, write-while-committing, search trees,
etc), it has very good synchronous I/O performance.
UBIFS mount time is considerably faster as well. For example,
In case of OLPC we observed 10-15 seconds faster boot time
comparing to JFFS2 (fast mount, no full media check).
UBIFS is quite complex because it is difficult to maintain
indexing information on the flash media and be fast at the same
time. Please, refer the UBIFS white paper for information
about UBIFS design.
UBIFS documentation and FAQ sections:
http://www.linux-mtd.infradead.org/doc/ubifs.html
http://www.linux-mtd.infradead.org/faq/ubifs.html
UBIFS white-paper:
http://www.linux-mtd.infradead.org/doc/ubifs_whitepaper.pdf
Since UBIFS is closely related to UBI, the UBI documentation/FAQ
is also useful:
http://www.linux-mtd.infradead.org/doc/ubi.html
http://www.linux-mtd.infradead.org/faq/ubi.html
Adrian Hunter
Artem Bityutskiy
The overall diffstat:
fs/Kconfig | 3 +
fs/Makefile | 1 +
fs/fs-writeback.c | 8 +
fs/ubifs/Kconfig | 47 +
fs/ubifs/Kconfig.debug | 159 ++
fs/ubifs/Makefile | 9 +
fs/ubifs/budget.c | 822 +++++++++++
fs/ubifs/build.c | 1351 ++++++++++++++++++
fs/ubifs/commit.c | 708 +++++++++
fs/ubifs/compress.c | 264 ++++
fs/ubifs/debug.c | 1125 +++++++++++++++
fs/ubifs/debug.h | 343 +++++
fs/ubifs/dir.c | 989 +++++++++++++
fs/ubifs/file.c | 790 ++++++++++
fs/ubifs/find.c | 951 +++++++++++++
fs/ubifs/gc.c | 773 ++++++++++
fs/ubifs/io.c | 921 ++++++++++++
fs/ubifs/ioctl.c | 205 +++
fs/ubifs/journal.c | 1230 ++++++++++++++++
fs/ubifs/key.h | 507 +++++++
fs/ubifs/log.c | 769 ++++++++++
fs/ubifs/lprops.c | 1341 +++++++++++++++++
fs/ubifs/lpt.c | 2239 +++++++++++++++++++++++++++++
fs/ubifs/lpt_commit.c | 1628 +++++++++++++++++++++
fs/ubifs/master.c | 415 ++++++
fs/ubifs/misc.h | 267 ++++
fs/ubifs/orphan.c | 952 +++++++++++++
fs/ubifs/recovery.c | 1437 +++++++++++++++++++
fs/ubifs/replay.c | 1006 +++++++++++++
fs/ubifs/sb.c | 581 ++++++++
fs/ubifs/scan.c | 368 +++++
fs/ubifs/shrinker.c | 410 ++++++
fs/ubifs/super.c | 531 +++++++
fs/ubifs/tnc.c | 3483 +++++++++++++++++++++++++++++++++++++++++++++
fs/ubifs/tnc_commit.c | 1088 ++++++++++++++
fs/ubifs/ubifs-media.h | 701 +++++++++
fs/ubifs/ubifs.h | 1519 ++++++++++++++++++++
fs/ubifs/xattr.c | 587 ++++++++
include/linux/writeback.h | 1 +
39 files changed, 30529 insertions(+), 0 deletions(-)
Note, the code is quite large because of complexity and because
of great deal of comments it has. The debugging stuff also
introduces quite a few lines of code.
--
100 time improvement
Wow, a 100 time improvement. Nice!
UBIFS stands for
UBIFS stands for UBI file system.
I chuckled.
Now what does UBI mean?
Now what does UBI mean?
Now what does UBI mean?
http://linux-mtd.infradead.org/doc/ubi.html
Good!
Good, I've been tired of waiting for LogFS to become usable.
How does UBI compare to YAFFS?
YAFFS is Yet Another Flash File System. It's GPLed and used in lots of devices. How does UBI compare?
How does UBI compare to YAFFS?
* YAFFS2 is production quality, has commercial support and is available under both GPL and proprietary licenses.
* A slightly patched version of YAFFS2 supports mounting in constant time, regardless of file system size. Not sure about production quality with regard to this, though.
* YAFFS2 seems to get less performance boost from caching.
* YAFFS2 depends on OOB
* YAFFS2 depends on OOB data
* YAFFS2 is NOT in mainline linux kernel (this personally big big red sign for somthing as critical as FS)
* YAFFS2 does not support compression
How does it compare to logfs
How does it compare to logfs - http://logfs.org?
I know logfs works not only on pure flash, but also on normal block devices, like USB-sticks, which are still quite expensive per GB when compared to hard disks. Compression is a major benefit here.
Au contraire, logfs only
Au contraire, logfs only works on pure flash. Well, it probably "works" on "normal" block devices, but that is far from optimal. It would mean that a lot of the work (including all the wear-levelling) is done twice. Once by LogFS and once by the flash device.
LogFS gains part of its speed by doing away with the overhead of the (hardware) abstraction layer that makes the raw flash look like a normal harddisk.
As LogFS has a much better understanding of what's going on, because it has a view of what's going on in the software layer, and it knows about the hardware characteristics. You can't have both on devices that emulate an IDE drive in hardware.
> Au contraire, logfs only
> Au contraire, logfs only works on pure flash. Well, it probably "works" on "normal" block > devices, but that is far from optimal.
Well, you contradict yourself here :)
For block devices like USB-stick the main advantage would be compression. Flash/flash based devices are still much more expensive than hard disks.
> It would mean that a lot of the work (including all > the wear-levelling) is done twice.
> Once by LogFS and once by the flash device.
Which is good, because you never know how well wear-levelling is implemented in your USB-stick or IDE-flash disk. Probably not that great.
Consider this: you have a SAN device which starts off IDE-flash disk. To improve RAID performance, bitmap file for RAID is kept on this IDE-flash disk. As the bitmap file is constantly updated, it will wear off the flash, possibly in one area of flash, because of weak wear-levelling implementation.
At least this is what happened for me after using bitmap file on a IDE-flash device (Transcend) - as it turns out, an area of flash died after a month or so.
With a true wear-levelling filesystem, all writes would be spread over the whole area.
See also here:
http://logfs.org/pipermail/logfs/2008-March/000039.html
> As LogFS has a much better
> As LogFS has a much better understanding of what's going on, because it has a view of what's going on in the software layer
UBI does not hide flash hardware nature, so UBIFS has the same level of "understanding". UBI has nothing to do with FTL, which does hide the real nature of flash.
Much use?
As I understand it, most flash devices on the market today hide the wear-levelling behind their block-device interface (USB, SATA etc), the expectation being that you treat them just like a conventional disk, and put a conventional filesystem (ext3, FAT etc) on them.
So is there much scope left these days for a filesystem that wants to handle the wear-levelling itself?
Yes. Embedded devices that
Yes. Embedded devices that have a NAND chip tacked onto the bus(or separate NAND controller). And there are A LOT of them.
Those embedded SOCs hooked
Those embedded SOCs hooked directly up to a NAND chip (through a dedicated controller doing ECC, or otherwise) may well be the primary way NAND gets used. USB sticks, or NAND disks, are the exception to the rule.
Take apart your cell phone and that's what you'll see: a SOC, a RAM chip, increasingly a NAND chip not NOR (maybe those three are stacked so they only look like one chip), a radio. A power management chip. Rarely much more in terms of LSI/VLSI.
Flash in the embedded world
Yeah, we embedded weenies *really* want something that performs better than JFFS2, both at mount time (because that affects the time from power on until the user sees the system is actually alive) as well as during normal I/O. I'm thrilled to see an upswing of interest in getting more and better offerings in the flash interface and flash filesystem area.