io.c (ea1329bb3a8d5cd25b70e3dbf73e7ded4d5ad756) | io.c (bd86fb990cfedc50d9705b8ed31d183f01942035) |
---|---|
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 --- 36 unchanged lines hidden (view full) --- 45 int64_t offset, int bytes, BdrvRequestFlags flags); 46 47static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore, 48 bool ignore_bds_parents) 49{ 50 BdrvChild *c, *next; 51 52 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { | 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 --- 36 unchanged lines hidden (view full) --- 45 int64_t offset, int bytes, BdrvRequestFlags flags); 46 47static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore, 48 bool ignore_bds_parents) 49{ 50 BdrvChild *c, *next; 51 52 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { |
53 if (c == ignore || (ignore_bds_parents && c->role->parent_is_bds)) { | 53 if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) { |
54 continue; 55 } 56 bdrv_parent_drained_begin_single(c, false); 57 } 58} 59 60static void bdrv_parent_drained_end_single_no_poll(BdrvChild *c, 61 int *drained_end_counter) 62{ 63 assert(c->parent_quiesce_counter > 0); 64 c->parent_quiesce_counter--; | 54 continue; 55 } 56 bdrv_parent_drained_begin_single(c, false); 57 } 58} 59 60static void bdrv_parent_drained_end_single_no_poll(BdrvChild *c, 61 int *drained_end_counter) 62{ 63 assert(c->parent_quiesce_counter > 0); 64 c->parent_quiesce_counter--; |
65 if (c->role->drained_end) { 66 c->role->drained_end(c, drained_end_counter); | 65 if (c->klass->drained_end) { 66 c->klass->drained_end(c, drained_end_counter); |
67 } 68} 69 70void bdrv_parent_drained_end_single(BdrvChild *c) 71{ 72 int drained_end_counter = 0; 73 bdrv_parent_drained_end_single_no_poll(c, &drained_end_counter); 74 BDRV_POLL_WHILE(c->bs, atomic_read(&drained_end_counter) > 0); 75} 76 77static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore, 78 bool ignore_bds_parents, 79 int *drained_end_counter) 80{ 81 BdrvChild *c; 82 83 QLIST_FOREACH(c, &bs->parents, next_parent) { | 67 } 68} 69 70void bdrv_parent_drained_end_single(BdrvChild *c) 71{ 72 int drained_end_counter = 0; 73 bdrv_parent_drained_end_single_no_poll(c, &drained_end_counter); 74 BDRV_POLL_WHILE(c->bs, atomic_read(&drained_end_counter) > 0); 75} 76 77static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore, 78 bool ignore_bds_parents, 79 int *drained_end_counter) 80{ 81 BdrvChild *c; 82 83 QLIST_FOREACH(c, &bs->parents, next_parent) { |
84 if (c == ignore || (ignore_bds_parents && c->role->parent_is_bds)) { | 84 if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) { |
85 continue; 86 } 87 bdrv_parent_drained_end_single_no_poll(c, drained_end_counter); 88 } 89} 90 91static bool bdrv_parent_drained_poll_single(BdrvChild *c) 92{ | 85 continue; 86 } 87 bdrv_parent_drained_end_single_no_poll(c, drained_end_counter); 88 } 89} 90 91static bool bdrv_parent_drained_poll_single(BdrvChild *c) 92{ |
93 if (c->role->drained_poll) { 94 return c->role->drained_poll(c); | 93 if (c->klass->drained_poll) { 94 return c->klass->drained_poll(c); |
95 } 96 return false; 97} 98 99static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore, 100 bool ignore_bds_parents) 101{ 102 BdrvChild *c, *next; 103 bool busy = false; 104 105 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { | 95 } 96 return false; 97} 98 99static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore, 100 bool ignore_bds_parents) 101{ 102 BdrvChild *c, *next; 103 bool busy = false; 104 105 QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) { |
106 if (c == ignore || (ignore_bds_parents && c->role->parent_is_bds)) { | 106 if (c == ignore || (ignore_bds_parents && c->klass->parent_is_bds)) { |
107 continue; 108 } 109 busy |= bdrv_parent_drained_poll_single(c); 110 } 111 112 return busy; 113} 114 115void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) 116{ 117 c->parent_quiesce_counter++; | 107 continue; 108 } 109 busy |= bdrv_parent_drained_poll_single(c); 110 } 111 112 return busy; 113} 114 115void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) 116{ 117 c->parent_quiesce_counter++; |
118 if (c->role->drained_begin) { 119 c->role->drained_begin(c); | 118 if (c->klass->drained_begin) { 119 c->klass->drained_begin(c); |
120 } 121 if (poll) { 122 BDRV_POLL_WHILE(c->bs, bdrv_parent_drained_poll_single(c)); 123 } 124} 125 126static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) 127{ --- 3193 unchanged lines hidden (view full) --- 3321 dst, dst_offset, 3322 bytes, read_flags, write_flags); 3323} 3324 3325static void bdrv_parent_cb_resize(BlockDriverState *bs) 3326{ 3327 BdrvChild *c; 3328 QLIST_FOREACH(c, &bs->parents, next_parent) { | 120 } 121 if (poll) { 122 BDRV_POLL_WHILE(c->bs, bdrv_parent_drained_poll_single(c)); 123 } 124} 125 126static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) 127{ --- 3193 unchanged lines hidden (view full) --- 3321 dst, dst_offset, 3322 bytes, read_flags, write_flags); 3323} 3324 3325static void bdrv_parent_cb_resize(BlockDriverState *bs) 3326{ 3327 BdrvChild *c; 3328 QLIST_FOREACH(c, &bs->parents, next_parent) { |
3329 if (c->role->resize) { 3330 c->role->resize(c); | 3329 if (c->klass->resize) { 3330 c->klass->resize(c); |
3331 } 3332 } 3333} 3334 3335/** 3336 * Truncate file to 'offset' bytes (needed only for file protocols) 3337 * 3338 * If 'exact' is true, the file must be resized to exactly the given --- 163 unchanged lines hidden --- | 3331 } 3332 } 3333} 3334 3335/** 3336 * Truncate file to 'offset' bytes (needed only for file protocols) 3337 * 3338 * If 'exact' is true, the file must be resized to exactly the given --- 163 unchanged lines hidden --- |