From: Tom Tucker <tom@opengridcomputing.com>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
"David S. Miller" <davem@davemloft.net>,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] svcrdma: endian bug in send_write_chunks()
Date: Thu, 12 Jan 2012 19:37:29 +0000 [thread overview]
Message-ID: <4F0F3679.7090304@opengridcomputing.com> (raw)
In-Reply-To: <1326396510.6198.12.camel@lade.trondhjem.org>
On 1/12/12 1:28 PM, Trond Myklebust wrote:
> On Thu, 2012-01-12 at 13:24 -0600, Tom Tucker wrote:
>> On 1/12/12 1:15 PM, Trond Myklebust wrote:
>>> On Thu, 2012-01-12 at 11:21 -0500, J. Bruce Fields wrote:
>>>> On Thu, Jan 12, 2012 at 09:47:22AM +0300, Dan Carpenter wrote:
>>>>> Sparse complains because arg_ch->rs_length is declared as network
>>>>> endian but we're treating it as CPU endian.
>>>> This looks like it would actually change behavior on a little endian
>>>> architecture, so how did this work before?
>>>>
>>>>> From some quick grepping, I see assignments both of the form
>>>> ...rs_length = ntohl(...)
>>>>
>>>> and
>>>>
>>>> ...rs_length = htonl(...)
>>>>
>>>> but only see one declaration for a field named rs_length.
>>>>
>>>> So my best guess would be that the code is ugly but working as is, and
>>>> needs cleanup by someone who knows how this field was intended to be
>>>> used.
>>> It looks to me as if rs_handle and rs_offset are being similarly abused.
>>> Basically, we need a serious clean up in svc_rdma_marshall.c to separate
>>> out those variables that are in XDR-encoded form and those that are not.
>>>
>> The abuse is taking place because the marshal/unmarshall is being done
>> in-place and it seemed wasteful at the time to add a chunk of memory to
>> preserve the aesthetic. A union would 'work', but you still wouldn't
>> 'know' whether the data was NBO or not by where it was -- which seems like
>> the intent of the __beXX in the first place.
> These are not variables that are used in hundreds of different places:
> why not just do the conversion from big-endian to cpu-endian when you
> actually need to use them?
That would work fine actually. At the time, I was trying to put all that
marshalling logic in that one file and reuse the already present
client-side header file that copies that stuff when it decodes it.
I'll dig around a little bit and see what might be the simplest way to
clean this up.
Tom
WARNING: multiple messages have this Message-ID (diff)
From: Tom Tucker <tom@opengridcomputing.com>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
"David S. Miller" <davem@davemloft.net>,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] svcrdma: endian bug in send_write_chunks()
Date: Thu, 12 Jan 2012 13:37:29 -0600 [thread overview]
Message-ID: <4F0F3679.7090304@opengridcomputing.com> (raw)
In-Reply-To: <1326396510.6198.12.camel@lade.trondhjem.org>
On 1/12/12 1:28 PM, Trond Myklebust wrote:
> On Thu, 2012-01-12 at 13:24 -0600, Tom Tucker wrote:
>> On 1/12/12 1:15 PM, Trond Myklebust wrote:
>>> On Thu, 2012-01-12 at 11:21 -0500, J. Bruce Fields wrote:
>>>> On Thu, Jan 12, 2012 at 09:47:22AM +0300, Dan Carpenter wrote:
>>>>> Sparse complains because arg_ch->rs_length is declared as network
>>>>> endian but we're treating it as CPU endian.
>>>> This looks like it would actually change behavior on a little endian
>>>> architecture, so how did this work before?
>>>>
>>>>> From some quick grepping, I see assignments both of the form
>>>> ...rs_length = ntohl(...)
>>>>
>>>> and
>>>>
>>>> ...rs_length = htonl(...)
>>>>
>>>> but only see one declaration for a field named rs_length.
>>>>
>>>> So my best guess would be that the code is ugly but working as is, and
>>>> needs cleanup by someone who knows how this field was intended to be
>>>> used.
>>> It looks to me as if rs_handle and rs_offset are being similarly abused.
>>> Basically, we need a serious clean up in svc_rdma_marshall.c to separate
>>> out those variables that are in XDR-encoded form and those that are not.
>>>
>> The abuse is taking place because the marshal/unmarshall is being done
>> in-place and it seemed wasteful at the time to add a chunk of memory to
>> preserve the aesthetic. A union would 'work', but you still wouldn't
>> 'know' whether the data was NBO or not by where it was -- which seems like
>> the intent of the __beXX in the first place.
> These are not variables that are used in hundreds of different places:
> why not just do the conversion from big-endian to cpu-endian when you
> actually need to use them?
That would work fine actually. At the time, I was trying to put all that
marshalling logic in that one file and reuse the already present
client-side header file that copies that stuff when it decodes it.
I'll dig around a little bit and see what might be the simplest way to
clean this up.
Tom
WARNING: multiple messages have this Message-ID (diff)
From: Tom Tucker <tom-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>
To: Trond Myklebust
<Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>
Cc: "J. Bruce Fields"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
Dan Carpenter
<dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [patch] svcrdma: endian bug in send_write_chunks()
Date: Thu, 12 Jan 2012 13:37:29 -0600 [thread overview]
Message-ID: <4F0F3679.7090304@opengridcomputing.com> (raw)
In-Reply-To: <1326396510.6198.12.camel-SyLVLa/KEI9HwK5hSS5vWB2eb7JE58TQ@public.gmane.org>
On 1/12/12 1:28 PM, Trond Myklebust wrote:
> On Thu, 2012-01-12 at 13:24 -0600, Tom Tucker wrote:
>> On 1/12/12 1:15 PM, Trond Myklebust wrote:
>>> On Thu, 2012-01-12 at 11:21 -0500, J. Bruce Fields wrote:
>>>> On Thu, Jan 12, 2012 at 09:47:22AM +0300, Dan Carpenter wrote:
>>>>> Sparse complains because arg_ch->rs_length is declared as network
>>>>> endian but we're treating it as CPU endian.
>>>> This looks like it would actually change behavior on a little endian
>>>> architecture, so how did this work before?
>>>>
>>>>> From some quick grepping, I see assignments both of the form
>>>> ...rs_length = ntohl(...)
>>>>
>>>> and
>>>>
>>>> ...rs_length = htonl(...)
>>>>
>>>> but only see one declaration for a field named rs_length.
>>>>
>>>> So my best guess would be that the code is ugly but working as is, and
>>>> needs cleanup by someone who knows how this field was intended to be
>>>> used.
>>> It looks to me as if rs_handle and rs_offset are being similarly abused.
>>> Basically, we need a serious clean up in svc_rdma_marshall.c to separate
>>> out those variables that are in XDR-encoded form and those that are not.
>>>
>> The abuse is taking place because the marshal/unmarshall is being done
>> in-place and it seemed wasteful at the time to add a chunk of memory to
>> preserve the aesthetic. A union would 'work', but you still wouldn't
>> 'know' whether the data was NBO or not by where it was -- which seems like
>> the intent of the __beXX in the first place.
> These are not variables that are used in hundreds of different places:
> why not just do the conversion from big-endian to cpu-endian when you
> actually need to use them?
That would work fine actually. At the time, I was trying to put all that
marshalling logic in that one file and reuse the already present
client-side header file that copies that stuff when it decodes it.
I'll dig around a little bit and see what might be the simplest way to
clean this up.
Tom
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-01-12 19:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-12 6:47 [patch] svcrdma: endian bug in send_write_chunks() Dan Carpenter
2012-01-12 6:47 ` Dan Carpenter
2012-01-12 6:47 ` Dan Carpenter
2012-01-12 16:21 ` J. Bruce Fields
2012-01-12 16:21 ` J. Bruce Fields
2012-01-12 19:15 ` Trond Myklebust
2012-01-12 19:15 ` Trond Myklebust
2012-01-12 19:24 ` Tom Tucker
2012-01-12 19:24 ` Tom Tucker
2012-01-12 19:28 ` Trond Myklebust
2012-01-12 19:28 ` Trond Myklebust
2012-01-12 19:28 ` Trond Myklebust
2012-01-12 19:37 ` Tom Tucker [this message]
2012-01-12 19:37 ` Tom Tucker
2012-01-12 19:37 ` Tom Tucker
2012-01-12 19:28 ` J. Bruce Fields
2012-01-12 19:28 ` J. Bruce Fields
2012-01-12 19:28 ` J. Bruce Fields
2012-01-12 21:32 ` Dan Carpenter
2012-01-12 21:32 ` Dan Carpenter
2012-01-12 21:32 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F0F3679.7090304@opengridcomputing.com \
--to=tom@opengridcomputing.com \
--cc=Trond.Myklebust@netapp.com \
--cc=bfields@fieldses.org \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.