Re: [PATCH] md: fix for divide error in status_resync

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 14, 2019 at 2:48 PM Song Liu <liu.song.a23@xxxxxxxxx> wrote:
>
> On Thu, Jun 13, 2019 at 8:09 AM Mariusz Tkaczyk
> <mariusz.tkaczyk@xxxxxxxxx> wrote:
> >
> > Stopping external metadata arrays during resync/recovery causes
> > retries, loop of interrupting and starting reconstruction, until it
> > hit at good moment to stop completely. While these retries
> > curr_mark_cnt can be small- especially on HDD drives, so subtraction
> > result can be smaller than 0. However it is casted to uint without
> > checking. As a result of it the status bar in /proc/mdstat while stopping
> > is strange (it jumps between 0% and 99%).
> >
> > The real problem occurs here after commit 72deb455b5ec ("block: remove
> > CONFIG_LBDAF"). Sector_div() macro has been changed, now the
> > divisor is casted to uint32. For db = -8 the divisior(db/32-1) becomes 0.
> >
> > Check if db value can be really counted and replace these macro by
> > div64_u64() inline.
> >
> > Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@xxxxxxxxx>
>
> This looks good! Thanks for the fix.
>
> > ---
> >  drivers/md/md.c | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/md/md.c b/drivers/md/md.c
> > index 04f4f131f9d6..9a8b258ce1ef 100644
> > --- a/drivers/md/md.c
> > +++ b/drivers/md/md.c
> > @@ -7607,9 +7607,9 @@ static void status_unused(struct seq_file *seq)
> >  static int status_resync(struct seq_file *seq, struct mddev *mddev)
> >  {
> >         sector_t max_sectors, resync, res;
> > -       unsigned long dt, db;
> > -       sector_t rt;
> > -       int scale;
> > +       unsigned long dt, db = 0;
> > +       sector_t rt, curr_mark_cnt, resync_mark_cnt;
> > +       int scale, recovery_active;
> >         unsigned int per_milli;
> >
> >         if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ||
> > @@ -7709,11 +7709,16 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
> >          */
>
> Could you please also update comments before this section? (sector_t
> is always u64 now).

Never mind, I fixed the comments while applying the patch.

Song



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux