Re: [PATCH take3 1/1] nanosecond timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux