summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-06-23 10:49:15 +1000
committerNeilBrown <neilb@suse.de>2011-06-23 10:49:15 +1000
commitb92e848309425a50545657220d05a3d42fdbd04c (patch)
tree6ca43a3566cf00ca9bee1e3584e8ec67ba5bd3b8
parenta8d1d1b6a4057365c608628359d79abcdc216519 (diff)
md/raid5: finalise new merged handle_stripe.
handle_stripe5() and handle_stripe6() are now virtually identical. So discard one and rename the other to 'analyse_stripe()'. It always returns 0, so change it to 'void' and remove the 'done' variable in handle_stripe(). Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/raid5.c103
1 files changed, 9 insertions, 94 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 56b42e208cfc..82c07fb38961 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2899,85 +2899,7 @@ static void handle_stripe_expansion(raid5_conf_t *conf, struct stripe_head *sh,
*
*/
-static int handle_stripe5(struct stripe_head *sh, struct stripe_head_state *s)
-{
- raid5_conf_t *conf = sh->raid_conf;
- int disks = sh->disks, i;
- struct r5dev *dev;
-
- /* Now to look around and see what can be done */
- rcu_read_lock();
- spin_lock_irq(&conf->device_lock);
- for (i=disks; i--; ) {
- mdk_rdev_t *rdev;
-
- dev = &sh->dev[i];
-
- pr_debug("check %d: state 0x%lx toread %p read %p write %p "
- "written %p\n", i, dev->flags, dev->toread, dev->read,
- dev->towrite, dev->written);
-
- /* maybe we can request a biofill operation
- *
- * new wantfill requests are only permitted while
- * ops_complete_biofill is guaranteed to be inactive
- */
- if (test_bit(R5_UPTODATE, &dev->flags) && dev->toread &&
- !test_bit(STRIPE_BIOFILL_RUN, &sh->state))
- set_bit(R5_Wantfill, &dev->flags);
-
- /* now count some things */
- if (test_bit(R5_LOCKED, &dev->flags)) s->locked++;
- if (test_bit(R5_UPTODATE, &dev->flags)) s->uptodate++;
- if (test_bit(R5_Wantcompute, &dev->flags)) s->compute++;
-
- if (test_bit(R5_Wantfill, &dev->flags))
- s->to_fill++;
- else if (dev->toread)
- s->to_read++;
- if (dev->towrite) {
- s->to_write++;
- if (!test_bit(R5_OVERWRITE, &dev->flags))
- s->non_overwrite++;
- }
- if (dev->written)
- s->written++;
- rdev = rcu_dereference(conf->disks[i].rdev);
- if (s->blocked_rdev == NULL &&
- rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
- s->blocked_rdev = rdev;
- atomic_inc(&rdev->nr_pending);
- }
- clear_bit(R5_Insync, &dev->flags);
- if (!rdev)
- /* Not in-sync */;
- else if (test_bit(In_sync, &rdev->flags))
- set_bit(R5_Insync, &dev->flags);
- else {
- /* could be in-sync depending on recovery/reshape status */
- if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
- set_bit(R5_Insync, &dev->flags);
- }
- if (!test_bit(R5_Insync, &dev->flags)) {
- /* The ReadError flag will just be confusing now */
- clear_bit(R5_ReadError, &dev->flags);
- clear_bit(R5_ReWrite, &dev->flags);
- }
- if (test_bit(R5_ReadError, &dev->flags))
- clear_bit(R5_Insync, &dev->flags);
- if (!test_bit(R5_Insync, &dev->flags)) {
- if (s->failed < 2)
- s->failed_num[s->failed] = i;
- s->failed++;
- }
- }
- spin_unlock_irq(&conf->device_lock);
- rcu_read_unlock();
-
- return 0;
-}
-
-static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
+static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
{
raid5_conf_t *conf = sh->raid_conf;
int disks = sh->disks;
@@ -2985,11 +2907,11 @@ static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
int i;
/* Now to look around and see what can be done */
-
rcu_read_lock();
spin_lock_irq(&conf->device_lock);
for (i=disks; i--; ) {
mdk_rdev_t *rdev;
+
dev = &sh->dev[i];
pr_debug("check %d: state 0x%lx read %p write %p written %p\n",
@@ -3004,16 +2926,18 @@ static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
set_bit(R5_Wantfill, &dev->flags);
/* now count some things */
- if (test_bit(R5_LOCKED, &dev->flags)) s->locked++;
- if (test_bit(R5_UPTODATE, &dev->flags)) s->uptodate++;
+ if (test_bit(R5_LOCKED, &dev->flags))
+ s->locked++;
+ if (test_bit(R5_UPTODATE, &dev->flags))
+ s->uptodate++;
if (test_bit(R5_Wantcompute, &dev->flags)) {
s->compute++;
BUG_ON(s->compute > 2);
}
- if (test_bit(R5_Wantfill, &dev->flags)) {
+ if (test_bit(R5_Wantfill, &dev->flags))
s->to_fill++;
- } else if (dev->toread)
+ else if (dev->toread)
s->to_read++;
if (dev->towrite) {
s->to_write++;
@@ -3053,14 +2977,11 @@ static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
}
spin_unlock_irq(&conf->device_lock);
rcu_read_unlock();
-
- return 0;
}
static void handle_stripe(struct stripe_head *sh)
{
struct stripe_head_state s;
- int done;
raid5_conf_t *conf = sh->raid_conf;
int i;
int prexor;
@@ -3094,13 +3015,7 @@ static void handle_stripe(struct stripe_head *sh)
s.failed_num[0] = -1;
s.failed_num[1] = -1;
- if (conf->level == 6)
- done = handle_stripe6(sh, &s);
- else
- done = handle_stripe5(sh, &s);
-
- if (done)
- goto finish;
+ analyse_stripe(sh, &s);
if (unlikely(s.blocked_rdev)) {
if (s.syncing || s.expanding || s.expanded ||