* UBI: Cannot create static volumes when FTL is enabled
@ 2007-05-04 22:22 John Smith
2007-05-05 11:39 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: John Smith @ 2007-05-04 22:22 UTC (permalink / raw)
To: linux-mtd
Hi,
Probably not a major bug, but here it is....
I have a slightly muddled kernel using MTD and UBI from a recent snapshot
from kernel.org, and the rest of the kernel from a derivative of 2.6.18.
I accidentally enabled the CONFIG_FTL as well as MTD and UBI.
When trying to create a static UBI volume with the command
# ubimkvol -d 0 -n 1 -N ubi-volume --type=static -s 123000
I trigger a kernel stack dump. It arises from the ubi_assert
ubi_assert(vol->vol_type != UBI_STATIC_VOLUME);
in function ubi_eba_read_leb() of file drivers/mtd/ubi/eba.c
The rest of the call trace reads:
Call Trace:
[<801d2e04>] gluebi_read+0x144/0x1bc drivers/mtd/ubi/gluebi.c:132
[<801aa2b4>] scan_header+0x84/0x248 drivers/mtd/ftl.c:178
[<801aba18>] ftl_add_mtd+0x2c/0xcc drivers/mtd/ftl.c:1045
[<801a961c>] blktrans_notify_add+0x50/0x7c drivers/mtd/mtd_blkdevs.c:336
[<801a5d74>] add_mtd_device+0xd4/0x148 drivers/mtd/mtdcore.c:75
[<801d32f0>] ubi_create_gluebi+0xd8/0x170 drivers/mtd/ubi/gluebi.c:297
[<801c459c>] ubi_create_volume+0x43c/0x854 drivers/mtd/ubi/vmt.c:316
[<801c7f60>] ubi_cdev_ioctl+0x1d0/0x2f0 drivers/mtd/ubi/cdev.c:630
[<8008b6d4>] do_ioctl+0x54/0x7c fs/ioctl.c:34
[<8008b8e0>] vfs_ioctl+0x78/0x220 fs/ioctl.c:153
[<8008bad8>] sys_ioctl+0x50/0x98 fs/ioctl.c:173
Regards
John
John Smith
Blackburn,
England.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: UBI: Cannot create static volumes when FTL is enabled
2007-05-04 22:22 UBI: Cannot create static volumes when FTL is enabled John Smith
@ 2007-05-05 11:39 ` Artem Bityutskiy
2007-05-05 11:54 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2007-05-05 11:39 UTC (permalink / raw)
To: John Smith; +Cc: linux-mtd
On Fri, 2007-05-04 at 23:22 +0100, John Smith wrote:
> Probably not a major bug, but here it is....
>
> I have a slightly muddled kernel using MTD and UBI from a recent snapshot
> from kernel.org, and the rest of the kernel from a derivative of 2.6.18.
>
> I accidentally enabled the CONFIG_FTL as well as MTD and UBI.
>
> When trying to create a static UBI volume with the command
>
> # ubimkvol -d 0 -n 1 -N ubi-volume --type=static -s 123000
>
> I trigger a kernel stack dump. It arises from the ubi_assert
>
> ubi_assert(vol->vol_type != UBI_STATIC_VOLUME);
>
> in function ubi_eba_read_leb() of file drivers/mtd/ubi/eba.c
Yeah, you have found a flaw. We actually assume that mtd devices are
emulated _only_ for dynamic volumes, but we do not disable the MTD
device emulation for static volumes. This should we fixed.
The reason why only dynamic volumes may have emulated MTD devices is
that they have "stable" size. I mean, if you create dynamic volume of
size N, you can always read N bytes from it. And it does not depend on
how many bytes of data you have on them.
In case of static volumes the situation is different. When you create an
empty static volume, it contains no data, and a read operation returns
EOF immediately. Then you write put some data to it using the "volume
update" operation. In this case you'll be able to read that amount of
data back.
Here is an example:
1. Create static volume A of size Sa.
2. Create dynamic volume B of size Sb.
3. Read whole A - 0 bytes are read.
4. Read whole B - Sb bytes are read, all of them contain 0xFFs.
5. Update A with Xa bytes of data (Xa <= Sa).
6. Update B with Xb bytes of data (Xb <= Sb).
7. Read whole A - Sa bytes are read.
8. Read whole B - Xb bytes are read.
See the difference in semantics? In case of dynamic volumes we always
read Sb bytes. If there is only Xb bytes of data, the rest will be 0xFF
bytes.
So you see that dynamic volumes are mapped to the MTD device model quite
nicely: mtd device size = volume size.
Size of static volumes depends on how much data you put there. And since
MTD infrastructure assumes that MTD device sizes are stable, there is no
good and nice way to emulate MTD devices on top of static volumes,
unless MTD subsystem is somehow re-designed.
But anyway, you have found a bug. I am going to disable MTD device
emulation for static volumes.
Thanks.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: UBI: Cannot create static volumes when FTL is enabled
2007-05-05 11:39 ` Artem Bityutskiy
@ 2007-05-05 11:54 ` Artem Bityutskiy
2007-05-05 13:40 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2007-05-05 11:54 UTC (permalink / raw)
To: John Smith; +Cc: linux-mtd
On Sat, 2007-05-05 at 14:39 +0300, Artem Bityutskiy wrote:
> So you see that dynamic volumes are mapped to the MTD device model quite
> nicely: mtd device size = volume size.
>
> Size of static volumes depends on how much data you put there. And since
> MTD infrastructure assumes that MTD device sizes are stable, there is no
> good and nice way to emulate MTD devices on top of static volumes,
> unless MTD subsystem is somehow re-designed.
>
> But anyway, you have found a bug. I am going to disable MTD device
> emulation for static volumes.
Although it still would be nice to have MTD device emulation for static
volumes. May be we have the same semantics as dynamic volumes if they
are used via gluebi. It needs more thinking.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: UBI: Cannot create static volumes when FTL is enabled
2007-05-05 11:54 ` Artem Bityutskiy
@ 2007-05-05 13:40 ` Artem Bityutskiy
0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2007-05-05 13:40 UTC (permalink / raw)
To: John Smith; +Cc: linux-mtd
On Sat, 2007-05-05 at 14:54 +0300, Artem Bityutskiy wrote:
> On Sat, 2007-05-05 at 14:39 +0300, Artem Bityutskiy wrote:
> > So you see that dynamic volumes are mapped to the MTD device model quite
> > nicely: mtd device size = volume size.
> >
> > Size of static volumes depends on how much data you put there. And since
> > MTD infrastructure assumes that MTD device sizes are stable, there is no
> > good and nice way to emulate MTD devices on top of static volumes,
> > unless MTD subsystem is somehow re-designed.
> >
> > But anyway, you have found a bug. I am going to disable MTD device
> > emulation for static volumes.
>
> Although it still would be nice to have MTD device emulation for static
> volumes. May be we have the same semantics as dynamic volumes if they
> are used via gluebi. It needs more thinking.
Well, after thinking more I have fixed this. Now we set emulated mtd
device size to data size if the volume is static.
I.e., when you create a static volume, its size is zero:
# ubimkvol -d0 -n0 -Nvol1 -s60MiB -t static
# cat /sys/class/ubi/ubi0_0/data_bytes
# 0
# cat /proc/mtd
# dev: size erasesize name
# mtd0: 08000000 00004000 "NAND simulator partition 0"
# mtd1: 00000000 00003e00 "vol1"
# ubiupdatevol -d 0 -n 0 small_file_72_bytes
# cat /sys/class/ubi/ubi0_0/data_bytes
# 72
# cat /proc/mtd
# dev: size erasesize name
# mtd0: 08000000 00004000 "NAND simulator partition 0"
# mtd1: 00000048 00003e00 "vol1"
I've committed the fix to git://git.infradead.org/~dedekind/ubi-2.6.git.
Or see
http://git.infradead.org/?p=users/dedekind/ubi-2.6.git;a=commit;h=962f24709f91fe0634b3faa3cac915c66357a239
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-05 13:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-04 22:22 UBI: Cannot create static volumes when FTL is enabled John Smith
2007-05-05 11:39 ` Artem Bityutskiy
2007-05-05 11:54 ` Artem Bityutskiy
2007-05-05 13:40 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox