aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Harkes <jaharkes@cs.cmu.edu>2019-07-16 19:28:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-16 22:23:23 -0400
commit5e7c31dfe74703f428220384b2863525957cc160 (patch)
tree83b0eef7ab15394a95a96f90d66e1a002e9539df
parent6ced9aa7b56baeb241a715df4539e60d5e3118e2 (diff)
coda: change Coda's user api to use 64-bit time_t in timespec
Move the 32-bit time_t problems to userspace. Link: http://lkml.kernel.org/r/8d089068823bfb292a4020f773922fbd82ffad39.1558117389.git.jaharkes@cs.cmu.edu Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Colin Ian King <colin.king@canonical.com> Cc: Dan Carpenter <dan.carpenter@oracle.com> Cc: David Howells <dhowells@redhat.com> Cc: Fabian Frederick <fabf@skynet.be> Cc: Mikko Rapeli <mikko.rapeli@iki.fi> Cc: Sam Protsenko <semen.protsenko@linaro.org> Cc: Yann Droneaud <ydroneaud@opteya.com> Cc: Zhouyang Jia <jiazhouyang09@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/filesystems/coda.txt10
-rw-r--r--fs/coda/coda_linux.c21
-rw-r--r--include/uapi/linux/coda.h33
3 files changed, 19 insertions, 45 deletions
diff --git a/Documentation/filesystems/coda.txt b/Documentation/filesystems/coda.txt
index ea5969068895..545262c167c3 100644
--- a/Documentation/filesystems/coda.txt
+++ b/Documentation/filesystems/coda.txt
@@ -481,8 +481,8 @@ kernel support.
481 481
482 482
483 483
484 struct vtimespec { 484 struct coda_timespec {
485 long tv_sec; /* seconds */ 485 int64_t tv_sec; /* seconds */
486 long tv_nsec; /* nanoseconds */ 486 long tv_nsec; /* nanoseconds */
487 }; 487 };
488 488
@@ -496,9 +496,9 @@ kernel support.
496 long va_fileid; /* file id */ 496 long va_fileid; /* file id */
497 u_quad_t va_size; /* file size in bytes */ 497 u_quad_t va_size; /* file size in bytes */
498 long va_blocksize; /* blocksize preferred for i/o */ 498 long va_blocksize; /* blocksize preferred for i/o */
499 struct vtimespec va_atime; /* time of last access */ 499 struct coda_timespec va_atime; /* time of last access */
500 struct vtimespec va_mtime; /* time of last modification */ 500 struct coda_timespec va_mtime; /* time of last modification */
501 struct vtimespec va_ctime; /* time file changed */ 501 struct coda_timespec va_ctime; /* time file changed */
502 u_long va_gen; /* generation number of file */ 502 u_long va_gen; /* generation number of file */
503 u_long va_flags; /* flags defined for file */ 503 u_long va_flags; /* flags defined for file */
504 dev_t va_rdev; /* device special file represents */ 504 dev_t va_rdev; /* device special file represents */
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index 8addcd166908..e4b5f02f0dd4 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -66,13 +66,8 @@ unsigned short coda_flags_to_cflags(unsigned short flags)
66 return coda_flags; 66 return coda_flags;
67} 67}
68 68
69static struct timespec64 coda_to_timespec64(struct vtimespec ts) 69static struct timespec64 coda_to_timespec64(struct coda_timespec ts)
70{ 70{
71 /*
72 * We interpret incoming timestamps as 'signed' to match traditional
73 * usage and support pre-1970 timestamps, but this breaks in y2038
74 * on 32-bit machines.
75 */
76 struct timespec64 ts64 = { 71 struct timespec64 ts64 = {
77 .tv_sec = ts.tv_sec, 72 .tv_sec = ts.tv_sec,
78 .tv_nsec = ts.tv_nsec, 73 .tv_nsec = ts.tv_nsec,
@@ -81,12 +76,10 @@ static struct timespec64 coda_to_timespec64(struct vtimespec ts)
81 return ts64; 76 return ts64;
82} 77}
83 78
84static struct vtimespec timespec64_to_coda(struct timespec64 ts64) 79static struct coda_timespec timespec64_to_coda(struct timespec64 ts64)
85{ 80{
86 /* clamp the timestamps to the maximum range rather than wrapping */ 81 struct coda_timespec ts = {
87 struct vtimespec ts = { 82 .tv_sec = ts64.tv_sec,
88 .tv_sec = lower_32_bits(clamp_t(time64_t, ts64.tv_sec,
89 LONG_MIN, LONG_MAX)),
90 .tv_nsec = ts64.tv_nsec, 83 .tv_nsec = ts64.tv_nsec,
91 }; 84 };
92 85
@@ -156,11 +149,11 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr)
156 vattr->va_uid = (vuid_t) -1; 149 vattr->va_uid = (vuid_t) -1;
157 vattr->va_gid = (vgid_t) -1; 150 vattr->va_gid = (vgid_t) -1;
158 vattr->va_size = (off_t) -1; 151 vattr->va_size = (off_t) -1;
159 vattr->va_atime.tv_sec = (long) -1; 152 vattr->va_atime.tv_sec = (int64_t) -1;
160 vattr->va_atime.tv_nsec = (long) -1; 153 vattr->va_atime.tv_nsec = (long) -1;
161 vattr->va_mtime.tv_sec = (long) -1; 154 vattr->va_mtime.tv_sec = (int64_t) -1;
162 vattr->va_mtime.tv_nsec = (long) -1; 155 vattr->va_mtime.tv_nsec = (long) -1;
163 vattr->va_ctime.tv_sec = (long) -1; 156 vattr->va_ctime.tv_sec = (int64_t) -1;
164 vattr->va_ctime.tv_nsec = (long) -1; 157 vattr->va_ctime.tv_nsec = (long) -1;
165 vattr->va_type = C_VNON; 158 vattr->va_type = C_VNON;
166 vattr->va_fileid = -1; 159 vattr->va_fileid = -1;
diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index fc5f7874208a..5dba636b6e11 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -86,10 +86,6 @@ typedef unsigned long long u_quad_t;
86 86
87#define inline 87#define inline
88 88
89struct timespec {
90 long ts_sec;
91 long ts_nsec;
92};
93#else /* DJGPP but not KERNEL */ 89#else /* DJGPP but not KERNEL */
94#include <sys/time.h> 90#include <sys/time.h>
95typedef unsigned long long u_quad_t; 91typedef unsigned long long u_quad_t;
@@ -110,13 +106,6 @@ typedef unsigned long long u_quad_t;
110#define cdev_t dev_t 106#define cdev_t dev_t
111#endif 107#endif
112 108
113#ifdef __CYGWIN32__
114struct timespec {
115 time_t tv_sec; /* seconds */
116 long tv_nsec; /* nanoseconds */
117};
118#endif
119
120#ifndef __BIT_TYPES_DEFINED__ 109#ifndef __BIT_TYPES_DEFINED__
121#define __BIT_TYPES_DEFINED__ 110#define __BIT_TYPES_DEFINED__
122typedef signed char int8_t; 111typedef signed char int8_t;
@@ -211,19 +200,10 @@ struct CodaFid {
211 */ 200 */
212enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD }; 201enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
213 202
214#ifdef __linux__ 203struct coda_timespec {
215/* 204 int64_t tv_sec; /* seconds */
216 * This matches the traditional Linux 'timespec' structure binary layout,
217 * before using 64-bit time_t everywhere. Overflows in y2038 on 32-bit
218 * architectures.
219 */
220struct vtimespec {
221 long tv_sec; /* seconds */
222 long tv_nsec; /* nanoseconds */ 205 long tv_nsec; /* nanoseconds */
223}; 206};
224#else
225#define vtimespec timespec
226#endif
227 207
228struct coda_vattr { 208struct coda_vattr {
229 long va_type; /* vnode type (for create) */ 209 long va_type; /* vnode type (for create) */
@@ -234,9 +214,9 @@ struct coda_vattr {
234 long va_fileid; /* file id */ 214 long va_fileid; /* file id */
235 u_quad_t va_size; /* file size in bytes */ 215 u_quad_t va_size; /* file size in bytes */
236 long va_blocksize; /* blocksize preferred for i/o */ 216 long va_blocksize; /* blocksize preferred for i/o */
237 struct vtimespec va_atime; /* time of last access */ 217 struct coda_timespec va_atime; /* time of last access */
238 struct vtimespec va_mtime; /* time of last modification */ 218 struct coda_timespec va_mtime; /* time of last modification */
239 struct vtimespec va_ctime; /* time file changed */ 219 struct coda_timespec va_ctime; /* time file changed */
240 u_long va_gen; /* generation number of file */ 220 u_long va_gen; /* generation number of file */
241 u_long va_flags; /* flags defined for file */ 221 u_long va_flags; /* flags defined for file */
242 cdev_t va_rdev; /* device special file represents */ 222 cdev_t va_rdev; /* device special file represents */
@@ -301,7 +281,8 @@ struct coda_statfs {
301 281
302#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t) 282#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
303 283
304#define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */ 284// CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
285#define CODA_KERNEL_VERSION 4 /* 64-bit timespec */
305 286
306/* 287/*
307 * Venus <-> Coda RPC arguments 288 * Venus <-> Coda RPC arguments