diff mbox

quorum: fix segfault when read fails in fifo mode

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

Commit Message

Changlong Xie Feb. 4, 2016, 10:19 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, 3 insertions(+)

Comments

Kevin Wolf Feb. 4, 2016, 12:24 p.m. UTC | #1
Am 04.02.2016 um 11:19 hat Changlong Xie geschrieben:
> 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, 3 insertions(+)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index a5ae4b8..0965277 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -295,6 +295,9 @@ static void quorum_aio_cb(void *opaque, int ret)
>              quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->child_iter].qiov);
>          }
>          acb->vote_ret = ret;
> +        if (ret < 0) {
> +            acb->child_iter--;
> +        }
>          quorum_aio_finalize(acb);
>          return;
>      }

This looks semantically correct to me (but I'd like to have an Ack from
Berto), but I would fix it above: We shouldn't do ++acb->child_iter in
the first place if the new value is >= s->num_children. So instead of
decrementing after the fact, just move the increment to inside the then
branch above.

Kevin
Changlong Xie Feb. 5, 2016, 1:57 a.m. UTC | #2
On 02/04/2016 08:24 PM, Kevin Wolf wrote:
> Am 04.02.2016 um 11:19 hat Changlong Xie geschrieben:
>> 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, 3 insertions(+)
>>
>> diff --git a/block/quorum.c b/block/quorum.c
>> index a5ae4b8..0965277 100644
>> --- a/block/quorum.c
>> +++ b/block/quorum.c
>> @@ -295,6 +295,9 @@ static void quorum_aio_cb(void *opaque, int ret)
>>               quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->child_iter].qiov);
>>           }
>>           acb->vote_ret = ret;
>> +        if (ret < 0) {
>> +            acb->child_iter--;
>> +        }
>>           quorum_aio_finalize(acb);
>>           return;
>>       }
>
> This looks semantically correct to me (but I'd like to have an Ack from
> Berto), but I would fix it above: We shouldn't do ++acb->child_iter in
> the first place if the new value is >= s->num_children. So instead of
> decrementing after the fact, just move the increment to inside the then
> branch above.

Yes, will fix in next version.

Thanks
	-Xie
>
> Kevin
>
>
> .
>
diff mbox

Patch

diff --git a/block/quorum.c b/block/quorum.c
index a5ae4b8..0965277 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -295,6 +295,9 @@  static void quorum_aio_cb(void *opaque, int ret)
             quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->child_iter].qiov);
         }
         acb->vote_ret = ret;
+        if (ret < 0) {
+            acb->child_iter--;
+        }
         quorum_aio_finalize(acb);
         return;
     }