linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Garbage returned in nanosecond component of timestamps
@ 2010-11-20  6:22 Jordan Russell
  2010-11-20  7:53 ` Eric Sandeen
  2010-11-22 17:45 ` [PATCH] ext4: zero out nanosecond timestamps for small inodes Eric Sandeen
  0 siblings, 2 replies; 4+ messages in thread
From: Jordan Russell @ 2010-11-20  6:22 UTC (permalink / raw)
  To: linux-ext4

[Fedora 14 with vendor kernel 2.6.35.6-48.fc14.i686.PAE]

When nanosecond timestamp resolution isn't supported on an ext4
partition (inode size = 128), stat() appears to be returning
uninitialized garbage in the nanosecond component of timestamps.

See the following tests.
Expected: All timestamps should end with '.0000000000'.
Actual: '.0026721629' popping up on a different file each time.

> # tune2fs -l /dev/md0 | fgrep 'Inode size'
> Inode size:               128
> # echo 3 >/proc/sys/vm/drop_caches
> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
> Wed Nov  4 16:53:20.0026721629 2009 - /boot/oldconfigs/config-2.6.27.38-170.2.113.fc10.i686.PAE
> # echo 3 >/proc/sys/vm/drop_caches
> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
> Thu Nov  8 20:38:30.0026721629 2007 - /boot/oldconfigs/config-2.6.23.1-49.fc8PAE
> # echo 3 >/proc/sys/vm/drop_caches
> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
> Thu Aug 12 17:44:51.0026721629 2010 - /lib/firmware/emi26/bitstream.fw
> # echo 3 >/proc/sys/vm/drop_caches
> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
> Thu Aug 12 17:44:51.0026721629 2010 - /lib/firmware/slicoss/gbdownload.sys
> # echo 3 >/proc/sys/vm/drop_caches
> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
> Fri Nov  5 01:16:32.0026721629 2010 - /boot/grub/e2fs_stage1_5


Shouldn't EXT4_INODE_GET_XTIME zero out tv_nsec when EXT4_FITS_IN_INODE
evaluates to false...?

