Re: [PATCH 5/6] xfs: clamp timestamp nanoseconds correctly

"Darrick J. Wong" <[email protected]>
Newsgroups org.kernel.vger.linux-xfs,org.kernel.vger.stable
Message-ID <20260714163431.GD7398@frogsfrogsfrogs>
On Tue, Jul 14, 2026 at 08:15:57AM +0200, Christoph Hellwig wrote:
> On Mon, Jul 13, 2026 at 11:07:15PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <[email protected]>
> > 
> > LOLLM noticed an off-by-one error in the nsec clamping; fix that so that
> > we never have tv_nsec == 1e9.
> 
> Hah..  
> 
> >  {
> > -	ts->tv_nsec = clamp_t(long, ts->tv_nsec, 0, NSEC_PER_SEC);
> > +	ts->tv_nsec = clamp_t(long, ts->tv_nsec, 0, NSEC_PER_SEC - 1);
> >  	*ts = timestamp_truncate(*ts, VFS_I(ip));
> 
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <[email protected]>
> 
> But I'd really expect this would be handled by core timing/timestamp
> helpers.

I'd have thought so too, but timestamp_truncate doesn't clamp tv_nsec to
[0, 1e9) because it assumes that callers (mostly the vfs) already did
that.

--D
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.