871c415fd2c897328df8a3e64cdbda27bc9319fb
[packages/zfs.git] / kernel-5.6.patch
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
5
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.
10
11 This change additionally adds the 'const' keyword to all of the
12 existing proc operations structures.
13
14 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
15 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
16 Closes #9961
17 ---
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
26
27 diff --git a/config/kernel-proc-operations.m4 b/config/kernel-proc-operations.m4
28 new file mode 100644
29 index 00000000000..df216222ecc
30 --- /dev/null
31 +++ b/config/kernel-proc-operations.m4
32 @@ -0,0 +1,41 @@
33 +dnl #
34 +dnl # 5.6 API Change
35 +dnl # The proc_ops structure was introduced to replace the use of
36 +dnl # of the file_operations structure when registering proc handlers.
37 +dnl #
38 +AC_DEFUN([ZFS_AC_KERNEL_SRC_PROC_OPERATIONS], [
39 +       ZFS_LINUX_TEST_SRC([proc_ops_struct], [
40 +               #include <linux/proc_fs.h>
41 +
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)
48 +                   { return 0; }
49 +               int test_release(struct inode *ip, struct file *fp)
50 +                   { return 0; }
51 +
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,
58 +               };
59 +       ], [
60 +               struct proc_dir_entry *entry __attribute__ ((unused)) =
61 +                   proc_create_data("test", 0444, NULL, &test_ops, NULL);
62 +       ])
63 +])
64 +
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], [
68 +               AC_MSG_RESULT(yes)
69 +               AC_DEFINE(HAVE_PROC_OPS_STRUCT, 1, [proc_ops structure exists])
70 +       ], [
71 +               AC_MSG_RESULT(no)
72 +       ])
73 +])
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)
101  
102 +#ifdef HAVE_PROC_OPS_STRUCT
103 +typedef struct proc_ops kstat_proc_op_t;
104 +#else
105 +typedef struct file_operations kstat_proc_op_t;
106 +#endif
107 +
108  typedef struct kstat_intr {
109         uint_t intrs[KSTAT_NUM_INTRS];
110  } kstat_intr_t;
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);
117  
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,
125         return (len);
126  }
127  
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,
136 +#else
137         .open           = proc_kstat_open,
138         .write          = proc_kstat_write,
139         .read           = seq_read,
140         .llseek         = seq_lseek,
141         .release        = seq_release,
142 +#endif
143  };
144  
145  void
146 @@ -656,7 +664,7 @@ kstat_detect_collision(kstat_proc_entry_t *kpep)
147   */
148  void
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)
152  {
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,
156  
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));
170  }
171  
172 -static struct file_operations proc_slab_operations = {
173 -       .open      = proc_slab_open,
174 -       .read      = seq_read,
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,
182 +#else
183 +       .open           = proc_slab_open,
184 +       .read           = seq_read,
185 +       .llseek         = seq_lseek,
186         .release        = seq_release,
187 +#endif
188  };
189  
190  static void
191 @@ -571,18 +578,32 @@ proc_taskq_open(struct inode *inode, struct file *filp)
192         return (seq_open(filp, &taskq_seq_ops));
193  }
194  
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,
202 +#else
203         .open           = proc_taskq_all_open,
204         .read           = seq_read,
205         .llseek         = seq_lseek,
206         .release        = seq_release,
207 +#endif
208  };
209  
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,
217 +#else
218         .open           = proc_taskq_open,
219         .read           = seq_read,
220         .llseek         = seq_lseek,
221         .release        = seq_release,
222 +#endif
223  };
224  
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,
231         return (len);
232  }
233  
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,
243 +#else
244         .open           = procfs_list_open,
245         .write          = procfs_list_write,
246         .read           = seq_read,
247         .llseek         = seq_lseek,
248         .release        = seq_release_private,
249 +#endif
250  };
251  
252  /*
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()
257
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.
262
263 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
264 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
265 Closes #9956
266 Closes #9961
267 ---
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(-)
273
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
278 @@ -1,8 +1,22 @@
279 -dnl #
280 -dnl # 4.18 API change
281 -dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
282 -dnl #
283  AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
284 +
285 +       dnl #
286 +       dnl # 5.6 API change
287 +       dnl # timespec64_trunc() replaced by timestamp_truncate() interface.
288 +       dnl #
289 +       ZFS_LINUX_TEST_SRC([timestamp_truncate], [
290 +               #include <linux/fs.h>
291 +       ],[
292 +               struct timespec64 ts;
293 +               struct inode ip;
294 +
295 +               ts = timestamp_truncate(ts, &ip);
296 +       ])
297 +
298 +       dnl #
299 +       dnl # 4.18 API change
300 +       dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
301 +       dnl #
302         ZFS_LINUX_TEST_SRC([inode_times], [
303                 #include <linux/fs.h>
304         ],[
305 @@ -15,6 +29,15 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
306  ])
307  
308  AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
309 +       AC_MSG_CHECKING([whether timestamp_truncate() exists])
310 +       ZFS_LINUX_TEST_RESULT([timestamp_truncate], [
311 +               AC_MSG_RESULT(yes)
312 +               AC_DEFINE(HAVE_INODE_TIMESTAMP_TRUNCATE, 1,
313 +                   [timestamp_truncate() exists])
314 +       ],[
315 +               AC_MSG_RESULT(no)
316 +       ])
317 +
318         AC_MSG_CHECKING([whether inode->i_*time's are timespec64])
319         ZFS_LINUX_TEST_RESULT([inode_times], [
320                 AC_MSG_RESULT(no)
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)
326  }
327  #endif /* HAVE_VFS_ITERATE */
328  
329 -/*
330 - * Linux 4.18, inode times converted from timespec to timespec64.
331 - */
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)
339  #else
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)
343  #endif
344  
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)
351  
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));
358  
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)
362  
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,
368 +                   ZTOI(zp));
369                 SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL,
370                     ctime, sizeof (ctime));
371         }
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;
379  
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);
383 -       }
384 +       if (vap->va_mask & ATTR_ATIME)
385 +               ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip);
386  
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()
393
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.
397
398 Reviewed-by: Tony Hutter <hutter2@llnl.gov>
399 Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
400 Closes #10052
401 Closes #10064
402 ---
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
410
411 diff --git a/config/kernel-ktime.m4 b/config/kernel-ktime.m4
412 new file mode 100644
413 index 00000000000..64c3b5f9032
414 --- /dev/null
415 +++ b/config/kernel-ktime.m4
416 @@ -0,0 +1,55 @@
417 +dnl #
418 +dnl # 4.18: ktime_get_coarse_real_ts64() replaces current_kernel_time64().
419 +dnl #
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>
423 +       ], [
424 +               struct timespec64 ts;
425 +               ktime_get_coarse_real_ts64(&ts);
426 +       ])
427 +])
428 +
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], [
432 +               AC_MSG_RESULT(yes)
433 +               AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
434 +                   [ktime_get_coarse_real_ts64() exists])
435 +       ], [
436 +               AC_MSG_RESULT(no)
437 +       ])
438 +])
439 +
440 +dnl #
441 +dnl # 4.18: ktime_get_raw_ts64() replaces getrawmonotonic64().
442 +dnl #
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>
446 +       ], [
447 +               struct timespec64 ts;
448 +               ktime_get_raw_ts64(&ts);
449 +       ])
450 +])
451 +
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], [
455 +               AC_MSG_RESULT(yes)
456 +               AC_DEFINE(HAVE_KTIME_GET_RAW_TS64, 1,
457 +                   [ktime_get_raw_ts64() exists])
458 +       ], [
459 +               AC_MSG_RESULT(no)
460 +       ])
461 +])
462 +
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
466 +])
467 +
468 +AC_DEFUN([ZFS_AC_KERNEL_KTIME], [
469 +       ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64
470 +       ZFS_AC_KERNEL_KTIME_GET_RAW_TS64
471 +])
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
476 +++ /dev/null
477 @@ -1,23 +0,0 @@
478 -dnl #
479 -dnl # 4.18: ktime_get_coarse_real_ts64() added.  Use it in place of
480 -dnl # current_kernel_time64().
481 -dnl #
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>
485 -       ], [
486 -               struct timespec64 ts;
487 -               ktime_get_coarse_real_ts64(&ts);
488 -       ])
489 -])
490 -
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], [
494 -               AC_MSG_RESULT(yes)
495 -               AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
496 -                   [ktime_get_coarse_real_ts64() exists])
497 -       ], [
498 -               AC_MSG_RESULT(no)
499 -       ])
500 -])
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
529  gethrtime(void)
530  {
531 +#if defined(HAVE_KTIME_GET_RAW_TS64)
532 +       struct timespec64 ts;
533 +       ktime_get_raw_ts64(&ts);
534 +#else
535         struct timespec ts;
536         getrawmonotonic(&ts);
537 +#endif
538         return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec);
539  }
540  
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
545
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.
548
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.
553
554 Going forward we should work towards updating the remaining user
555 space time_t consumers to the 64-bit interfaces.
556
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>
560 Closes #10052
561 Closes #10064
562 ---
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(-)
570
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)
576  #endif
577  }
578  
579 -static inline time_t
580 +static inline uint64_t
581  gethrestime_sec(void)
582  {
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 */
594  
595         /* TRIM related */
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 */
603  
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;
612  }
613  
614 -static inline time_t
615 +static inline uint64_t
616  gethrestime_sec(void)
617  {
618         struct timeval tv;
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
623 @@ -28,7 +28,7 @@
624  
625  typedef struct zfs_dbgmsg {
626         procfs_list_node_t      zdm_node;
627 -       time_t                  zdm_timestamp;
628 +       uint64_t                zdm_timestamp;
629         int                     zdm_size;
630         char                    zdm_msg[1]; /* variable length allocation */
631  } zfs_dbgmsg_t;
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, &timestamp);
639                 ASSERT(err == 0 || err == ENOENT);
640 -               vd->vdev_initialize_action_time = (time_t)timestamp;
641 +               vd->vdev_initialize_action_time = timestamp;
642  
643                 if (vd->vdev_initialize_state == VDEV_INITIALIZE_SUSPENDED ||
644                     vd->vdev_offline) {
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, &timestamp);
652                 ASSERT(err == 0 || err == ENOENT);
653 -               vd->vdev_trim_action_time = (time_t)timestamp;
654 +               vd->vdev_trim_action_time = timestamp;
655  
656                 if (vd->vdev_trim_state == VDEV_TRIM_SUSPENDED ||
657                     vd->vdev_offline) {
This page took 0.14428 seconds and 2 git commands to generate.