Skip to content

Commit

Permalink
dm raid: change rs_set_dev_and_array_sectors API and callers
Browse files Browse the repository at this point in the history
Add a size argument to rs_set_dev_and_array_sectors as prerequisite
to fixing grown device resynchronization not occuring when new MD
bitmap pages have to be allocated as a result of the extension in
a follwup patch.

Also avoid code duplication by using rs_set_rdev_sectors
in the aforementioned function.

Signed-off-by: Heinz Mauelshagen <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
mauelsha authored and snitm committed Nov 5, 2019
1 parent 6ba01df commit 22c992e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/md/dm-raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1615,13 +1615,12 @@ static int _check_data_dev_sectors(struct raid_set *rs)
}

/* Calculate the sectors per device and per array used for @rs */
static int rs_set_dev_and_array_sectors(struct raid_set *rs, bool use_mddev)
static int rs_set_dev_and_array_sectors(struct raid_set *rs, sector_t sectors, bool use_mddev)
{
int delta_disks;
unsigned int data_stripes;
sector_t array_sectors = sectors, dev_sectors = sectors;
struct mddev *mddev = &rs->md;
struct md_rdev *rdev;
sector_t array_sectors = rs->ti->len, dev_sectors = rs->ti->len;

if (use_mddev) {
delta_disks = mddev->delta_disks;
Expand Down Expand Up @@ -1656,12 +1655,9 @@ static int rs_set_dev_and_array_sectors(struct raid_set *rs, bool use_mddev)
/* Striped layouts */
array_sectors = (data_stripes + delta_disks) * dev_sectors;

rdev_for_each(rdev, mddev)
if (!test_bit(Journal, &rdev->flags))
rdev->sectors = dev_sectors;

mddev->array_sectors = array_sectors;
mddev->dev_sectors = dev_sectors;
rs_set_rdev_sectors(rs);

return _check_data_dev_sectors(rs);
bad:
Expand Down Expand Up @@ -2911,7 +2907,7 @@ static int rs_setup_reshape(struct raid_set *rs)

/* Remove disk(s) */
} else if (rs->delta_disks < 0) {
r = rs_set_dev_and_array_sectors(rs, true);
r = rs_set_dev_and_array_sectors(rs, rs->ti->len, true);
mddev->reshape_backwards = 1; /* removing disk(s) -> backward reshape */

/* Change layout and/or chunk size */
Expand Down Expand Up @@ -3067,7 +3063,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
*
* Any existing superblock will overwrite the array and device sizes
*/
r = rs_set_dev_and_array_sectors(rs, false);
r = rs_set_dev_and_array_sectors(rs, rs->ti->len, false);
if (r)
goto bad;

Expand Down

0 comments on commit 22c992e

Please sign in to comment.