Message ID | 1456134637-421-2-git-send-email-xiecl.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon 22 Feb 2016 10:50:37 AM CET, Changlong Xie wrote: > - winner = quorum_get_vote_winner(&error_votes); > - result = winner->value.l; > - > + if (success_count >= s->threshold) > + result = 0; > + else { > + winner = quorum_get_vote_winner(&error_votes); > + result = winner->value.l; > + } Please use braces in both branches of the if. scripts/checkpatch.pl should report that. Other than that I think the patch is correct, but I still wonder if we should emit QUORUM_REPORT_BAD (or a new event) for the operations that fail. Or why wouldn't the user want to be notified of a flush failure? Berto
On 02/22/2016 10:33 PM, Alberto Garcia wrote: > On Mon 22 Feb 2016 10:50:37 AM CET, Changlong Xie wrote: >> - winner = quorum_get_vote_winner(&error_votes); >> - result = winner->value.l; >> - >> + if (success_count >= s->threshold) >> + result = 0; >> + else { >> + winner = quorum_get_vote_winner(&error_votes); >> + result = winner->value.l; >> + } > > Please use braces in both branches of the if. scripts/checkpatch.pl > should report that. Surely. > > Other than that I think the patch is correct, but I still wonder if we > should emit QUORUM_REPORT_BAD (or a new event) for the operations that To me QUORUM_REPORT_BAD is not a good choice. > fail. Or why wouldn't the user want to be notified of a flush failure? > I'll introduce a new event in next series. Thanks -Xie > Berto > > > . >
diff --git a/block/quorum.c b/block/quorum.c index f78d4cb..62d3ccb 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -763,19 +763,26 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) QuorumVoteValue result_value; int i; int result = 0; + int success_count = 0; QLIST_INIT(&error_votes.vote_list); error_votes.compare = quorum_64bits_compare; for (i = 0; i < s->num_children; i++) { result = bdrv_co_flush(s->children[i]->bs); - result_value.l = result; - quorum_count_vote(&error_votes, &result_value, i); + if (result) { + result_value.l = result; + quorum_count_vote(&error_votes, &result_value, i); + } else + success_count++; } - winner = quorum_get_vote_winner(&error_votes); - result = winner->value.l; - + if (success_count >= s->threshold) + result = 0; + else { + winner = quorum_get_vote_winner(&error_votes); + result = winner->value.l; + } quorum_free_vote_list(&error_votes); return result;