From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: shouldn't rpc_pipe_upcall message structs be __attribute__((packed)) ?
Date: Fri, 9 Sep 2011 16:03:04 -0400 [thread overview]
Message-ID: <20110909200304.GA32125@fieldses.org> (raw)
In-Reply-To: <20110909143605.57d54899@tlielax.poochiereds.net>
On Fri, Sep 09, 2011 at 02:36:05PM -0400, Jeff Layton wrote:
> I've been looking at replacing the current scheme that knfsd uses to
> track client_id4's (aka the v4recoverydir stuff), with an
> upcall/downcall scheme. Primarily this is to allow for more robust
> handling of clustered NFSv4 services.
>
> In the process, I've been looking at the various upcall schemes we use
> to see which ones might be suitable to use in this effort. I've noticed
> that we have several upcalls that use rpc_pipefs, and that all of them
> seem to make assumptions that the userspace programs will align their
> message structs identically to how the kernel does.
>
> For instance, here's the idmap one:
>
> struct idmap_msg {
> __u8 im_type;
> __u8 im_conv;
> char im_name[IDMAP_NAMESZ];
> __u32 im_id;
> __u8 im_status;
> };
That's the "legacy" idmap code, right?
In which case we want to leave it alone if at all possible and move
people to the new idmapper.
--b.
>
> Note that this struct does not have __attribute__((packed)), so the
> compiler is allowed to add padding between the fields as it sees fit.
>
> If, for instance, someone were to build the userspace programs
> differently than the kernel (for instance x86_64 kernel with i686
> userspace), it's possible that the padding between them would be
> different. It's also possible that different compilers might align
> things differently here.
>
> The blocklayout upcall is even more scary as the width of the status
> field is not explicit:
>
> struct bl_dev_msg {
> int status;
> uint32_t major, minor;
> };
>
> ...it's unlikely that the kernel and userspace would differ on the size
> of an int here, but it might be a good idea to go ahead and make that
> explicitly 32 bits in case we end up dealing with more exotic arches at
> some point in the future.
>
> I'm not sure what we can really do about this at this point. Adding
> this attribute now would definitely be an kernel/userspace
> compatibility issue.
>
> One possibility is to add padding between the fields that aligns with
> the current padding that the compiler adds and then make them "packed".
> That might make these structs arch-specific though since different
> arches probably pad these differently... :-/
>
> Am I making mountains out of molehills here? Thoughts?
>
> --
> Jeff Layton <jlayton@redhat.com>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-09-09 20:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-09 18:36 shouldn't rpc_pipe_upcall message structs be __attribute__((packed)) ? Jeff Layton
2011-09-09 19:56 ` Jim Rees
2011-09-09 21:16 ` Jeff Layton
2011-09-09 22:03 ` Jim Rees
2011-09-09 22:32 ` Trond Myklebust
2011-09-10 0:14 ` Jeff Layton
2011-09-09 20:03 ` J. Bruce Fields [this message]
2011-09-09 21:05 ` Jeff Layton
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=20110909200304.GA32125@fieldses.org \
--to=bfields@fieldses.org \
--cc=jlayton@redhat.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;
as well as URLs for NNTP newsgroup(s).