]> git.baikalelectronics.ru Git - kernel.git/commit
md: fix for divide error in status_resync
authorMariusz Tkaczyk <mariusz.tkaczyk@intel.com>
Thu, 13 Jun 2019 14:11:41 +0000 (16:11 +0200)
committerSong Liu <songliubraving@fb.com>
Tue, 18 Jun 2019 15:02:25 +0000 (08:02 -0700)
commit5e786db091e6936f72a9ac4dbc173f46924974f4
treecd0bd2bc929fd1ac51b4cde63037c2ff0f9c3a7b
parent5e26ecc21d367c1e0d221ae9d85fde1fdccd153b
md: fix for divide error in status_resync

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 be6b5790f1a0 ("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@intel.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
drivers/md/md.c