diff mbox

[GIT,PULL] y2038 changes for vfs

Message ID 5722005.e8ezZRvZ1E@wuerfel
State New
Headers show

Commit Message

Arnd Bergmann May 24, 2016, 8:11 p.m. UTC
The following changes since commit bf16200689118d19de1b8d2a3c314fc21f5dc7bb:

  Linux 4.6-rc3 (2016-04-10 17:58:30 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git tags/y2038-4.7

for you to fetch changes up to 4b277763c5b3ce6d60168797e6f38260416d9b13:

  vfs: Add support to document max and min inode times (2016-04-26 18:12:30 +0200)

----------------------------------------------------------------
y2038 changes for vfs

This is a preparation series for changing the VFS infrastructure to use
time64_t in inode timestamps, introducing a couple of simple conversion
helper functions that can be used to make the individual file systems
independent of the type of inode->i_{a,c,m}time and
iattr->ia_{a,c,m}time, following the plan described at
http://kernelnewbies.org/y2038/vfs.

The patches were done by Deepa Dinamani during her Outreachy internship
along with the following set of more than 100 patches that depend on
them but that can get merged through the individual file system
maintainer trees.

Thomas Gleixner reviewed the patches and the approach before, but after
http://www.spinics.net/lists/y2038/msg01514.html, both he and Al Viro
were busy in other areas of the kernel and neither of them picked them
up. I'm sending the series for inclusion directly so we can make
progress on the follow-up series and hopefully convert struct inode
to timespec64 in 4.8 or 4.9.

One small cleanup patch from Tina Ruchandani is included in the branch
as well, this is also related to the y2038 effort and is the last one
of a backlog of older patches that I picked up last year and otherwise
got merged through maintainer trees.

----------------------------------------------------------------
Deepa Dinamani (3):
      fs: Add current_fs_time_sec() function
      vfs: Add vfs_time accessors
      vfs: Add support to document max and min inode times

Tina Ruchandani (1):
      AFS: Correctly use 64-bit time for UUID

 fs/afs/main.c      |  6 ++----
 include/linux/fs.h | 29 ++++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/fs/afs/main.c b/fs/afs/main.c
index 35de0c04729f..129ff432391c 100644
--- a/fs/afs/main.c
+++ b/fs/afs/main.c
@@ -14,6 +14,7 @@ 
 #include <linux/init.h>
 #include <linux/completion.h>
 #include <linux/sched.h>
+#include <linux/ktime.h>
 #include "internal.h"
 
 MODULE_DESCRIPTION("AFS Client File System");
@@ -37,7 +38,6 @@  struct workqueue_struct *afs_wq;
  */
 static int __init afs_get_client_UUID(void)
 {
-	struct timespec ts;
 	u64 uuidtime;
 	u16 clockseq;
 	int ret;
@@ -48,9 +48,7 @@  static int __init afs_get_client_UUID(void)
 	if (ret < 0)
 		return ret;
 
-	getnstimeofday(&ts);
-	uuidtime = (u64) ts.tv_sec * 1000 * 1000 * 10;
-	uuidtime += ts.tv_nsec / 100;
+	uuidtime = ktime_divns(ktime_get_real(), 100);
 	uuidtime += AFS_UUID_TO_UNIX_TIME;
 	afs_uuid.time_low = uuidtime;
 	afs_uuid.time_mid = uuidtime >> 32;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 70e61b58baaf..d9573060591e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1362,7 +1362,14 @@  struct super_block {
 
 	/* Granularity of c/m/atime in ns.
 	   Cannot be worse than a second */
-	u32		   s_time_gran;
+	u32		s_time_gran;
+
+	/*
+	 * Max and min values for timestamps
+	 * according to the range supported by filesystems.
+	 */
+	time64_t	s_time_min;
+	time64_t	s_time_max;
 
 	/*
 	 * The next field is for VFS *only*. No filesystems have any business
@@ -1423,6 +1430,26 @@  struct super_block {
 
 extern struct timespec current_fs_time(struct super_block *sb);
 
+static inline struct timespec current_fs_time_sec(struct super_block *sb)
+{
+	return (struct timespec) { get_seconds(), 0 };
+}
+
+/* Place holder defines to ensure safe transition to timespec64
+ * in the vfs layer.
+ * These can be deleted after all filesystems and vfs are switched
+ * over to using 64 bit time.
+ */
+static inline struct timespec vfs_time_to_timespec(struct timespec inode_ts)
+{
+	return inode_ts;
+}
+
+static inline struct timespec timespec_to_vfs_time(struct timespec ts)
+{
+	return ts;
+}
+
 /*
  * Snapshotting support.
  */