libnvdimm, btt: refactor initial_offset calculations

In preparation for BTT error clearing, refactor the initial offset
calculations. Until now, all callers of arena_{read,write}_bytes assumed
a relative offset to the arena, and it was later adjusted for the
initial offset. Until now, every time we calculated a relative offset,
we passed it to these functions to do reads or writes, and so where the
offset calculations happened didn't matter.

For error clearing, there will be places where we calculate offsets to
check for the presence of media errors, and the above scheme becomes
error prone.

Make the initial_offset calculations explicit for all callers of
arena_{read,write}_bytes, and provide a helper to do them. The error
checking/clearing code can then use these same helpers.

Reported-by: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
1 file changed