Skip to content

Commit 6265251

Browse files
QSchulzrichardweinberger
authored andcommitted
ubi: provide a way to skip CRC checks
Some users of static UBI volumes implement their own integrity check, thus making the volume CRC check done at open time useless. For instance, this is the case when one use the ubiblock + dm-verity + squashfs combination, where dm-verity already checks integrity of the block device but this time at the block granularity instead of verifying the whole volume. Skipping this test drastically improves the boot-time. Suggested-by: Boris Brezillon <[email protected]> Signed-off-by: Quentin Schulz <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Reviewed-by: Richard Weinberger <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent a3d2182 commit 6265251

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

drivers/mtd/ubi/kapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
202202
desc->mode = mode;
203203

204204
mutex_lock(&ubi->ckvol_mutex);
205-
if (!vol->checked) {
205+
if (!vol->checked && !vol->skip_check) {
206206
/* This is the first open - check the volume */
207207
err = ubi_check_volume(ubi, vol_id);
208208
if (err < 0) {

drivers/mtd/ubi/ubi-media.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ enum {
4545
* Volume flags used in the volume table record.
4646
*
4747
* @UBI_VTBL_AUTORESIZE_FLG: auto-resize this volume
48+
* @UBI_VTBL_SKIP_CRC_CHECK_FLG: skip the CRC check done on a static volume at
49+
* open time. Should only be set on volumes that
50+
* are used by upper layers doing this kind of
51+
* check. Main use-case for this flag is
52+
* boot-time reduction
4853
*
4954
* %UBI_VTBL_AUTORESIZE_FLG flag can be set only for one volume in the volume
5055
* table. UBI automatically re-sizes the volume which has this flag and makes
@@ -76,6 +81,7 @@ enum {
7681
*/
7782
enum {
7883
UBI_VTBL_AUTORESIZE_FLG = 0x01,
84+
UBI_VTBL_SKIP_CRC_CHECK_FLG = 0x02,
7985
};
8086

8187
/*

drivers/mtd/ubi/ubi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ struct ubi_eba_leb_desc {
327327
* atomic LEB change
328328
*
329329
* @eba_tbl: EBA table of this volume (LEB->PEB mapping)
330+
* @skip_check: %1 if CRC check of this static volume should be skipped.
331+
* Directly reflects the presence of the
332+
* %UBI_VTBL_SKIP_CRC_CHECK_FLG flag in the vtbl entry
330333
* @checked: %1 if this static volume was checked
331334
* @corrupted: %1 if the volume is corrupted (static volumes only)
332335
* @upd_marker: %1 if the update marker is set for this volume
@@ -374,6 +377,7 @@ struct ubi_volume {
374377
void *upd_buf;
375378

376379
struct ubi_eba_table *eba_tbl;
380+
unsigned int skip_check:1;
377381
unsigned int checked:1;
378382
unsigned int corrupted:1;
379383
unsigned int upd_marker:1;

drivers/mtd/ubi/vmt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
299299
vtbl_rec.vol_type = UBI_VID_DYNAMIC;
300300
else
301301
vtbl_rec.vol_type = UBI_VID_STATIC;
302+
303+
if (vol->skip_check)
304+
vtbl_rec.flags |= UBI_VTBL_SKIP_CRC_CHECK_FLG;
305+
302306
memcpy(vtbl_rec.name, vol->name, vol->name_len);
303307

304308
err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec);
@@ -733,6 +737,11 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id)
733737
ubi_err(ubi, "bad used_bytes");
734738
goto fail;
735739
}
740+
741+
if (vol->skip_check) {
742+
ubi_err(ubi, "bad skip_check");
743+
goto fail;
744+
}
736745
} else {
737746
if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) {
738747
ubi_err(ubi, "bad used_ebs");

drivers/mtd/ubi/vtbl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ static int init_volumes(struct ubi_device *ubi,
560560
vol->name[vol->name_len] = '\0';
561561
vol->vol_id = i;
562562

563+
if (vtbl[i].flags & UBI_VTBL_SKIP_CRC_CHECK_FLG)
564+
vol->skip_check = 1;
565+
563566
if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) {
564567
/* Auto re-size flag may be set only for one volume */
565568
if (ubi->autoresize_vol_id != -1) {

0 commit comments

Comments
 (0)