Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139926
b: refs/heads/master
c: d562b0c
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown committed Mar 31, 2009
1 parent 668be71 commit 5e55586
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 245f46c2c221ef09c7db892f0e3fc2149be42052
refs/heads/master: d562b0c4313e3ddea402a400371afa47ddf679f9
48 changes: 48 additions & 0 deletions trunk/drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -4884,6 +4884,53 @@ static void raid5_quiesce(mddev_t *mddev, int state)
}
}


static void *raid5_takeover_raid1(mddev_t *mddev)
{
int chunksect;

if (mddev->raid_disks != 2 ||
mddev->degraded > 1)
return ERR_PTR(-EINVAL);

/* Should check if there are write-behind devices? */

chunksect = 64*2; /* 64K by default */

/* The array must be an exact multiple of chunksize */
while (chunksect && (mddev->array_sectors & (chunksect-1)))
chunksect >>= 1;

if ((chunksect<<9) < STRIPE_SIZE)
/* array size does not allow a suitable chunk size */
return ERR_PTR(-EINVAL);

mddev->new_level = 5;
mddev->new_layout = ALGORITHM_LEFT_SYMMETRIC;
mddev->new_chunk = chunksect << 9;

return setup_conf(mddev);
}


static void *raid5_takeover(mddev_t *mddev)
{
/* raid5 can take over:
* raid0 - if all devices are the same - make it a raid4 layout
* raid1 - if there are two drives. We need to know the chunk size
* raid4 - trivial - just use a raid4 layout.
* raid6 - Providing it is a *_6 layout
*
* For now, just do raid1
*/

if (mddev->level == 1)
return raid5_takeover_raid1(mddev);

return ERR_PTR(-EINVAL);
}


static struct mdk_personality raid5_personality;

static void *raid6_takeover(mddev_t *mddev)
Expand Down Expand Up @@ -4975,6 +5022,7 @@ static struct mdk_personality raid5_personality =
.start_reshape = raid5_start_reshape,
#endif
.quiesce = raid5_quiesce,
.takeover = raid5_takeover,
};

static struct mdk_personality raid4_personality =
Expand Down

0 comments on commit 5e55586

Please sign in to comment.