Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm: refactor dm_suspend completion wait

Move completion wait to separate function

Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>

authored by

Milan Broz and committed by
Alasdair G Kergon
46125c1c 94d6351e

+27 -16
+27 -16
drivers/md/dm.c
··· 1259 1259 } 1260 1260 EXPORT_SYMBOL_GPL(dm_put); 1261 1261 1262 + static int dm_wait_for_completion(struct mapped_device *md) 1263 + { 1264 + int r = 0; 1265 + 1266 + while (1) { 1267 + set_current_state(TASK_INTERRUPTIBLE); 1268 + 1269 + smp_mb(); 1270 + if (!atomic_read(&md->pending)) 1271 + break; 1272 + 1273 + if (signal_pending(current)) { 1274 + r = -EINTR; 1275 + break; 1276 + } 1277 + 1278 + io_schedule(); 1279 + } 1280 + set_current_state(TASK_RUNNING); 1281 + 1282 + return r; 1283 + } 1284 + 1262 1285 /* 1263 1286 * Process the deferred bios 1264 1287 */ ··· 1380 1357 { 1381 1358 struct dm_table *map = NULL; 1382 1359 DECLARE_WAITQUEUE(wait, current); 1383 - int pending, r = 0; 1360 + int r = 0; 1384 1361 int do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG ? 1 : 0; 1385 1362 int noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG ? 1 : 0; 1386 1363 ··· 1437 1414 dm_table_unplug_all(map); 1438 1415 1439 1416 /* 1440 - * Then we wait for the already mapped ios to 1441 - * complete. 1417 + * Wait for the already-mapped ios to complete. 1442 1418 */ 1443 - while (1) { 1444 - set_current_state(TASK_INTERRUPTIBLE); 1445 - 1446 - smp_mb(); 1447 - pending = atomic_read(&md->pending); 1448 - if (!pending || signal_pending(current)) 1449 - break; 1450 - 1451 - io_schedule(); 1452 - } 1453 - set_current_state(TASK_RUNNING); 1419 + r = dm_wait_for_completion(md); 1454 1420 1455 1421 down_write(&md->io_lock); 1456 1422 remove_wait_queue(&md->wait, &wait); ··· 1449 1437 up_write(&md->io_lock); 1450 1438 1451 1439 /* were we interrupted ? */ 1452 - if (pending) { 1440 + if (r < 0) { 1453 1441 down_write(&md->io_lock); 1454 1442 __flush_deferred_io(md); 1455 1443 up_write(&md->io_lock); 1456 1444 1457 1445 unlock_fs(md); 1458 - r = -EINTR; 1459 1446 goto out; /* pushback list is already flushed, so skip flush */ 1460 1447 } 1461 1448