dm-mpath.c (bb51eeee5a947f61eeefaa55221c26460542654d) dm-mpath.c (b63349a7a53d34ffde70cb4feec48ea9e6f5e97b)
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>

--- 73 unchanged lines hidden (view full) ---

82 struct priority_group *current_pg;
83 struct priority_group *next_pg; /* Switch to this PG if set */
84 unsigned repeat_count; /* I/Os left before calling PS again */
85
86 unsigned queue_io:1; /* Must we queue all I/O? */
87 unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */
88 unsigned saved_queue_if_no_path:1; /* Saved state during suspension */
89 unsigned retain_attached_hw_handler:1; /* If there's already a hw_handler present, don't change it. */
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>

--- 73 unchanged lines hidden (view full) ---

82 struct priority_group *current_pg;
83 struct priority_group *next_pg; /* Switch to this PG if set */
84 unsigned repeat_count; /* I/Os left before calling PS again */
85
86 unsigned queue_io:1; /* Must we queue all I/O? */
87 unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */
88 unsigned saved_queue_if_no_path:1; /* Saved state during suspension */
89 unsigned retain_attached_hw_handler:1; /* If there's already a hw_handler present, don't change it. */
90 unsigned pg_init_disabled:1; /* pg_init is not currently allowed */
90
91 unsigned pg_init_retries; /* Number of times to retry pg_init */
92 unsigned pg_init_count; /* Number of times pg_init called */
93 unsigned pg_init_delay_msecs; /* Number of msecs before pg_init retry */
94
95 unsigned queue_size;
96 struct work_struct process_queued_ios;
97 struct list_head queued_ios;

--- 287 unchanged lines hidden (view full) ---

385 (!m->queue_io && (m->repeat_count && --m->repeat_count == 0)))
386 __choose_pgpath(m, nr_bytes);
387
388 pgpath = m->current_pgpath;
389
390 if (was_queued)
391 m->queue_size--;
392
91
92 unsigned pg_init_retries; /* Number of times to retry pg_init */
93 unsigned pg_init_count; /* Number of times pg_init called */
94 unsigned pg_init_delay_msecs; /* Number of msecs before pg_init retry */
95
96 unsigned queue_size;
97 struct work_struct process_queued_ios;
98 struct list_head queued_ios;

--- 287 unchanged lines hidden (view full) ---

386 (!m->queue_io && (m->repeat_count && --m->repeat_count == 0)))
387 __choose_pgpath(m, nr_bytes);
388
389 pgpath = m->current_pgpath;
390
391 if (was_queued)
392 m->queue_size--;
393
393 if ((pgpath && m->queue_io) ||
394 (!pgpath && m->queue_if_no_path)) {
394 if (m->pg_init_required) {
395 if (!m->pg_init_in_progress)
396 queue_work(kmultipathd, &m->process_queued_ios);
397 r = DM_MAPIO_REQUEUE;
398 } else if ((pgpath && m->queue_io) ||
399 (!pgpath && m->queue_if_no_path)) {
395 /* Queue for the daemon to resubmit */
396 list_add_tail(&clone->queuelist, &m->queued_ios);
397 m->queue_size++;
400 /* Queue for the daemon to resubmit */
401 list_add_tail(&clone->queuelist, &m->queued_ios);
402 m->queue_size++;
398 if ((m->pg_init_required && !m->pg_init_in_progress) ||
399 !m->queue_io)
403 if (!m->queue_io)
400 queue_work(kmultipathd, &m->process_queued_ios);
401 pgpath = NULL;
402 r = DM_MAPIO_SUBMITTED;
403 } else if (pgpath) {
404 bdev = pgpath->path.dev->bdev;
405 clone->q = bdev_get_queue(bdev);
406 clone->rq_disk = bdev->bd_disk;
407 } else if (__must_push_back(m))

--- 84 unchanged lines hidden (view full) ---

492 __choose_pgpath(m, 0);
493
494 pgpath = m->current_pgpath;
495
496 if ((pgpath && !m->queue_io) ||
497 (!pgpath && !m->queue_if_no_path))
498 must_queue = 0;
499
404 queue_work(kmultipathd, &m->process_queued_ios);
405 pgpath = NULL;
406 r = DM_MAPIO_SUBMITTED;
407 } else if (pgpath) {
408 bdev = pgpath->path.dev->bdev;
409 clone->q = bdev_get_queue(bdev);
410 clone->rq_disk = bdev->bd_disk;
411 } else if (__must_push_back(m))

--- 84 unchanged lines hidden (view full) ---

