linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] [v2, RESEND] afs: stop using time_t for internal times
@ 2018-07-13 14:25 Arnd Bergmann
  2018-07-13 14:25 ` [PATCH 2/2] [v2, RESEND] afs: avoid deprecated get_seconds() Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-07-13 14:25 UTC (permalink / raw)
  To: David Howells; +Cc: Arnd Bergmann, linux-afs, linux-kernel

afs uses 32-bit timestamps everywhere, but mixes signed and unsigned
usage, which is a bit inconsistent. In particular on 32-bit machines,
it currently uses unsigned timestamps (ranging from 1970 to 2106) for
locally modified files, but signed timestamps (rand 1902 to 2038) when
reading from a remote end. On 64-bit machines, we always interpret
timestamps as unsigned here.

This replaces the deprecated time_t with a new explicitly unsigned
afs_time32_t to get a consistent interpretation of inode times
according the the wire protocol definition.

This avoids the y2038 overflow on 32-bit machines, extending the range
to the end of the afs_time32_t in year 2106. On 64-bit machines, using
the shorter type saves a few bytes for each afs_file_status and
afs_volsync saves a few bytes over time_t or time64_t.

Note that mtime_server and struct afs_volsync are not currently
used in any meaningful way and could be removed completely.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Originally submitted this on June 20, but got no reply.
Resending this in case it got lost somewhere on the way.
David, can you pick up both patches?
---
 fs/afs/afs.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/afs/afs.h b/fs/afs/afs.h
index b4ff1f7ae4ab..a17f4ce06323 100644
--- a/fs/afs/afs.h
+++ b/fs/afs/afs.h
@@ -26,6 +26,7 @@
 typedef unsigned			afs_volid_t;
 typedef unsigned			afs_vnodeid_t;
 typedef unsigned long long		afs_dataversion_t;
+typedef unsigned			afs_time32_t;
 
 typedef enum {
 	AFSVL_RWVOL,			/* read/write volume */
@@ -129,8 +130,8 @@ typedef u32 afs_access_t;
 struct afs_file_status {
 	u64			size;		/* file size */
 	afs_dataversion_t	data_version;	/* current data version */
-	time_t			mtime_client;	/* last time client changed data */
-	time_t			mtime_server;	/* last time server changed data */
+	afs_time32_t		mtime_client;	/* last time client changed data */
+	afs_time32_t		mtime_server;	/* last time server changed data */
 	unsigned		abort_code;	/* Abort if bulk-fetching this failed */
 
 	afs_file_type_t		type;		/* file type */
@@ -158,7 +159,7 @@ struct afs_file_status {
  * AFS volume synchronisation information
  */
 struct afs_volsync {
-	time_t			creation;	/* volume creation time */
+	afs_time32_t		creation;	/* volume creation time */
 };
 
 /*
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] [v2, RESEND] afs: avoid deprecated get_seconds()
  2018-07-13 14:25 [PATCH 1/2] [v2, RESEND] afs: stop using time_t for internal times Arnd Bergmann
@ 2018-07-13 14:25 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2018-07-13 14:25 UTC (permalink / raw)
  To: David Howells; +Cc: Arnd Bergmann, Anna Schumaker, linux-afs, linux-kernel

get_seconds() has a limited range on 32-bit architectures and is
deprecated because of that. While AFS uses the same limits for
its inode timestamps on the wire protocol, let's just use the
simpler current_time() as we do for other file systems.

This will still zero out the 'tv_nsec' field of the timestamps
internally.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Originally submitted this on June 20, but got no reply.
Resending this in case it got lost somewhere on the way.
David, can you pick up both patches?
---
 fs/afs/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 479b7fdda124..0507e52e3330 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -213,9 +213,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
 	set_nlink(inode, 2);
 	inode->i_uid		= GLOBAL_ROOT_UID;
 	inode->i_gid		= GLOBAL_ROOT_GID;
-	inode->i_ctime.tv_sec	= get_seconds();
-	inode->i_ctime.tv_nsec	= 0;
-	inode->i_atime		= inode->i_mtime = inode->i_ctime;
+	inode->i_ctime = inode->i_atime = inode->i_mtime = current_time(inode);
 	inode->i_blocks		= 0;
 	inode_set_iversion_raw(inode, 0);
 	inode->i_generation	= 0;
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-13 14:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-13 14:25 [PATCH 1/2] [v2, RESEND] afs: stop using time_t for internal times Arnd Bergmann
2018-07-13 14:25 ` [PATCH 2/2] [v2, RESEND] afs: avoid deprecated get_seconds() Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).