1 From 0dd73648532e8654e07c28bba6c80bfb779a4938 Mon Sep 17 00:00:00 2001
2 From: Brian Behlendorf <behlendorf1@llnl.gov>
3 Date: Thu, 6 Feb 2020 10:30:41 -0800
4 Subject: [PATCH] Linux 5.6 compat: struct proc_ops
6 The proc_ops structure was introduced to replace the use of of the
7 file_operations structure when registering proc handlers. This
8 change creates a new kstat_proc_op_t typedef for compatibility
9 which can be used to pass around the correct structure.
11 This change additionally adds the 'const' keyword to all of the
12 existing proc operations structures.
14 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
15 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
18 config/kernel-proc-operations.m4 | 41 +++++++++++++++++++++++++++
19 config/kernel.m4 | 2 ++
20 include/spl/sys/kstat.h | 8 +++++-
21 module/spl/spl-kstat.c | 14 +++++++--
22 module/spl/spl-proc.c | 33 +++++++++++++++++----
23 module/spl/spl-procfs-list.c | 11 +++++--
24 6 files changed, 97 insertions(+), 12 deletions(-)
25 create mode 100644 config/kernel-proc-operations.m4
27 diff --git a/config/kernel-proc-operations.m4 b/config/kernel-proc-operations.m4
29 index 00000000000..df216222ecc
31 +++ b/config/kernel-proc-operations.m4
35 +dnl # The proc_ops structure was introduced to replace the use of
36 +dnl # of the file_operations structure when registering proc handlers.
38 +AC_DEFUN([ZFS_AC_KERNEL_SRC_PROC_OPERATIONS], [
39 + ZFS_LINUX_TEST_SRC([proc_ops_struct], [
40 + #include <linux/proc_fs.h>
42 + int test_open(struct inode *ip, struct file *fp) { return 0; }
43 + ssize_t test_read(struct file *fp, char __user *ptr,
44 + size_t size, loff_t *offp) { return 0; }
45 + ssize_t test_write(struct file *fp, const char __user *ptr,
46 + size_t size, loff_t *offp) { return 0; }
47 + loff_t test_lseek(struct file *fp, loff_t off, int flag)
49 + int test_release(struct inode *ip, struct file *fp)
52 + const struct proc_ops test_ops __attribute__ ((unused)) = {
53 + .proc_open = test_open,
54 + .proc_read = test_read,
55 + .proc_write = test_write,
56 + .proc_lseek = test_lseek,
57 + .proc_release = test_release,
60 + struct proc_dir_entry *entry __attribute__ ((unused)) =
61 + proc_create_data("test", 0444, NULL, &test_ops, NULL);
65 +AC_DEFUN([ZFS_AC_KERNEL_PROC_OPERATIONS], [
66 + AC_MSG_CHECKING([whether proc_ops structure exists])
67 + ZFS_LINUX_TEST_RESULT([proc_ops_struct], [
69 + AC_DEFINE(HAVE_PROC_OPS_STRUCT, 1, [proc_ops structure exists])
74 diff --git a/config/kernel.m4 b/config/kernel.m4
75 index ec8f6a5c107..23643e0c3de 100644
76 --- a/config/kernel.m4
77 +++ b/config/kernel.m4
78 @@ -52,6 +52,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
79 ZFS_AC_KERNEL_SRC_CURRENT_BIO_TAIL
80 ZFS_AC_KERNEL_SRC_SUPER_USER_NS
81 ZFS_AC_KERNEL_SRC_SUBMIT_BIO
82 + ZFS_AC_KERNEL_SRC_PROC_OPERATIONS
83 ZFS_AC_KERNEL_SRC_BLOCK_DEVICE_OPERATIONS
84 ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH
85 ZFS_AC_KERNEL_SRC_BLKDEV_REREAD_PART
86 @@ -145,6 +146,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
87 ZFS_AC_KERNEL_CURRENT_BIO_TAIL
88 ZFS_AC_KERNEL_SUPER_USER_NS
89 ZFS_AC_KERNEL_SUBMIT_BIO
90 + ZFS_AC_KERNEL_PROC_OPERATIONS
91 ZFS_AC_KERNEL_BLOCK_DEVICE_OPERATIONS
92 ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH
93 ZFS_AC_KERNEL_BLKDEV_REREAD_PART
94 diff --git a/include/spl/sys/kstat.h b/include/spl/sys/kstat.h
95 index 3ce47424887..c93c53171d8 100644
96 --- a/include/spl/sys/kstat.h
97 +++ b/include/spl/sys/kstat.h
98 @@ -152,6 +152,12 @@ typedef struct kstat_named_s {
99 #define KSTAT_NAMED_STR_PTR(knptr) ((knptr)->value.string.addr.ptr)
100 #define KSTAT_NAMED_STR_BUFLEN(knptr) ((knptr)->value.string.len)
102 +#ifdef HAVE_PROC_OPS_STRUCT
103 +typedef struct proc_ops kstat_proc_op_t;
105 +typedef struct file_operations kstat_proc_op_t;
108 typedef struct kstat_intr {
109 uint_t intrs[KSTAT_NUM_INTRS];
111 @@ -197,7 +203,7 @@ extern void kstat_proc_entry_init(kstat_proc_entry_t *kpep,
112 const char *module, const char *name);
113 extern void kstat_proc_entry_delete(kstat_proc_entry_t *kpep);
114 extern void kstat_proc_entry_install(kstat_proc_entry_t *kpep, mode_t mode,
115 - const struct file_operations *file_ops, void *data);
116 + const kstat_proc_op_t *file_ops, void *data);
118 extern void __kstat_install(kstat_t *ksp);
119 extern void __kstat_delete(kstat_t *ksp);
120 diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c
121 index 75565d082ab..b971b4498cc 100644
122 --- a/module/spl/spl-kstat.c
123 +++ b/module/spl/spl-kstat.c
124 @@ -507,12 +507,20 @@ proc_kstat_write(struct file *filp, const char __user *buf, size_t len,
128 -static struct file_operations proc_kstat_operations = {
129 +static const kstat_proc_op_t proc_kstat_operations = {
130 +#ifdef HAVE_PROC_OPS_STRUCT
131 + .proc_open = proc_kstat_open,
132 + .proc_write = proc_kstat_write,
133 + .proc_read = seq_read,
134 + .proc_lseek = seq_lseek,
135 + .proc_release = seq_release,
137 .open = proc_kstat_open,
138 .write = proc_kstat_write,
141 .release = seq_release,
146 @@ -656,7 +664,7 @@ kstat_detect_collision(kstat_proc_entry_t *kpep)
149 kstat_proc_entry_install(kstat_proc_entry_t *kpep, mode_t mode,
150 - const struct file_operations *file_ops, void *data)
151 + const kstat_proc_op_t *proc_ops, void *data)
153 kstat_module_t *module;
154 kstat_proc_entry_t *tmp = NULL;
155 @@ -690,7 +698,7 @@ kstat_proc_entry_install(kstat_proc_entry_t *kpep, mode_t mode,
157 kpep->kpe_owner = module;
158 kpep->kpe_proc = proc_create_data(kpep->kpe_name, mode,
159 - module->ksm_proc, file_ops, data);
160 + module->ksm_proc, proc_ops, data);
161 if (kpep->kpe_proc == NULL) {
162 list_del_init(&kpep->kpe_list);
163 if (list_empty(&module->ksm_kstat_list))
164 diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c
165 index 45bc7f96360..f68f9b5220d 100644
166 --- a/module/spl/spl-proc.c
167 +++ b/module/spl/spl-proc.c
168 @@ -532,11 +532,18 @@ proc_slab_open(struct inode *inode, struct file *filp)
169 return (seq_open(filp, &slab_seq_ops));
172 -static struct file_operations proc_slab_operations = {
173 - .open = proc_slab_open,
175 - .llseek = seq_lseek,
176 +static const kstat_proc_op_t proc_slab_operations = {
177 +#ifdef HAVE_PROC_OPS_STRUCT
178 + .proc_open = proc_slab_open,
179 + .proc_read = seq_read,
180 + .proc_lseek = seq_lseek,
181 + .proc_release = seq_release,
183 + .open = proc_slab_open,
185 + .llseek = seq_lseek,
186 .release = seq_release,
191 @@ -571,18 +578,32 @@ proc_taskq_open(struct inode *inode, struct file *filp)
192 return (seq_open(filp, &taskq_seq_ops));
195 -static struct file_operations proc_taskq_all_operations = {
196 +static const kstat_proc_op_t proc_taskq_all_operations = {
197 +#ifdef HAVE_PROC_OPS_STRUCT
198 + .proc_open = proc_taskq_all_open,
199 + .proc_read = seq_read,
200 + .proc_lseek = seq_lseek,
201 + .proc_release = seq_release,
203 .open = proc_taskq_all_open,
206 .release = seq_release,
210 -static struct file_operations proc_taskq_operations = {
211 +static const kstat_proc_op_t proc_taskq_operations = {
212 +#ifdef HAVE_PROC_OPS_STRUCT
213 + .proc_open = proc_taskq_open,
214 + .proc_read = seq_read,
215 + .proc_lseek = seq_lseek,
216 + .proc_release = seq_release,
218 .open = proc_taskq_open,
221 .release = seq_release,
225 static struct ctl_table spl_kmem_table[] = {
226 diff --git a/module/spl/spl-procfs-list.c b/module/spl/spl-procfs-list.c
227 index f6a00da5c91..189d6a7c608 100644
228 --- a/module/spl/spl-procfs-list.c
229 +++ b/module/spl/spl-procfs-list.c
230 @@ -185,13 +185,20 @@ procfs_list_write(struct file *filp, const char __user *buf, size_t len,
234 -static struct file_operations procfs_list_operations = {
235 - .owner = THIS_MODULE,
236 +static const kstat_proc_op_t procfs_list_operations = {
237 +#ifdef HAVE_PROC_OPS_STRUCT
238 + .proc_open = procfs_list_open,
239 + .proc_write = procfs_list_write,
240 + .proc_read = seq_read,
241 + .proc_lseek = seq_lseek,
242 + .proc_release = seq_release_private,
244 .open = procfs_list_open,
245 .write = procfs_list_write,
248 .release = seq_release_private,
253 From 795699a6cc28b8f1059397e03d1a86d576bfc7dc Mon Sep 17 00:00:00 2001
254 From: Brian Behlendorf <behlendorf1@llnl.gov>
255 Date: Thu, 6 Feb 2020 12:37:25 -0800
256 Subject: [PATCH] Linux 5.6 compat: timestamp_truncate()
258 The timestamp_truncate() function was added, it replaces the existing
259 timespec64_trunc() function. This change renames our wrapper function
260 to be consistent with the upstream name and updates the compatibility
261 code for older kernels accordingly.
263 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
264 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
268 config/kernel-inode-times.m4 | 31 +++++++++++++++++++++++++++----
269 include/sys/zpl.h | 13 +++++++------
270 module/zfs/zfs_vnops.c | 8 ++++----
271 module/zfs/zpl_inode.c | 6 ++----
272 4 files changed, 40 insertions(+), 18 deletions(-)
274 diff --git a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4
275 index 57e7f31fdcb..8a79c299e1a 100644
276 --- a/config/kernel-inode-times.m4
277 +++ b/config/kernel-inode-times.m4
280 -dnl # 4.18 API change
281 -dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
283 AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
286 + dnl # 5.6 API change
287 + dnl # timespec64_trunc() replaced by timestamp_truncate() interface.
289 + ZFS_LINUX_TEST_SRC([timestamp_truncate], [
290 + #include <linux/fs.h>
292 + struct timespec64 ts;
295 + ts = timestamp_truncate(ts, &ip);
299 + dnl # 4.18 API change
300 + dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
302 ZFS_LINUX_TEST_SRC([inode_times], [
303 #include <linux/fs.h>
305 @@ -15,6 +29,15 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
308 AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
309 + AC_MSG_CHECKING([whether timestamp_truncate() exists])
310 + ZFS_LINUX_TEST_RESULT([timestamp_truncate], [
312 + AC_DEFINE(HAVE_INODE_TIMESTAMP_TRUNCATE, 1,
313 + [timestamp_truncate() exists])
318 AC_MSG_CHECKING([whether inode->i_*time's are timespec64])
319 ZFS_LINUX_TEST_RESULT([inode_times], [
321 diff --git a/include/sys/zpl.h b/include/sys/zpl.h
322 index 20a3dc67498..ef5a0b842d0 100644
323 --- a/include/sys/zpl.h
324 +++ b/include/sys/zpl.h
325 @@ -170,13 +170,14 @@ zpl_dir_emit_dots(struct file *file, zpl_dir_context_t *ctx)
327 #endif /* HAVE_VFS_ITERATE */
330 - * Linux 4.18, inode times converted from timespec to timespec64.
332 -#if defined(HAVE_INODE_TIMESPEC64_TIMES)
333 -#define zpl_inode_timespec_trunc(ts, gran) timespec64_trunc(ts, gran)
334 +#if defined(HAVE_INODE_TIMESTAMP_TRUNCATE)
335 +#define zpl_inode_timestamp_truncate(ts, ip) timestamp_truncate(ts, ip)
336 +#elif defined(HAVE_INODE_TIMESPEC64_TIMES)
337 +#define zpl_inode_timestamp_truncate(ts, ip) \
338 + timespec64_trunc(ts, (ip)->i_sb->s_time_gran)
340 -#define zpl_inode_timespec_trunc(ts, gran) timespec_trunc(ts, gran)
341 +#define zpl_inode_timestamp_truncate(ts, ip) \
342 + timespec_trunc(ts, (ip)->i_sb->s_time_gran)
345 #endif /* _SYS_ZPL_H */
346 diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
347 index ec63dbdeb6c..406cd7ef229 100644
348 --- a/module/zfs/zfs_vnops.c
349 +++ b/module/zfs/zfs_vnops.c
350 @@ -3444,8 +3444,8 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr)
352 if (mask & (ATTR_MTIME | ATTR_SIZE)) {
353 ZFS_TIME_ENCODE(&vap->va_mtime, mtime);
354 - ZTOI(zp)->i_mtime = zpl_inode_timespec_trunc(vap->va_mtime,
355 - ZTOI(zp)->i_sb->s_time_gran);
356 + ZTOI(zp)->i_mtime = zpl_inode_timestamp_truncate(
357 + vap->va_mtime, ZTOI(zp));
359 SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL,
360 mtime, sizeof (mtime));
361 @@ -3453,8 +3453,8 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr)
363 if (mask & (ATTR_CTIME | ATTR_SIZE)) {
364 ZFS_TIME_ENCODE(&vap->va_ctime, ctime);
365 - ZTOI(zp)->i_ctime = zpl_inode_timespec_trunc(vap->va_ctime,
366 - ZTOI(zp)->i_sb->s_time_gran);
367 + ZTOI(zp)->i_ctime = zpl_inode_timestamp_truncate(vap->va_ctime,
369 SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL,
370 ctime, sizeof (ctime));
372 diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
373 index e1c6ce7b705..c1b5825748c 100644
374 --- a/module/zfs/zpl_inode.c
375 +++ b/module/zfs/zpl_inode.c
376 @@ -382,10 +382,8 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
377 vap->va_mtime = ia->ia_mtime;
378 vap->va_ctime = ia->ia_ctime;
380 - if (vap->va_mask & ATTR_ATIME) {
381 - ip->i_atime = zpl_inode_timespec_trunc(ia->ia_atime,
382 - ip->i_sb->s_time_gran);
384 + if (vap->va_mask & ATTR_ATIME)
385 + ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip);
387 cookie = spl_fstrans_mark();
388 error = -zfs_setattr(ITOZ(ip), vap, 0, cr);
389 From ff5587d651371ab496f7962e85fe2c337fdb8a59 Mon Sep 17 00:00:00 2001
390 From: Brian Behlendorf <behlendorf1@llnl.gov>
391 Date: Wed, 26 Feb 2020 12:42:33 -0800
392 Subject: [PATCH] Linux 5.6 compat: ktime_get_raw_ts64()
394 The getrawmonotonic() and getrawmonotonic64() interfaces have been
395 fully retired. Update gethrtime() to use the replacement interface
396 ktime_get_raw_ts64() which was introduced in the 4.18 kernel.
398 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
399 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
403 config/kernel-ktime.m4 | 55 +++++++++++++++++++++
404 config/kernel-ktime_get_coarse_real_ts64.m4 | 23 ---------
405 config/kernel.m4 | 4 +-
406 include/spl/sys/time.h | 5 ++
407 4 files changed, 62 insertions(+), 25 deletions(-)
408 create mode 100644 config/kernel-ktime.m4
409 delete mode 100644 config/kernel-ktime_get_coarse_real_ts64.m4
411 diff --git a/config/kernel-ktime.m4 b/config/kernel-ktime.m4
413 index 00000000000..64c3b5f9032
415 +++ b/config/kernel-ktime.m4
418 +dnl # 4.18: ktime_get_coarse_real_ts64() replaces current_kernel_time64().
420 +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64], [
421 + ZFS_LINUX_TEST_SRC([ktime_get_coarse_real_ts64], [
422 + #include <linux/mm.h>
424 + struct timespec64 ts;
425 + ktime_get_coarse_real_ts64(&ts);
429 +AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [
430 + AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64() exists])
431 + ZFS_LINUX_TEST_RESULT([ktime_get_coarse_real_ts64], [
433 + AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
434 + [ktime_get_coarse_real_ts64() exists])
441 +dnl # 4.18: ktime_get_raw_ts64() replaces getrawmonotonic64().
443 +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64], [
444 + ZFS_LINUX_TEST_SRC([ktime_get_raw_ts64], [
445 + #include <linux/mm.h>
447 + struct timespec64 ts;
448 + ktime_get_raw_ts64(&ts);
452 +AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_RAW_TS64], [
453 + AC_MSG_CHECKING([whether ktime_get_raw_ts64() exists])
454 + ZFS_LINUX_TEST_RESULT([ktime_get_raw_ts64], [
456 + AC_DEFINE(HAVE_KTIME_GET_RAW_TS64, 1,
457 + [ktime_get_raw_ts64() exists])
463 +AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME], [
464 + ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64
465 + ZFS_AC_KERNEL_SRC_KTIME_GET_RAW_TS64
468 +AC_DEFUN([ZFS_AC_KERNEL_KTIME], [
469 + ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
470 + ZFS_AC_KERNEL_KTIME_GET_RAW_TS64
472 diff --git a/config/kernel-ktime_get_coarse_real_ts64.m4 b/config/kernel-ktime_get_coarse_real_ts64.m4
473 deleted file mode 100644
474 index 28492bf04bc..00000000000
475 --- a/config/kernel-ktime_get_coarse_real_ts64.m4
479 -dnl # 4.18: ktime_get_coarse_real_ts64() added. Use it in place of
480 -dnl # current_kernel_time64().
482 -AC_DEFUN([ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64], [
483 - ZFS_LINUX_TEST_SRC([ktime_get_coarse_real_ts64], [
484 - #include <linux/mm.h>
486 - struct timespec64 ts;
487 - ktime_get_coarse_real_ts64(&ts);
491 -AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [
492 - AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64() exists])
493 - ZFS_LINUX_TEST_RESULT([ktime_get_coarse_real_ts64], [
495 - AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
496 - [ktime_get_coarse_real_ts64() exists])
501 diff --git a/config/kernel.m4 b/config/kernel.m4
502 index 6bb37937cb4..a0fa2514e5e 100644
503 --- a/config/kernel.m4
504 +++ b/config/kernel.m4
505 @@ -114,7 +114,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
506 ZFS_AC_KERNEL_SRC_CURRENT_TIME
507 ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES
508 ZFS_AC_KERNEL_SRC_IN_COMPAT_SYSCALL
509 - ZFS_AC_KERNEL_SRC_KTIME_GET_COARSE_REAL_TS64
510 + ZFS_AC_KERNEL_SRC_KTIME
511 ZFS_AC_KERNEL_SRC_TOTALRAM_PAGES_FUNC
512 ZFS_AC_KERNEL_SRC_TOTALHIGH_PAGES
513 ZFS_AC_KERNEL_SRC_KSTRTOUL
514 @@ -208,7 +208,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
515 ZFS_AC_KERNEL_CURRENT_TIME
516 ZFS_AC_KERNEL_USERNS_CAPABILITIES
517 ZFS_AC_KERNEL_IN_COMPAT_SYSCALL
518 - ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
519 + ZFS_AC_KERNEL_KTIME
520 ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNC
521 ZFS_AC_KERNEL_TOTALHIGH_PAGES
522 ZFS_AC_KERNEL_KSTRTOUL
523 diff --git a/include/spl/sys/time.h b/include/spl/sys/time.h
524 index 312415b7bc8..56fd725c03c 100644
525 --- a/include/spl/sys/time.h
526 +++ b/include/spl/sys/time.h
527 @@ -105,8 +105,13 @@ gethrestime_sec(void)
528 static inline hrtime_t
531 +#if defined(HAVE_KTIME_GET_RAW_TS64)
532 + struct timespec64 ts;
533 + ktime_get_raw_ts64(&ts);
536 getrawmonotonic(&ts);
538 return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec);
541 From 2c3a83701dd185cadb30db4556256534e2930c7d Mon Sep 17 00:00:00 2001
542 From: Brian Behlendorf <behlendorf1@llnl.gov>
543 Date: Wed, 26 Feb 2020 13:18:07 -0800
544 Subject: [PATCH] Linux 5.6 compat: time_t
546 As part of the Linux kernel's y2038 changes the time_t type has been
547 fully retired. Callers are now required to use the time64_t type.
549 Rather than move to the new type, I've removed the few remaining
550 places where a time_t is used in the kernel code. They've been
551 replaced with a uint64_t which is already how ZFS internally
552 handled these values.
554 Going forward we should work towards updating the remaining user
555 space time_t consumers to the 64-bit interfaces.
557 Reviewed-by: Matthew Macy <mmacy@freebsd.org>
558 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
559 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
563 include/spl/sys/time.h | 2 +-
564 include/sys/vdev_impl.h | 4 ++--
565 lib/libspl/include/sys/time.h | 2 +-
566 module/zfs/zfs_debug.c | 2 +-
567 module/zfs/vdev_initialize.c | 2 +-
568 module/zfs/vdev_trim.c | 2 +-
569 6 files changed, 7 insertions(+), 7 deletions(-)
571 diff --git a/include/spl/sys/time.h b/include/spl/sys/time.h
572 index 56fd725c03c..4309c300b26 100644
573 --- a/include/spl/sys/time.h
574 +++ b/include/spl/sys/time.h
575 @@ -85,7 +85,7 @@ gethrestime(inode_timespec_t *ts)
579 -static inline time_t
580 +static inline uint64_t
581 gethrestime_sec(void)
583 #if defined(HAVE_INODE_TIMESPEC64_TIMES)
584 diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h
585 index 4f63e1ae5f8..b55871a5d24 100644
586 --- a/include/sys/vdev_impl.h
587 +++ b/include/sys/vdev_impl.h
588 @@ -272,7 +272,7 @@ struct vdev {
589 range_tree_t *vdev_initialize_tree; /* valid while initializing */
590 uint64_t vdev_initialize_bytes_est;
591 uint64_t vdev_initialize_bytes_done;
592 - time_t vdev_initialize_action_time; /* start and end time */
593 + uint64_t vdev_initialize_action_time; /* start and end time */
596 boolean_t vdev_trim_exit_wanted;
597 @@ -293,7 +293,7 @@ struct vdev {
598 uint64_t vdev_trim_rate; /* requested rate (bytes/sec) */
599 uint64_t vdev_trim_partial; /* requested partial TRIM */
600 uint64_t vdev_trim_secure; /* requested secure TRIM */
601 - time_t vdev_trim_action_time; /* start and end time */
602 + uint64_t vdev_trim_action_time; /* start and end time */
604 /* for limiting outstanding I/Os (initialize and TRIM) */
605 kmutex_t vdev_initialize_io_lock;
606 diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h
607 index 291f2190a28..c9f6165047d 100644
608 --- a/lib/libspl/include/sys/time.h
609 +++ b/lib/libspl/include/sys/time.h
610 @@ -88,7 +88,7 @@ gethrestime(inode_timespec_t *ts)
611 ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
614 -static inline time_t
615 +static inline uint64_t
616 gethrestime_sec(void)
619 diff --git a/module/zfs/zfs_debug.c b/module/zfs/zfs_debug.c
620 index a64971d0a3a..d98463f1b7f 100644
621 --- a/module/zfs/zfs_debug.c
622 +++ b/module/zfs/zfs_debug.c
625 typedef struct zfs_dbgmsg {
626 procfs_list_node_t zdm_node;
627 - time_t zdm_timestamp;
628 + uint64_t zdm_timestamp;
630 char zdm_msg[1]; /* variable length allocation */
632 diff --git a/module/zfs/vdev_initialize.c b/module/zfs/vdev_initialize.c
633 index 3e691c7f532..5899af9fc67 100644
634 --- a/module/zfs/vdev_initialize.c
635 +++ b/module/zfs/vdev_initialize.c
636 @@ -713,7 +713,7 @@ vdev_initialize_restart(vdev_t *vd)
637 vd->vdev_leaf_zap, VDEV_LEAF_ZAP_INITIALIZE_ACTION_TIME,
638 sizeof (timestamp), 1, ×tamp);
639 ASSERT(err == 0 || err == ENOENT);
640 - vd->vdev_initialize_action_time = (time_t)timestamp;
641 + vd->vdev_initialize_action_time = timestamp;
643 if (vd->vdev_initialize_state == VDEV_INITIALIZE_SUSPENDED ||
645 diff --git a/module/zfs/vdev_trim.c b/module/zfs/vdev_trim.c
646 index c7c429cbd5e..7dec07e3c69 100644
647 --- a/module/zfs/vdev_trim.c
648 +++ b/module/zfs/vdev_trim.c
649 @@ -1051,7 +1051,7 @@ vdev_trim_restart(vdev_t *vd)
650 vd->vdev_leaf_zap, VDEV_LEAF_ZAP_TRIM_ACTION_TIME,
651 sizeof (timestamp), 1, ×tamp);
652 ASSERT(err == 0 || err == ENOENT);
653 - vd->vdev_trim_action_time = (time_t)timestamp;
654 + vd->vdev_trim_action_time = timestamp;
656 if (vd->vdev_trim_state == VDEV_TRIM_SUSPENDED ||