> #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)                          \
> do {                                                                           \
>         (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);       \
>         if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     \
>                 ext4_decode_extra_time(&(inode)->xtime,                        \
>                                        raw_inode->xtime ## _extra);            \
> } while (0)

-- 
Jordan Russell

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Garbage returned in nanosecond component of timestamps
  2010-11-20  6:22 Garbage returned in nanosecond component of timestamps Jordan Russell
@ 2010-11-20  7:53 ` Eric Sandeen
  2010-11-22 17:45 ` [PATCH] ext4: zero out nanosecond timestamps for small inodes Eric Sandeen
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2010-11-20  7:53 UTC (permalink / raw)
  To: Jordan Russell; +Cc: linux-ext4

On 11/20/10 12:22 AM, Jordan Russell wrote:
> [Fedora 14 with vendor kernel 2.6.35.6-48.fc14.i686.PAE]
> 
> When nanosecond timestamp resolution isn't supported on an ext4
> partition (inode size = 128), stat() appears to be returning
> uninitialized garbage in the nanosecond component of timestamps.
> 
> See the following tests.
> Expected: All timestamps should end with '.0000000000'.
> Actual: '.0026721629' popping up on a different file each time.
> 
>> # tune2fs -l /dev/md0 | fgrep 'Inode size'
>> Inode size:               128
>> # echo 3 >/proc/sys/vm/drop_caches
>> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
>> Wed Nov  4 16:53:20.0026721629 2009 - /boot/oldconfigs/config-2.6.27.38-170.2.113.fc10.i686.PAE
>> # echo 3 >/proc/sys/vm/drop_caches
>> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
>> Thu Nov  8 20:38:30.0026721629 2007 - /boot/oldconfigs/config-2.6.23.1-49.fc8PAE
>> # echo 3 >/proc/sys/vm/drop_caches
>> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
>> Thu Aug 12 17:44:51.0026721629 2010 - /lib/firmware/emi26/bitstream.fw
>> # echo 3 >/proc/sys/vm/drop_caches
>> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
>> Thu Aug 12 17:44:51.0026721629 2010 - /lib/firmware/slicoss/gbdownload.sys
>> # echo 3 >/proc/sys/vm/drop_caches
>> # find / -xdev -type f -printf '%t - %p\n' | fgrep -v '.0000000000'
>> Fri Nov  5 01:16:32.0026721629 2010 - /boot/grub/e2fs_stage1_5
> 
> 
> Shouldn't EXT4_INODE_GET_XTIME zero out tv_nsec when EXT4_FITS_IN_INODE
> evaluates to false...?

Yep I think so, good catch...

-Eric

>> #define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)                          \
>> do {                                                                           \
>>         (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);       \
>>         if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     \
>>                 ext4_decode_extra_time(&(inode)->xtime,                        \
>>                                        raw_inode->xtime ## _extra);            \
>> } while (0)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ext4: zero out nanosecond timestamps for small inodes
  2010-11-20  6:22 Garbage returned in nanosecond component of timestamps Jordan Russell
  2010-11-20  7:53 ` Eric Sandeen
@ 2010-11-22 17:45 ` Eric Sandeen
  2010-12-20  3:11   ` Ted Ts'o
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Sandeen @ 2010-11-22 17:45 UTC (permalink / raw)
  To: Jordan Russell; +Cc: linux-ext4

As reported by Jordan Russell:

When nanosecond timestamp resolution isn't supported on an ext4
partition (inode size = 128), stat() appears to be returning
uninitialized garbage in the nanosecond component of timestamps.

EXT4_INODE_GET_XTIME should zero out tv_nsec when EXT4_FITS_IN_INODE
evaluates to false.

Reported-by: Jordan Russell <jr-list-2010@quo.to>
Signed-of-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 6a5edea..1541e3e 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -709,6 +709,8 @@ do {									       \
 	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     \
 		ext4_decode_extra_time(&(inode)->xtime,			       \
 				       raw_inode->xtime ## _extra);	       \
+	else								       \
+		(inode)->xtime.tv_nsec = 0;				       \
 } while (0)
 
 #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode)			       \
@@ -719,6 +721,8 @@ do {									       \
 	if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra))	       \
 		ext4_decode_extra_time(&(einode)->xtime,		       \
 				       raw_inode->xtime ## _extra);	       \
+	else								       \
+		(einode)->xtime.tv_nsec = 0;				       \
 } while (0)
 
 #define i_disk_version osd1.linux1.l_i_version


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ext4: zero out nanosecond timestamps for small inodes
  2010-11-22 17:45 ` [PATCH] ext4: zero out nanosecond timestamps for small inodes Eric Sandeen
@ 2010-12-20  3:11   ` Ted Ts'o
  0 siblings, 0 replies; 4+ messages in thread
From: Ted Ts'o @ 2010-12-20  3:11 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Jordan Russell, linux-ext4

On Mon, Nov 22, 2010 at 11:45:48AM -0600, Eric Sandeen wrote:
> As reported by Jordan Russell:
> 
> When nanosecond timestamp resolution isn't supported on an ext4
> partition (inode size = 128), stat() appears to be returning
> uninitialized garbage in the nanosecond component of timestamps.
> 
> EXT4_INODE_GET_XTIME should zero out tv_nsec when EXT4_FITS_IN_INODE
> evaluates to false.
> 
> Reported-by: Jordan Russell <jr-list-2010@quo.to>
> Signed-of-by: Eric Sandeen <sandeen@redhat.com>

Thanks, added to the ext4 patch queue.

						- Ted

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-20  3:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-20  6:22 Garbage returned in nanosecond component of timestamps Jordan Russell
2010-11-20  7:53 ` Eric Sandeen
2010-11-22 17:45 ` [PATCH] ext4: zero out nanosecond timestamps for small inodes Eric Sandeen
2010-12-20  3:11   ` Ted Ts'o

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).