dm-mpath.c (6df400ab64c68fc4072a13019fc20fd7e3d51303) | dm-mpath.c (6380f26f0424034345461cabaab9a7030d905b59) |
---|---|
1/* 2 * Copyright (C) 2003 Sistina Software Limited. 3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include <linux/device-mapper.h> --- 79 unchanged lines hidden (view full) --- 88 89 struct work_struct trigger_event; 90 91 /* 92 * We must use a mempool of dm_mpath_io structs so that we 93 * can resubmit bios on error. 94 */ 95 mempool_t *mpio_pool; | 1/* 2 * Copyright (C) 2003 Sistina Software Limited. 3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include <linux/device-mapper.h> --- 79 unchanged lines hidden (view full) --- 88 89 struct work_struct trigger_event; 90 91 /* 92 * We must use a mempool of dm_mpath_io structs so that we 93 * can resubmit bios on error. 94 */ 95 mempool_t *mpio_pool; |
96 97 struct mutex work_mutex; |
|
96}; 97 98/* 99 * Context information attached to each bio we process. 100 */ 101struct dm_mpath_io { 102 struct pgpath *pgpath; 103 size_t nr_bytes; --- 89 unchanged lines hidden (view full) --- 193 m = kzalloc(sizeof(*m), GFP_KERNEL); 194 if (m) { 195 INIT_LIST_HEAD(&m->priority_groups); 196 INIT_LIST_HEAD(&m->queued_ios); 197 spin_lock_init(&m->lock); 198 m->queue_io = 1; 199 INIT_WORK(&m->process_queued_ios, process_queued_ios); 200 INIT_WORK(&m->trigger_event, trigger_event); | 98}; 99 100/* 101 * Context information attached to each bio we process. 102 */ 103struct dm_mpath_io { 104 struct pgpath *pgpath; 105 size_t nr_bytes; --- 89 unchanged lines hidden (view full) --- 195 m = kzalloc(sizeof(*m), GFP_KERNEL); 196 if (m) { 197 INIT_LIST_HEAD(&m->priority_groups); 198 INIT_LIST_HEAD(&m->queued_ios); 199 spin_lock_init(&m->lock); 200 m->queue_io = 1; 201 INIT_WORK(&m->process_queued_ios, process_queued_ios); 202 INIT_WORK(&m->trigger_event, trigger_event); |
203 mutex_init(&m->work_mutex); |
|
201 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); 202 if (!m->mpio_pool) { 203 kfree(m); 204 return NULL; 205 } 206 m->ti = ti; 207 ti->private = m; 208 } --- 1054 unchanged lines hidden (view full) --- 1263{ 1264 struct multipath *m = (struct multipath *) ti->private; 1265 1266 queue_if_no_path(m, 0, 1); 1267} 1268 1269static void multipath_postsuspend(struct dm_target *ti) 1270{ | 204 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); 205 if (!m->mpio_pool) { 206 kfree(m); 207 return NULL; 208 } 209 m->ti = ti; 210 ti->private = m; 211 } --- 1054 unchanged lines hidden (view full) --- 1266{ 1267 struct multipath *m = (struct multipath *) ti->private; 1268 1269 queue_if_no_path(m, 0, 1); 1270} 1271 1272static void multipath_postsuspend(struct dm_target *ti) 1273{ |
1274 struct multipath *m = ti->private; 1275 1276 mutex_lock(&m->work_mutex); |
|
1271 flush_multipath_work(); | 1277 flush_multipath_work(); |
1278 mutex_unlock(&m->work_mutex); |
|
1272} 1273 1274/* 1275 * Restore the queue_if_no_path setting. 1276 */ 1277static void multipath_resume(struct dm_target *ti) 1278{ 1279 struct multipath *m = (struct multipath *) ti->private; --- 122 unchanged lines hidden (view full) --- 1402 1403 spin_unlock_irqrestore(&m->lock, flags); 1404 1405 return 0; 1406} 1407 1408static int multipath_message(struct dm_target *ti, unsigned argc, char **argv) 1409{ | 1279} 1280 1281/* 1282 * Restore the queue_if_no_path setting. 1283 */ 1284static void multipath_resume(struct dm_target *ti) 1285{ 1286 struct multipath *m = (struct multipath *) ti->private; --- 122 unchanged lines hidden (view full) --- 1409 1410 spin_unlock_irqrestore(&m->lock, flags); 1411 1412 return 0; 1413} 1414 1415static int multipath_message(struct dm_target *ti, unsigned argc, char **argv) 1416{ |
1410 int r; | 1417 int r = -EINVAL; |
1411 struct dm_dev *dev; 1412 struct multipath *m = (struct multipath *) ti->private; 1413 action_fn action; 1414 | 1418 struct dm_dev *dev; 1419 struct multipath *m = (struct multipath *) ti->private; 1420 action_fn action; 1421 |
1422 mutex_lock(&m->work_mutex); 1423 |
|
1415 if (argc == 1) { | 1424 if (argc == 1) { |
1416 if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) 1417 return queue_if_no_path(m, 1, 0); 1418 else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) 1419 return queue_if_no_path(m, 0, 0); | 1425 if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) { 1426 r = queue_if_no_path(m, 1, 0); 1427 goto out; 1428 } else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) { 1429 r = queue_if_no_path(m, 0, 0); 1430 goto out; 1431 } |
1420 } 1421 | 1432 } 1433 |
1422 if (argc != 2) 1423 goto error; | 1434 if (argc != 2) { 1435 DMWARN("Unrecognised multipath message received."); 1436 goto out; 1437 } |
1424 | 1438 |
1425 if (!strnicmp(argv[0], MESG_STR("disable_group"))) 1426 return bypass_pg_num(m, argv[1], 1); 1427 else if (!strnicmp(argv[0], MESG_STR("enable_group"))) 1428 return bypass_pg_num(m, argv[1], 0); 1429 else if (!strnicmp(argv[0], MESG_STR("switch_group"))) 1430 return switch_pg_num(m, argv[1]); 1431 else if (!strnicmp(argv[0], MESG_STR("reinstate_path"))) | 1439 if (!strnicmp(argv[0], MESG_STR("disable_group"))) { 1440 r = bypass_pg_num(m, argv[1], 1); 1441 goto out; 1442 } else if (!strnicmp(argv[0], MESG_STR("enable_group"))) { 1443 r = bypass_pg_num(m, argv[1], 0); 1444 goto out; 1445 } else if (!strnicmp(argv[0], MESG_STR("switch_group"))) { 1446 r = switch_pg_num(m, argv[1]); 1447 goto out; 1448 } else if (!strnicmp(argv[0], MESG_STR("reinstate_path"))) |
1432 action = reinstate_path; 1433 else if (!strnicmp(argv[0], MESG_STR("fail_path"))) 1434 action = fail_path; | 1449 action = reinstate_path; 1450 else if (!strnicmp(argv[0], MESG_STR("fail_path"))) 1451 action = fail_path; |
1435 else 1436 goto error; | 1452 else { 1453 DMWARN("Unrecognised multipath message received."); 1454 goto out; 1455 } |
1437 1438 r = dm_get_device(ti, argv[1], ti->begin, ti->len, 1439 dm_table_get_mode(ti->table), &dev); 1440 if (r) { 1441 DMWARN("message: error getting device %s", 1442 argv[1]); | 1456 1457 r = dm_get_device(ti, argv[1], ti->begin, ti->len, 1458 dm_table_get_mode(ti->table), &dev); 1459 if (r) { 1460 DMWARN("message: error getting device %s", 1461 argv[1]); |
1443 return -EINVAL; | 1462 goto out; |
1444 } 1445 1446 r = action_dev(m, dev, action); 1447 1448 dm_put_device(ti, dev); 1449 | 1463 } 1464 1465 r = action_dev(m, dev, action); 1466 1467 dm_put_device(ti, dev); 1468 |
1469out: 1470 mutex_unlock(&m->work_mutex); |
|
1450 return r; | 1471 return r; |
1451 1452error: 1453 DMWARN("Unrecognised multipath message received."); 1454 return -EINVAL; | |
1455} 1456 1457static int multipath_ioctl(struct dm_target *ti, unsigned int cmd, 1458 unsigned long arg) 1459{ 1460 struct multipath *m = (struct multipath *) ti->private; 1461 struct block_device *bdev = NULL; 1462 fmode_t mode = 0; --- 194 unchanged lines hidden --- | 1472} 1473 1474static int multipath_ioctl(struct dm_target *ti, unsigned int cmd, 1475 unsigned long arg) 1476{ 1477 struct multipath *m = (struct multipath *) ti->private; 1478 struct block_device *bdev = NULL; 1479 fmode_t mode = 0; --- 194 unchanged lines hidden --- |