Commit 8a57dfc6 authored by Chandra Seetharaman's avatar Chandra Seetharaman Committed by Alasdair G Kergon

dm: avoid destroying table in dm_any_congested

dm_any_congested() just checks for the DMF_BLOCK_IO and has no
code to make sure that suspend waits for dm_any_congested() to
complete.  This patch adds such a check.

Without it, a race can occur with dm_table_put() attempting to
destroying the table in the wrong thread, the one running
dm_any_congested() which is meant to be quick and return
immediately.

Two examples of problems:
1. Sleeping functions called from congested code, the caller
   of which holds a spin lock.
2. An ABBA deadlock between pdflush and multipathd. The two locks
   in contention are inode lock and kernel lock.
Signed-off-by: default avatarChandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent d221d2e7
...@@ -937,16 +937,24 @@ static void dm_unplug_all(struct request_queue *q) ...@@ -937,16 +937,24 @@ static void dm_unplug_all(struct request_queue *q)
static int dm_any_congested(void *congested_data, int bdi_bits) static int dm_any_congested(void *congested_data, int bdi_bits)
{ {
int r; int r = bdi_bits;
struct mapped_device *md = (struct mapped_device *) congested_data; struct mapped_device *md = congested_data;
struct dm_table *map = dm_get_table(md); struct dm_table *map;
if (!map || test_bit(DMF_BLOCK_IO, &md->flags)) atomic_inc(&md->pending);
r = bdi_bits;
else if (!test_bit(DMF_BLOCK_IO, &md->flags)) {
r = dm_table_any_congested(map, bdi_bits); map = dm_get_table(md);
if (map) {
r = dm_table_any_congested(map, bdi_bits);
dm_table_put(map);
}
}
if (!atomic_dec_return(&md->pending))
/* nudge anyone waiting on suspend queue */
wake_up(&md->wait);
dm_table_put(map);
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment