Skip to contentSkip to conversation

UBI: Unsorted Block Images

PATCH In review Artem Bityutskiy 11 participants 88 messages Mar 14, 2007 – Mar 26, 2007 Page 2 of 2

Subsystems (3)
lore
Share & tools
lore
#61 lore raw
In reply to Matt Mackall
Quoted 8 lines · Matt Mackall
Quoted 7 lines
Quoted 4 lines

If a static volume is simply a non-dynamic volume, then device mapper can do that too. And countless other things. Which is not an aside. UBI growing to do all the things that device mapper does is exactly the thing we should be seeking to avoid.

No it can't and device mapper sits on top of block devices. FLASH is no block device. Period.

Quoted 7 lines

Which of the following two properties does it lack?

- discrete blocks
- non-sequential access to blocks

When you do the obvious s/blocks/eraseblocks/, this appears to be true.

It appears to be, but it is not. You enforce semantics on a device, which it does not have.

Quoted 2 lines

Saying "but I can't do I/O smaller than the blocksize" doesn't change this any more than it would for disks.

There is a huge difference. Disk block size is 512 byte and FLASH block size is min 16KiB and up to 256KiB.

Just do the math:

Write sampling data streams in 2KiB chunks to your uber devicemapper on a 1GiB device with 64KiB erase block size:

Fine grained FLASH aware writes allow 32 chunks in a block without erasing the block.

Your method erases the block 32 times to write the same amount of data.

Result: You wear out the flash 32 times faster. Cool feature.

Quoted 2 lines

Saying "but I can do smaller I/O efficiently in some circumstances" also doesn't change it.

We can do it under _any_ circumstances and that _does_ change it. Implementing a clever block device layer on top of UBI is simple and would provide FLASH page sized I/O, i.e. 2Kib in the above example.

Quoted 2 lines

In historical UNIX, some tapes were block devices too. Because they supported seek().

I'm impressed. How exactly are "some tapes" comparable to FLASH chips ?

Your next proposal is to throw away MTD-utils and use "mt" instead ?

Quoted 5 lines
Quoted 5 lines

Device mapper can not provide a simple easy to decode scheme for boot loaders. We need to be able to boot out of 512 - 2048 byte of NAND FLASH and be able to find the kernel or second stage boot loader in this unordered device.

Quoted 7 lines
Quoted 2 lines

And no, fixed addresses do not work. Do you want to implement device mapper into your Initialial Bootloader stage ?

This is exactly the same problem as booting on a desktop PC. But somehow LILO manages. My first Linux box had a hell of a lot less disk than the platform I bootstrapped (and wrote NAND drivers for) last month had in NAND.

No, it is not. You get the absolute sector address of your second stage and this is a complete nobrainer. The translation is done in the DISK device.

You simply ignore the fact, that inside each disk, USB Stick, CF-CARD, whatever - there is a more or less intellegent controller device, which does the mapping to the physical storage location. There is _NO_ such thing on a bare FLASH chip.

It does not matter, whether your embedded device had more NAND space than my old CP/M machines floppy. It simply matters, that even the old CP/M floppy device had some rudimentary intellence on board.

Furthermore I want to be able to get the bitflip correction on my second stage loader / kernel in the same safe way as we do it for everything else and still be able to bootstrap that from an extremly small bootloader.

Quoted 10 lines
Quoted 6 lines
Quoted 3 lines

If the right way is instead to extend the block layer and device mapper to encompass the quirks of NAND in a sensible fashion, then UBI should not go in.

No, block layer on top of FLASH needs 80% of the functionality of UBI in the first place.

Incorrect. A block-based filesystem on top of flash needs this functionality. But a block device suitable to device mapper layering (which then provides the functionality) does not.

How exactly does device mapper:

A) across device wear levelling ?
B) dynamic partitioning for FLASH aware file systems ?
C) across device wear levelling for FLASH aware file systems ?
D) background bit-flip corrections (copying affected blocks and recylce the old one) ?
E) allow position independent placement of the second stage bootloader ?

Quoted 6 lines
Quoted 4 lines

You need to implement a clever journalling block device emulator in order to keep the data alive and the FLASH not weared out within no time. You need the wear levelling, otherwise you can throw away your FLASH in no time.

And that's why it's in my picture.

Yes, it is in your picture, but:

1) it excludes FLASH aware file systems and UBI does not.
2) your picture does still not explain how it does achive the above A), B), C), D) and E)

Your extra path for partitioning(4) and JFFS2 is just a weird hack, which makes your proposal completely absurd.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Let me draw a picture so we have something to argue about:

                     iSCSI/nbd(6)
                          |
