Message ID | 20190426110538.11076-2-mk@mkio.de |
---|---|
State | Changes Requested |
Headers | show |
Series | fixes and extensions to ubivol_handler | expand |
On 26/04/19 13:05, Markus Klotzbuecher wrote: > Use vol_info.rsvd_bytes instead of data_bytes. For dynamic volumes > both values are equal, but for static volumes, data_bytes is the > number of stored bytes and rsvd_bytes is the size of the volume. > > As a consequence, the check in adjust_volume for whether the volume > size has changed is always true for static volumes, and the volume > gets unecessarily deleted and recreated. ok, this is a bug, agree. Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic > > Signed-off-by: Markus Klotzbuecher <markus.klotzbuecher@kistler.com> > --- > handlers/ubivol_handler.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c > index 805e610..62d9aea 100644 > --- a/handlers/ubivol_handler.c > +++ b/handlers/ubivol_handler.c > @@ -203,7 +203,7 @@ static int adjust_volume(struct img_type *cfg, > /* Check if size is changed */ > requested_lebs = cfg->partsize / mtd_info->dev_info.leb_size + > ((cfg->partsize % mtd_info->dev_info.leb_size) ? 1 : 0); > - allocated_lebs = ubivol->vol_info.data_bytes / mtd_info->dev_info.leb_size; > + allocated_lebs = ubivol->vol_info.rsvd_bytes / mtd_info->dev_info.leb_size; > > if (requested_lebs == allocated_lebs) > return 0; > @@ -258,7 +258,7 @@ static int adjust_volume(struct img_type *cfg, > } > LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next); > TRACE("Created UBI Volume %s of %lld bytes (requested %lld)", > - req.name, ubivol->vol_info.data_bytes, req.bytes); > + req.name, ubivol->vol_info.rsvd_bytes, req.bytes); > > return 0; > } >
diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 805e610..62d9aea 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -203,7 +203,7 @@ static int adjust_volume(struct img_type *cfg, /* Check if size is changed */ requested_lebs = cfg->partsize / mtd_info->dev_info.leb_size + ((cfg->partsize % mtd_info->dev_info.leb_size) ? 1 : 0); - allocated_lebs = ubivol->vol_info.data_bytes / mtd_info->dev_info.leb_size; + allocated_lebs = ubivol->vol_info.rsvd_bytes / mtd_info->dev_info.leb_size; if (requested_lebs == allocated_lebs) return 0; @@ -258,7 +258,7 @@ static int adjust_volume(struct img_type *cfg, } LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next); TRACE("Created UBI Volume %s of %lld bytes (requested %lld)", - req.name, ubivol->vol_info.data_bytes, req.bytes); + req.name, ubivol->vol_info.rsvd_bytes, req.bytes); return 0; }
Use vol_info.rsvd_bytes instead of data_bytes. For dynamic volumes both values are equal, but for static volumes, data_bytes is the number of stored bytes and rsvd_bytes is the size of the volume. As a consequence, the check in adjust_volume for whether the volume size has changed is always true for static volumes, and the volume gets unecessarily deleted and recreated. Signed-off-by: Markus Klotzbuecher <markus.klotzbuecher@kistler.com> --- handlers/ubivol_handler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)