Skip to contentSkip to conversation

libblkid: add support for UBI superblock

PATCH Superseded Rafał Miłecki 2 participants 9 messages Aug 1, 2017 – Aug 7, 2017 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libblkid: add support for UBI superblock

From: Rafał Miłecki <[email protected]>

Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI. Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe.

---
 libblkid/src/Makemodule.am             |  1 +
 libblkid/src/superblocks/superblocks.c |  1 +
 libblkid/src/superblocks/superblocks.h |  1 +
 libblkid/src/superblocks/ubi.c         | 50 ++++++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+)
 create mode 100644 libblkid/src/superblocks/ubi.c
libblkid/src/Makemodule.am +1 -0
index 2b70742bc..8dfe892ff 100644
@@ -85,6 +85,7 @@ libblkid_la_SOURCES = \
 	libblkid/src/superblocks/superblocks.h \
 	libblkid/src/superblocks/swap.c \
 	libblkid/src/superblocks/sysv.c \
+	libblkid/src/superblocks/ubi.c \
 	libblkid/src/superblocks/ubifs.c \
 	libblkid/src/superblocks/udf.c \
 	libblkid/src/superblocks/ufs.c \
libblkid/src/superblocks/superblocks.c +1 -0
index 88578c8db..cb887f8f1 100644
@@ -152,6 +152,7 @@ static const struct blkid_idinfo *idinfos[] =
 	&squashfs3_idinfo,
 	&netware_idinfo,
 	&btrfs_idinfo,
+	&ubi_idinfo,
 	&ubifs_idinfo,
 	&bfs_idinfo,
 	&vmfs_fs_idinfo,
libblkid/src/superblocks/superblocks.h +1 -0
index ea875d768..695c3b783 100644
@@ -64,6 +64,7 @@ extern const struct blkid_idinfo netware_idinfo;
 extern const struct blkid_idinfo sysv_idinfo;
 extern const struct blkid_idinfo xenix_idinfo;
 extern const struct blkid_idinfo btrfs_idinfo;
+extern const struct blkid_idinfo ubi_idinfo;
 extern const struct blkid_idinfo ubifs_idinfo;
 extern const struct blkid_idinfo zfs_idinfo;
 extern const struct blkid_idinfo bfs_idinfo;
libblkid/src/superblocks/ubi.c new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 5 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI. Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

How does it co-exists with ufifs? Does it share the same /dev node or attached UBI uses another device? (I have no UBI to test it.)

Note that by default libblkid does not support scenario where on the same device is more superblock - in this case extra care is necessary

It seems (according to ubifs prober code) that ubifs is on another device node.

It would be nice to have lsblk output with mounted ubifs.

Quoted 6 lines
 libblkid/src/Makemodule.am             |  1 +
 libblkid/src/superblocks/superblocks.c |  1 +
 libblkid/src/superblocks/superblocks.h |  1 +
 libblkid/src/superblocks/ubi.c         | 50 ++++++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+)
 create mode 100644 libblkid/src/superblocks/ubi.c

Rafał, see also tests/ts/blkid/images-fs/ and tests/expected/blkid/.

It would by nice to have small image with UBI superblock and expected output from "blkid -p -o udev <device>". It seems dd(1) the begin of the device would be good enough.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer
#2 lore raw
Quoted 10 lines · Karel Zak
Quoted 5 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI. Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

How does it co-exists with ufifs? Does it share the same /dev node or attached UBI uses another device? (I have no UBI to test it.)

Quoted 7 lines

Note that by default libblkid does not support scenario where on the same device is more superblock - in this case extra care is necessary

It seems (according to ubifs prober code) that ubifs is on another device node.

It would be nice to have lsblk output with mounted ubifs.

This page http://www.linux-mtd.infradead.org/doc/ubi.html explains a lot...

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer
#3 lore raw
In reply to Karel Zak
Quoted 1 line · Karel Zak

It would be nice to have lsblk output with mounted ubifs.

Ah, I've forgot, it's not block device...

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#4 lore raw

PATCH v2 1/1 libblkid: add support for UBI superblock

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

UBI is a volume management system that can be used on a raw flash partition for providing multiple logical volumes. Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI.

Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0) while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe.

---
V2: Update commit message (more UBI vs. ubifs details)

    Pass &hdr->image_seq to the blkid_probe_sprintf_uuid
    Add test
