qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nbd: avoid unaligned uint64_t store
@ 2016-02-03 23:48 John Snow
  2016-02-04 10:27 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: John Snow @ 2016-02-03 23:48 UTC (permalink / raw)
  To: qemu-block; +Cc: John Snow, pbonzini, famz, qemu-devel, mreitz

cpu_to_be64w can't be used to make unaligned stores, but stq_be_p can.
The other stores in this routine are left alone, they're aligned already.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 nbd/server.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nbd/server.c b/nbd/server.c
index 1ec79cf..5b65059 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -441,7 +441,7 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
         }
 
         assert ((client->exp->nbdflags & ~65535) == 0);
-        cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size);
+        stq_be_p((uint64_t *)(buf + 18), client->exp->size);
         cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
         if (nbd_negotiate_write(csock, buf + 18,
                                 sizeof(buf) - 18) != sizeof(buf) - 18) {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] nbd: avoid unaligned uint64_t store
  2016-02-03 23:48 [Qemu-devel] [PATCH] nbd: avoid unaligned uint64_t store John Snow
@ 2016-02-04 10:27 ` Paolo Bonzini
  2016-02-04 15:45   ` John Snow
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2016-02-04 10:27 UTC (permalink / raw)
  To: John Snow, qemu-block; +Cc: famz, qemu-devel, mreitz



On 04/02/2016 00:48, John Snow wrote:
> cpu_to_be64w can't be used to make unaligned stores, but stq_be_p can.
> The other stores in this routine are left alone, they're aligned already.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  nbd/server.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/nbd/server.c b/nbd/server.c
> index 1ec79cf..5b65059 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -441,7 +441,7 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
>          }
>  
>          assert ((client->exp->nbdflags & ~65535) == 0);
> -        cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size);
> +        stq_be_p((uint64_t *)(buf + 18), client->exp->size);
>          cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
>          if (nbd_negotiate_write(csock, buf + 18,
>                                  sizeof(buf) - 18) != sizeof(buf) - 18) {
> 

Let's change all of them.  But no need to send another patch.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] nbd: avoid unaligned uint64_t store
  2016-02-04 10:27 ` Paolo Bonzini
@ 2016-02-04 15:45   ` John Snow
  2016-02-04 15:57     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: John Snow @ 2016-02-04 15:45 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-block; +Cc: famz, qemu-devel, mreitz



On 02/04/2016 05:27 AM, Paolo Bonzini wrote:
> 
> 
> On 04/02/2016 00:48, John Snow wrote:
>> cpu_to_be64w can't be used to make unaligned stores, but stq_be_p can.
>> The other stores in this routine are left alone, they're aligned already.
>>
>> Signed-off-by: John Snow <jsnow@redhat.com>
>> ---
>>  nbd/server.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/nbd/server.c b/nbd/server.c
>> index 1ec79cf..5b65059 100644
>> --- a/nbd/server.c
>> +++ b/nbd/server.c
>> @@ -441,7 +441,7 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
>>          }
>>  
>>          assert ((client->exp->nbdflags & ~65535) == 0);
>> -        cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size);
>> +        stq_be_p((uint64_t *)(buf + 18), client->exp->size);
>>          cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
>>          if (nbd_negotiate_write(csock, buf + 18,
>>                                  sizeof(buf) - 18) != sizeof(buf) - 18) {
>>
> 
> Let's change all of them.  But no need to send another patch.
> 
> Paolo
> 

Does that mean that you're going to re-write the patch?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] nbd: avoid unaligned uint64_t store
  2016-02-04 15:45   ` John Snow
@ 2016-02-04 15:57     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2016-02-04 15:57 UTC (permalink / raw)
  To: John Snow, qemu-block; +Cc: famz, qemu-devel, mreitz



On 04/02/2016 16:45, John Snow wrote:
> 
> 
> On 02/04/2016 05:27 AM, Paolo Bonzini wrote:
>>
>>
>> On 04/02/2016 00:48, John Snow wrote:
>>> cpu_to_be64w can't be used to make unaligned stores, but stq_be_p can.
>>> The other stores in this routine are left alone, they're aligned already.
>>>
>>> Signed-off-by: John Snow <jsnow@redhat.com>
>>> ---
>>>  nbd/server.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/nbd/server.c b/nbd/server.c
>>> index 1ec79cf..5b65059 100644
>>> --- a/nbd/server.c
>>> +++ b/nbd/server.c
>>> @@ -441,7 +441,7 @@ static coroutine_fn int nbd_negotiate(NBDClientNewData *data)
>>>          }
>>>  
>>>          assert ((client->exp->nbdflags & ~65535) == 0);
>>> -        cpu_to_be64w((uint64_t*)(buf + 18), client->exp->size);
>>> +        stq_be_p((uint64_t *)(buf + 18), client->exp->size);
>>>          cpu_to_be16w((uint16_t*)(buf + 26), client->exp->nbdflags | myflags);
>>>          if (nbd_negotiate_write(csock, buf + 18,
>>>                                  sizeof(buf) - 18) != sizeof(buf) - 18) {
>>>
>>
>> Let's change all of them.  But no need to send another patch.
>>
>> Paolo
>>
> 
> Does that mean that you're going to re-write the patch?

I will just make it bigger. :)  Your one line change will still be there!

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-04 15:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-03 23:48 [Qemu-devel] [PATCH] nbd: avoid unaligned uint64_t store John Snow
2016-02-04 10:27 ` Paolo Bonzini
2016-02-04 15:45   ` John Snow
2016-02-04 15:57     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).