]> git.karo-electronics.de Git - karo-tx-linux.git/commit
dm ioctl: release _hash_lock between devices in remove_all
authorKiyoshi Ueda <k-ueda@ct.jp.nec.com>
Thu, 12 Aug 2010 03:13:55 +0000 (04:13 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 26 Aug 2010 23:45:56 +0000 (16:45 -0700)
commitd97eabc0a58382629c2ed4f406259ad615fcbc88
treef1f0f1d21a732bb0e9cce823d42d79da70f00084
parentc51ca7940efce22c43da532c6ff5b36c7cb3ea5e
dm ioctl: release _hash_lock between devices in remove_all

commit 98f332855effef02aeb738e4d62e9a5b903c52fd upstream.

This patch changes dm_hash_remove_all() to release _hash_lock when
removing a device.  After removing the device, dm_hash_remove_all()
takes _hash_lock and searches the hash from scratch again.

This patch is a preparation for the next patch, which changes device
deletion code to wait for md reference to be 0.  Without this patch,
the wait in the next patch may cause AB-BA deadlock:
  CPU0                                CPU1
  -----------------------------------------------------------------------
  dm_hash_remove_all()
    down_write(_hash_lock)
                                      table_status()
                                        md = find_device()
                                               dm_get(md)
                                                 <increment md->holders>
                                        dm_get_live_or_inactive_table()
                                          dm_get_inactive_table()
                                            down_write(_hash_lock)
    <in the md deletion code>
      <wait for md->holders to be 0>

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/md/dm-ioctl.c