filesystem {        swap  |  ext3        ext3     jffs2
                      \   |   |            |       /
               /       \  | dm-crypt->snapshot(5) /
device mapper -|        \ \   |                  /
               |         partitioning           /
               |              |          partitioning(4)
               |        wear leveling(3)  /
               |              |          /
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

| block concatenation
| | | | |
\ bad block remapping(2)
| | | |
MTD raw block { raw block devices with no smarts(1)

                      /     |     \      \
hardware {         NAND    NAND   NAND   NAND

Notes:

Let me draw an UBI picture:

VFS -Layer
|
(Future VFS-crypto)
/ \
| |
______ device mapper / fs |
/ | |
/ | |
| Do whatever you don't |
| want to do with FLASH |
| whether it makes sense |
| or not. |
| | |
Block layer UBI block device Flash aware filesystems
| \ /
device \ /

   driver                      |
     |                         |
_____|_______                  |
|           |                  |
| Device    |                 UBI
| resident  |                  |
| "UBI"     |                  |
|___________|                  |
                               |                     

MTD-CORE
|
nand base driver
/ | \
device driver device driver device driver
| |
NAND NAND NAND

No notes: it's simple and self explaining.

Quoted 12 lines
Quoted 12 lines
Quoted 3 lines

1. This would provide a block device that allowed writing pages and a secondary method for erasing whole blocks as well as a method for querying/setting out of band information.

Forget about OOB data. OOB data is reserved for ECC. Please read the recommendations of the NAND FLASH manufacturers. NAND gets less reliable with higher density devices and smaller processes.

Quoted 3 lines

2. This would hide erase blocks either by using an embedded table or out of band info. This could stack on top of block concatenation if desired.

Quoted 7 lines
Quoted 4 lines

Hide erase blocks ? UBI does not hide anything. It maps logical eraseblocks, which are exposed to the clients to arbitrary physical eraseblocks on the FLASH device in order to provide across device wear levelling.

Sorry, I meant hiding bad blocks here. That's why this layer was labeled "bad block remapping".

Oh well, a seperate bad block remapper. And how is the logical mapping of wear levelled erase blocks done ?

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

3. This would provide wear leveling, and probably simultaneously provide relatively efficient and safe access to write sector and page-sized I/O. Below this level, things had better be comfortable with the limitations of NAND if they want to work well.

I don't see how this provides across device wear levelling.

Because the layer immediately beneath it ("block concatenation") takes N devices and presents one logical device.

And how is the wear levelling done on this logical device in devicemapper ?

How is ensured, that the wear average is maintained also across the partitions which are used by JFFS2 or other FLASH aware filesystems ?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

4. JFFS2 has its own wear-leving scheme, as do several other filesystems, so they probably want to bypass this piece of the stack.

JFFS2 on top of UBI delegates the wear levelling to UBI, as JFFS2s own wear levelling sucks.

Ok, fine. How about LogFS, then?

LogFS can easily leverage UBI's wear algorithm.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

5. We don't reimplement higher pieces of the stack (dm-crypt, snapshot, etc.).

Why should we reimplement that ?

So that you can get encryption and snapshot, etc.?

1. On top of a clever block device.

2. UBI can do snapshots by design.

3. Encryption should be done on the VFS layer and not below the filesystem layer. Doing it inside the block layer or the device mapper is broken by design.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

6. We make some things possible that simply aren't otherwise.

And this picture isn't even interesting yet. Imagine a dm-cache layer that caches data read from disks in high-speed flash. Or using dm-mirror to mirror writes to local flash over NBD or to a USB drive. Neither of these can be done 'right' in a stack split between device mapper and UBI.

Quoted 5 lines
Quoted 2 lines

Err. Implement a clever block layer on top of UBI and use all the goodies you want including device mapper.

If I wanted to have both device mapper and device mapper's little brother in my kernel, I wouldn't have started this thread.

You still did not explain how devicemapper does:

- across device wear levelling
- dynamic partitioning for FLASH aware file systems
- across device wear levelling for FLASH aware file systems
- simple boot loader support
- fine grained I/O

UBI is not devicemappers little brother. It is the software version of the silicon in a CF-CARD / USB-Stick, but it does a better job and allows clever usage of FLASH aside of enforcing eraseblock sized I/O units. Does your CF-Card / USB-Stick do that ?

Just think about the 1GiB USB stick, which would present you 64KiB I/O units instead of 2KiB ones.

Your signature is a nice intellectual signboard, but the ancient simple rule of three just tells me, that you are off by factor 32.

tglx

#41 lore raw
In reply to Matt Mackall
Quoted 10 lines · Matt Mackall
Quoted 8 lines · Artem Bityutskiy
Quoted 1 line · Matt Mackall

The issue is 14000 lines of patch to make a parallel subsystem.

Parallel system exists since very long. One is flash->SW_or_HW_FTL->all_blkdev_stuff. The other is MTD->JFFS2. Think about _why_ there are 2 of them. Hint - reliability, performance. Your ranting basically says that only the first one makes sense. This is not true.

Quoted 4 lines

A better way would be for MTD to deliver a block dev with a rich enough interface for JFFS2 to use efficiently in the first place. Yes, I know that can't be done with the current block dev layer. But that's what the source is for.

Why the hell would JFFS2 need a block device interface ?

What's the gain ?

Quoted 21 lines
Quoted 21 lines

We enhance the second branch, not the first, please, realize this. Both branches have their user base, and have always had.

Quoted 17 lines
                     iSCSI/nbd(6)
                          |
filesystem {        swap  |  ext3        ext3     jffs2
                      \   |   |            |       /
               /       \  | dm-crypt->snapshot(5) /
device mapper -|        \ \   |                  /
               |         partitioning           /
               |              |          partitioning(4)
               |        wear leveling(3)  /
               |              |          /
               |      block concatenation
               |       |    |    |     |
               \      bad block remapping(2)   
                       |    |    |     |
MTD raw block {     raw block devices with no smarts(1)
                      /     |     \      \
hardware {         NAND    NAND   NAND   NAND
Quoted 6 lines
Quoted 1 line

Matt, as I pointed in the first mail, flash != block device.

And as I pointed out, you're wrong. It is both block oriented (eraseBLOCK??) and random access. That's what a block device is. The fact that it doesn't look like the other things that Linux currently calls a block device and supports well is another matter.

It does well matter, as it is not a block device. It is a FLASH device and you can do as much comparisons of eraseBLOCK as you want, you do not turn FLASH into a DISK.

Again: Disks (including CF-Cards and USB-Sticks) have intellegent controllers, which abstract the hardware oddities away and present you a block device.

Quoted 11 lines
Quoted 3 lines

In your picture I see NAND->MTD raw block. So am I right that you assume that we already have a decent FTL? The fact is that we do not.

No. Look at the picture for more than two seconds, please.

I can tell you didn't do this because you didn't manage to find (1) which explicitly says "with no smarts". And you also cut out the footnote where I explained what I meant by "with no smarts".

Find the spots marked (2) and (3). These are your FTL.

And where please are (2) and (3) inside of device mapper ?

Quoted 5 lines
Quoted 2 lines

Please, bear in mind that decent FTL is difficult and an FS on top of FTL is slow, FTL hits performance considerably.

...and if you'd actually looked at the picture, you'd have seen JFFS2 bypassing it. Along with another footnote explaining it.

The (4) partitioning and JFFS2 on top is a step back from the current UBI functionality. Now we can have resizable partitioning even for JFFS2 and JFFS2 can utilize the UBI wear levelling, which is way better than the crude heuristics of JFFS2.

You want to force FLASH into device mapper for some strange and no obvious reason. Just the coincidence of "eraseBLOCK" and "BLOCKdevice" is not really convincing.

You impose the usage of eraseblock size on FLASH, which is simply wrong:

DISK has a 1:1 relationship of "eraseblock" and minimal I/O. FLASH has not. I did the math in a different mail and I'm not buying your factor 32 FLASH life time reduction for the price of having a bunch of lines of code less in the kernel.

If you really consider to run ext3, xfs or whatever on top of FLASH, please go and do the homework on CF-Cards and USB-Sticks. Run them into the fast wearout death. And device mapper does not help anything to avoid that. Running ext3 on top of FLASH with a minimal I/O size of erase block size is simply braindead.

tglx

#62 lore raw
In reply to Thomas Gleixner
Quoted 28 lines · Thomas Gleixner
Quoted 8 lines · Matt Mackall
Quoted 7 lines
Quoted 4 lines

If a static volume is simply a non-dynamic volume, then device mapper can do that too. And countless other things. Which is not an aside. UBI growing to do all the things that device mapper does is exactly the thing we should be seeking to avoid.

No it can't and device mapper sits on top of block devices. FLASH is no block device. Period.

Quoted 7 lines

Which of the following two properties does it lack?

- discrete blocks
- non-sequential access to blocks

When you do the obvious s/blocks/eraseblocks/, this appears to be true.

It appears to be, but it is not. You enforce semantics on a device, which it does not have.

Quoted 2 lines

Saying "but I can't do I/O smaller than the blocksize" doesn't change this any more than it would for disks.

There is a huge difference. Disk block size is 512 byte and FLASH block size is min 16KiB and up to 256KiB.

Just do the math:

Quoted 7 lines

Write sampling data streams in 2KiB chunks to your uber devicemapper on a 1GiB device with 64KiB erase block size:

Fine grained FLASH aware writes allow 32 chunks in a block without erasing the block.

Your method erases the block 32 times to write the same amount of data.

Sigh. That's the current /dev/mtdblock method, not my method. You're too fixated on what you think I'm saying to hear what I'm saying.

Quoted 6 lines
Quoted 2 lines

Saying "but I can do smaller I/O efficiently in some circumstances" also doesn't change it.

We can do it under _any_ circumstances and that _does_ change it. Implementing a clever block device layer on top of UBI is simple and would provide FLASH page sized I/O, i.e. 2Kib in the above example.

Yes. I know. I've written a complete (non-Linux) FTL. I know what's entailed.

Quoted 6 lines
Quoted 2 lines

In historical UNIX, some tapes were block devices too. Because they supported seek().

I'm impressed. How exactly are "some tapes" comparable to FLASH chips ?

Your next proposal is to throw away MTD-utils and use "mt" instead ?

Don't be an ass. I'm pointing out that not all block devices are disks.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Device mapper can not provide a simple easy to decode scheme for boot loaders. We need to be able to boot out of 512 - 2048 byte of NAND FLASH and be able to find the kernel or second stage boot loader in this unordered device.

And no, fixed addresses do not work. Do you want to implement device mapper into your Initialial Bootloader stage ?

Quoted 8 lines
Quoted 4 lines

This is exactly the same problem as booting on a desktop PC. But somehow LILO manages. My first Linux box had a hell of a lot less disk than the platform I bootstrapped (and wrote NAND drivers for) last month had in NAND.

No, it is not. You get the absolute sector address of your second stage and this is a complete nobrainer. The translation is done in the DISK device.

LILO and friends manage to boot systems that use software RAID and LVM. There are multiple methods. Some use block lists, some use tiny boot partitions, etc. All of them are applicable to controllerless NAND.

Quoted 4 lines

You simply ignore the fact, that inside each disk, USB Stick, CF-CARD, whatever - there is a more or less intellegent controller device, which does the mapping to the physical storage location. There is _NO_ such thing on a bare FLASH chip.

How many times do I have to tell you that I wrote a driver for controllerless NAND just last month?

Quoted 3 lines

How exactly does device mapper:

A) across device wear levelling ?

The same way UBI does, but encapsulated in a device mapper layer.

Quoted 1 line

B) dynamic partitioning for FLASH aware file systems ?

See above.

Quoted 1 line

C) across device wear levelling for FLASH aware file systems ?

See above.

Quoted 2 lines

D) background bit-flip corrections (copying affected blocks and recylce the old one) ?

See above.

Quoted 1 line

E) allow position independent placement of the second stage bootloader ?

See way above to my LILO response.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

You need to implement a clever journalling block device emulator in order to keep the data alive and the FLASH not weared out within no time. You need the wear levelling, otherwise you can throw away your FLASH in no time.

And that's why it's in my picture.

Quoted 8 lines

Yes, it is in your picture, but:

1) it excludes FLASH aware file systems and UBI does not.
2) your picture does still not explain how it does achive the above A), B), C), D) and E)

Your extra path for partitioning(4) and JFFS2 is just a weird hack, which makes your proposal completely absurd.

No, it's just there to show the flexibility of device mapper. But I have the sneaking suspicion you have no idea how device mapper works.

In brief: device mapper takes one or more devices, applies a mapping to them, and returns a new device. For example, take various spans of /dev/hda1 and /dev/sda3 and present them as new-device1. Take new-device1 and transform it with dm-crypt to get new-device2. The kernel doesn't decide how to do this, any more than it decides where to mount your filesystems. Userspace does.

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

5. We don't reimplement higher pieces of the stack (dm-crypt, snapshot, etc.).

Why should we reimplement that ?

So that you can get encryption and snapshot, etc.?

1. On top of a clever block device.

2. UBI can do snapshots by design.

Oh, so you HAVE reimplemented it.

Quoted 3 lines

3. Encryption should be done on the VFS layer and not below the filesystem layer. Doing it inside the block layer or the device mapper is broken by design.

That's highly debatable and not a topic for this thread.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#63 lore raw
Quoted 7 lines · Matt Mackall
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Matt Mackall

This is exactly the same problem as booting on a desktop PC. But somehow LILO manages. My first Linux box had a hell of a lot less disk than the platform I bootstrapped (and wrote NAND drivers for) last month had in NAND.

Quoted 7 lines
Quoted 3 lines

