[sheepdog] [PATCH] collie/farm: fixed wrong way of calculating nr_vmstate_obejct
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Tue Jun 25 09:06:26 CEST 2013
At Tue, 25 Jun 2013 14:58:35 +0800,
Liu Yuan wrote:
>
> On Tue, Jun 25, 2013 at 02:37:55PM +0800, Liu Yuan wrote:
> > On Mon, Jun 24, 2013 at 10:54:17PM -0700, Kai Zhang wrote:
> > > Without this patch, tests/functional/030 will not pass.
> > >
> > > Signed-off-by: Kai Zhang <kyle at zelin.io>
> > > ---
> > > collie/cluster.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/collie/cluster.c b/collie/cluster.c
> > > index 4e94ad2..21218dc 100644
> > > --- a/collie/cluster.c
> > > +++ b/collie/cluster.c
> > > @@ -273,7 +273,9 @@ static void fill_object_tree(uint32_t vid, const char *name, const char *tag,
> > > }
> > >
> > > /* fill vmstate object id */
> > > - nr_vmstate_object = (i->vm_state_size / SD_DATA_OBJ_SIZE) + 1;
> > > + nr_vmstate_object = i->vm_state_size / SD_DATA_OBJ_SIZE;
> > > + if (i->vm_state_size % SD_DATA_OBJ_SIZE != 0)
> > > + nr_vmstate_object++;
> >
> > How about following?
> > nr_vmstate_object = i->vm_state_size ?
> > i->vm_state_size / SD_DATA_OBJ_SIZE + 1 : 0;
> >
>
> It seems that you are worried about vm_state_size not aligned to SD_DATA_OBJ_SIZE,
> so following is better approach:
> nr_vmstate_object = round_up(i->vm_state_size, SD_DATA_OBJ_SIZE) / SD_DATA_OBJ_SIZE;
DIV_ROUND_UP is better.
Thanks,
Kazutaka
More information about the sheepdog
mailing list