Skip to content

Commit 5e7c31d

Browse files
jaharkestorvalds
authored andcommitted
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>
1 parent 6ced9aa commit 5e7c31d

3 files changed

Lines changed: 19 additions & 45 deletions

File tree

‎Documentation/filesystems/coda.txt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ kernel support.
481481

482482

483483

484-
struct vtimespec {
485-
long tv_sec; /* seconds */
484+
struct coda_timespec {
485+
int64_t tv_sec; /* seconds */
486486
long tv_nsec; /* nanoseconds */
487487
};
488488

@@ -496,9 +496,9 @@ kernel support.
496496
long va_fileid; /* file id */
497497
u_quad_t va_size; /* file size in bytes */
498498
long va_blocksize; /* blocksize preferred for i/o */
499-
struct vtimespec va_atime; /* time of last access */
500-
struct vtimespec va_mtime; /* time of last modification */
501-
struct vtimespec va_ctime; /* time file changed */
499+
struct coda_timespec va_atime; /* time of last access */
500+
struct coda_timespec va_mtime; /* time of last modification */
501+
struct coda_timespec va_ctime; /* time file changed */
502502
u_long va_gen; /* generation number of file */
503503
u_long va_flags; /* flags defined for file */
504504
dev_t va_rdev; /* device special file represents */

‎fs/coda/coda_linux.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,8 @@ unsigned short coda_flags_to_cflags(unsigned short flags)
6666
return coda_flags;
6767
}
6868

69-
static struct timespec64 coda_to_timespec64(struct vtimespec ts)
69+
static struct timespec64 coda_to_timespec64(struct coda_timespec ts)
7070
{
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-
*/
7671
struct timespec64 ts64 = {
7772
.tv_sec = ts.tv_sec,
7873
.tv_nsec = ts.tv_nsec,
@@ -81,12 +76,10 @@ static struct timespec64 coda_to_timespec64(struct vtimespec ts)
8176
return ts64;
8277
}
8378

84-
static struct vtimespec timespec64_to_coda(struct timespec64 ts64)
79+
static struct coda_timespec timespec64_to_coda(struct timespec64 ts64)
8580
{
86-
/* clamp the timestamps to the maximum range rather than wrapping */
87-
struct vtimespec ts = {
88-
.tv_sec = lower_32_bits(clamp_t(time64_t, ts64.tv_sec,
89-
LONG_MIN, LONG_MAX)),
81+
struct coda_timespec ts = {
82+
.tv_sec = ts64.tv_sec,
9083
.tv_nsec = ts64.tv_nsec,
9184
};
9285

@@ -156,11 +149,11 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr)
156149
vattr->va_uid = (vuid_t) -1;
157150
vattr->va_gid = (vgid_t) -1;
158151
vattr->va_size = (off_t) -1;
159-
vattr->va_atime.tv_sec = (long) -1;
152+
vattr->va_atime.tv_sec = (int64_t) -1;
160153
vattr->va_atime.tv_nsec = (long) -1;
161-
vattr->va_mtime.tv_sec = (long) -1;
154+
vattr->va_mtime.tv_sec = (int64_t) -1;
162155
vattr->va_mtime.tv_nsec = (long) -1;
163-
vattr->va_ctime.tv_sec = (long) -1;
156+
vattr->va_ctime.tv_sec = (int64_t) -1;
164157
vattr->va_ctime.tv_nsec = (long) -1;
165158
vattr->va_type = C_VNON;
166159
vattr->va_fileid = -1;

‎include/uapi/linux/coda.h‎

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ typedef unsigned long long u_quad_t;
8686

8787
#define inline
8888

89-
struct timespec {
90-
long ts_sec;
91-
long ts_nsec;
92-
};
9389
#else /* DJGPP but not KERNEL */
9490
#include <sys/time.h>
9591
typedef unsigned long long u_quad_t;
@@ -110,13 +106,6 @@ typedef unsigned long long u_quad_t;
110106
#define cdev_t dev_t
111107
#endif
112108

113-
#ifdef __CYGWIN32__
114-
struct timespec {
115-
time_t tv_sec; /* seconds */
116-
long tv_nsec; /* nanoseconds */
117-
};
118-
#endif
119-
120109
#ifndef __BIT_TYPES_DEFINED__
121110
#define __BIT_TYPES_DEFINED__
122111
typedef signed char int8_t;
@@ -211,19 +200,10 @@ struct CodaFid {
211200
*/
212201
enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
213202

214-
#ifdef __linux__
215-
/*
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-
*/
220-
struct vtimespec {
221-
long tv_sec; /* seconds */
203+
struct coda_timespec {
204+
int64_t tv_sec; /* seconds */
222205
long tv_nsec; /* nanoseconds */
223206
};
224-
#else
225-
#define vtimespec timespec
226-
#endif
227207

228208
struct coda_vattr {
229209
long va_type; /* vnode type (for create) */
@@ -234,9 +214,9 @@ struct coda_vattr {
234214
long va_fileid; /* file id */
235215
u_quad_t va_size; /* file size in bytes */
236216
long va_blocksize; /* blocksize preferred for i/o */
237-
struct vtimespec va_atime; /* time of last access */
238-
struct vtimespec va_mtime; /* time of last modification */
239-
struct vtimespec va_ctime; /* time file changed */
217+
struct coda_timespec va_atime; /* time of last access */
218+
struct coda_timespec va_mtime; /* time of last modification */
219+
struct coda_timespec va_ctime; /* time file changed */
240220
u_long va_gen; /* generation number of file */
241221
u_long va_flags; /* flags defined for file */
242222
cdev_t va_rdev; /* device special file represents */
@@ -301,7 +281,8 @@ struct coda_statfs {
301281

302282
#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
303283

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 */
305286

306287
/*
307288
* Venus <-> Coda RPC arguments

0 commit comments

Comments
 (0)