diff mbox

[V2] quorum: fix segfault when read fails in fifo mode

Message ID 1454639122-14027-1-git-send-email-xiecl.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Changlong Xie Feb. 5, 2016, 2:25 a.m. UTC
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
---
 block/quorum.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alberto Garcia Feb. 5, 2016, 1:28 p.m. UTC | #1
On Fri 05 Feb 2016 03:25:22 AM CET, Changlong Xie <xiecl.fnst@cn.fujitsu.com> wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto
Eric Blake Feb. 5, 2016, 3:46 p.m. UTC | #2
On 02/04/2016 07:25 PM, Changlong Xie wrote:
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
> ---
>  block/quorum.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index a5ae4b8..11cc60b 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -286,7 +286,8 @@ static void quorum_aio_cb(void *opaque, int ret)
>  
>      if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) {
>          /* We try to read next child in FIFO order if we fail to read */
> -        if (ret < 0 && ++acb->child_iter < s->num_children) {
> +        if (ret < 0 && (acb->child_iter + 1) < s->num_children) {

Could shorten this as
  if (ret < 0 && acb->child_iter <= s->num_children) {
but I'm not sure it's worth the mental gymnastics.
Kevin Wolf Feb. 5, 2016, 3:47 p.m. UTC | #3
Am 05.02.2016 um 14:28 hat Alberto Garcia geschrieben:
> On Fri 05 Feb 2016 03:25:22 AM CET, Changlong Xie <xiecl.fnst@cn.fujitsu.com> wrote:
> > Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> > Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
> 
> Reviewed-by: Alberto Garcia <berto@igalia.com>

Thanks, applied to the block branch.

Kevin
Changlong Xie Feb. 15, 2016, 5:08 a.m. UTC | #4
On 02/05/2016 11:46 PM, Eric Blake wrote:
> On 02/04/2016 07:25 PM, Changlong Xie wrote:
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
>> ---
>>   block/quorum.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/quorum.c b/block/quorum.c
>> index a5ae4b8..11cc60b 100644
>> --- a/block/quorum.c
>> +++ b/block/quorum.c
>> @@ -286,7 +286,8 @@ static void quorum_aio_cb(void *opaque, int ret)
>>
>>       if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) {
>>           /* We try to read next child in FIFO order if we fail to read */
>> -        if (ret < 0 && ++acb->child_iter < s->num_children) {
>> +        if (ret < 0 && (acb->child_iter + 1) < s->num_children) {
>
> Could shorten this as
>    if (ret < 0 && acb->child_iter <= s->num_children) {
> but I'm not sure it's worth the mental gymnastics.

Hi Eric

Just the same to me. Since it has been applied to block branch. Let's 
keep the original one.

Thanks
	-Xie
>
diff mbox

Patch

diff --git a/block/quorum.c b/block/quorum.c
index a5ae4b8..11cc60b 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -286,7 +286,8 @@  static void quorum_aio_cb(void *opaque, int ret)
 
     if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) {
         /* We try to read next child in FIFO order if we fail to read */
-        if (ret < 0 && ++acb->child_iter < s->num_children) {
+        if (ret < 0 && (acb->child_iter + 1) < s->num_children) {
+            acb->child_iter++;
             read_fifo_child(acb);
             return;
         }