···12591259}12601260EXPORT_SYMBOL_GPL(dm_put);1261126112621262+static int dm_wait_for_completion(struct mapped_device *md)12631263+{12641264+ int r = 0;12651265+12661266+ while (1) {12671267+ set_current_state(TASK_INTERRUPTIBLE);12681268+12691269+ smp_mb();12701270+ if (!atomic_read(&md->pending))12711271+ break;12721272+12731273+ if (signal_pending(current)) {12741274+ r = -EINTR;12751275+ break;12761276+ }12771277+12781278+ io_schedule();12791279+ }12801280+ set_current_state(TASK_RUNNING);12811281+12821282+ return r;12831283+}12841284+12621285/*12631286 * Process the deferred bios12641287 */···13801357{13811358 struct dm_table *map = NULL;13821359 DECLARE_WAITQUEUE(wait, current);13831383- int pending, r = 0;13601360+ int r = 0;13841361 int do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG ? 1 : 0;13851362 int noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG ? 1 : 0;13861363···14371414 dm_table_unplug_all(map);1438141514391416 /*14401440- * Then we wait for the already mapped ios to14411441- * complete.14171417+ * Wait for the already-mapped ios to complete.14421418 */14431443- while (1) {14441444- set_current_state(TASK_INTERRUPTIBLE);14451445-14461446- smp_mb();14471447- pending = atomic_read(&md->pending);14481448- if (!pending || signal_pending(current))14491449- break;14501450-14511451- io_schedule();14521452- }14531453- set_current_state(TASK_RUNNING);14191419+ r = dm_wait_for_completion(md);1454142014551421 down_write(&md->io_lock);14561422 remove_wait_queue(&md->wait, &wait);···14491437 up_write(&md->io_lock);1450143814511439 /* were we interrupted ? */14521452- if (pending) {14401440+ if (r < 0) {14531441 down_write(&md->io_lock);14541442 __flush_deferred_io(md);14551443 up_write(&md->io_lock);1456144414571445 unlock_fs(md);14581458- r = -EINTR;14591446 goto out; /* pushback list is already flushed, so skip flush */14601447 }14611448