io.c (91c6e4b7bba906cfb8d84481da6340957f876c90) | io.c (7c8eece45b10fc9b716850345118ed6fa8d17887) |
---|---|
1/* 2 * Block layer I/O functions 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 256 unchanged lines hidden (view full) --- 265 * 266 * This function does not flush data to disk, use bdrv_flush_all() for that 267 * after calling this function. 268 */ 269void bdrv_drain_all(void) 270{ 271 /* Always run first iteration so any pending completion BHs run */ 272 bool busy = true; | 1/* 2 * Block layer I/O functions 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 256 unchanged lines hidden (view full) --- 265 * 266 * This function does not flush data to disk, use bdrv_flush_all() for that 267 * after calling this function. 268 */ 269void bdrv_drain_all(void) 270{ 271 /* Always run first iteration so any pending completion BHs run */ 272 bool busy = true; |
273 BlockDriverState *bs = NULL; | 273 BlockDriverState *bs; 274 BdrvNextIterator *it = NULL; |
274 GSList *aio_ctxs = NULL, *ctx; 275 | 275 GSList *aio_ctxs = NULL, *ctx; 276 |
276 while ((bs = bdrv_next(bs))) { | 277 while ((it = bdrv_next(it, &bs))) { |
277 AioContext *aio_context = bdrv_get_aio_context(bs); 278 279 aio_context_acquire(aio_context); 280 if (bs->job) { 281 block_job_pause(bs->job); 282 } 283 bdrv_parent_drained_begin(bs); 284 bdrv_io_unplugged_begin(bs); --- 11 unchanged lines hidden (view full) --- 296 * request completion. Therefore we must keep looping until there was no 297 * more activity rather than simply draining each device independently. 298 */ 299 while (busy) { 300 busy = false; 301 302 for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) { 303 AioContext *aio_context = ctx->data; | 278 AioContext *aio_context = bdrv_get_aio_context(bs); 279 280 aio_context_acquire(aio_context); 281 if (bs->job) { 282 block_job_pause(bs->job); 283 } 284 bdrv_parent_drained_begin(bs); 285 bdrv_io_unplugged_begin(bs); --- 11 unchanged lines hidden (view full) --- 297 * request completion. Therefore we must keep looping until there was no 298 * more activity rather than simply draining each device independently. 299 */ 300 while (busy) { 301 busy = false; 302 303 for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) { 304 AioContext *aio_context = ctx->data; |
304 bs = NULL; | 305 it = NULL; |
305 306 aio_context_acquire(aio_context); | 306 307 aio_context_acquire(aio_context); |
307 while ((bs = bdrv_next(bs))) { | 308 while ((it = bdrv_next(it, &bs))) { |
308 if (aio_context == bdrv_get_aio_context(bs)) { 309 if (bdrv_requests_pending(bs)) { 310 busy = true; 311 aio_poll(aio_context, busy); 312 } 313 } 314 } 315 busy |= aio_poll(aio_context, false); 316 aio_context_release(aio_context); 317 } 318 } 319 | 309 if (aio_context == bdrv_get_aio_context(bs)) { 310 if (bdrv_requests_pending(bs)) { 311 busy = true; 312 aio_poll(aio_context, busy); 313 } 314 } 315 } 316 busy |= aio_poll(aio_context, false); 317 aio_context_release(aio_context); 318 } 319 } 320 |
320 bs = NULL; 321 while ((bs = bdrv_next(bs))) { | 321 it = NULL; 322 while ((it = bdrv_next(it, &bs))) { |
322 AioContext *aio_context = bdrv_get_aio_context(bs); 323 324 aio_context_acquire(aio_context); 325 bdrv_io_unplugged_end(bs); 326 bdrv_parent_drained_end(bs); 327 if (bs->job) { 328 block_job_resume(bs->job); 329 } --- 2235 unchanged lines hidden --- | 323 AioContext *aio_context = bdrv_get_aio_context(bs); 324 325 aio_context_acquire(aio_context); 326 bdrv_io_unplugged_end(bs); 327 bdrv_parent_drained_end(bs); 328 if (bs->job) { 329 block_job_resume(bs->job); 330 } --- 2235 unchanged lines hidden --- |