From: Al Viro <viro@ZenIV.linux.org.uk>
To: Dan Luedtke <mail@danrl.de>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: Introducing Lanyard Filesystem
Date: Sun, 19 Aug 2012 16:12:51 +0100 [thread overview]
Message-ID: <20120819151251.GC23464@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1345395217.2716.58.camel@tunafish>
On Sun, Aug 19, 2012 at 06:53:37PM +0200, Dan Luedtke wrote:
> > * minor point, but endianness-flipping in place is *the* way to get
> > hard-to-catch endianness bugs. foo = cpu_to_le64(foo) is a bloody bad idea;
> > either use object for host-endian all along, or use it only for (in your
> > case) little-endian.
> I am not sure I understood this right.
> At what point should I convert e.g. the file size (little endian 64bit
> value stored on disk) to host endianess? When filling the inode?
> Is inode->i_size = le64_to_cpu(size) bad, too?
Conversions *in* *place* are bad. The above is fine if you have 'size'
variable used only for little-endian values (and declare it __le64, then).
The thing is, thinking of endianness conversions as architecture-conditional
byteswaps is wrong. Treat them as you would treat dealing with some
encoding; that's the reason why we have separate le64_to_cpu() and
cpu_to_le64(), even though they are identical as functions - on all
architectures we support. And don't use the same variable for both the
host- and fixed-endian values; it's far too easy to get confused on
code modifications and get the situation when two code paths lead to
the same point, one with host-endian value in that variable and another
with fixed-endian. Real fun to debug, especially when one of the codepaths
is rarely taken...
next prev parent reply other threads:[~2012-08-19 15:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-18 23:38 [PATCH] fs: Introducing Lanyard Filesystem Dan Luedtke
2012-08-18 22:06 ` Alan Cox
2012-08-18 22:16 ` richard -rw- weinberger
[not found] ` <c925f795-28d8-4e6d-8131-9a14d6e83659@email.android.com>
2012-08-18 22:27 ` richard -rw- weinberger
2012-08-19 10:12 ` Dan Luedtke
2012-08-19 10:14 ` Marco Stornelli
2012-08-19 13:34 ` Dan Luedtke
2012-08-19 12:02 ` Jochen Striepe
2012-08-19 15:33 ` Dan Luedtke
2012-08-19 14:07 ` Jochen Striepe
2012-08-19 14:27 ` Al Viro
2012-08-19 16:53 ` Dan Luedtke
2012-08-19 15:12 ` Al Viro [this message]
2012-08-19 15:24 ` Marco Stornelli
2012-08-20 17:36 ` Dan Luedtke
2012-08-19 21:04 ` Theodore Ts'o
2012-08-19 21:20 ` Andi Kleen
2012-08-19 23:06 ` Carlos Alberto Lopez Perez
2012-08-20 0:47 ` Theodore Ts'o
2012-08-20 6:07 ` Raymond Jennings
2012-08-20 6:49 ` Oliver Neukum
2012-08-20 9:12 ` Alexander Thomas
2012-08-20 13:21 ` Theodore Ts'o
2012-08-22 8:38 ` Arnd Bergmann
2012-08-20 11:36 ` Pavel Machek
2012-08-20 12:49 ` Ronnie Collinson
2012-08-20 17:48 ` Dan Luedtke
2012-08-19 13:25 ` Marco Stornelli
2012-08-19 15:45 ` Dan Luedtke
2012-08-22 9:53 ` Jan Engelhardt
2012-08-21 6:09 ` Vyacheslav Dubeyko
2012-08-23 17:29 ` Eric W. Biederman
2012-08-24 11:50 ` Prashant Shah
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=20120819151251.GC23464@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@danrl.de \
/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).