Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubi: expose the volume CRC check skip flag

Now that we have the logic for skipping CRC check for static UBI volumes
in the core, let's expose it to users.

This makes use of a padding byte in the volume description data
structure as a flag. This flag only tell for now whether we should skip
the CRC check of a volume.

This checks the UBI volume for which we are trying to skip the CRC check
is static.

Let's also make sure that the flags passed to verify_mkvol_req are
valid.

We voluntarily do not take into account the skip_check flag in
vol_cdev_write() as we want to make sure what we wrote was correctly
written.

Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Quentin Schulz and committed by
Richard Weinberger
c355aa46 62652517

+30 -2
+11
drivers/mtd/ubi/cdev.c
··· 367 367 return count; 368 368 } 369 369 370 + /* 371 + * We voluntarily do not take into account the skip_check flag 372 + * as we want to make sure what we wrote was correctly written. 373 + */ 370 374 err = ubi_check_volume(ubi, vol->vol_id); 371 375 if (err < 0) 372 376 return err; ··· 623 619 goto bad; 624 620 625 621 if (req->vol_type != UBI_DYNAMIC_VOLUME && 622 + req->vol_type != UBI_STATIC_VOLUME) 623 + goto bad; 624 + 625 + if (req->flags & ~UBI_VOL_VALID_FLGS) 626 + goto bad; 627 + 628 + if (req->flags & UBI_VOL_SKIP_CRC_CHECK_FLG && 626 629 req->vol_type != UBI_STATIC_VOLUME) 627 630 goto bad; 628 631
+3
drivers/mtd/ubi/vmt.c
··· 174 174 vol->dev.class = &ubi_class; 175 175 vol->dev.groups = volume_dev_groups; 176 176 177 + if (req->flags & UBI_VOL_SKIP_CRC_CHECK_FLG) 178 + vol->skip_check = 1; 179 + 177 180 spin_lock(&ubi->volumes_lock); 178 181 if (vol_id == UBI_VOL_NUM_AUTO) { 179 182 /* Find unused volume ID */
+16 -2
include/uapi/mtd/ubi-user.h
··· 285 285 __s8 padding[10]; 286 286 }; 287 287 288 + /* 289 + * UBI volume flags. 290 + * 291 + * @UBI_VOL_SKIP_CRC_CHECK_FLG: skip the CRC check done on a static volume at 292 + * open time. Only valid for static volumes and 293 + * should only be used if the volume user has a 294 + * way to verify data integrity 295 + */ 296 + enum { 297 + UBI_VOL_SKIP_CRC_CHECK_FLG = 0x1, 298 + }; 299 + 300 + #define UBI_VOL_VALID_FLGS (UBI_VOL_SKIP_CRC_CHECK_FLG) 301 + 288 302 /** 289 303 * struct ubi_mkvol_req - volume description data structure used in 290 304 * volume creation requests. ··· 306 292 * @alignment: volume alignment 307 293 * @bytes: volume size in bytes 308 294 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) 309 - * @padding1: reserved for future, not used, has to be zeroed 295 + * @flags: volume flags (%UBI_VOL_SKIP_CRC_CHECK_FLG) 310 296 * @name_len: volume name length 311 297 * @padding2: reserved for future, not used, has to be zeroed 312 298 * @name: volume name ··· 335 321 __s32 alignment; 336 322 __s64 bytes; 337 323 __s8 vol_type; 338 - __s8 padding1; 324 + __u8 flags; 339 325 __s16 name_len; 340 326 __s8 padding2[4]; 341 327 char name[UBI_MAX_VOLUME_NAME + 1];