Repository navigation
backup: stream UBI volumes, back up all of Novatek's partitions (#234) - #235
Conversation
`ipctool upload` with a backup on a Novatek NT98566 with 128 MB of NAND
refused with "Not sent: 1 partition(s) of the flash could not be read".
Its rootfs is a 62.5 MB UBI volume, and the backup malloc()ed every UBI
volume whole and held them all at once -- more than the camera has
free. The sha1s in the same report were fine, because those stream.
- A UBI volume is now a span with a path: http_post() and save_file()
read it in 64 KB pieces while sending or writing. Nothing else
changes in the body or the file. A file that ends short of its length
stops the upload with ERR_SOURCE, since the Content-Length is already
sent.
- A partition that cannot be read is named, with the reason
("rootfs (UBI volume rootfs, /dev/ubi0_0): ..."), instead of only
being counted. "No partition found" is no longer reported as "1
partition could not be read".
- read_ubi_volume() is gone, with nothing left calling it.
- http_test: a file-backed span arrives whole between in-memory ones,
and a short file is ERR_SOURCE.
PR Summary by QodoStream UBI volumes during backup uploads and file saves
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1.
|
…ailed write is named as one
On a gk7205v510 with NAND, each UBI volume is also an MTD device (gluebi: mtd3 kernel, mtd4 rootfs, mtd5 rootfs_data). The ones not mounted opened here and were listed as partitions after the UBI partition that already holds them: the report showed `kernel` twice and the backup carried it twice. The mounted ones refuse O_RDWR and were skipped. So what appeared depended on what was mounted. They are MTD_UBIVOLUME, not flash, and are now skipped for every consumer.
The NT98566 in #234 has twelve MTD partitions; /proc/mtd was read up to ten, so "encrypt" (4 MB at 0x7c00000) and "all" were dropped without a word. The report said 124M for a 128 MB chip, and a backup would have lacked "encrypt" while calling itself whole. MAX_MTD is now MAX_MTDBLOCKS (20; restore indexes partitions by number up to that). "all" -- 0 to the chip's end, after the partitions that cover it -- is another name for the flash, and backing it up would put the chip in twice. mtd_mark_aliases() leaves out a partition that contains another whole, by the offsets in /sys/class/mtd/mtdN/offset, or, without them, one whose size is the sum of all the others'. mtd_alias_test holds it to #234's layout both ways, and to a NOR layout where nothing is an alias. On the lab gk7205v510 NAND and hi3516ev300 NOR the report and backup are unchanged.
Fixes #234.
backup: stream UBI volumes instead of holding them in RAM
ipctool uploadwith a backup on a Novatek NT98566 with 128 MB of NANDrefused with "Not sent: 1 partition(s) of the flash could not be read".
Its rootfs is a 62.5 MB UBI volume, and the backup malloc()ed every UBI
volume whole and held them all at once -- more than the camera has
free. The sha1s in the same report were fine, because those stream.
read it in 64 KB pieces while sending or writing. Nothing else
changes in the body or the file. A file that ends short of its length
stops the upload with ERR_SOURCE, since the Content-Length is already
sent.
("rootfs (UBI volume rootfs, /dev/ubi0_0): ..."), instead of only
being counted. "No partition found" is no longer reported as "1
partition could not be read".
and a short file is ERR_SOURCE.
mtd: leave gluebi's UBI-volume devices out of the partitions
On a gk7205v510 with NAND, each UBI volume is also an MTD device
(gluebi: mtd3 kernel, mtd4 rootfs, mtd5 rootfs_data). The ones not
mounted opened here and were listed as partitions after the UBI
partition that already holds them: the report showed
kerneltwiceand the backup carried it twice. The mounted ones refuse O_RDWR and
were skipped. So what appeared depended on what was mounted. They are
MTD_UBIVOLUME, not flash, and are now skipped for every consumer.
Tested on hardware
On a lab gk7205v510 with 128 MB NAND, which has three UBI volumes (rootfs_data 84 MB, rootfs 32 MB, kernel 4 MB) and ~50 MB free:
Not sent: 1 partition(s) of the flash could not be read, the same as the report from the Novatek NT98566 in ipctool upload bug #232.Backing up 5 partitions, 124032 KB; 127,010,625 bytes reached a test receiver, and the camera's free RAM didn't move. Each block in the received backup matchessha1sumon the camera: mtdblock0, mtdblock1, /dev/ubi0_0..2.kernellisted and backed up twice) before the last commit, and not after.Not tested:
ipctool backup <file>'s streamed path on hardware (no room for 124 MB on the camera).http_testcovers the shared streaming code.mtd: all twelve of Novatek's partitions, and not its "all"
The NT98566 in #234 has 12 MTD partitions. /proc/mtd was read only up to 10, so
encrypt(4 MB) andallwere dropped without a word: the report said 124M on a 128 MB chip, and a backup would have lackedencrypt. The limit is now 20 (MAX_MTDBLOCKS).all, an alias for the whole chip, is left out using the offsets in sysfs, or by size where a kernel has no offsets.mtd_alias_testcovers #234's layout both ways and a NOR layout. On both lab boards the report and backup are unchanged.