aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid6main.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:24 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:04 -0500
commit9910f16af35419a5382fa7850eecc220103036fa (patch)
tree3b5145b8a706e03a6f2b4da4bd84fe98c83de31a /drivers/md/raid6main.c
parentcf30a473a02901fe4db37abc0b0fa26dd5ba3f72 (diff)
[PATCH] md: fix up some rdev rcu locking in raid5/6
There is this "FIXME" comment with a typo in it!! that been annoying me for days, so I just had to remove it. conf->disks[i].rdev should only be accessed if - we know we hold a reference or - the mddev->reconfig_sem is down or - we have a rcu_readlock handle_stripe was referencing rdev in three places without any of these. For the first two, get an rcu_readlock. For the last, the same access (md_sync_acct call) is made a little later after the rdev has been claimed under and rcu_readlock, if R5_Syncio is set. So just use that access... However R5_Syncio isn't really needed as the 'syncing' variable contains the same information. So use that instead. Issues, comment, and fix are identical in raid5 and raid6. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/raid6main.c')
-rw-r--r--drivers/md/raid6main.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 7a51553d8be5..b5b7a8d0b165 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1060,11 +1060,11 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1060 syncing = test_bit(STRIPE_SYNCING, &sh->state); 1060 syncing = test_bit(STRIPE_SYNCING, &sh->state);
1061 /* Now to look around and see what can be done */ 1061 /* Now to look around and see what can be done */
1062 1062
1063 rcu_read_lock();
1063 for (i=disks; i--; ) { 1064 for (i=disks; i--; ) {
1064 mdk_rdev_t *rdev; 1065 mdk_rdev_t *rdev;
1065 dev = &sh->dev[i]; 1066 dev = &sh->dev[i];
1066 clear_bit(R5_Insync, &dev->flags); 1067 clear_bit(R5_Insync, &dev->flags);
1067 clear_bit(R5_Syncio, &dev->flags);
1068 1068
1069 PRINTK("check %d: state 0x%lx read %p write %p written %p\n", 1069 PRINTK("check %d: state 0x%lx read %p write %p written %p\n",
1070 i, dev->flags, dev->toread, dev->towrite, dev->written); 1070 i, dev->flags, dev->toread, dev->towrite, dev->written);
@@ -1103,7 +1103,7 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1103 non_overwrite++; 1103 non_overwrite++;
1104 } 1104 }
1105 if (dev->written) written++; 1105 if (dev->written) written++;
1106 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ 1106 rdev = rcu_dereference(conf->disks[i].rdev);
1107 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 1107 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
1108 /* The ReadError flag will just be confusing now */ 1108 /* The ReadError flag will just be confusing now */
1109 clear_bit(R5_ReadError, &dev->flags); 1109 clear_bit(R5_ReadError, &dev->flags);
@@ -1117,6 +1117,7 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1117 } else 1117 } else
1118 set_bit(R5_Insync, &dev->flags); 1118 set_bit(R5_Insync, &dev->flags);
1119 } 1119 }
1120 rcu_read_unlock();
1120 PRINTK("locked=%d uptodate=%d to_read=%d" 1121 PRINTK("locked=%d uptodate=%d to_read=%d"
1121 " to_write=%d failed=%d failed_num=%d,%d\n", 1122 " to_write=%d failed=%d failed_num=%d,%d\n",
1122 locked, uptodate, to_read, to_write, failed, 1123 locked, uptodate, to_read, to_write, failed,
@@ -1129,10 +1130,13 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1129 int bitmap_end = 0; 1130 int bitmap_end = 0;
1130 1131
1131 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 1132 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
1132 mdk_rdev_t *rdev = conf->disks[i].rdev; 1133 mdk_rdev_t *rdev;
1134 rcu_read_lock();
1135 rdev = rcu_dereference(conf->disks[i].rdev);
1133 if (rdev && test_bit(In_sync, &rdev->flags)) 1136 if (rdev && test_bit(In_sync, &rdev->flags))
1134 /* multiple read failures in one stripe */ 1137 /* multiple read failures in one stripe */
1135 md_error(conf->mddev, rdev); 1138 md_error(conf->mddev, rdev);
1139 rcu_read_unlock();
1136 } 1140 }
1137 1141
1138 spin_lock_irq(&conf->device_lock); 1142 spin_lock_irq(&conf->device_lock);
@@ -1307,9 +1311,6 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1307 locked++; 1311 locked++;
1308 PRINTK("Reading block %d (sync=%d)\n", 1312 PRINTK("Reading block %d (sync=%d)\n",
1309 i, syncing); 1313 i, syncing);
1310 if (syncing)
1311 md_sync_acct(conf->disks[i].rdev->bdev,
1312 STRIPE_SECTORS);
1313 } 1314 }
1314 } 1315 }
1315 } 1316 }
@@ -1463,14 +1464,12 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1463 locked++; 1464 locked++;
1464 set_bit(R5_LOCKED, &dev->flags); 1465 set_bit(R5_LOCKED, &dev->flags);
1465 set_bit(R5_Wantwrite, &dev->flags); 1466 set_bit(R5_Wantwrite, &dev->flags);
1466 set_bit(R5_Syncio, &dev->flags);
1467 } 1467 }
1468 if (failed >= 1) { 1468 if (failed >= 1) {
1469 dev = &sh->dev[failed_num[0]]; 1469 dev = &sh->dev[failed_num[0]];
1470 locked++; 1470 locked++;
1471 set_bit(R5_LOCKED, &dev->flags); 1471 set_bit(R5_LOCKED, &dev->flags);
1472 set_bit(R5_Wantwrite, &dev->flags); 1472 set_bit(R5_Wantwrite, &dev->flags);
1473 set_bit(R5_Syncio, &dev->flags);
1474 } 1473 }
1475 1474
1476 if (update_p) { 1475 if (update_p) {
@@ -1478,14 +1477,12 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1478 locked ++; 1477 locked ++;
1479 set_bit(R5_LOCKED, &dev->flags); 1478 set_bit(R5_LOCKED, &dev->flags);
1480 set_bit(R5_Wantwrite, &dev->flags); 1479 set_bit(R5_Wantwrite, &dev->flags);
1481 set_bit(R5_Syncio, &dev->flags);
1482 } 1480 }
1483 if (update_q) { 1481 if (update_q) {
1484 dev = &sh->dev[qd_idx]; 1482 dev = &sh->dev[qd_idx];
1485 locked++; 1483 locked++;
1486 set_bit(R5_LOCKED, &dev->flags); 1484 set_bit(R5_LOCKED, &dev->flags);
1487 set_bit(R5_Wantwrite, &dev->flags); 1485 set_bit(R5_Wantwrite, &dev->flags);
1488 set_bit(R5_Syncio, &dev->flags);
1489 } 1486 }
1490 clear_bit(STRIPE_DEGRADED, &sh->state); 1487 clear_bit(STRIPE_DEGRADED, &sh->state);
1491 1488
@@ -1557,7 +1554,7 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1557 rcu_read_unlock(); 1554 rcu_read_unlock();
1558 1555
1559 if (rdev) { 1556 if (rdev) {
1560 if (test_bit(R5_Syncio, &sh->dev[i].flags)) 1557 if (syncing)
1561 md_sync_acct(rdev->bdev, STRIPE_SECTORS); 1558 md_sync_acct(rdev->bdev, STRIPE_SECTORS);
1562 1559
1563 bi->bi_bdev = rdev->bdev; 1560 bi->bi_bdev = rdev->bdev;