---
 libblkid/src/Makemodule.am             |   1 +
 libblkid/src/superblocks/superblocks.c |   1 +
 libblkid/src/superblocks/superblocks.h |   1 +
 libblkid/src/superblocks/ubi.c         |  51 +++++++++++++++++++++++++++++++++
 tests/expected/blkid/low-probe-ubi     |   5 ++++
 tests/ts/blkid/images-fs/ubi.img.xz    | Bin 0 -> 136 bytes
 6 files changed, 59 insertions(+)
 create mode 100644 libblkid/src/superblocks/ubi.c
 create mode 100644 tests/expected/blkid/low-probe-ubi
 create mode 100644 tests/ts/blkid/images-fs/ubi.img.xz
libblkid/src/Makemodule.am +1 -0
index 2b70742bc..8dfe892ff 100644
@@ -85,6 +85,7 @@ libblkid_la_SOURCES = \
 	libblkid/src/superblocks/superblocks.h \
 	libblkid/src/superblocks/swap.c \
 	libblkid/src/superblocks/sysv.c \
+	libblkid/src/superblocks/ubi.c \
 	libblkid/src/superblocks/ubifs.c \
 	libblkid/src/superblocks/udf.c \
 	libblkid/src/superblocks/ufs.c \
libblkid/src/superblocks/superblocks.c +1 -0
index 88578c8db..cb887f8f1 100644
@@ -152,6 +152,7 @@ static const struct blkid_idinfo *idinfos[] =
 	&squashfs3_idinfo,
 	&netware_idinfo,
 	&btrfs_idinfo,
+	&ubi_idinfo,
 	&ubifs_idinfo,
 	&bfs_idinfo,
 	&vmfs_fs_idinfo,
libblkid/src/superblocks/superblocks.h +1 -0
index ea875d768..695c3b783 100644
@@ -64,6 +64,7 @@ extern const struct blkid_idinfo netware_idinfo;
 extern const struct blkid_idinfo sysv_idinfo;
 extern const struct blkid_idinfo xenix_idinfo;
 extern const struct blkid_idinfo btrfs_idinfo;
+extern const struct blkid_idinfo ubi_idinfo;
 extern const struct blkid_idinfo ubifs_idinfo;
 extern const struct blkid_idinfo zfs_idinfo;
 extern const struct blkid_idinfo bfs_idinfo;
libblkid/src/superblocks/ubi.c new file +51 -0

51 lines not on this page · raw message

tests/expected/blkid/low-probe-ubi new file +5 -0
new file mode 100644
index 000000000..318a35152
@@ -0,0 +1,5 @@
+ID_FS_TYPE=ubi
+ID_FS_USAGE=filesystem
+ID_FS_UUID=1329411831
+ID_FS_UUID_ENC=1329411831
+ID_FS_VERSION=1
tests/ts/blkid/images-fs/ubi.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ed3b3f4260f543608887d7cf09c9ff8fec8a7f1b
GIT binary patch
Signature · 1 line
2.11.0
maintainer Applied
#5 lore raw
Quoted 13 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

UBI is a volume management system that can be used on a raw flash partition for providing multiple logical volumes. Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI.

Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0) while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

Quoted 8 lines

This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe.

---
V2: Update commit message (more UBI vs. ubifs details)

    Pass &hdr->image_seq to the blkid_probe_sprintf_uuid
    Add test

Applied, thanks.

tests/expected/blkid/low-probe-ubi line 2

Quoted 2 lines
tests/expected/blkid/low-probe-ubi new file +2 -0
+ID_FS_TYPE=ubi
+ID_FS_USAGE=filesystem

This is probably not ideal. We use "RAID" flag for logic volume managers. The advantage is that probing is faster as it does not try to check for another signature when "RAID" is detected.

The question is how small could be the UBI device? We don't probe for "RAID" on very small devices (<=1MiB).

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#6 lore raw
Quoted 32 lines · Karel Zak
Quoted 13 lines · On Wed, Aug 02, 2017 at 02:14:18PM +0200, Rafa=C5=82 Mi=C5=82ecki wrote:

From: Rafa=C5=82 Mi=C5=82ecki <[email protected]>

UBI is a volume management system that can be used on a raw flash partition for providing multiple logical volumes. Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI.

Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0) while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

Quoted 8 lines

This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe.

---
V2: Update commit message (more UBI vs. ubifs details)

    Pass &hdr->image_seq to the blkid_probe_sprintf_uuid
    Add test

Applied, thanks.

Review

Quoted 2 lines
(quoted diff) +2 -0
+ID_FS_TYPE=3Dubi
+ID_FS_USAGE=3Dfilesystem

This is probably not ideal. We use "RAID" flag for logic volume managers. The advantage is that probing is faster as it does not try to check for another signature when "RAID" is detected.

Quoted 2 lines

The question is how small could be the UBI device? We don't probe for "RAID" on very small devices (<=3D1MiB).