No, it is not. You get the absolute sector address of your second stage and this is a complete nobrainer. The translation is done in the DISK device.

LILO and friends manage to boot systems that use software RAID and LVM. There are multiple methods. Some use block lists, some use tiny boot partitions, etc. All of them are applicable to controllerless NAND.

Yes, by using fixed addresses, which is not what I want.

Quoted 7 lines
Quoted 4 lines

You simply ignore the fact, that inside each disk, USB Stick, CF-CARD, whatever - there is a more or less intellegent controller device, which does the mapping to the physical storage location. There is _NO_ such thing on a bare FLASH chip.

How many times do I have to tell you that I wrote a driver for controllerless NAND just last month?

Wow. I'm impressed because I'm pulling my opinion out of thin air.

Quoted 5 lines
Quoted 3 lines

How exactly does device mapper:

A) across device wear levelling ?

The same way UBI does, but encapsulated in a device mapper layer.

Does the device mapper do that ?

Quoted 3 lines
Quoted 1 line

B) dynamic partitioning for FLASH aware file systems ?

See above.

Does the device mapper do that ?

Quoted 3 lines
Quoted 1 line

C) across device wear levelling for FLASH aware file systems ?

See above.

Look at your own drawing.

Quoted 4 lines
Quoted 2 lines

D) background bit-flip corrections (copying affected blocks and recylce the old one) ?

See above.

Repeating patterns do not impress me. Your drawing tells otherwise

Quoted 3 lines
Quoted 1 line

E) allow position independent placement of the second stage bootloader ?

See way above to my LILO response.

Neither LILO nor GRUB have search capabilities for randomly located second stage loaders.

Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
Quoted 4 lines

You need to implement a clever journalling block device emulator in order to keep the data alive and the FLASH not weared out within no time. You need the wear levelling, otherwise you can throw away your FLASH in no time.

And that's why it's in my picture.

Yes, it is in your picture, but:

1) it excludes FLASH aware file systems and UBI does not.
2) your picture does still not explain how it does achive the above A), B), C), D) and E)

Quoted 5 lines
Quoted 2 lines

Your extra path for partitioning(4) and JFFS2 is just a weird hack, which makes your proposal completely absurd.

No, it's just there to show the flexibility of device mapper. But I have the sneaking suspicion you have no idea how device mapper works.

Sigh. Layering violation == flexibility.

Quoted 6 lines

In brief: device mapper takes one or more devices, applies a mapping to them, and returns a new device. For example, take various spans of /dev/hda1 and /dev/sda3 and present them as new-device1. Take new-device1 and transform it with dm-crypt to get new-device2. The kernel doesn't decide how to do this, any more than it decides where to mount your filesystems. Userspace does.

I know how it works. But your blurb does not answer any of my questions.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

5. We don't reimplement higher pieces of the stack (dm-crypt, snapshot, etc.).

Why should we reimplement that ?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

So that you can get encryption and snapshot, etc.?

1. On top of a clever block device.

2. UBI can do snapshots by design.

Oh, so you HAVE reimplemented it.

No, it already works

Quoted 5 lines
Quoted 3 lines

3. Encryption should be done on the VFS layer and not below the filesystem layer. Doing it inside the block layer or the device mapper is broken by design.

That's highly debatable and not a topic for this thread.

I see, you define, what has to be discussed.

tglx

#84 lore raw
In reply to Matt Mackall
Quoted 9 lines · Matt Mackall

False starts that get mainlined delay or prevent things getting done right. The question is and remains "is UBI the right way to do things?" Not "is UBI the easiest way to do things?" or "is UBI something people have already adopted?"

If the right way is instead to extend the block layer and device mapper to encompass the quirks of NAND in a sensible fashion, then UBI should not go in.

This is where we disagree obviously. However, getting UBI into mainline won't delay or prevent your proposal from getting done. That's like saying having ext3 in mainline prevents other filesystems from getting created. There is nothing wrong with having different subsystems that overlap in a few areas.

What you're proposing seems like it would take at least several weeks to even get close to what is needed in terms of reliability and the required wear-leveling if it is indeed possible to implement. And it would likely duplicate some of the wear-leveling and bad block handling code that is present in UBI anyway. In the meantime, the need for UBI exists today and there is a working, tested implementation available.

josh

#42 lore raw
In reply to Matt Mackall
Quoted 10 lines
                     iSCSI/nbd(6)
                          |
