All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: y2038@lists.linaro.org
Cc: "Ksenija Stanojević" <ksenija.stanojevic@gmail.com>,
	outreachy-kernel <outreachy-kernel@googlegroups.com>
Subject: Re: [Y2038] [PATCH 2/5] fs: nfsd: Replace time_t with u32 in nfsd4_lease
Date: Tue, 10 Nov 2015 11:01:44 +0100	[thread overview]
Message-ID: <3868597.PIV5n69lhm@wuerfel> (raw)
In-Reply-To: <CAL7P5jK=pbSvFURGN55TYUfbhPedOuNyi+Rm=wRKbxxuQdnU5Q@mail.gmail.com>

On Monday 09 November 2015 20:37:22 Ksenija Stanojević wrote:
> On Tue, Nov 3, 2015 at 4:14 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tuesday 27 October 2015 09:09:35 Ksenija Stanojevic wrote:
> >> Replace time_t type and get_seconds function which are not y2038 safe on
> >> 32-bit systems. Function ktime_get_seconds use monotonic instead of real
> >> time and therefore will not cause overflow.
> >>
> >> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> >
> > You are missing an explanation about why the u32 type is used. The
> > change to that type looks absolutely appropriate here, but it seems
> > unrelated to what you write above.
> 
> It' safe to assume that system will be rebooted in 136 years and 32-bit
> number is enough to store a monotonic time value.

Not exactly in this case: nfsd4_lease is not actually used to store
a monotonic time (which would be local to the system, starting at boot
and not shared with other systems), but instead stores a time interval
that *is* shared with other systems as a 32-bit value in
nfsd4_encode_fattr().

So in order to make it obvious to everyone what happens here, explain
that you picked this type because it matches the size on the wire protocol,
and also why the wire protocol is safe.

> >> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> >> index 8245236..4bceb878 100644
> >> --- a/fs/nfsd/nfs4state.c
> >> +++ b/fs/nfsd/nfs4state.c
> >> @@ -4332,8 +4332,8 @@ nfs4_laundromat(struct nfsd_net *nn)
> >>       struct nfs4_delegation *dp;
> >>       struct nfs4_ol_stateid *stp;
> >>       struct list_head *pos, *next, reaplist;
> >> -     time_t cutoff = get_seconds() - nn->nfsd4_lease;
> >> -     time_t t, new_timeo = nn->nfsd4_lease;
> >> +     u32 cutoff = ktime_get_seconds() - nn->nfsd4_lease;
> >> +     u32 t, new_timeo = nn->nfsd4_lease;
> >>
> >>       dprintk("NFSD: laundromat service - starting\n");
> >>       nfsd4_end_grace(nn);
> >
> > The change to "cutoff" needs to be done together with the 'cl_time'
> > change from patch 1, and all the users of that variable.
> 
> You commented in patch 1 that change to cl_time is unrelated to other
> changes in that patch. Should I make a new patch which changes cl_time
> and cutoff or do all those changes in patch 1?

Try to make it a separate patch. As you are dealing with rather complex
stuff here, the patches should be as small as possible while being
large enough to make sense on their own. I see now that there are
also 'oo_time' and 'dl_time' in the same function that are compared to
'cutoff'. I would try changing all four of these in one patch at first,
and then see if that patch is simple enough to still be explained
easily.

> >> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> >> index 9690cb4..6e0cfd6 100644
> >> --- a/fs/nfsd/nfsctl.c
> >> +++ b/fs/nfsd/nfsctl.c
> >> @@ -932,7 +932,7 @@ static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
> >>
> >>  #ifdef CONFIG_NFSD_V4
> >>  static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
> >> -                               time_t *time, struct nfsd_net *nn)
> >> +                               u32 *time, struct nfsd_net *nn)
> >>  {
> >>       char *mesg = buf;
> >>       int rv, i;
> >> @@ -964,7 +964,7 @@ static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
> >>  }
> >>
> >>  static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size,
> >> -                             time_t *time, struct nfsd_net *nn)
> >> +                             u32 *time, struct nfsd_net *nn)
> >>  {
> >>       ssize_t rv;
> >
> > This function is called for both nfsd4_lease and nfsd4_grace, so by changing
> > only one of the two types, you generate a compiler warning.
> 
> Ok, so changes to nfsd4_lease and nfsd4_grace should be done in one patch?

Yes, I think so. Again, try it first as a combined patch for the two and then see
if the patch gets simpler or more complicated when split up.

	Arnd


  reply	other threads:[~2015-11-10 10:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 16:07 [PATCH 0/5] fs: nfsd: Remove time_t Ksenija Stanojevic
2015-10-27 16:08 ` [PATCH 1/5] fs: nfsd: Replace time_t with u32 in boot_time Ksenija Stanojevic
2015-11-04  0:04   ` [Y2038] " Arnd Bergmann
2015-11-04  2:17     ` Ksenija Stanojević
2015-11-04 14:44       ` [Outreachy kernel] " Arnd Bergmann
2015-10-27 16:09 ` [PATCH 2/5] fs: nfsd: Replace time_t with u32 in nfsd4_lease Ksenija Stanojevic
2015-11-04  0:14   ` [Y2038] " Arnd Bergmann
2015-11-10  4:37     ` Ksenija Stanojević
2015-11-10 10:01       ` Arnd Bergmann [this message]
2015-10-27 16:10 ` [PATCH 3/5] fs: nfsd: Replace time_t with u32 in nfsd4_grace Ksenija Stanojevic
2015-11-04  0:17   ` [Y2038] " Arnd Bergmann
2015-11-04  2:27     ` Ksenija Stanojević
2015-11-04 13:57       ` Arnd Bergmann
2015-10-27 16:11 ` [PATCH 4/5] fs: nfsd: Replace time_t with u32 dl_time Ksenija Stanojevic
2015-11-04  0:20   ` [Y2038] " Arnd Bergmann
2015-10-27 16:12 ` [PATCH 5/5] fs: nfsd: Replace time_t with u32 oo_time Ksenija Stanojevic
2015-11-04  0:21   ` [Y2038] " Arnd Bergmann

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=3868597.PIV5n69lhm@wuerfel \
    --to=arnd@arndb.de \
    --cc=ksenija.stanojevic@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=y2038@lists.linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.