NeilBrown 4b80991c6c md: Protect access to mddev->disks list using RCU
All modifications and most access to the mddev->disks list are made
under the reconfig_mutex lock.  However there are three places where
the list is walked without any locking.  If a reconfig happens at this
time, havoc (and oops) can ensue.

So use RCU to protect these accesses:
  - wrap them in rcu_read_{,un}lock()
  - use list_for_each_entry_rcu
  - add to the list with list_add_rcu
  - delete from the list with list_del_rcu
  - delay the 'free' with call_rcu rather than schedule_work

Note that export_rdev did a list_del_init on this list.  In almost all
cases the entry was not in the list anymore so it was a no-op and so
safe.  It is no longer safe as after list_del_rcu we may not touch
the list_head.
An audit shows that export_rdev is called:
  - after unbind_rdev_from_array, in which case the delete has
     already been done,
  - after bind_rdev_to_array fails, in which case the delete isn't needed.
  - before the device has been put on a list at all (e.g. in
      add_new_disk where reading the superblock fails).
  - and in autorun devices after a failure when the device is on a
      different list.

So remove the list_del_init call from export_rdev, and add it back
immediately before the called to export_rdev for that last case.

Note also that ->same_set is sometimes used for lists other than
mddev->list (e.g. candidates).  In these cases rcu is not needed.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-07-21 17:05:25 +10:00
..
2008-05-20 14:14:15 -07:00
2008-06-19 10:42:17 +10:00
2008-06-19 10:42:17 +10:00
2008-04-29 08:06:00 -07:00
2008-04-29 08:11:16 -07:00
2008-06-06 11:29:10 -07:00
2008-04-29 12:36:54 -07:00
2008-04-29 08:06:01 -07:00
2008-07-04 10:40:05 -07:00
2008-05-01 08:03:59 -07:00
2008-04-30 08:29:52 -07:00
2008-07-04 10:40:09 -07:00
2008-04-28 08:58:30 -07:00
2008-05-07 09:48:23 +02:00
2008-04-28 08:58:35 -07:00
2008-05-16 17:22:26 -04:00
2008-05-01 13:08:16 -04:00
2008-05-13 08:02:26 -07:00
2008-05-24 09:56:13 -07:00
2008-05-20 16:44:43 +02:00
2008-05-20 16:44:43 +02:00
2008-04-29 23:11:38 +02:00
2008-07-01 22:38:18 +02:00
2008-04-29 08:06:25 -07:00
2008-04-29 08:06:03 -07:00
2008-06-30 09:25:12 -04:00
2008-04-29 08:06:02 -07:00
2008-05-05 16:47:14 +10:00
2008-06-11 19:13:46 -04:00
2008-04-29 08:06:15 -07:00
2008-05-01 08:03:58 -07:00
2008-07-04 10:40:05 -07:00
2008-04-29 08:06:01 -07:00
2008-06-12 18:05:41 -07:00
2008-05-24 09:56:09 -07:00
2008-05-26 16:08:40 +02:00
2008-06-06 11:29:12 -07:00
2008-04-28 08:58:29 -07:00
2008-06-12 10:12:42 +02:00
2008-04-29 08:06:02 -07:00
2008-04-29 08:06:02 -07:00
2008-05-06 12:01:41 -04:00
2008-07-04 10:40:07 -07:00
2008-04-30 08:29:51 -07:00
2008-04-29 08:05:59 -07:00
2008-04-28 08:58:32 -07:00
2008-07-04 10:40:04 -07:00
2008-07-04 10:40:04 -07:00
2008-04-28 08:58:20 -07:00
2008-04-28 08:58:29 -07:00
2008-05-04 17:07:03 -07:00
2008-06-12 10:48:00 +02:00
2008-05-01 08:03:59 -07:00
2008-05-29 14:46:30 +02:00
2008-05-09 07:45:18 -07:00
2008-04-28 08:58:21 -07:00