496 __choose_pgpath(m, 0);
497
498 pgpath = m->current_pgpath;
499
500 if ((pgpath && !m->queue_io) ||
501 (!pgpath && !m->queue_if_no_path))
502 must_queue = 0;
503
500 if (m->pg_init_required && !m->pg_init_in_progress && pgpath)
504 if (m->pg_init_required && !m->pg_init_in_progress && pgpath &&
505 !m->pg_init_disabled)
501 __pg_init_all_paths(m);
502
503 spin_unlock_irqrestore(&m->lock, flags);
504 if (!must_queue)
505 dispatch_queued_ios(m);
506}
507
508/*

--- 428 unchanged lines hidden (view full) ---

937 }
938 set_current_state(TASK_RUNNING);
939
940 remove_wait_queue(&m->pg_init_wait, &wait);
941}
942
943static void flush_multipath_work(struct multipath *m)
944{
506 __pg_init_all_paths(m);
507
508 spin_unlock_irqrestore(&m->lock, flags);
509 if (!must_queue)
510 dispatch_queued_ios(m);
511}
512
513/*

--- 428 unchanged lines hidden (view full) ---

942 }
943 set_current_state(TASK_RUNNING);
944
945 remove_wait_queue(&m->pg_init_wait, &wait);
946}
947
948static void flush_multipath_work(struct multipath *m)
949{
950 unsigned long flags;
951
952 spin_lock_irqsave(&m->lock, flags);
953 m->pg_init_disabled = 1;
954 spin_unlock_irqrestore(&m->lock, flags);
955
945 flush_workqueue(kmpath_handlerd);
946 multipath_wait_for_pg_init_completion(m);
947 flush_workqueue(kmultipathd);
948 flush_work(&m->trigger_event);
956 flush_workqueue(kmpath_handlerd);
957 multipath_wait_for_pg_init_completion(m);
958 flush_workqueue(kmultipathd);
959 flush_work(&m->trigger_event);
960
961 spin_lock_irqsave(&m->lock, flags);
962 m->pg_init_disabled = 0;
963 spin_unlock_irqrestore(&m->lock, flags);
949}
950
951static void multipath_dtr(struct dm_target *ti)
952{
953 struct multipath *m = ti->private;
954
955 flush_multipath_work(m);
956 free_multipath(m);

--- 202 unchanged lines hidden (view full) ---

1159 */
1160static int pg_init_limit_reached(struct multipath *m, struct pgpath *pgpath)
1161{
1162 unsigned long flags;
1163 int limit_reached = 0;
1164
1165 spin_lock_irqsave(&m->lock, flags);
1166
964}
965
966static void multipath_dtr(struct dm_target *ti)
967{
968 struct multipath *m = ti->private;
969
970 flush_multipath_work(m);
971 free_multipath(m);

--- 202 unchanged lines hidden (view full) ---

1174 */
1175static int pg_init_limit_reached(struct multipath *m, struct pgpath *pgpath)
1176{
1177 unsigned long flags;
1178 int limit_reached = 0;
1179
1180 spin_lock_irqsave(&m->lock, flags);
1181
1167 if (m->pg_init_count <= m->pg_init_retries)
1182 if (m->pg_init_count <= m->pg_init_retries && !m->pg_init_disabled)
1168 m->pg_init_required = 1;
1169 else
1170 limit_reached = 1;
1171
1172 spin_unlock_irqrestore(&m->lock, flags);
1173
1174 return limit_reached;
1175}

--- 484 unchanged lines hidden (view full) ---

1660 int busy = 0, has_active = 0;
1661 struct multipath *m = ti->private;
1662 struct priority_group *pg;
1663 struct pgpath *pgpath;
1664 unsigned long flags;
1665
1666 spin_lock_irqsave(&m->lock, flags);
1667
1183 m->pg_init_required = 1;
1184 else
1185 limit_reached = 1;
1186
1187 spin_unlock_irqrestore(&m->lock, flags);
1188
1189 return limit_reached;
1190}

--- 484 unchanged lines hidden (view full) ---

1675 int busy = 0, has_active = 0;
1676 struct multipath *m = ti->private;
1677 struct priority_group *pg;
1678 struct pgpath *pgpath;
1679 unsigned long flags;
1680
1681 spin_lock_irqsave(&m->lock, flags);
1682
1683 /* pg_init in progress, requeue until done */
1684 if (m->pg_init_in_progress) {
1685 busy = 1;
1686 goto out;
1687 }
1668 /* Guess which priority_group will be used at next mapping time */
1669 if (unlikely(!m->current_pgpath && m->next_pg))
1670 pg = m->next_pg;
1671 else if (likely(m->current_pg))
1672 pg = m->current_pg;
1673 else
1674 /*
1675 * We don't know which pg will be used at next mapping time.

--- 33 unchanged lines hidden (view full) ---

1709 return busy;
1710}
1711
1712/*-----------------------------------------------------------------
1713 * Module setup
1714 *---------------------------------------------------------------*/
1715static struct target_type multipath_target = {
1716 .name = "multipath",
1688 /* Guess which priority_group will be used at next mapping time */
1689 if (unlikely(!m->current_pgpath && m->next_pg))
1690 pg = m->next_pg;
1691 else if (likely(m->current_pg))
1692 pg = m->current_pg;
1693 else
1694 /*
1695 * We don't know which pg will be used at next mapping time.

--- 33 unchanged lines hidden (view full) ---

1729 return busy;
1730}
1731
1732/*-----------------------------------------------------------------
1733 * Module setup
1734 *---------------------------------------------------------------*/
1735static struct target_type multipath_target = {
1736 .name = "multipath",
1717 .version = {1, 5, 1},
1737 .version = {1, 6, 0},
1718 .module = THIS_MODULE,
1719 .ctr = multipath_ctr,
1720 .dtr = multipath_dtr,
1721 .map_rq = multipath_map,
1722 .rq_end_io = multipath_end_io,
1723 .presuspend = multipath_presuspend,
1724 .postsuspend = multipath_postsuspend,
1725 .resume = multipath_resume,

--- 69 unchanged lines hidden ---
1738 .module = THIS_MODULE,
1739 .ctr = multipath_ctr,
1740 .dtr = multipath_dtr,
1741 .map_rq = multipath_map,
1742 .rq_end_io = multipath_end_io,
1743 .presuspend = multipath_presuspend,
1744 .postsuspend = multipath_postsuspend,
1745 .resume = multipath_resume,

--- 69 unchanged lines hidden ---