[PATCH v3 02/11] erofs-utils: lib: scan devtable if extra_devices is not specified
Gao Xiang
hsiangkao at linux.alibaba.com
Wed Aug 23 13:15:44 AEST 2023
On 2023/8/22 17:24, Jingbo Xu wrote:
> Scan the devtable (if any) automatically when reading superblock from
> disk if sbi->extra_devices is not specified, and initialize
> sbi->extra_devices with the number of on-disk device slots.
>
> Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
> ---
> lib/super.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/super.c b/lib/super.c
> index 4fe81c3..fc709fc 100644
> --- a/lib/super.c
> +++ b/lib/super.c
> @@ -37,7 +37,8 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,
> else
> ondisk_extradevs = le16_to_cpu(dsb->extra_devices);
>
> - if (ondisk_extradevs != sbi->extra_devices) {
> + if (sbi->extra_devices &&
> + ondisk_extradevs != sbi->extra_devices) {
If you'd like to keep in sync with the kernel
erofs_scan_devices(), please point it out explicitly in the commit message.
Thanks,
Gao Xiang
> erofs_err("extra devices don't match (ondisk %u, given %u)",
> ondisk_extradevs, sbi->extra_devices);
> return -EINVAL;
> @@ -45,6 +46,7 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,
> if (!ondisk_extradevs)
> return 0;
>
> + sbi->extra_devices = ondisk_extradevs;
> sbi->device_id_mask = roundup_pow_of_two(ondisk_extradevs + 1) - 1;
> sbi->devs = calloc(ondisk_extradevs, sizeof(*sbi->devs));
> if (!sbi->devs)
More information about the Linux-erofs
mailing list