From: Andreas Dilger <adilger@clusterfs.com>
To: Kalpak Shah <kalpak@clusterfs.com>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>,
Dave Kleikamp <shaggy@linux.vnet.ibm.com>,
Johann Lombardi <johann.lombardi@bull.net>,
TheodoreTso <tytso@mit.edu>, sct <sct@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH take3 1/1] nanosecond timestamps
Date: Tue, 27 Feb 2007 15:45:24 -0700 [thread overview]
Message-ID: <20070227224523.GU10715@schatzie.adilger.int> (raw)
In-Reply-To: <1172569486.17385.12.camel@garfield>
On Feb 27, 2007 15:14 +0530, Kalpak Shah wrote:
> +#define EXT4_EPOCH_BITS 2
> +
> +static inline __le32 ext4_encode_extra_time(struct timespec *time)
> +{
> + return cpu_to_le32((sizeof(time->tv_sec) > 4 ?
> + time->tv_sec >> 32 : 0) |
> + ((time->tv_nsec << 2) & EXT4_NSEC_MASK));
This should be "(time->tv_nsec << EXT4_EPOCH_BITS)". We don't strictly
need the EXT4_NSEC_MASK because cpu_to_le32() will truncate the field to
32 bits anyways.
> +static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) {
> + if (sizeof(time->tv_sec) > 4)
> + time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK)
> + << 32;
> + time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2;
This should be ">> EXT4_EPOCH_BITS". Similarly, le32_to_cpu() will truncate
extra to 32 bits and we shift away the "epoch" part of the field, so we don't
need the EXT4_NSEC_MASK at all.
> +#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode) \
> +do { \
> + if (EXT4_FITS_IN_INODE(raw_inode, xtime)) \
> + (inode)->xtime.tv_sec = le32_to_cpu((raw_inode)->xtime); \
We might consider doing this in the caller for the crtime field. That is
only read/written in a single place, and it is the only one that needs the
extra check to determine if the seconds field is in the body of the inode.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
prev parent reply other threads:[~2007-02-27 22:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-27 9:44 [PATCH take3 1/1] nanosecond timestamps Kalpak Shah
2007-02-27 22:45 ` Andreas Dilger [this message]
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=20070227224523.GU10715@schatzie.adilger.int \
--to=adilger@clusterfs.com \
--cc=akpm@linux-foundation.org \
--cc=johann.lombardi@bull.net \
--cc=kalpak@clusterfs.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sct@redhat.com \
--cc=shaggy@linux.vnet.ibm.com \
--cc=tytso@mit.edu \
/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