filesystem {        swap  |  ext3        ext3     jffs2
                      \   |   |            |       /
               /       \  | dm-crypt->snapshot(5) /
device mapper -|        \ \   |                  /
               |         partitioning           /
               |              |          partitioning(4)
               |        wear leveling(3)  /
Quoted 8 lines
               |              |          /
               |      block concatenation
               |       |    |    |     |
               \      bad block remapping(2)   
                       |    |    |     |
MTD raw block {     raw block devices with no smarts(1)
                      /     |     \      \
hardware {         NAND    NAND   NAND   NAND

You failed to clearly define what is block until now, then you blame me that I do not understand you. So I see block = eraseblock, lets assume for further conversation.

OK. Suppose we have done what you say, although I _do not_ think it is makes a lot of sense. So, now we have a block device, with 128KiB block size. We have LVM, dm-wl or whatever stuff. Fine.

Do you realize that 128KiB is _huge_ block size, and performance will suck, and suck a lot if you utilize say, ext2 or whatever block device FS.

Do you realize that I may not be satisfied with slow I/O? Do I have right to have faster one? Thanks if yes.

To make it faster I have to have a way to do finer grained I/O:
read/write to different positions of 128KiB block. Do you realize how much you will abuse all the generic block device infrastructure if you try to add this? Note, all levels up to LVM will need to have this. A believe it is braindead ((c) tglx) to add this feature.

Also, in UBI we have the following features:
1. data type hints: you basically may help UBI to pick optimal eraseblock if you specify data life-time - is it long-live data, or short-live/temporary data.
2. Some other ones, do not want to describe now.

Do you offer to add this stuff to DM-mapper?

So, you approach only makes sense if you are going to work with flash as block device with block size = eraseblock size. No finer grained access at all. It is fine, some users may be ok with this. But please, do not be so naive - the performance will suck a _lot_. Let alone I doubt it will really fit the DM infrastructure.

We work on different approach. And in general, the picture which Thomas drew to you makes _much more_ sense. Please, do not be so stuck to your way, it is not bad or good, it is just _different_, and it has obvious limitations which we do not want to have, thus we go other way.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#43 lore raw
Quoted 11 lines · Artem Bityutskiy

You failed to clearly define what is block until now, then you blame me that I do not understand you. So I see block = eraseblock, lets assume for further conversation.

OK. Suppose we have done what you say, although I _do not_ think it is makes a lot of sense. So, now we have a block device, with 128KiB block size. We have LVM, dm-wl or whatever stuff. Fine.

Do you realize that 128KiB is _huge_ block size, and performance will suck, and suck a lot if you utilize say, ext2 or whatever block device FS.

As a suggestion, let's stop right here and see if we can get both sides talking in a more constructive fashion. Maybe it's just me, but I see both sides talking past each other in a rather dramatic fashion.

Linux seems to allow multiple implementations of things at the edge (such as filesystems), but not at the core (devicemapper when in, device mapper didn't; it's unlikely that we would have two competing block device layers or two VFS layers, etc.). The question then is whether UBI and dm are close enough or not that should be one subsystem or not.

There a number of red herrings that have been introduced in this discussion; of *course* the existing block device layer can handle FLASH devices; Matt is proposing that they be extended. And of *course* you woulnd't propose to use ext2 on top of an 128k blocksize, anymore than you would force a flash filesystem to use a 4k or 512 byte blocksize; there are plenty of configurations that won't make sense, and by itself this isn't an indictment of the core idea that the block device layer and dm should be augmented to encompass flash functionality.

As far as who gets to do the work, unfortunately sometimes the people submitting the new code have to make the changes suggested by the reviewer. That's one of the prices that gets paid for mainline inclusion. It's different when someone asks for a completely new feature, especially for code that is already in mainline; then, "feel free to send a patch" is perfectly accepted. But if it's a matter of refactoring the code to fit in some other framework, that's often up to the submitter to do, not the reviewer.

Of course, it remains to be seen whether or not this is a good idea to do in the first place; but some of the arguments being used to shoot down Matt's suggestion aren't really good ones to begin with.

Quoted 5 lines

To make it faster I have to have a way to do finer grained I/O:
read/write to different positions of 128KiB block. Do you realize how much you will abuse all the generic block device infrastructure if you try to add this? Note, all levels up to LVM will need to have this. A believe it is braindead ((c) tglx) to add this feature.

OK, and this could be it. But I suspect one of the things which may be missing that make it easier for you to explain why what UBI is doing is so different from the dm and block device stack is to include the contents of:

http://www.linux-mtd.infradead.org/faq/ubi.html
http://www.linux-mtd.infradead.org/doc/ubi.html

and some system level documentation in a Documentation/ubi.txt file as part of the patch set. I don't think people completely understand the high-level architecture of what UBI is trying to achieve. What are the interfaces at the top and the bottom of the stack? For example, the fact that UBI exports Logical Erase blocks that are not a power-of-two (possibly 128k minus 128 bytes) means that it certainly might not be a good match for the dm stack. But why is that the case? I can imagine good reasons for it, but a high-level description of the design decisions would be very useful.

It would also help people understand why there are so many "units" in UBI, since hopefully the high-level documentation would explain why they fit together, and perhaps why some of the units weren't folded together. What value do they add as separate components?

There are hints of the overall system architecture in some of the indivdual comments for data structures, but even reading all of those, there isn't quite enough for people to figure out what it is; and that may be causing some of these comments of people saying there's too much code to evaluate, or why didn't you do it *this* way?

Regards,

- Ted

#44 lore raw
Quoted 4 lines · Theodore Tso

It would also help people understand why there are so many "units" in UBI, since hopefully the high-level documentation would explain why they fit together, and perhaps why some of the units weren't folded together. What value do they add as separate components?

Teo, the units will go away. I'll leave only 4 of them:

1. I/O, just to hide some I/O related complexities.
2. Scanning: just because I am planning to add other device attaching methods, without scanning.
3. Wear-leveling, just because I want to improve the algorithm in future. Changing algorithm means changing data structures. So I want to keeps them separate.
4. EBA - because I want to keep all mapping-related stuff in one place. Well, this does not have to be called unit, just mapping-related code in on file. Also, long-term is to have the table on-flash (currently it is in-ram which does not scale well).

Everything else will be folded together. No itsy-bitsy. I've almost finished this re-structuring, doing bug-fixing.

P.S.: I'll let other folks to comment the other stuff.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#45 lore raw
In reply to Theodore Tso
Quoted 3 lines · Theodore Tso

As a suggestion, let's stop right here and see if we can get both sides talking in a more constructive fashion. Maybe it's just me, but I see both sides talking past each other in a rather dramatic fashion.

Perhaps, yes. Though I've been trying to be open to Matt's suggestions. Please don't mistake confusion for hostility.

Quoted 3 lines

There a number of red herrings that have been introduced in this discussion; of *course* the existing block device layer can handle FLASH devices; Matt is proposing that they be extended. And of

Sure. But the larger question is *should* it be extended to do so.

Quoted 3 lines

*course* you woulnd't propose to use ext2 on top of an 128k blocksize, anymore than you would force a flash filesystem to use a 4k or 512 byte blocksize; there are plenty of configurations that won't make

Except that flash filesystems don't use block devices at all. They use MTD interfaces.

Quoted 3 lines

sense, and by itself this isn't an indictment of the core idea that the block device layer and dm should be augmented to encompass flash functionality.

This is where the concept starts to lose me. Augmented how? To not use MTD at all (obviously with the exception of the low-level flash drivers)? How is that not going to duplicate MTD? Etc, etc.

Look at it from this point of view. MTD is the existing interface for dealing with flash devices. UBI was written to solve issues with flash devices. UBI was written on top of MTD. Suggesting that the UBI developers go off and hack the block layer to work with flash devices just to use dm seems completely foreign. Most of the boards UBI is used on disable the block layer as much as they can because it's not needed.

This is the biggest source of confusion/contention. Making the somewhat magical jump to representing flash as a block device without a bit more detail as to how it's going to really cope with the requirements needed for flash and why it's a great idea to do so is a bit hard to swallow. Discussing the device mapper extensions is sort of pointless until this is figured out.

Quoted 7 lines

high-level architecture of what UBI is trying to achieve. What are the interfaces at the top and the bottom of the stack? For example, the fact that UBI exports Logical Erase blocks that are not a power-of-two (possibly 128k minus 128 bytes) means that it certainly might not be a good match for the dm stack. But why is that the case? I can imagine good reasons for it, but a high-level description of the design decisions would be very useful.

Basically because you need to store metadata in each eraseblock (and not in OOB). That metadata consumes space reducing the usable storage in each eraseblock by an amount and making it no longer a power-of-two.

Quoted 4 lines

It would also help people understand why there are so many "units" in UBI, since hopefully the high-level documentation would explain why they fit together, and perhaps why some of the units weren't folded together. What value do they add as separate components?

Artem is reworking the units per your (and other's) suggestions. The debugging code is also being worked on.

Quoted 5 lines

There are hints of the overall system architecture in some of the indivdual comments for data structures, but even reading all of those, there isn't quite enough for people to figure out what it is; and that may be causing some of these comments of people saying there's too much code to evaluate, or why didn't you do it *this* way?

Some of that can probably be added, sure. Though to be fair, it'll add even more lines to the patch and those links have been posted 4 times already. They're even posted at the start of _this_ thread. Having it in the patch under Documentation/ is a good idea, but you can't force people to read that before they comment on things.

josh

#46 lore raw
Quoted 21 lines · Josh Boyer
Quoted 3 lines · Theodore Tso

As a suggestion, let's stop right here and see if we can get both sides talking in a more constructive fashion. Maybe it's just me, but I see both sides talking past each other in a rather dramatic fashion.

Perhaps, yes. Though I've been trying to be open to Matt's suggestions. Please don't mistake confusion for hostility.

Quoted 3 lines

There a number of red herrings that have been introduced in this discussion; of *course* the existing block device layer can handle FLASH devices; Matt is proposing that they be extended. And of

Sure. But the larger question is *should* it be extended to do so.

Quoted 3 lines

*course* you woulnd't propose to use ext2 on top of an 128k blocksize, anymore than you would force a flash filesystem to use a 4k or 512 byte blocksize; there are plenty of configurations that won't make

Except that flash filesystems don't use block devices at all. They use MTD interfaces.

Quoted 7 lines
Quoted 3 lines

sense, and by itself this isn't an indictment of the core idea that the block device layer and dm should be augmented to encompass flash functionality.

This is where the concept starts to lose me. Augmented how? To not use MTD at all (obviously with the exception of the low-level flash drivers)? How is that not going to duplicate MTD? Etc, etc.

What Matt and Ted are looking at is the question 'are flash devices close enough to other block devices that it would make sense to change the existing linux definition of a block device to handle the special requirements of flash'

if the block device layer can be reasonably modified to accomodate flash, then doing so greatly improves flexibility and maintainability. It would also reduce the overall code size since existing features of the block layer (for example snapshots) would not need to be duplicated or re-written for the flash block layer.

if not then so be it.

everyone understands that flash has different requirement from a hard drive as a block device, what isn't clear to the people reading this thread (and reviewing the code) is why you believe that it is _so_ different that it's impossible to consider extending the linux definition of a block device.

the fact that the native eraseblock size is significantly larger isn't a factor.

the fact that you erase in large blocks and then write in smaller blocks is a difference, and one that the current block layer doesn't understand. but this is a difference that the current block layer could be changed to understand. it's not something that would justify a seperate-but-equal block layer for flash devices.

as Ted notes, the idea that block sizes may not be powers of 2 (128k-128b from his e-mail) _may_ end up being a big enough difference that it's not worth teaching the exising block layer how to deal with, but it's not clear why you are useing this odd size.

this is why you are being asked for further explinations.

David Lang

#47 lore raw
Quoted 5 lines · David Lang

the fact that you erase in large blocks and then write in smaller blocks is a difference, and one that the current block layer doesn't understand. but this is a difference that the current block layer could be changed to understand. it's not something that would justify a seperate-but-equal block layer for flash devices.

I am _not_ an block device layer expert. But I think it is silly idea to abuse it adding a possibility of reading/writing from/to the middle of the block. Isn't it obvious that the fact that block is _minimal_ I/O unit is _deep_ inside the design???

We also need few other features as well, like data life-time hints to help the wear-leveling engine to pick optimal eraseblock. And there are more features we need to have. Do you want to add all those to block device infrastructure?

Thomas wrote about how one can reuse all block device goodies, like LVM, FSes etc. He drew a picture, just roll back and glance. This makes much more sense.

Guess why we still do not have a decent FTL? Because it is _difficult_. Now, when we have UBI one can implement FTL much, much easier. It becomes really possible now. Because UBI already hides many complexities of flash, and FTL layer should not care about many things. It may concentrate on FTL problems, for example on a smart garbage collector, which is also a difficult thing. Also, with UBI, for example, the FTL layer may store on-flash tables with block mappings, because UBI takes care of wear-leveling. I mean, FTL may update those tables as may times as it want, without caring that corresponding eraseblocks go worn-out.

After we have implemented FTL, we can re-use all the block device infrastructure - LVM, dm-crypt, ext3 and 4, and so on. This does make sense. And this is at Thomas's picture.

So please, look at UBI as a low-level layer just which hides flash complexities like wear and bad blocks. It also does write-failure recovery automatically - this is very important feature. These are essentially the features which makes our life horrible, and UBI kicks them out. I am not a newbie in the area and I know how difficult is it to develop on top of a raw flash. Yes, it allows creating volumes, but this is not the main feature of it. It gust goes naturally.

And one note: UBI is flash type independent, so you can use it on top of NOR/NAND/DataFlash/AG-AND/ECCd NOR and so on, as long as MTD support exists. For example, we do not use OOB at all. I write it just because Matt always used NAND as an example, just for clarification.

Quoted 4 lines

as Ted notes, the idea that block sizes may not be powers of 2 (128k-128b from his e-mail) _may_ end up being a big enough difference that it's not worth teaching the exising block layer how to deal with, but it's not clear why you are useing this odd size.

Eraseblock size is power of 2. We store the erase counter (needed for wear-levelling) and logical to physical eraseblock mapping in each eraseblock. Thus, we reduce the size.

We do not want to have any on-flash table, because we end up with a chicken-and-egg problem: the tables are updated often, so they cannot sit in fixed eraseblocks. They should constantly change position to ensure wear-leveling. This is very difficult and less robust.

Quoted 1 line

this is why you are being asked for further explinations.

Although we do not have shiny documentation, but all _essential_ are explained in the existing, not shiny one, so those really interested could find this there. I mean, if one does not know much about the area, and does not spend time to explore it, we cannot really help. But anyway, we will try to write better docs, it just a question of time.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
maintainer
#50 lore raw
In reply to David Lang
Quoted 3 lines · David Lang

What Matt and Ted are looking at is the question 'are flash devices close enough to other block devices that it would make sense to change the existing linux definition of a block device to handle the special requirements of flash'

I've seen no real proposals about how this could be done, so it's a purely academic question. But I'm dubious. The block layer is optimised, perhaps unsurprisingly, for block devices. Making it handle our special case might be possible, but I don't really think it's likely to fly once it becomes real code and not just mental self-abuse. Hell, we haven't even got block _discard_ support merged yet, because it's too esoteric for people to care about.

The MTD API does need to be re-thought. It's no longer quite so unthinkable that we'll encounter flash sizes above 4GiB, and the way we (theoretically) handle asynchronous erases while read and write are synchronous is a bit icky. I'm not averse to using queues and making it look a _bit_ like block devices in some respects, but in practice I don't think it'll be very close at all.

The MTD API is intended to represent the raw capabilities of the underlying flash devices, with all the bizarre restrictions and features that the various types of flash chip have. If you want to use it as a block device, that's what translation layers are for.

Signature · 1 line
dwmw2
maintainer
#48 lore raw
In reply to Artem Bityutskiy
Quoted 2 lines · Artem Bityutskiy

Guess why we still do not have a decent FTL? Because it is _difficult_.

No. We don't have a decent FTL because it's _pointless_. We've got basic implementations of FTL, NFTL, INFTL etc. for compatibility with PCMCIA stuff and DiskOnChip, but the fact remains that pretending to be a normal block device with atomically-overwritten 512-byte sectors is just _stupid_. You end up implementing a kind of pseudo-filesystem to do that, and then on top of that you put a 'normal' filesystem with no real knowledge about what's underneath. It's crap -- and as we currently have it, the top level file system doesn't even get to tell the underlying FTL that a given block can be discarded because it's no longer used. So during garbage collection the FTL even ends up copying crap around the medium that's no longer relevant.

This isn't DOS. We don't have to make our storage available through the restricted interface that INT 13h offers us. We can, and do, do better than that. And that's why we don't have a decent FTL implementation.

Signature · 1 line
dwmw2
#52 lore raw
In reply to Josh Boyer
Quoted 1 line · Josh Boyer

Sure. But the larger question is *should* it be extended to do so.

Absolutely, and so let's focus on that.

Quoted 2 lines

Except that flash filesystems don't use block devices at all. They use MTD interfaces.

Yes, so that would be first issue. We would need to change the flash filesystems to the block interface issue, and expand the block device to use MTD. Now, maybe Matt is conversant about what would be involved to do this, but I will admit to being MTD ignorant. But if that's there is a huge impendance mismatch right there, that that might be enough to kill it right there.

Quoted 11 lines
Quoted 7 lines

high-level architecture of what UBI is trying to achieve. What are the interfaces at the top and the bottom of the stack? For example, the fact that UBI exports Logical Erase blocks that are not a power-of-two (possibly 128k minus 128 bytes) means that it certainly might not be a good match for the dm stack. But why is that the case? I can imagine good reasons for it, but a high-level description of the design decisions would be very useful.

Basically because you need to store metadata in each eraseblock (and not in OOB). That metadata consumes space reducing the usable storage in each eraseblock by an amount and making it no longer a power-of-two.

So this is probably a stupid question, but what drives the design decision to store the metadata in-band instead of out-of-band (and you don't have to answer me here; putting it in the overall system architecture document is just as good, and probably better. :-)

Quoted 7 lines
Quoted 4 lines

It would also help people understand why there are so many "units" in UBI, since hopefully the high-level documentation would explain why they fit together, and perhaps why some of the units weren't folded together. What value do they add as separate components?

Artem is reworking the units per your (and other's) suggestions. The debugging code is also being worked on.

As I mentioned to you in IRC, in the future if there is pending changes in response to reviewer comments, it might be a good idea to mention that, so that reviewers know not make those comments again, or worry that the comments had been ignored.

Quoted 11 lines
Quoted 5 lines

There are hints of the overall system architecture in some of the indivdual comments for data structures, but even reading all of those, there isn't quite enough for people to figure out what it is; and that may be causing some of these comments of people saying there's too much code to evaluate, or why didn't you do it *this* way?

Some of that can probably be added, sure. Though to be fair, it'll add even more lines to the patch and those links have been posted 4 times already. They're even posted at the start of _this_ thread. Having it in the patch under Documentation/ is a good idea, but you can't force people to read that before they comment on things.

Well, having spent some time looking at the FAQ's and all of the comments kernel docs embedded in the header files and source files, there are sections that I would move to an overall system architecture documentation, but there is still a lot that was missing that makes it hard to review the patches. I'm sure a lot of it is my own ignorance, but that's probably one of the challenges with the UBI layer; not as more people have a basic background in say say scheduling or VM or filesystem than there are people who have a basic background in flash devices.

Regards,

- Ted

#53 lore raw
Quoted 4 lines · Theodore Tso

So this is probably a stupid question, but what drives the design decision to store the metadata in-band instead of out-of-band (and you don't have to answer me here; putting it in the overall system architecture document is just as good, and probably better. :-)

Because
a. Many flashes have no out-of-band. We want to support them as well b. Modern MLC NAND flashes use _whole_ OOB for ECC and this is the modern trend.

I will update FAQ and add this there later.

Quoted 4 lines

As I mentioned to you in IRC, in the future if there is pending changes in response to reviewer comments, it might be a good idea to mention that, so that reviewers know not make those comments again, or worry that the comments had been ignored.

Teo, I wrote you 2 times that your point was understood and this would be fixed. You should not think your comments are ignored because they are not.

Quoted 9 lines

Well, having spent some time looking at the FAQ's and all of the comments kernel docs embedded in the header files and source files, there are sections that I would move to an overall system architecture documentation, but there is still a lot that was missing that makes it hard to review the patches. I'm sure a lot of it is my own ignorance, but that's probably one of the challenges with the UBI layer; not as more people have a basic background in say say scheduling or VM or filesystem than there are people who have a basic background in flash devices.

Docs and FAQ will be improved, this is a question of time.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#49 lore raw
In reply to David Woodhouse
Quoted 16 lines · David Woodhouse
Quoted 2 lines · Artem Bityutskiy

Guess why we still do not have a decent FTL? Because it is _difficult_.

No. We don't have a decent FTL because it's _pointless_. We've got basic implementations of FTL, NFTL, INFTL etc. for compatibility with PCMCIA stuff and DiskOnChip, but the fact remains that pretending to be a normal block device with atomically-overwritten 512-byte sectors is just _stupid_. You end up implementing a kind of pseudo-filesystem to do that, and then on top of that you put a 'normal' filesystem with no real knowledge about what's underneath. It's crap -- and as we currently have it, the top level file system doesn't even get to tell the underlying FTL that a given block can be discarded because it's no longer used. So during garbage collection the FTL even ends up copying crap around the medium that's no longer relevant.

Quoted 3 lines

This isn't DOS. We don't have to make our storage available through the restricted interface that INT 13h offers us. We can, and do, do better than that. And that's why we don't have a decent FTL implementation.

While I agree with you, I still think decent FTL (a) makes sense and is
(b) difficult.

a. Some people may be satisfied with FTL and enjoy all the block device-related software, which is huge benefit, although costs you performance. Yes, FTL moves garbage around, but who cares as long as the performance fits the system requirements.

b. It is certainly not easy.

But anyway, I agree with what you say, although you seem to be too assertive.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#64 lore raw
In reply to Thomas Gleixner
Quoted 11 lines · Thomas Gleixner
Quoted 7 lines · Matt Mackall
Quoted 5 lines
Quoted 2 lines

4. JFFS2 has its own wear-leving scheme, as do several other filesystems, so they probably want to bypass this piece of the stack.

JFFS2 on top of UBI delegates the wear levelling to UBI, as JFFS2s own wear levelling sucks.

Ok, fine. How about LogFS, then?

LogFS can easily leverage UBI's wear algorithm.

Ok, now we have reached the absurd. UBI quite fundamentally cannot do wear leveling as good as LogFS can. Simply because UBI has zero knowledge of the _contents_ of its blocks. Knowing whether a block is 90% garbage or not makes a great difference.

Also LogFS currently requires erasesizes of 2^n.

Thomas, I can give you my opinion on this flamewar in private - after you have cooled off.

Jörn

Signature · 4 lines
When I am working on a problem I never think about beauty.  I think
only how to solve the problem.  But when I have finished, if the
solution is not beautiful, I know it is wrong.
-- R. Buckminster Fuller
#65 lore raw
Quoted 11 lines · Jörn Engel
Quoted 10 lines · Thomas Gleixner
Quoted 7 lines · Matt Mackall
Quoted 5 lines
Quoted 2 lines

4. JFFS2 has its own wear-leving scheme, as do several other filesystems, so they probably want to bypass this piece of the stack.

JFFS2 on top of UBI delegates the wear levelling to UBI, as JFFS2s own wear levelling sucks.

Ok, fine. How about LogFS, then?

Quoted 8 lines
Quoted 1 line

LogFS can easily leverage UBI's wear algorithm.

Ok, now we have reached the absurd. UBI quite fundamentally cannot do wear leveling as good as LogFS can. Simply because UBI has zero knowledge of the _contents_ of its blocks. Knowing whether a block is 90% garbage or not makes a great difference.

Also LogFS currently requires erasesizes of 2^n.

Last time I talked to you about that, you said it would be possible and fixable. We talked about several mechanisms, which would allow a filesystem or other users to hint such things to UBI.

Even if the LogFS wear levelling is so superior, it CAN'T do across device wear levelling.

tglx

#66 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 6 lines · Jörn Engel

Ok, now we have reached the absurd. UBI quite fundamentally cannot do wear leveling as good as LogFS can. Simply because UBI has zero knowledge of the _contents_ of its blocks. Knowing whether a block is 90% garbage or not makes a great difference.

Quoted 5 lines
Quoted 1 line

Also LogFS currently requires erasesizes of 2^n.

Last time I talked to you about that, you said it would be possible and fixable. We talked about several mechanisms, which would allow a filesystem or other users to hint such things to UBI.

Note the word "currently". And yes, we did talk about hints. Back then I still believed in UBI. That has changed and I would like to spare myself another flamewar, so please leave it at that.

Quoted 2 lines

Even if the LogFS wear levelling is so superior, it CAN'T do across device wear levelling.

Correct. And I don't see any problem with this. I see two classes of usecases for flash, with some amount of overlap in between.

1. Small amounts of flash.

Here the flash contains a large ratio of read-only data. Bootloader, kernel, etc. Having wear levelling across the device will gain you something. This is what you designed UBI for.

2. Large amounts of flash.

Just to be precise, large can go well into the Terabyte range and beyond. I don't mean large as in "the biggest embedded device I worked on last year" - that is still small.

Even if such flashes still contain a bootloader and a kernel, that will occupy less than 1% of the device. Wear leveling across the device is fairly pointless here. This is what I designed LogFS for.

There is some middle ground where a combination of UBI and LogFS may make sense. LogFS can still make sense for devices as small as 64MiB. But I'm not too concerned about that because flashes will continue to grow and the advantages of cross-device wear leveling will continue to diminish.

Jörn

Signature · 2 lines
"Security vulnerabilities are here to stay."
-- Scott Culp, Manager of the Microsoft Security Response Center, 2001
#70 lore raw
In reply to Thomas Gleixner
Quoted 6 lines · Thomas Gleixner

Last time I talked to you about that, you said it would be possible and fixable. We talked about several mechanisms, which would allow a filesystem or other users to hint such things to UBI.

Even if the LogFS wear levelling is so superior, it CAN'T do across device wear levelling.

Exactly. Although it is true that it cannot be _as good_ as FS, one can optimize this by means of asking FS beforehand and make it quite OK. And eraseblock movement is not so frequent event - we do it only once the erase counter difference is more then 4Ki (although it is tunable).

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#67 lore raw
In reply to Jörn Engel
Quoted 3 lines · Jörn Engel

Even if such flashes still contain a bootloader and a kernel, that will occupy less than 1% of the device. Wear leveling across the device is fairly pointless here. This is what I designed LogFS for.

Still you need to have a solution for handling bitflips in those bootloader and kernel areas.

I don't dispute, that on a Terrabyte solid state disk which is used in a totally different way, UBI is not necessarily the right tool.

Quoted 5 lines

There is some middle ground where a combination of UBI and LogFS may make sense. LogFS can still make sense for devices as small as 64MiB. But I'm not too concerned about that because flashes will continue to grow and the advantages of cross-device wear leveling will continue to diminish.

Flashes will grow, but this will not change the embedded use case with a relativly small FLASH and the bootloader / kernel / rootfs / datafs scenario, where UBI is the right tool to use.

There is no hammer for all nails and I don't see device mapper doing what UBI does right now.

tglx

#68 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 3 lines · Jörn Engel

Even if such flashes still contain a bootloader and a kernel, that will occupy less than 1% of the device. Wear leveling across the device is fairly pointless here. This is what I designed LogFS for.

Still you need to have a solution for handling bitflips in those bootloader and kernel areas.

Correct. It may make sense to use UBI for that, I don't know. What I do know is that UBI cannot make wear leveling decisions as well as LogFS.

And that is all I care about wrt. this discussion.

Jörn

Signature · 2 lines
Joern's library part 8:
http://citeseer.ist.psu.edu/plank97tutorial.html
#69 lore raw
Quoted 3 lines · Jörn Engel

Correct. It may make sense to use UBI for that, I don't know. What I do know is that UBI cannot make wear leveling decisions as well as LogFS.

So lets discuss this in different thread when you post a request to include LogFS into mainline.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#51 lore raw
In reply to David Woodhouse

*sigh*

I really did not want to become involved in this. So please be nice and leave the flamethrower in your weapon closet or I will disappear again before you can say "fire".

Quoted 7 lines · David Woodhouse
Quoted 3 lines · David Lang

What Matt and Ted are looking at is the question 'are flash devices close enough to other block devices that it would make sense to change the existing linux definition of a block device to handle the special requirements of flash'

I've seen no real proposals about how this could be done, so it's a purely academic question.

What you have seen and shot down were patches to make mtd more generic. So let me just assume both mtd and jffs2 were generic, even though they currently aren't.

In very broad terms, an mtd is a device with:
1. a read operation
2. a write operation
3. an erase operation
4. a minimal write blocksize
5. a minimal erase blocksize
6. a method to query bad eraseblocks
7. a method to mark bad eraseblocks

Anything else? There are many more fields, but I believe this is the essential. point() and unpoint() were omitted, because they are just one option to provide XIP. filemap_xip.c is another used for block devices.

In very broad terms, a block device has:
1. a read operation
2. a write operation
3. some devices have an ioctl() for erase, but that is uncommon
4. a blocksize

What is missing? Obviously the erase operation needs to become a first-class citizen and block devices need two fields for the two meaningful blocksizes. And they need methods to query and set bad blocks.

So far it looks simple enough. Obviously there are many messy details left out, so it will be a lot of work in practice. So the question is:
is it worth it?

What are the gains from combining mtd and block devices?

[ And at this point I would like to state again that I don't want to become involved in the UBI discussion. The question whether two seperate subsystems make sense is quite independent and I don't want both discussions to get mixed up. ]

Jörn

Signature · 3 lines
He who knows others is wise.
He who knows himself is enlightened.
-- Lao Tsu
#54 lore raw
In reply to Artem Bityutskiy
Quoted 8 lines · Artem Bityutskiy
Quoted 4 lines

As I mentioned to you in IRC, in the future if there is pending changes in response to reviewer comments, it might be a good idea to mention that, so that reviewers know not make those comments again, or worry that the comments had been ignored.

Teo, I wrote you 2 times that your point was understood and this would be fixed. You should not think your comments are ignored because they are not.

Artem, no need to be defensive. You did tell me that you were going to address them; but then you resubmitted patches where they weren't address. Normally, patch authors take all of the comments, clear them all, and then in the next repost of the patch, either explain why it wasn't feasible to handle some of the comments, *OR* why some of the comments were so hard to handle that they wouldn't be handled until a future version of the patch. Furthermore, in a patch of the size that you are submitting, a listing of what you *did* fix would also be good.

And at this point, I don't doubt that you will at some point going to heed my comments --- but note that doing so will involve a massive refactorization of the code, which will tend to invalidate the reviews done of this current (take 3) version of the patches; so I am bit curious what was your motiviation in reposting this round of the patches.

Believe it or not, the people who are responding on this thread are trying to help. Otherwise they would just be ignoring you and UBI. Keeping this thought in mind and trying to help them, where in some cases perhaps they are lacking in the same knowledge and experience and those who have been working on UBI and have spent many months thinking about the problem, may help keep things more constructive.

Regards,

- Ted

#55 lore raw
Quoted 7 lines · Theodore Tso

And at this point, I don't doubt that you will at some point going to heed my comments --- but note that doing so will involve a massive refactorization of the code, which will tend to invalidate the reviews done of this current (take 3) version of the patches; so I am bit curious what was your motiviation in reposting this round of the patches.

Yes. However, nobody has actually reviewed any of the _code_ in this round. So while it may have been somewhat superfluous from a submission standpoint, at least no code review has been wasted and we are getting some fairly decent design discussions.

josh

#56 lore raw
In reply to Theodore Tso
Quoted 6 lines · Theodore Tso

And at this point, I don't doubt that you will at some point going to heed my comments --- but note that doing so will involve a massive refactorization of the code, which will tend to invalidate the reviews done of this current (take 3) version of the patches; so I am bit curious what was your motiviation in reposting this round of the patches.

Well, in take 3 I _already_ removed quite _a lot_ of itsy-bitsy units, and I thought it is enough, so I've submitted it. But later I've realized that I should go further (e.g., dispose of per-unit data structures), and started more re-work. Yes, I should have notified about this new re-work, apologies.

Point taken, will be fixed :-)

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#57 lore raw
In reply to Theodore Tso

Hi Ted,

Quoted 4 lines · Theodore Tso

Keeping this thought in mind and trying to help them, where in some cases perhaps they are lacking in the same knowledge and experience and those who have been working on UBI and have spent many months thinking about the problem, may help keep things more constructive.

since I am one of those who are working on UBI together with Artem, I would like to try to describe how we are using UBI and how it solves some problems, we could not solve to our satisfaction with existing solutions.

Our system is using only NAND flashes and we use a nand-flash-controller for the 1st stage boot-code (we called it IPL - initial program loader) to appear contiguous in memory. The size of the IPL is limited to 4 KiB.

In these 4KiB code we initialize the processor, and scan the NAND flash for copies of our 2nd stage boot-loader (SPL), which is stored in one or even redundantly in multiple static UBI volumes. If the SPL has one-bit flips we can correct them in the IPL before loading it into RAM.

We want to correct bit-flips as soon as possible to avoid getting uncorrectable errors. UBI is doing that transparently for us by copying the block with the bitflip to a free block. The logic in the IPL is able to cope with the situation where UBI is interrupted when doing that.

Imagine if you have boot-code at a fixed location (skipping bad blocks of course too): if you erase a block of the SPL to write it back to the same block (to remove bit-errors), you will not be robust against power-loss anymore! You could put a 2nd temporary SPL before you could do this, but that is not nice too.

The static UBI volumes are so simple structured, that it is possible to load them to RAM using only a few KiB of code. We do not even look at UBIs volume information table to be able to do this.

UBI solves here:
1. possiblitly to boot a controller with limited resources using NAND
2. transparent bitflip correction on read only data e.g. boot-code, kernel, initrd. Note that the mechanisms here are robust against power-loss, that is also very important to us

We wanted to use JFFS2 and found that the traditional update mechanisms did not ensure that an interrupted update attempt can be detected as such. The UBI volume update ensures, that the volume is only usable after it was updated completely.

3. Update mechanism which ensures that incomplete data cannot be used

We found that putting certain flash content at fixed locations with fixed size is especially cumbersome if raw NAND is used e.g. if you consider that bad blocks have to be skipped. Resizing partitions is a pain.

UBI helps us to get rid of those limitations. We can resize the UBI volumes and because UBI takes care to find the volume data even our second stage boot-code can be located anywhere on the chip.

4. Volume resizing is easy

Because we want to ensure that we gain maximum lifetime for our systems, we want that bitflips are corrected immediately when they are found. Feature 2. of UBI does this for us.

I think that the largest portion of what we put in our NAND flashes is code and data and basically read-only. Nevertheless data is written during operation and, as already pointed out, maximum lifetime is important for us, and wear-leveling across the whole flash chip helps espcially with our usage-pattern. UBIs ability to copy blocks transparently e.g. a read-only block with small erase count to a free block with relatively high erase count, helps to get this done.

5. wear-leveling across the whole flash chip

We found that being able to use the same code update mechanisms for NAND/NOR/? based systems is a nice side effect too. That was one reason beside others (see previous mails) to up the UBI meta data into the data section of the flashes and sacrifice therefore some space for data and of course that the usable size of a block is not n^2 anymore. I think it was a good decision, because if we would have put in in NAND OOB area, the discussion here might be limited to NAND users only.

Regards,

Frank Haverkamp

#58 lore raw

On Wed, 21 Mar 2007, Frank Haverkamp wrote:

several of these things sound like they would be useful to other block devices as well

Quoted 10 lines

UBI solves here:
1. possiblitly to boot a controller with limited resources using NAND
2. transparent bitflip correction on read only data e.g. boot-code, kernel, initrd. Note that the mechanisms here are robust against power-loss, that is also very important to us

We wanted to use JFFS2 and found that the traditional update mechanisms did not ensure that an interrupted update attempt can be detected as such. The UBI volume update ensures, that the volume is only usable after it was updated completely.

a dm layer that detects and remaps soft errors before they become hard errors is useful for hard drives as well.

Quoted 17 lines

3. Update mechanism which ensures that incomplete data cannot be used

We found that putting certain flash content at fixed locations with fixed size is especially cumbersome if raw NAND is used e.g. if you consider that bad blocks have to be skipped. Resizing partitions is a pain.

UBI helps us to get rid of those limitations. We can resize the UBI volumes and because UBI takes care to find the volume data even our second stage boot-code can be located anywhere on the chip.

4. Volume resizing is easy

Because we want to ensure that we gain maximum lifetime for our systems, we want that bitflips are corrected immediately when they are found. Feature 2. of UBI does this for us.

Quoted 7 lines

I think that the largest portion of what we put in our NAND flashes is code and data and basically read-only. Nevertheless data is written during operation and, as already pointed out, maximum lifetime is important for us, and wear-leveling across the whole flash chip helps espcially with our usage-pattern. UBIs ability to copy blocks transparently e.g. a read-only block with small erase count to a free block with relatively high erase count, helps to get this done.

both of these also sound useful as dm layers (in fact lvm already does some of the resizing things)

Quoted 9 lines

5. wear-leveling across the whole flash chip

We found that being able to use the same code update mechanisms for NAND/NOR/? based systems is a nice side effect too. That was one reason beside others (see previous mails) to up the UBI meta data into the data section of the flashes and sacrifice therefore some space for data and of course that the usable size of a block is not n^2 anymore. I think it was a good decision, because if we would have put in in NAND OOB area, the discussion here might be limited to NAND users only.

wear leveling would also be useful on other block devices (think CD-RAM for example)

cross-device wear leveling sounds a lot like putting the wear leveling layer above a lvm-like layer that stitches the seperate flash chips togeather into one logical device.

additionally, if wear leveling is an optional layer in dm then it can be left out when it's not appropriate (like when the FS has features that make it unnessasary, or when it's read-only so you don't have writes to worry about (or even if it's read-only 99.9999% of the time so writes are so rare that all the writes in the expected lifetime of the device won't cause problems)

David Lang

#71 lore raw
In reply to Thomas Gleixner
Quoted 6 lines · Thomas Gleixner
Quoted 2 lines · Jörn Engel

Also LogFS currently requires erasesizes of 2^n.

Last time I talked to you about that, you said it would be possible and fixable.

Actually, no. LogFS is not broken, there is nothing to fix.

And there is no fundamental reason why UBI should export blocks with non-power-of-two sizes. UBI currently consists of two parts that are intimately intertwined in the current implementation, but have relatively little connection otherwise.

1. Logical volume management.
2. Static volumes.

Logical volume management can just as easily move its management information into a table, instead of having it spread across all blocks. Blocks can keep their original size. Since you have to scan flash anyway, you can also scan for a table, compare a magical number and do some extra check to protect yourself against a UBI image inside some logical volume. No big deal.

Static volumes can keep a header inside their volumes. The tiny first-stage bootloader is currently scanning flash and can continue to do so. But at least this header no longer causes trouble for LogFS or any other UBI user.

UBI is just as broken as LogFS is. It works with every user in mainline (which comes down to JFFS2). LogFS works with every MTD device in mainline. The only combination that doesn't work is LogFS on UBI - due to deliberate design decisions on both sides.

Jörn

Signature · 2 lines
Joern's library part 8:
http://citeseer.ist.psu.edu/plank97tutorial.html
#72 lore raw
Quoted 18 lines · Jörn Engel
Quoted 6 lines · Thomas Gleixner
Quoted 2 lines · Jörn Engel

Also LogFS currently requires erasesizes of 2^n.

Last time I talked to you about that, you said it would be possible and fixable.

Actually, no. LogFS is not broken, there is nothing to fix.

And there is no fundamental reason why UBI should export blocks with non-power-of-two sizes. UBI currently consists of two parts that are intimately intertwined in the current implementation, but have relatively little connection otherwise.

1. Logical volume management.
2. Static volumes.

Quoted 6 lines

Logical volume management can just as easily move its management information into a table, instead of having it spread across all blocks. Blocks can keep their original size. Since you have to scan flash anyway, you can also scan for a table, compare a magical number and do some extra check to protect yourself against a UBI image inside some logical volume. No big deal.

if you are being paranoid about write cycles putting the write count in the block you are writing avoids doing an erase/write elsewhere

although, since you can flip bits to 1 without requireing an erase you could sacrafice some space and say that your table has a normal counter for the number of times the block has been erased, but a 'tally counter' where you turn one bit on each time you erase the block, and when you fill up the tally block you re-write the entire table, clearing all the tallys. if you have relativly large eraseblocks it seems like you could afford to sacrafice the space in your master table to avoid erases of it

IIRC someone said that the count per block was 128 bits? if so you could have a master table with a 32 bit integer (4B writes) + 96 bits of tally so that you would only have to re-write the table when a block on the flash has been erased 96 times. with this approach the wear on your table is unlikely to be a factor until the point where you are loosing a lot of other eraseblocks due to wear (at which point you could shift to a different block for your table, or retire the flash)

David Lang

#73 lore raw
Quoted 8 lines · David Lang
Quoted 6 lines · Jörn Engel

Logical volume management can just as easily move its management information into a table, instead of having it spread across all blocks. Blocks can keep their original size. Since you have to scan flash anyway, you can also scan for a table, compare a magical number and do some extra check to protect yourself against a UBI image inside some logical volume. No big deal.

[ This was not a request for UBI to be changed. The only purpose was to illustrate that LogFS is not broken. The previous thread suggested otherwise and I just couldn't leave it at that. ]

Quoted 4 lines

if you are being paranoid about write cycles putting the write count in the block you are writing avoids doing an erase/write elsewhere

although, since you can flip bits to 1 without requireing an erase you

[ vice versa. you can flip bits to 0 without erasing. ]

Quoted 6 lines

could sacrafice some space and say that your table has a normal counter for the number of times the block has been erased, but a 'tally counter' where you turn one bit on each time you erase the block, and when you fill up the tally block you re-write the entire table, clearing all the tallys. if you have relativly large eraseblocks it seems like you could afford to sacrafice the space in your master table to avoid erases of it

Or you could have a table and any number of updates to it. Erase one block, append a small update marker to the table. There are plenty of options. All have in common that code would be more complicated.

Another advantage is that erase counts don't get reset if the race against a power failure during erase is lost.

Whether the advantaves of power-of-two blocksizes and safe erasecounts are worth it, I leave for others to decide.

Jörn

Signature · 3 lines
Fools ignore complexity.  Pragmatists suffer it.
Some can avoid it.  Geniuses remove it.
-- Perlis's Programming Proverb #58, SIGPLAN Notices, Sept.  1982
maintainer
#74 lore raw
Quoted 2 lines · Jörn Engel
Quoted 1 line

although, since you can flip bits to 1 without requireing an erase you

[ vice versa. you can flip bits to 0 without erasing. ]

And on NAND flash you can't just do it in multiple cycles one bit at a time. The 'tally' trick isn't viable there.

Signature · 1 line
dwmw2
#75 lore raw
Quoted 6 lines · David Woodhouse
Quoted 2 lines · Jörn Engel
Quoted 1 line

although, since you can flip bits to 1 without requireing an erase you

[ vice versa. you can flip bits to 0 without erasing. ]

And on NAND flash you can't just do it in multiple cycles one bit at a time. The 'tally' trick isn't viable there.

You can on NAND. ECC is done in software. And for a data structure as simple as the 'tally', foregoing ECC is not a huge problem - most bitflips are easily detected and the remaining only cause off-by-a-few on the erase count.

On NOR with transparent (hardware) ECC you can't.

Jörn

Signature · 2 lines
Homo Sapiens is a goal, not a description.
-- unknown
maintainer
#76 lore raw
Quoted 4 lines · Jörn Engel

You can on NAND. ECC is done in software. And for a data structure as simple as the 'tally', foregoing ECC is not a huge problem - most bitflips are easily detected and the remaining only cause off-by-a-few on the erase count.

You're only allowed a limited number of write cycles to each page though. So you can't just clear the bits in a 2112-byte page one at a time; typically when you clear the fifth bit, the contents of the whole page become undefined until the next erase cycle.

Signature · 1 line
dwmw2
#77 lore raw
Quoted 10 lines · David Woodhouse
Quoted 4 lines · Jörn Engel

You can on NAND. ECC is done in software. And for a data structure as simple as the 'tally', foregoing ECC is not a huge problem - most bitflips are easily detected and the remaining only cause off-by-a-few on the erase count.

You're only allowed a limited number of write cycles to each page though. So you can't just clear the bits in a 2112-byte page one at a time; typically when you clear the fifth bit, the contents of the whole page become undefined until the next erase cycle.

That limitation stems from ECC and ECC is done in software. Currently everyone and his dog is doing ECC in chunks of 256 bytes on NAND. So your minimum write size is 256 bytes _if you care about ECC_. If you don't care, you can write single bits on NAND, just as you can on NOR.

Controlling ECC in software means we are quite flexible. Given sufficient incentive, we can change the rules quite significantly.

Jörn

Signature · 4 lines
You can't tell where a program is going to spend its time. Bottlenecks
occur in surprising places, so don't try to second guess and put in a
speed hack until you've proven that's where the bottleneck is.
-- Rob Pike
maintainer
#78 lore raw
Quoted 4 lines · Jörn Engel

That limitation stems from ECC and ECC is done in software. Currently everyone and his dog is doing ECC in chunks of 256 bytes on NAND. So your minimum write size is 256 bytes _if you care about ECC_. If you don't care, you can write single bits on NAND, just as you can on NOR.

No, on NAND flash it's a limitation of the hardware. The number of write cycles you can perform to a given page is limited. Exceed it and the contents of that page become undefined due to leakage, until you next erase it.

Signature · 1 line
dwmw2
#79 lore raw
Quoted 5 lines · David Woodhouse

No, on NAND flash it's a limitation of the hardware. The number of write cycles you can perform to a given page is limited. Exceed it and the contents of that page become undefined due to leakage, until you next erase it.

Are you sure? Do you have any specs or similar that state this?

So far I have only encountered this limitation by word of mouth. And such a myth coming from ECC effects is nothing that would surprise me.

Jörn

Signature · 3 lines
The cheapest, fastest and most reliable components of a computer
system are those that aren't there.
-- Gordon Bell, DEC labratories
#81 lore raw
In reply to David Woodhouse
Quoted 10 lines · David Woodhouse
Quoted 4 lines · Jörn Engel

That limitation stems from ECC and ECC is done in software. Currently everyone and his dog is doing ECC in chunks of 256 bytes on NAND. So your minimum write size is 256 bytes _if you care about ECC_. If you don't care, you can write single bits on NAND, just as you can on NOR.

No, on NAND flash it's a limitation of the hardware. The number of write cycles you can perform to a given page is limited. Exceed it and the contents of that page become undefined due to leakage, until you next erase it.

Right and you cannot write to random locations in a page. The write chunks have to be in consecutive order. If you write 0xAA to offset 0, you cannot rewrite it to 0x00 later without risking corruption.

tglx

#82 lore raw
In reply to Jörn Engel
Quoted 2 lines · Jörn Engel

And there is no fundamental reason why UBI should export blocks with non-power-of-two sizes.

False. There is.

Quoted 3 lines

UBI currently consists of two parts that are
intimately intertwined in the current implementation, but have relatively little connection otherwise.

False. They do have connection.

Quoted 9 lines

1. Logical volume management.
2. Static volumes.

Logical volume management can just as easily move its management information into a table, instead of having it spread across all blocks. Blocks can keep their original size. Since you have to scan flash anyway, you can also scan for a table, compare a magical number and do some extra check to protect yourself against a UBI image inside some logical volume. No big deal.

First off, I see these no big deal statements for years already, and no decent implementation proved by usage in real world. Could we please, move these academic discussions to another thread?

Second, it is much more robust to kip erase counter and mapping information on per-eraseblock basis then to keep any on-flash table - you may always scan whole media and gracefully recover from errors and corruptions. And you do not loose use a lot in case of corruptions.

Third, it is much simpler then keeping any on-flash table, it is thus robust. We do not need a journal to update any table.

Third, if needed, on-flash table may be _added_ to increase scalability, so "since you have to scan flash anyway" may become false when there is real need in better scalability. For now scanning is OK. And still, scanning method will be a good fall-back way to recover from errors.

Quoted 4 lines

UBI is just as broken as LogFS is. It works with every user in mainline (which comes down to JFFS2). LogFS works with every MTD device in mainline. The only combination that doesn't work is LogFS on UBI - due to deliberate design decisions on both sides.

You are welcome to discuss other irrelevant things to this thread.

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#83 lore raw
Quoted 9 lines · Artem Bityutskiy
Quoted 7 lines · Jörn Engel

Logical volume management can just as easily move its management information into a table, instead of having it spread across all blocks. Blocks can keep their original size. Since you have to scan flash anyway, you can also scan for a table, compare a magical number and do some extra check to protect yourself against a UBI image inside some logical volume. No big deal.

Quoted 3 lines

First off, I see these no big deal statements for years already, and no decent implementation proved by usage in real world. Could we please, move these academic discussions to another thread?

You could wait a day, then reread what I wrote. Maybe you will notice that what I wrote is not identical to what we have discussed about a year ago and you seem to have read.

You may also want to reread this:

||[ This was not a request for UBI to be changed.  The only purpose was to
||illustrate that LogFS is not broken.  The previous thread suggested
||otherwise and I just couldn't leave it at that. ]

Jörn

Signature · 2 lines
tglx1 thinks that joern should get a (TM) for "Thinking Is Hard"
-- Thomas Gleixner