All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Dave Chinner <david@fromorbit.com>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>,
	Andreas Dilger <adilger@dilger.ca>,
	"y2038@lists.linaro.org" <y2038@lists.linaro.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC 02/15] vfs: Change all structures to support 64 bit time
Date: Tue, 19 Jan 2016 23:25:02 +0100	[thread overview]
Message-ID: <14988333.dbUrT9DQnz@wuerfel> (raw)
In-Reply-To: <20160119204946.GA20456@dastard>

On Wednesday 20 January 2016 07:49:46 Dave Chinner wrote:
> On Mon, Jan 18, 2016 at 09:27:13PM -0800, Deepa Dinamani wrote:
> > On Mon, Jan 18, 2016 at 5:38 PM, Dave Chinner <david@fromorbit.com> wrote:
> > > On Mon, Jan 18, 2016 at 10:46:07PM +0100, Arnd Bergmann wrote:
> > >> On Tuesday 19 January 2016 08:14:59 Dave Chinner wrote:
> > >> > On Mon, Jan 18, 2016 at 08:53:22PM +0100, Arnd Bergmann wrote:
> > 
> > Let's back out a bit and consider a few changes with the suggested "abstraction":
> > 
> > original code:
> > 
> > extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
> > __le16 __time, __le16 __date, u8 time_cs);
> > 
> > fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
> > 
> > becomes ugly
> > 
> > extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec64 *ts,
> > __le16 __time, __le16 __date, u8 time_cs);
> > 
> > struct timespec64 mtime = vfs_time_to_timespec64(i_mtime, inode);
> > fat_time_fat2unix(sbi, &mtime, de->time, de->date, 0);
> 
> You're doing it wrong. fat_time_fat2unix() still gets passed
> &inode->i_mtime, and the function prototype is changed to a
> timespec64.  *Nothing else needs to change*, because
> fat_time_fat2unix() does it own calculations and then stores the
> time directly into the timespec structure members....

That puts us back at the 'one big patch' problem: We can't change
fat_time_fat2unix() to pass a timespec64 until we also change 
struct inode. The change may be small, but I see roughly 30 file
systems that assign i_?time into or from a local variable or pass it
into by reference into a function that is not from VFS.

see http://pastebin.com/BSnwJa1N for a list (certainly some false
positives and some false negatives in there)

Roughly two thirds of the instances can be handled easily using
vfs_time_to_timespec(), the others could be done much nicer
with additional helpers such as inode_timespec_compare()

> I think you're making a mountain out of a molehill. Most filesystems
> will be unchanged except for s/timespec/timespec64/ as they store
> values directly into timespec members when encoding/decoding. There
> is no need for timestamp conversion in places like this - you're
> simply not looking deep enough and applying the conversion at the
> wrong layer.

Any idea how to improve this somewhat lacking patch?

diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c
index b97f1df910ab..7fbb07dcad36 100644
--- a/fs/xfs/xfs_trans_inode.c
+++ b/fs/xfs/xfs_trans_inode.c
@@ -68,22 +68,24 @@ xfs_trans_ichgtime(
 	int			flags)
 {
 	struct inode		*inode = VFS_I(ip);
-	struct timespec		tv;
+	struct timespec		tv, mtime, ctime;
 
 	ASSERT(tp);
 	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
 
-	tv = current_fs_time(inode->i_sb);
+	tv = vfs_time_to_timespec(current_fs_time(inode->i_sb));
+	mtime = vfs_time_to_timespec(inode->i_mtime);
+	ctime = vfs_time_to_timespec(inode->i_ctime);
 
 	if ((flags & XFS_ICHGTIME_MOD) &&
-	    !timespec_equal(&inode->i_mtime, &tv)) {
-		inode->i_mtime = tv;
+	    !timespec_equal(&mtime, &tv)) {
+		inode->i_mtime = timespec_to_vfs_time(tv);
 		ip->i_d.di_mtime.t_sec = tv.tv_sec;
 		ip->i_d.di_mtime.t_nsec = tv.tv_nsec;
 	}
 	if ((flags & XFS_ICHGTIME_CHG) &&
-	    !timespec_equal(&inode->i_ctime, &tv)) {
-		inode->i_ctime = tv;
+	    !timespec_equal(&ctime, &tv)) {
+		inode->i_ctime = timespec_to_vfs_time(tv);
 		ip->i_d.di_ctime.t_sec = tv.tv_sec;
 		ip->i_d.di_ctime.t_nsec = tv.tv_nsec;
 	}


The way that Deepa suggests I think would turn out as:

diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c
index b97f1df910ab..54fc3c41047a 100644
--- a/fs/xfs/xfs_trans_inode.c
+++ b/fs/xfs/xfs_trans_inode.c
@@ -68,7 +68,7 @@ xfs_trans_ichgtime(
 	int			flags)
 {
 	struct inode		*inode = VFS_I(ip);
-	struct timespec		tv;
+	struct vfs_time		tv;
 
 	ASSERT(tp);
 	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
@@ -76,13 +76,13 @@ xfs_trans_ichgtime(
 	tv = current_fs_time(inode->i_sb);
 
 	if ((flags & XFS_ICHGTIME_MOD) &&
-	    !timespec_equal(&inode->i_mtime, &tv)) {
+	    !vfs_time_equal(&inode->i_mtime, &tv)) {
 		inode->i_mtime = tv;
 		ip->i_d.di_mtime.t_sec = tv.tv_sec;
 		ip->i_d.di_mtime.t_nsec = tv.tv_nsec;
 	}
 	if ((flags & XFS_ICHGTIME_CHG) &&
-	    !timespec_equal(&inode->i_ctime, &tv)) {
+	    !vfs_time_equal(&inode->i_ctime, &tv)) {
 		inode->i_ctime = tv;
 		ip->i_d.di_ctime.t_sec = tv.tv_sec;
 		ip->i_d.di_ctime.t_nsec = tv.tv_nsec;


which I would much prefer here.

	Arnd

  reply	other threads:[~2016-01-19 22:25 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07  5:35 [RFC 00/15] Add 64 bit timestamp support Deepa Dinamani
2016-01-07  5:35 ` [RFC 01/15] fs: add Kconfig entry CONFIG_FS_USES_64BIT_TIME Deepa Dinamani
2016-01-07  5:35 ` [RFC 02/15] vfs: Change all structures to support 64 bit time Deepa Dinamani
2016-01-10 23:03   ` Dave Chinner
2016-01-12  5:42     ` Deepa Dinamani
2016-01-12  8:29       ` Dave Chinner
2016-01-12  9:27         ` [Y2038] " Arnd Bergmann
2016-01-13  6:27           ` Dave Chinner
2016-01-13  9:20             ` Arnd Bergmann
2016-01-13  9:20               ` Arnd Bergmann
2016-01-13 16:33         ` Deepa Dinamani
2016-01-13 21:04           ` Dave Chinner
2016-01-14 16:53             ` [Y2038] " Arnd Bergmann
2016-01-14 18:00               ` Deepa Dinamani
2016-01-14 21:00               ` Dave Chinner
2016-01-14 22:46                 ` Arnd Bergmann
2016-01-14 22:54                   ` Arnd Bergmann
2016-01-15  2:27                     ` Dave Chinner
2016-01-15 17:01                       ` Arnd Bergmann
2016-01-15 22:41                         ` Dave Chinner
2016-01-15  2:49                   ` Dave Chinner
2016-01-15 16:50                     ` Arnd Bergmann
2016-01-16 19:14                       ` Andreas Dilger
2016-01-16 23:36                         ` Arnd Bergmann
2016-01-17  2:30                           ` Andreas Dilger
2016-01-18  6:09                             ` Deepa Dinamani
2016-01-18 10:56                               ` Arnd Bergmann
2016-01-18 17:40                                 ` Deepa Dinamani
2016-01-18 19:53                                   ` Arnd Bergmann
2016-01-18 21:14                                     ` Dave Chinner
2016-01-18 21:46                                       ` Arnd Bergmann
2016-01-19  1:38                                         ` Dave Chinner
2016-01-19  5:27                                           ` Deepa Dinamani
2016-01-19 20:49                                             ` Dave Chinner
2016-01-19 22:25                                               ` Arnd Bergmann [this message]
2016-01-20  5:12                                                 ` Deepa Dinamani
2016-01-20 15:04                                                   ` Deepa Dinamani
2016-01-20 23:06                                                 ` Dave Chinner
2016-01-20 23:17                                                   ` [Y2038] " Arnd Bergmann
2016-01-27  6:26                                                     ` Deepa Dinamani
2016-01-15  5:03                 ` Deepa Dinamani
2016-01-07  5:36 ` [RFC 03/15] kernel: time: Add macros and functions " Deepa Dinamani
2016-01-07  5:36 ` [RFC 04/15] vfs: Add support for vfs code to use " Deepa Dinamani
2016-01-07  5:36 ` [RFC 05/15] fs: cifs: Add support for cifs " Deepa Dinamani
2016-01-07  5:36 ` [RFC 06/15] fs: fat: convert fat to " Deepa Dinamani
2016-01-07  5:36 ` [RFC 07/15] fs: ext4: convert to use " Deepa Dinamani
2016-01-07  5:36 ` [RFC 08/15] fs: Enable " Deepa Dinamani
2016-01-07  5:36 ` [RFC 09/15] fs: cifs: replace inode_timespec with timespec64 Deepa Dinamani
2016-01-07  5:36 ` [RFC 10/15] fs: fat: " Deepa Dinamani
2016-01-07  5:36 ` [RFC 11/15] fs: ext4: " Deepa Dinamani
2016-01-07  5:36 ` [RFC 12/15] vfs: remove inode_timespec and timespec references Deepa Dinamani
2016-01-07  5:36 ` [RFC 13/15] kernel: time: change inode_timespec to timespec64 Deepa Dinamani
2016-01-07  8:50   ` Michael Adam
2016-01-07 10:42     ` Deepa Dinamani
2016-01-07  5:36 ` [RFC 14/15] vfs: Remove inode_timespec aliases Deepa Dinamani
2016-01-07  5:36 ` [RFC 15/15] fs: Drop CONFIG_FS_USES_64BIT_TIME Deepa Dinamani

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=14988333.dbUrT9DQnz@wuerfel \
    --to=arnd@arndb.de \
    --cc=adilger@dilger.ca \
    --cc=david@fromorbit.com \
    --cc=deepa.kernel@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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.