md/raid10: simplify/reindent some loops.

When a loop ends with a large if, it can be neater to change the
if to invert the condition and just 'continue'.
Then the body of the if can be indented to a lower level.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-07-28 11:39:23 +10:00
parent b84db560ea
commit 1294b9c973
1 changed files with 64 additions and 61 deletions

View File

@ -1533,80 +1533,83 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
sl--; sl--;
d = r10_bio->devs[sl].devnum; d = r10_bio->devs[sl].devnum;
rdev = rcu_dereference(conf->mirrors[d].rdev); rdev = rcu_dereference(conf->mirrors[d].rdev);
if (rdev && if (!rdev ||
test_bit(In_sync, &rdev->flags)) { !test_bit(In_sync, &rdev->flags))
atomic_inc(&rdev->nr_pending); continue;
rcu_read_unlock();
if (sync_page_io(rdev, atomic_inc(&rdev->nr_pending);
r10_bio->devs[sl].addr + rcu_read_unlock();
sect, if (sync_page_io(rdev,
s<<9, conf->tmppage, WRITE, false) r10_bio->devs[sl].addr +
== 0) { sect,
/* Well, this device is dead */ s<<9, conf->tmppage, WRITE, false)
printk(KERN_NOTICE == 0) {
"md/raid10:%s: read correction " /* Well, this device is dead */
"write failed" printk(KERN_NOTICE
" (%d sectors at %llu on %s)\n", "md/raid10:%s: read correction "
mdname(mddev), s, "write failed"
(unsigned long long)( " (%d sectors at %llu on %s)\n",
sect + rdev->data_offset), mdname(mddev), s,
bdevname(rdev->bdev, b)); (unsigned long long)(
printk(KERN_NOTICE "md/raid10:%s: %s: failing " sect + rdev->data_offset),
"drive\n", bdevname(rdev->bdev, b));
mdname(mddev), printk(KERN_NOTICE "md/raid10:%s: %s: failing "
bdevname(rdev->bdev, b)); "drive\n",
md_error(mddev, rdev); mdname(mddev),
} bdevname(rdev->bdev, b));
rdev_dec_pending(rdev, mddev); md_error(mddev, rdev);
rcu_read_lock();
} }
rdev_dec_pending(rdev, mddev);
rcu_read_lock();
} }
sl = start; sl = start;
while (sl != r10_bio->read_slot) { while (sl != r10_bio->read_slot) {
char b[BDEVNAME_SIZE];
if (sl==0) if (sl==0)
sl = conf->copies; sl = conf->copies;
sl--; sl--;
d = r10_bio->devs[sl].devnum; d = r10_bio->devs[sl].devnum;
rdev = rcu_dereference(conf->mirrors[d].rdev); rdev = rcu_dereference(conf->mirrors[d].rdev);
if (rdev && if (!rdev ||
test_bit(In_sync, &rdev->flags)) { !test_bit(In_sync, &rdev->flags))
char b[BDEVNAME_SIZE]; continue;
atomic_inc(&rdev->nr_pending);
rcu_read_unlock();
if (sync_page_io(rdev,
r10_bio->devs[sl].addr +
sect,
s<<9, conf->tmppage,
READ, false) == 0) {
/* Well, this device is dead */
printk(KERN_NOTICE
"md/raid10:%s: unable to read back "
"corrected sectors"
" (%d sectors at %llu on %s)\n",
mdname(mddev), s,
(unsigned long long)(
sect + rdev->data_offset),
bdevname(rdev->bdev, b));
printk(KERN_NOTICE "md/raid10:%s: %s: failing drive\n",
mdname(mddev),
bdevname(rdev->bdev, b));
md_error(mddev, rdev); atomic_inc(&rdev->nr_pending);
} else { rcu_read_unlock();
printk(KERN_INFO if (sync_page_io(rdev,
"md/raid10:%s: read error corrected" r10_bio->devs[sl].addr +
" (%d sectors at %llu on %s)\n", sect,
mdname(mddev), s, s<<9, conf->tmppage,
(unsigned long long)( READ, false) == 0) {
sect + rdev->data_offset), /* Well, this device is dead */
bdevname(rdev->bdev, b)); printk(KERN_NOTICE
atomic_add(s, &rdev->corrected_errors); "md/raid10:%s: unable to read back "
} "corrected sectors"
" (%d sectors at %llu on %s)\n",
mdname(mddev), s,
(unsigned long long)(
sect + rdev->data_offset),
bdevname(rdev->bdev, b));
printk(KERN_NOTICE "md/raid10:%s: %s: failing "
"drive\n",
mdname(mddev),
bdevname(rdev->bdev, b));
rdev_dec_pending(rdev, mddev); md_error(mddev, rdev);
rcu_read_lock(); } else {
printk(KERN_INFO
"md/raid10:%s: read error corrected"
" (%d sectors at %llu on %s)\n",
mdname(mddev), s,
(unsigned long long)(
sect + rdev->data_offset),
bdevname(rdev->bdev, b));
atomic_add(s, &rdev->corrected_errors);
} }
rdev_dec_pending(rdev, mddev);
rcu_read_lock();
} }
rcu_read_unlock(); rcu_read_unlock();