From: "Måns Rullgård" <mans-2StjZFpD7GcAvxtiuMwx3w@public.gmane.org>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 19/19] lockd: clean up 64-bit alignment fix in nsm_init_private()
Date: Tue, 28 Apr 2009 23:31:38 +0100 [thread overview]
Message-ID: <yw1xws94xved.fsf@ps3.mansr.com> (raw)
In-Reply-To: <CAA58A55-4ED9-4D45-BE54-66DD8CEF191C@oracle.com> (Chuck Lever's message of "Tue, 28 Apr 2009 18:11:06 -0400")
Chuck Lever <chuck.lever@oracle.com> writes:
> On Apr 28, 2009, at 5:36 PM, J. Bruce Fields wrote:
>
>> On Tue, Apr 28, 2009 at 01:24:24PM -0400, Chuck Lever wrote:
>>> On Apr 28, 2009, at 12:40 PM, J. Bruce Fields wrote:
>>>> On Tue, Apr 28, 2009 at 12:35:50PM -0400, Chuck Lever wrote:
>>>>> On Apr 28, 2009, at 12:31 PM, J. Bruce Fields wrote:
>>>>>> On Thu, Apr 23, 2009 at 07:33:40PM -0400, Chuck Lever wrote:
>>>>>>> Recently, commit ad5b365c fixed a data type alignment issue in
>>>>>>> nsm_init_private() by introducing put_unaligned(). We don't
>>>>>>> actually _require_ an unaligned access to nsm_private here.
>>>>>>>
>>>>>>> Instead, we should always use memcpy/memcmp to access the
>>>>>>> contents of RPC opaque data types. This permits us to
>>>>>>> continue to define these as simple character arrays, as most
>>>>>>> legacy RPC code does, and to rely on gcc to pack the fields in
>>>>>>> in-core structures optimally without breaking on platforms
>>>>>>> that require strict alignment.
>>>>>>
>>>>>> OK, I'm confused. What structures will get packed differently?
>>>>>
>>>>> Any struct that has an nsm_private embedded in it, such as struct
>>>>> nlm_reboot.
>>>>
>>>> I don't see how that or any structure is changed by this patch.
>>>
>>> It's not. Note the phrase above in the description: "permits us to
>>> _continue_ to define these" -- meaning, I'm not changing the
>>> structures.
>>
>> Err, but that's not right either, is it?: We don't need to apply th=
is
>> patch in order to continue to define the structures as they're
>> currently
>> defined.
>>
>> Help! I'm confused!
>
> This patch is simply a clean up. We don't need to use put_unaligned
> in nsm_init_private. There is absolutely nothing special about the
> nsm_private data type that would require this. It should be accessed
The "special" thing is has not guaranteed alignment. Hence, any
access to it must use unaligned-safe methods.
> and modified the way all other RPC opaques are, via memset/memcpy.
What is so special about put_unaligned() that you insist on replacing i=
t?
> Take a look at http://thread.gmane.org/gmane.linux.nfs/25607 and
> commit ad5b365c.
>
> The controversy is over how to define opaques so they are accessible
> on both 32- and 64-bit hardware platforms. My first pass at
> nsm_init_private worked on 32-bit systems, but broke on 64-bit
> systems. An expedient fix for this was to add the put_unaligned in
> there so 64-bit systems could access the field no matter how it was
> aligned. I argue this is unneeded complexity, and inconsistent with
> the way most other RPC opaques are treated in the kernel.
>
> Andrew Morton proposed making RPC opaques a union of u8, u32 (or
> __be32), and u64 -- the u8 would allow us to treat an opaque as a byt=
e
> array when needed, the u32 would allow access via XDR quads, and the
> u64 would force 64-bit alignment. The issues with this are:
>
> 1. Defined this way, opaque fields in data structures will force the
> encompassing structures to be large enough to honor the alignment
> requirements of the fields, and
>
> 2. Most other RPC opaques are already defined as character arrays, s=
o
> we would have to visit all of them to see if there were issues.
>
> If we insist on accessing opaques only via memset() and memcpy()
> problem 1 goes away and we remain compatible with the traditional
> definition of an RPC opaque as an array of bytes, on both 64- and 32-
> bit systems.
I still don't see what problem put_unaligned() poses. Think of it as
a more efficient memcpy(). We don't want the code to be larger and
slower than necessary, do we?
--=20
M=E5ns Rullg=E5rd
mans-2StjZFpD7GcAvxtiuMwx3w@public.gmane.org
next prev parent reply other threads:[~2009-04-28 22:38 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-23 23:31 [PATCH 00/19] Proposed server-side patches for 2.6.31 Chuck Lever
[not found] ` <20090423231550.17283.24432.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-23 23:31 ` [PATCH 01/19] SUNRPC: Fix error return value of svc_addr_len() Chuck Lever
[not found] ` <20090423233124.17283.40252.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-25 22:17 ` J. Bruce Fields
2009-04-27 16:49 ` Chuck Lever
2009-04-27 23:51 ` J. Bruce Fields
2009-04-28 15:28 ` Chuck Lever
2009-04-28 15:31 ` J. Bruce Fields
2009-04-23 23:31 ` [PATCH 02/19] NFSD: Refactor transport removal out of __write_ports() Chuck Lever
2009-04-23 23:31 ` [PATCH 03/19] NFSD: Refactor transport addition " Chuck Lever
2009-04-23 23:31 ` [PATCH 04/19] NFSD: Refactor portlist socket closing into a helper Chuck Lever
2009-04-23 23:31 ` [PATCH 05/19] NFSD: Refactor socket creation out of __write_ports() Chuck Lever
[not found] ` <20090423233155.17283.37345.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-25 22:40 ` J. Bruce Fields
2009-04-23 23:32 ` [PATCH 06/19] NFSD: Note an additional requirement when passing TCP sockets to portlist Chuck Lever
2009-04-23 23:32 ` [PATCH 07/19] NFSD: Finish refactoring __write_ports() Chuck Lever
2009-04-23 23:32 ` [PATCH 08/19] NFSD: move lockd_up() before svc_addsock() Chuck Lever
2009-04-23 23:32 ` [PATCH 09/19] NFSD: Prevent a buffer overflow in svc_xprt_names() Chuck Lever
[not found] ` <20090423233225.17283.10176.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-27 23:56 ` J. Bruce Fields
2009-04-23 23:32 ` [PATCH 10/19] SUNRPC: pass buffer size to svc_addsock() Chuck Lever
2009-04-23 23:32 ` [PATCH 11/19] SUNRPC: pass buffer size to svc_sock_names() Chuck Lever
2009-04-23 23:32 ` [PATCH 12/19] SUNRPC: Switch one_sock_name() to use snprintf() Chuck Lever
2009-04-23 23:32 ` [PATCH 13/19] SUNRPC: Support PF_INET6 in one_sock_name() Chuck Lever
2009-04-23 23:33 ` [PATCH 14/19] SUNRPC: Clean up one_sock_name() Chuck Lever
2009-04-23 23:33 ` [PATCH 15/19] NFSD: Stricter buffer size checking in write_recoverydir() Chuck Lever
2009-04-23 23:33 ` [PATCH 16/19] NFSD: Stricter buffer size checking in write_versions() Chuck Lever
2009-04-23 23:33 ` [PATCH 17/19] NFSD: Stricter buffer size checking in fs/nfsd/nfsctl.c Chuck Lever
[not found] ` <20090423233325.17283.71127.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-28 16:31 ` J. Bruce Fields
2009-04-28 16:36 ` Chuck Lever
2009-04-28 21:30 ` J. Bruce Fields
2009-04-23 23:33 ` [PATCH 18/19] lockd: Update NSM state from SM_MON replies Chuck Lever
[not found] ` <20090423233332.17283.23011.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-28 16:25 ` J. Bruce Fields
2009-04-28 16:34 ` Chuck Lever
2009-04-28 16:38 ` J. Bruce Fields
2009-04-28 19:11 ` Chuck Lever
2009-05-08 15:19 ` Chuck Lever
2009-05-08 15:33 ` J. Bruce Fields
2009-04-23 23:33 ` [PATCH 19/19] lockd: clean up 64-bit alignment fix in nsm_init_private() Chuck Lever
[not found] ` <20090423233340.17283.29580.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2009-04-28 16:31 ` J. Bruce Fields
2009-04-28 16:35 ` Chuck Lever
2009-04-28 16:40 ` J. Bruce Fields
2009-04-28 17:24 ` Chuck Lever
2009-04-28 21:36 ` J. Bruce Fields
2009-04-28 22:03 ` Måns Rullgård
[not found] ` <yw1x63gozb9f.fsf-O+uoZmgXk1l54TAoqtyWWQ@public.gmane.org>
2009-04-28 22:14 ` Chuck Lever
2009-04-28 22:11 ` Chuck Lever
2009-04-28 22:23 ` J. Bruce Fields
2009-04-28 22:31 ` Måns Rullgård [this message]
[not found] ` <yw1xws94xved.fsf-O+uoZmgXk1l54TAoqtyWWQ@public.gmane.org>
2009-04-28 22:43 ` Chuck Lever
2009-04-28 22:52 ` Måns Rullgård
[not found] ` <yw1xskjsxuff.fsf-O+uoZmgXk1l54TAoqtyWWQ@public.gmane.org>
2009-04-29 15:16 ` Chuck Lever
2009-04-29 18:02 ` Måns Rullgård
2009-04-25 22:14 ` [PATCH 00/19] Proposed server-side patches for 2.6.31 J. Bruce Fields
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=yw1xws94xved.fsf@ps3.mansr.com \
--to=mans-2stjzfpd7gcavxtiumwx3w@public.gmane.org \
--cc=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox