dm mpath: add missing path switching locking
authorChandra Seetharaman <sekharan@us.ibm.com>
Wed, 1 Oct 2008 13:39:27 +0000 (14:39 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Wed, 1 Oct 2008 13:39:27 +0000 (14:39 +0100)
commit7253a33434245ee8243897559188186df65f3611
tree24156c85ddd38319ab92ae56a5c585c0f2e273cc
parentb01cd5ac43b00c49759c126c21e7d22c7e80b245
dm mpath: add missing path switching locking

Moving the path activation to workqueue along with scsi_dh patches introduced
a race. It is due to the fact that the current_pgpath (in the multipath data
structure) can be modified if changes happen in any of the paths leading to
the lun. If the changes lead to current_pgpath being set to NULL, then it
leads to the invalid access which results in the panic below.

This patch fixes that by storing the pgpath to activate in the multipath data
structure and properly protecting it.

Note that if activate_path is called twice in succession with different pgpath,
with the second one being called before the first one is done, then activate
path will be called twice for the second pgpath, which is fine.

Unable to handle kernel paging request for data at address 0x00000020
Faulting instruction address: 0xd000000000aa1844
cpu 0x1: Vector: 300 (Data Access) at [c00000006b987a80]
    pc: d000000000aa1844: .activate_path+0x30/0x218 [dm_multipath]
    lr: c000000000087a2c: .run_workqueue+0x114/0x204
    sp: c00000006b987d00
   msr: 8000000000009032
   dar: 20
 dsisr: 40000000
  current = 0xc0000000676bb3f0
  paca    = 0xc0000000006f3680
    pid   = 2528, comm = kmpath_handlerd
enter ? for help
[c00000006b987da0c000000000087a2c .run_workqueue+0x114/0x204
[c00000006b987e40c000000000088b58 .worker_thread+0x120/0x144
[c00000006b987f00c00000000008ca70 .kthread+0x78/0xc4
[c00000006b987f90c000000000027cc8 .kernel_thread+0x4c/0x68

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-mpath.c