On Wed, Feb 19, 2020 at 05:26:40PM +0100, Otto Moerbeek wrote:
> On Wed, Feb 19, 2020 at 05:10:11PM +0100, Otto Moerbeek wrote:
> 
> > On Wed, Feb 19, 2020 at 10:02:10AM -0600, Scott Cheloha wrote:
> > 
> > > On Wed, Feb 19, 2020 at 04:00:34PM +0100, Otto Moerbeek wrote:
> > > > 
> > > > [...]
> > > > 
> > > > FFS1, the default filesystem, uses 32-bit signed timestamps on disk.
> > > > That means that in 2038, there's going to be a problem, timestamps
> > > > will the be interperet as coming from the start of the 1900's.
> > > > 
> > > > FFS2 does not have this limitation, but at the moment, we cannot boot
> > > > from it. I'm working on that as well, but for now I like to propose a
> > > > diff that interprets all timestamps in FFS1 as unsigned.
> > > > 
> > > > * On disk format dos not change
> > > > * Current timestamp values do not change
> > > 
> > > Doesn't this change the interpretation of timestamps before 1970?
> > > 
> > > Humor me:
> > > 
> > > # date 196901010000
> > > Wed Jan  1 00:00:00 CST 1969
> > > # touch test && ls -l test
> > > -rw-r--r--  1 ssc  ssc  0 Jan  1 00:00 test
> > > # stat test
> > > 1038 8878266 -rw-r--r-- 1 ssc ssc 0 0 "Jan  1 00:00:58 1969" "Jan  1 
> > > 00:00:58 1969" "Jan  1 00:00:58 1969" 32768 0 0 test
> > > 
> > > ... so what happens to such files?  The timestamps wrap around?
> > > 
> > > I'm not sure if that should prevent us from implementing this stopgap,
> > > but it's worth considering.
> > > 
> > > > I have checked various tools like dump(8) and restore(8), they work
> > > > properly. Code normally works with the fields from struct stat, which
> > > > is already 64-bit. I can imagine code setting timestamps to -1
> > > > explicitly, that could cause surprises.
> > > > 
> > > > So I'm asking for wider testing of the diff below.
> > > 
> > > One small bug below.
> > > 
> > > > Index: ufs/ffs/ffs_alloc.c
> > > > ===================================================================
> > > > RCS file: /cvs/src/sys/ufs/ffs/ffs_alloc.c,v
> > > > retrieving revision 1.109
> > > > diff -u -p -r1.109 ffs_alloc.c
> > > > --- ufs/ffs/ffs_alloc.c 19 Jul 2019 00:24:31 -0000      1.109
> > > > +++ ufs/ffs/ffs_alloc.c 16 Feb 2020 19:33:07 -0000
> > > > @@ -888,7 +888,8 @@ ffs_fragextend(struct inode *ip, int cg,
> > > >                 return (0);
> > > >  
> > > >         cgp = (struct cg *)bp->b_data;
> > > > -       cgp->cg_ffs2_time = cgp->cg_time = time_second;
> > > > +       cgp->cg_ffs2_time = time_second;
> > > > +       cgp->cg_time = time_second;
> > > 
> > > You shouldn't re-read time_second here unless you want to introduce a
> > > possible difference between cg_ffs2_time and cg_time.
> > > 
> > > You should also, in general, avoid time_second.  There is a split-read
> > > bug on 32-bit platforms at the 2038 cross-over.
> > > 
> > > That one I'm less certain about, though.  time_second assignment is
> > > brief compared to the alternative:
> > > 
> > >   struct timespec now;
> > > 
> > >   nanotime(&now);
> > >   cgp->cg_ffs2_time = now.tv_sec;
> > >   cgp->cg_time = now.tv_sec;
> > > 
> > > ... and the window for the split-read bug is very small...
> > > 
> > > At minimum, don't re-read time_second.
> > 
> > OK, I'll change that. Ne aware the filesystems is full of time_second.
> 
> It's not as bad as I thought.

The changes to from time_second(9) to nanotime(9) are ok cheloha@.

I'm a bit uneasy about changing the sign of the timestamp if the
ultimate solution is just "switch to ffs2".

If that's the case, why not make ffs2 bootable and leave ffs1 as-is?

Reply via email to