UBI is responsible for bad blocks handling, so it needs enough erase blocks (PEBs) reserved in order to work. If one's MTD partition is as small as 1 MiB, it won't have enough of erase blocks (PEBs) [0].

There is some formula for amount of reserved blocks, like:
n_reserved =3D n_max_bad_blocks + n_internal_volumes_blocks + 1 but basically 1 MiB is said to be too small.

Does it mean we should & we're save to switch from OTHER to the RAID?

[0] http://lists.infradead.org/pipermail/linux-mtd/2014-November/056658.htm=
l
[1] http://www.dubeiko.com/development/FileSystems/UBI/ubidesign.pdf

--=20
Rafa=C5=82

maintainer
#7 lore raw
Quoted 40 lines · Rafał Miłecki
Quoted 32 lines · Karel Zak
Quoted 13 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

UBI is a volume management system that can be used on a raw flash partition for providing multiple logical volumes. Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI.

Please note it's not directly related to the ubifs support which is just a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0) while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

Quoted 8 lines

This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe.

---
V2: Update commit message (more UBI vs. ubifs details)

    Pass &hdr->image_seq to the blkid_probe_sprintf_uuid
    Add test

Applied, thanks.

tests/expected/blkid/low-probe-ubi line 2

Quoted 2 lines
tests/expected/blkid/low-probe-ubi new file +2 -0
+ID_FS_TYPE=ubi
+ID_FS_USAGE=filesystem

This is probably not ideal. We use "RAID" flag for logic volume managers. The advantage is that probing is faster as it does not try to check for another signature when "RAID" is detected.

Quoted 2 lines

The question is how small could be the UBI device? We don't probe for "RAID" on very small devices (<=1MiB).

UBI is responsible for bad blocks handling, so it needs enough erase blocks (PEBs) reserved in order to work. If one's MTD partition is as small as 1 MiB, it won't have enough of erase blocks (PEBs) [0].

Quoted 5 lines

There is some formula for amount of reserved blocks, like:
n_reserved = n_max_bad_blocks + n_internal_volumes_blocks + 1 but basically 1 MiB is said to be too small.

Does it mean we should & we're save to switch from OTHER to the RAID?

I have pushed this change to the master branch. Now UBI uses BLKID_USAGE_RAID flag (and the test image has been enlarged (> 1MiB)).

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#8 lore raw
Quoted 3 lines · Karel Zak
Quoted 2 lines · On Mon, Aug 07, 2017 at 07:40:17AM +0200, Rafa=C5=82 Mi=C5=82ecki wrote:
Quoted 1 line · Karel Zak

On Wed, Aug 02, 2017 at 02:14:18PM +0200, Rafa=C5=82 Mi=C5=82ecki wrot=

e:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Rafa=C5=82 Mi=C5=82ecki <[email protected]>

UBI is a volume management system that can be used on a raw flash partition for providing multiple logical volumes. Detecting UBI superblock may be useful for tools wanting to simplify or automate attaching UBI.

Please note it's not directly related to the ubifs support which is j=

ust

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0=

)

Quoted 27 lines
Quoted 27 lines
Quoted 20 lines
Quoted 10 lines

while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

This patch adds simple code reading UBI version and unique number and setting it in the blkid_probe.

---
V2: Update commit message (more UBI vs. ubifs details)

    Pass &hdr->image_seq to the blkid_probe_sprintf_uuid
    Add test

Applied, thanks.

Review

Quoted 2 lines
(quoted diff) +2 -0
+ID_FS_TYPE=3Dubi
+ID_FS_USAGE=3Dfilesystem

This is probably not ideal. We use "RAID" flag for logic volume managers. The advantage is that probing is faster as it does not try to check for another signature when "RAID" is detected.

Quoted 2 lines

The question is how small could be the UBI device? We don't probe for "RAID" on very small devices (<=3D1MiB).

UBI is responsible for bad blocks handling, so it needs enough erase blocks (PEBs) reserved in order to work. If one's MTD partition is as small as 1 MiB, it won't have enough of erase blocks (PEBs) [0].

Quoted 8 lines
Quoted 5 lines

There is some formula for amount of reserved blocks, like:
n_reserved =3D n_max_bad_blocks + n_internal_volumes_blocks + 1 but basically 1 MiB is said to be too small.

Does it mean we should & we're save to switch from OTHER to the RAID?

I have pushed this change to the master branch. Now UBI uses BLKID_USAGE_RAID flag (and the test image has been enlarged (> 1MiB)).

Thank you! I appreciate your help on getting this feature in place :)

--=20
Rafa=C5=82