dm-mpath.c (d0259bf0eefc503d3c9c9ccda35033c3dd3aac30) | dm-mpath.c (2bded7bd7e8b12a913b0b58167a48220560e1514) |
---|---|
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> --- 55 unchanged lines hidden (view full) --- 64 spinlock_t lock; 65 66 const char *hw_handler_name; 67 char *hw_handler_params; 68 unsigned nr_priority_groups; 69 struct list_head priority_groups; 70 unsigned pg_init_required; /* pg_init needs calling? */ 71 unsigned pg_init_in_progress; /* Only one pg_init allowed at once */ | 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> --- 55 unchanged lines hidden (view full) --- 64 spinlock_t lock; 65 66 const char *hw_handler_name; 67 char *hw_handler_params; 68 unsigned nr_priority_groups; 69 struct list_head priority_groups; 70 unsigned pg_init_required; /* pg_init needs calling? */ 71 unsigned pg_init_in_progress; /* Only one pg_init allowed at once */ |
72 wait_queue_head_t pg_init_wait; /* Wait for pg_init completion */ |
|
72 73 unsigned nr_valid_paths; /* Total number of usable paths */ 74 struct pgpath *current_pgpath; 75 struct priority_group *current_pg; 76 struct priority_group *next_pg; /* Switch to this PG if set */ 77 unsigned repeat_count; /* I/Os left before calling PS again */ 78 79 unsigned queue_io; /* Must we queue all I/O? */ --- 115 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); | 73 74 unsigned nr_valid_paths; /* Total number of usable paths */ 75 struct pgpath *current_pgpath; 76 struct priority_group *current_pg; 77 struct priority_group *next_pg; /* Switch to this PG if set */ 78 unsigned repeat_count; /* I/Os left before calling PS again */ 79 80 unsigned queue_io; /* Must we queue all I/O? */ --- 115 unchanged lines hidden (view full) --- 196 m = kzalloc(sizeof(*m), GFP_KERNEL); 197 if (m) { 198 INIT_LIST_HEAD(&m->priority_groups); 199 INIT_LIST_HEAD(&m->queued_ios); 200 spin_lock_init(&m->lock); 201 m->queue_io = 1; 202 INIT_WORK(&m->process_queued_ios, process_queued_ios); 203 INIT_WORK(&m->trigger_event, trigger_event); |
204 init_waitqueue_head(&m->pg_init_wait); |
|
203 mutex_init(&m->work_mutex); 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; --- 675 unchanged lines hidden (view full) --- 886 887 return 0; 888 889 bad: 890 free_multipath(m); 891 return r; 892} 893 | 205 mutex_init(&m->work_mutex); 206 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); 207 if (!m->mpio_pool) { 208 kfree(m); 209 return NULL; 210 } 211 m->ti = ti; 212 ti->private = m; --- 675 unchanged lines hidden (view full) --- 888 889 return 0; 890 891 bad: 892 free_multipath(m); 893 return r; 894} 895 |
894static void flush_multipath_work(void) | 896static void multipath_wait_for_pg_init_completion(struct multipath *m) |
895{ | 897{ |
898 DECLARE_WAITQUEUE(wait, current); 899 unsigned long flags; 900 901 add_wait_queue(&m->pg_init_wait, &wait); 902 903 while (1) { 904 set_current_state(TASK_UNINTERRUPTIBLE); 905 906 spin_lock_irqsave(&m->lock, flags); 907 if (!m->pg_init_in_progress) { 908 spin_unlock_irqrestore(&m->lock, flags); 909 break; 910 } 911 spin_unlock_irqrestore(&m->lock, flags); 912 913 io_schedule(); 914 } 915 set_current_state(TASK_RUNNING); 916 917 remove_wait_queue(&m->pg_init_wait, &wait); 918} 919 920static void flush_multipath_work(struct multipath *m) 921{ |
|
896 flush_workqueue(kmpath_handlerd); | 922 flush_workqueue(kmpath_handlerd); |
923 multipath_wait_for_pg_init_completion(m); |
|
897 flush_workqueue(kmultipathd); 898 flush_scheduled_work(); 899} 900 901static void multipath_dtr(struct dm_target *ti) 902{ 903 struct multipath *m = ti->private; 904 | 924 flush_workqueue(kmultipathd); 925 flush_scheduled_work(); 926} 927 928static void multipath_dtr(struct dm_target *ti) 929{ 930 struct multipath *m = ti->private; 931 |
905 flush_multipath_work(); | 932 flush_multipath_work(m); |
906 free_multipath(m); 907} 908 909/* 910 * Map cloned requests 911 */ 912static int multipath_map(struct dm_target *ti, struct request *clone, 913 union map_info *map_context) --- 274 unchanged lines hidden (view full) --- 1188 /* Activations of other paths are still on going */ 1189 goto out; 1190 1191 if (!m->pg_init_required) 1192 m->queue_io = 0; 1193 1194 queue_work(kmultipathd, &m->process_queued_ios); 1195 | 933 free_multipath(m); 934} 935 936/* 937 * Map cloned requests 938 */ 939static int multipath_map(struct dm_target *ti, struct request *clone, 940 union map_info *map_context) --- 274 unchanged lines hidden (view full) --- 1215 /* Activations of other paths are still on going */ 1216 goto out; 1217 1218 if (!m->pg_init_required) 1219 m->queue_io = 0; 1220 1221 queue_work(kmultipathd, &m->process_queued_ios); 1222 |
1223 /* 1224 * Wake up any thread waiting to suspend. 1225 */ 1226 wake_up(&m->pg_init_wait); 1227 |
|
1196out: 1197 spin_unlock_irqrestore(&m->lock, flags); 1198} 1199 1200static void activate_path(struct work_struct *work) 1201{ 1202 struct pgpath *pgpath = 1203 container_of(work, struct pgpath, activate_path); --- 72 unchanged lines hidden (view full) --- 1276 queue_if_no_path(m, 0, 1); 1277} 1278 1279static void multipath_postsuspend(struct dm_target *ti) 1280{ 1281 struct multipath *m = ti->private; 1282 1283 mutex_lock(&m->work_mutex); | 1228out: 1229 spin_unlock_irqrestore(&m->lock, flags); 1230} 1231 1232static void activate_path(struct work_struct *work) 1233{ 1234 struct pgpath *pgpath = 1235 container_of(work, struct pgpath, activate_path); --- 72 unchanged lines hidden (view full) --- 1308 queue_if_no_path(m, 0, 1); 1309} 1310 1311static void multipath_postsuspend(struct dm_target *ti) 1312{ 1313 struct multipath *m = ti->private; 1314 1315 mutex_lock(&m->work_mutex); |
1284 flush_multipath_work(); | 1316 flush_multipath_work(m); |
1285 mutex_unlock(&m->work_mutex); 1286} 1287 1288/* 1289 * Restore the queue_if_no_path setting. 1290 */ 1291static void multipath_resume(struct dm_target *ti) 1292{ --- 393 unchanged lines hidden --- | 1317 mutex_unlock(&m->work_mutex); 1318} 1319 1320/* 1321 * Restore the queue_if_no_path setting. 1322 */ 1323static void multipath_resume(struct dm_target *ti) 1324{ --- 393 unchanged lines hidden --- |