From: David Turner <novalis@novalis.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Andreas Dilger <adilger@dilger.ca>, Mark Harris <mhlk@osj.us>,
Jan Kara <jack@suse.cz>,
Ext4 Developers List <linux-ext4@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v7 1/2] e2fsck: Correct ext4 dates generated by old kernels.
Date: Sat, 07 Dec 2013 21:58:17 -0500 [thread overview]
Message-ID: <1386471497.10748.32.camel@chiang> (raw)
In-Reply-To: <20131208005357.GB13776@thunk.org>
On Sat, 2013-12-07 at 19:53 -0500, Theodore Ts'o wrote:
> On Sat, Dec 07, 2013 at 03:02:40PM -0500, David Turner wrote:
> >
> > However, as Andreas notes, "we want to verify .. that "debugfs -R
> > 'stat testfile'" decodes the times correctly." Unfortunately, it
> > does not, and it is not trivial to fix. debugfs uses an internal
> > function time_to_string(__u32), which calls gmtime or localtime.
> > These functions are defined on time_t, which is 32-bits on 32-bit
> > Linux systems. In addition, because time_to_string takes
> > an unsigned int, it returns bad results for pre-1970 dates.
>
> We can and should change time_to_string to take an unsigned 64-bit
> type; it's an internal interface to debugfs.
Shouldn't this be a signed 64-bit type, since we have to support times
before 1970?
> The question of what to do if the system time_t is only 32-bit.
>
> What I'd probably suggest is to have a mode (set either by an
> environment variable, or a debugfs command) which causes
> time_to_string to use an internal version of a 64-bit capable gmtime
> function. This will allow for better regression testing, and it in a
> way that will be have stable results regardless of whether a
> particular platform, or a future version of glibc has a 64-bit time_t
> or not.
Presently, the TZ environment variable selects between gmtime and
localtime. How about the following:
We supply a 64-bit version of gmtime (but not localtime). If time_t is
32 bits, and the date being printed is after 2038, and TZ is not GMT,
then we return an error message instead of calling localtime. Then, in
any of the tests that depend on debugfs date printing we can simply set
TZ=GMT, so that they will continue to work regardless of the size of
time_t.
> > Also, while I was making this change, I happened to notice that
> > there is no dtime_extra field into which to put the extra bits.
> > This means that there is still a year 2038 problem with tools
> > that deal with deleted files (including the corner case that the
> > system is shut down cleanly at the exact second that the bottom
> > 32 bits of the current time are zero, leading fsck to believe
> > that there was an unclean shutdown).
>
> I'm not sure we care, since nothing is actually using the dtime. This
> was originally intended to make it easy to recover from accident file
> deletions, using debugfs's lsdel command. However, ever since ext3,
> in order to make sure the file system is consistent if it crashes
> during an unlink, we end up truncating the file before we unlink it,
> so i_blocks[] is completely cleared for deleted inodes. This makes it
> essentially impossible for lsdel to work.
I just did a quick grep, and it looks like
fs/ext4/ialloc.c:recently_deleted is using it. That's not relevant to
e2fsprogs, but we should correct it anyway, because it will probably
break in 2038.
Also fs/ext4/inode.c:ext4_do_update_inode -- I'm not sure quite what's
going on there, but it seems like it should be fixed as well.
I'll volunteer to make these changes to the kernel and to e2fsprogs, but
I think my current set of patches can be safely merged before I do that.
> > I want to make an additional change to correct this. Since I
> > assume it is impossible to add an additional field, I propose to
> > use ctime_extra to store the extra bits of dtime on deletion.
> > This is a bit hackish, since it does destroy a bit of data, but
> > it is significantly better than dtime being totally broken after
> > 2038. What do people think?
>
> Given that we always set ctime when delete a file (which makes sense,
> since we are decrementing i_links_count), I think changing debugfs
> (which is the only thing that even looks at dtime, BTW) makes a lot of
> sense.
I'm not really very familiar with the ext4 internals. Are you saying
that it's safe to just read ctime_extra (without explicitly writing it
when we write dtime)? Or just that it is safe to overwrite it when we
write dtime?
next prev parent reply other threads:[~2013-12-08 2:58 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-07 7:16 [PATCH] ext4: Fix reading of extended tv_sec (bug 23732) David Turner
2013-11-07 16:03 ` Jan Kara
2013-11-07 22:54 ` [PATCH v2] " David Turner
2013-11-07 23:14 ` Jan Kara
2013-11-07 23:26 ` [PATCH v3] " David Turner
2013-11-08 5:17 ` Theodore Ts'o
2013-11-08 21:37 ` Andreas Dilger
2013-11-09 7:19 ` [PATCH] ext4: explain encoding of 34-bit a,c,mtime values David Turner
2013-11-09 23:51 ` Mark Harris
2013-11-10 7:56 ` David Turner
2013-11-12 0:30 ` Theodore Ts'o
2013-11-12 21:35 ` Andreas Dilger
2013-11-13 7:00 ` [PATCH v4 1/2] ext4: Fix handling of extended tv_sec (bug 23732) David Turner
2013-11-13 8:19 ` Darrick J. Wong
2013-11-13 7:00 ` [PATCH v4 2/2] e2fsck: Correct ext4 dates generated by old kernels David Turner
2013-11-13 7:56 ` Andreas Dilger
2013-11-14 8:38 ` [PATCH v5 1/2] ext4: Fix handling of extended tv_sec (bug 23732) David Turner
2013-11-14 8:44 ` [PATCH v5 2/2] e2fsck: Correct ext4 dates generated by old kernels David Turner
2013-11-14 10:15 ` Mark Harris
2013-11-14 21:06 ` [PATCH v6] " David Turner
2013-11-29 21:54 ` David Turner
2013-11-29 22:11 ` Andreas Dilger
2013-12-07 20:02 ` [PATCH v7 1/2] " David Turner
2013-12-07 22:33 ` Andreas Dilger
2013-12-08 0:53 ` Theodore Ts'o
2013-12-08 2:58 ` David Turner [this message]
2013-12-08 3:21 ` Theodore Ts'o
2013-12-07 20:02 ` [PATCH v7 2/2] debugfs: Decode {a,c,cr,m}time_extra fields in stat David Turner
2013-11-12 23:03 ` [PATCH] ext4: explain encoding of 34-bit a,c,mtime values Darrick J. Wong
2013-11-13 2:36 ` David Turner
2014-01-22 6:22 ` Darrick J. Wong
2014-02-11 5:12 ` David Turner
2014-02-11 7:07 ` Andreas Dilger
2014-02-14 3:47 ` [PATCH v8 1/2] ext4: Fix handling of extended tv_sec (bug 23732) David Turner
2014-02-14 3:47 ` [PATCH v8 2/2] e2fsck: Correct ext4 dates generated by old kernels David Turner
2014-02-14 5:40 ` Andreas Dilger
2014-02-14 22:11 ` Darrick J. Wong
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=1386471497.10748.32.camel@chiang \
--to=novalis@novalis.org \
--cc=adilger@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhlk@osj.us \
--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;
as well as URLs for NNTP newsgroup(s).