UBIFS: How to reserve space to be used right before power cut
Hi,
we try the following:
1) setup some data in an 8kByte block in RAM
2) frequently modify this data during normal operation
3) on a power fail signal write the block to a file on an UBIFS partition
4) recover from the written data after the power cut
The time between power failure notification and the uP-reset is
guaranteed by hardware
and is about 20ms.
We first thought about using fallocate() to allocate a corresponding block on the partition but soon found that UBIFS does not implement a native fallocate() and thus the generic one simply wrote the file to 8k of zeros. This of course will not help.
Simply fsync()ing the file in case of a power cut does not seem reliable, for
- the file system might be full
- write back cache operation may interfere with the synch-ing of our file
- the garbage collector might run to free dirty LEBs and erase the
corresponding PEBs
The latter 2 overstretching our timing requirements.
This is on an embedded system (i.mx31, arm1136@532MHz) running Linux 3.something (we are quite flexible in adapting new kernel versions), currently testing on 3.0.45.
Could someone hint the course to follow for this szenario?
Any pointers appreciated,
Helmut
--
Scanned by MailScanner.
Hi,
Why do you do this in ubifs ?
If you do it in ubi/mtd this will be a lot's of easier.
Matthieu
Quoted 47 lines · Helmut Raiger
Hi,
we try the following:
1) setup some data in an 8kByte block in RAM
2) frequently modify this data during normal operation
3) on a power fail signal write the block to a file on an UBIFS partition 4) recover from the written data after the power cutThe time between power failure notification and the uP-reset is
guaranteed by hardware
and is about 20ms.We first thought about using
fallocate()to allocate a corresponding block on the partition
but soon found that UBIFS does not implement a nativefallocate()and thus the generic
one simply wrote the file to 8k of zeros. This of course will not help.Simply fsync()ing the file in case of a power cut does not seem reliable, for
- the file system might be full
- write back cache operation may interfere with the synch-ing of
our file
- the garbage collector might run to free dirty LEBs and erase the
corresponding PEBs
The latter 2 overstretching our timing requirements.This is on an embedded system (i.mx31, arm1136@532MHz) running Linux 3.something
(we are quite flexible in adapting new kernel versions), currently testing on 3.0.45.Could someone hint the course to follow for this szenario?
Any pointers appreciated,
Helmut--
Scanned by MailScanner.______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 9 lines
----- Original Message -----
From: "Matthieu CASTET" <[email protected]>
To: "Helmut Raiger" <[email protected]>
Cc: [email protected]
Sent: Thursday, June 13, 2013 1:50:31 PM
Subject: Re: UBIFS: How to reserve space to be used right before power cut
Quoted 7 lines
Hi,
Why do you do this in ubifs ?
If you do it in ubi/mtd this will be a lot's of easier.
Matthieu
I wasn't aware of an userspace interface for ubi/mtd, but just found out about gluebi. Is this the path you suggest?
Could you please elaborate a bit more on this, I'm still unsure if this will meet our timing constraints (background operation of ubi?)
Helmut
--
Scanned by MailScanner.
Quoted 16 lines · Raiger Helmut
Quoted 16 lines
----- Original Message -----
From: "Matthieu CASTET" <[email protected]>
To: "Helmut Raiger" <[email protected]>
Cc: [email protected]
Sent: Thursday, June 13, 2013 1:50:31 PM
Subject: Re: UBIFS: How to reserve space to be used right before power cutHi,
Why do you do this in ubifs ?
If you do it in ubi/mtd this will be a lot's of easier.
Quoted 8 lines
Quoted 1 line
Matthieu
I wasn't aware of an userspace interface for ubi/mtd, but just found out about gluebi. Is this the path you suggest?
Could you please elaborate a bit more on this, I'm still unsure if this will meet our timing constraints (background operation of ubi?)
Not gluebi
you have a userspace inferface to ubi : /usr/include/mtd/ubi-user.h
You could create a small ubi volume (dynamic or static) of 1 LEB next to ubifs (on the same ubi device).
When you start you make sure the LEB have enough space and that the LEB is mapped.
on a power fail signal you write the LEB with your data. Because the LEB is already mapped, the write should be imediate.
If the ubi volume is on the same ubi device than ubifs, the wear leveling will be shared with ubifs.
Quoted 10 lines · Matthieu CASTET
Not gluebi
you have a userspace inferface to ubi :
/usr/include/mtd/ubi-user.hYou could create a small ubi volume (dynamic or static) of 1 LEB next to ubifs (on the same ubi device).
When you start you make sure the LEB have enough space and that the LEB is mapped.
Quoted 7 lines
on a power fail signal you write the LEB with your data. Because the LEB is already mapped, the write should be imediate.
If the ubi volume is on the same ubi device than ubifs, the wear leveling will be shared with ubifs.
I digged the UBI sources and still have the feeling this won't work:
1) There seems to be no way to (long term) protect a PEB from being moved by the wear leveling sub-system (even scrubbing on bit-flips, which may be induced by read-disturbances (reads on nearby pages)).
2) Temporary protection of a PEB is not really time specific, but depends on global PEB erase action (i.e. anything UBIFS does on the same device), which is something I can't control.
My impression is, that UBI simply does not support this sort of application well. Unmoveable blocks will have a low erase count (below average), which is exactly what the WL should avoid.
However I've never timed such a move operation:
a) move content to a new unused PEB
b) schedule original PEB for erasure
It might fit into my timing requirements, but will probably be heavily influenced by system load and priorities.
Helmut
--
Scanned by MailScanner.
Quoted 14 lines · Helmut Raiger
I digged the UBI sources and still have the feeling this won't work:
1) There seems to be no way to (long term) protect a PEB from being moved by the wear leveling sub-system (even scrubbing on bit-flips, which may be induced by read-disturbances (reads on nearby pages)).
2) Temporary protection of a PEB is not really time specific, but depends on global PEB erase action (i.e. anything UBIFS does on the same device), which is something I can't control.
My impression is, that UBI simply does not support this sort of application well. Unmoveable blocks will have a low erase count (below average), which is exactly what the WL should avoid.
Quoted 7 lines
However I've never timed such a move operation:
a) move content to a new unused PEB
b) schedule original PEB for erasure
It might fit into my timing requirements, but will probably be heavily influenced by system load and priorities.Helmut
Just an update to 'enlight the world'. We are moving to YAFFS2, it has a deterministic garbage collector which makes it a lot easier to implement the requested behaviour.
It seems we can even take it off the shelf, currently we are perfomance testing the write timing.
Helmut
--
Scanned by MailScanner.