block.c (58e2e17dba49b43f4ac9de19468aeae1c787dcc2) | block.c (2b148f392b2bfeba76d3e6d9607c3bd072350e8c) |
---|---|
1/* 2 * QEMU System Emulator block driver 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 --- 4195 unchanged lines hidden (view full) --- 4204} 4205 4206void bdrv_init_with_whitelist(void) 4207{ 4208 use_bdrv_whitelist = 1; 4209 bdrv_init(); 4210} 4211 | 1/* 2 * QEMU System Emulator block driver 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 --- 4195 unchanged lines hidden (view full) --- 4204} 4205 4206void bdrv_init_with_whitelist(void) 4207{ 4208 use_bdrv_whitelist = 1; 4209 bdrv_init(); 4210} 4211 |
4212void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) | 4212static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, 4213 Error **errp) |
4213{ 4214 BdrvChild *child, *parent; 4215 uint64_t perm, shared_perm; 4216 Error *local_err = NULL; 4217 int ret; 4218 4219 if (!bs->drv) { 4220 return; 4221 } 4222 4223 if (!(bs->open_flags & BDRV_O_INACTIVE)) { 4224 return; 4225 } 4226 4227 QLIST_FOREACH(child, &bs->children, next) { | 4214{ 4215 BdrvChild *child, *parent; 4216 uint64_t perm, shared_perm; 4217 Error *local_err = NULL; 4218 int ret; 4219 4220 if (!bs->drv) { 4221 return; 4222 } 4223 4224 if (!(bs->open_flags & BDRV_O_INACTIVE)) { 4225 return; 4226 } 4227 4228 QLIST_FOREACH(child, &bs->children, next) { |
4228 bdrv_invalidate_cache(child->bs, &local_err); | 4229 bdrv_co_invalidate_cache(child->bs, &local_err); |
4229 if (local_err) { 4230 error_propagate(errp, local_err); 4231 return; 4232 } 4233 } 4234 4235 /* 4236 * Update permissions, they may differ for inactive nodes. --- 13 unchanged lines hidden (view full) --- 4250 ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, &local_err); 4251 if (ret < 0) { 4252 bs->open_flags |= BDRV_O_INACTIVE; 4253 error_propagate(errp, local_err); 4254 return; 4255 } 4256 bdrv_set_perm(bs, perm, shared_perm); 4257 | 4230 if (local_err) { 4231 error_propagate(errp, local_err); 4232 return; 4233 } 4234 } 4235 4236 /* 4237 * Update permissions, they may differ for inactive nodes. --- 13 unchanged lines hidden (view full) --- 4251 ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, &local_err); 4252 if (ret < 0) { 4253 bs->open_flags |= BDRV_O_INACTIVE; 4254 error_propagate(errp, local_err); 4255 return; 4256 } 4257 bdrv_set_perm(bs, perm, shared_perm); 4258 |
4258 if (bs->drv->bdrv_invalidate_cache) { 4259 bs->drv->bdrv_invalidate_cache(bs, &local_err); | 4259 if (bs->drv->bdrv_co_invalidate_cache) { 4260 bs->drv->bdrv_co_invalidate_cache(bs, &local_err); |
4260 if (local_err) { 4261 bs->open_flags |= BDRV_O_INACTIVE; 4262 error_propagate(errp, local_err); 4263 return; 4264 } 4265 } 4266 4267 ret = refresh_total_sectors(bs, bs->total_sectors); --- 9 unchanged lines hidden (view full) --- 4277 if (local_err) { 4278 error_propagate(errp, local_err); 4279 return; 4280 } 4281 } 4282 } 4283} 4284 | 4261 if (local_err) { 4262 bs->open_flags |= BDRV_O_INACTIVE; 4263 error_propagate(errp, local_err); 4264 return; 4265 } 4266 } 4267 4268 ret = refresh_total_sectors(bs, bs->total_sectors); --- 9 unchanged lines hidden (view full) --- 4278 if (local_err) { 4279 error_propagate(errp, local_err); 4280 return; 4281 } 4282 } 4283 } 4284} 4285 |
4286typedef struct InvalidateCacheCo { 4287 BlockDriverState *bs; 4288 Error **errp; 4289 bool done; 4290} InvalidateCacheCo; 4291 4292static void coroutine_fn bdrv_invalidate_cache_co_entry(void *opaque) 4293{ 4294 InvalidateCacheCo *ico = opaque; 4295 bdrv_co_invalidate_cache(ico->bs, ico->errp); 4296 ico->done = true; 4297} 4298 4299void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) 4300{ 4301 Coroutine *co; 4302 InvalidateCacheCo ico = { 4303 .bs = bs, 4304 .done = false, 4305 .errp = errp 4306 }; 4307 4308 if (qemu_in_coroutine()) { 4309 /* Fast-path if already in coroutine context */ 4310 bdrv_invalidate_cache_co_entry(&ico); 4311 } else { 4312 co = qemu_coroutine_create(bdrv_invalidate_cache_co_entry, &ico); 4313 qemu_coroutine_enter(co); 4314 BDRV_POLL_WHILE(bs, !ico.done); 4315 } 4316} 4317 |
|
4285void bdrv_invalidate_cache_all(Error **errp) 4286{ 4287 BlockDriverState *bs; 4288 Error *local_err = NULL; 4289 BdrvNextIterator it; 4290 4291 for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { 4292 AioContext *aio_context = bdrv_get_aio_context(bs); --- 893 unchanged lines hidden --- | 4318void bdrv_invalidate_cache_all(Error **errp) 4319{ 4320 BlockDriverState *bs; 4321 Error *local_err = NULL; 4322 BdrvNextIterator it; 4323 4324 for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { 4325 AioContext *aio_context = bdrv_get_aio_context(bs); --- 893 unchanged lines hidden --- |