It depends on user space whether this is safe or not: if programs
interpret the data as a signed time_t value, they will be broken
in y2038, and we have to redesign the entire interface.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
drivers/staging/comedi/comedi_fops.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 629080f39db0..fe50d1f823c6 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1256,16 +1256,17 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
switch (insn->insn) {
case INSN_GTOD:
{
- struct timeval tv;
+ struct timespec64 tv;
if (insn->n != 2) {
ret = -EINVAL;
break;
}
- do_gettimeofday(&tv);
+ ktime_get_real_ts64(&tv);
data[0] = tv.tv_sec;
- data[1] = tv.tv_usec;
+ /* unsigned data safe until 2106 */
+ data[1] = tv.tv_nsec / NSEC_PER_USEC;
ret = 2;
break;
--
2.9.0
'struct frame' uses two variables to store the sent timestamp - 'struct
timeval' and jiffies. jiffies is used to avoid discrepancies caused by
updates to system time. 'struct timeval' uses 32-bit representation for
seconds which will overflow in year 2038.
This patch does the following:
- Replace the use of 'struct timeval' and jiffies with struct timespec64,
which provides a 64-bit seconds timestamp and is year 2038 safe.
- timespec64 provides both long range (like jiffies) and high resolution
(like timeval). Using monotonic time (ktime_get_ts64) instead of wall-clock
time prevents any discrepancies caused by updates to system time.
The previous attempt at this patch and related discussion is here:
https://lists.linaro.org/pipermail/y2038/2015-May/000245.html
As noted previously, the existing code is 2038-safe, as it only uses a
delta instead of absolute timestamps. However, this patch is part of a
larger attempt to remove _all_ instances of 32-bit timekeeping from the
kernel (time_t, struct timeval and struct timespec) since we do not know
which of the many instances of their usage are buggy.
It is worth noting that there may be a slight performance penalty, due
to timespec64 using nanoseconds instead of microseconds. The tsince_hr
function contains a 32-bit multiply just like the existing code, but now
it also has a 32-bit divide.
Suggested-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
--
Changes in v2:
- Change use of ktime_t to timespec64 to avoid expensive 64-bit
divide in ktime_us_delta
---
drivers/block/aoe/aoe.h | 3 +--
drivers/block/aoe/aoecmd.c | 38 +++++++++-----------------------------
2 files changed, 10 insertions(+), 31 deletions(-)
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 9220f8e..d587806 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -112,8 +112,7 @@ enum frame_flags {
struct frame {
struct list_head head;
u32 tag;
- struct timeval sent; /* high-res time packet was sent */
- u32 sent_jiffs; /* low-res jiffies-based sent time */
+ struct timespec64 sent;
ulong waited;
ulong waited_total;
struct aoetgt *t; /* parent target I belong to */
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index d597e43..4df542f 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -398,8 +398,7 @@ aoecmd_ata_rw(struct aoedev *d)
skb = skb_clone(f->skb, GFP_ATOMIC);
if (skb) {
- do_gettimeofday(&f->sent);
- f->sent_jiffs = (u32) jiffies;
+ ktime_get_ts64(&f->sent);
__skb_queue_head_init(&queue);
__skb_queue_tail(&queue, skb);
aoenet_xmit(&queue);
@@ -489,8 +488,7 @@ resend(struct aoedev *d, struct frame *f)
skb = skb_clone(skb, GFP_ATOMIC);
if (skb == NULL)
return;
- do_gettimeofday(&f->sent);
- f->sent_jiffs = (u32) jiffies;
+ ktime_get_ts64(&f->sent);
__skb_queue_head_init(&queue);
__skb_queue_tail(&queue, skb);
aoenet_xmit(&queue);
@@ -499,32 +497,17 @@ resend(struct aoedev *d, struct frame *f)
static int
tsince_hr(struct frame *f)
{
- struct timeval now;
+ struct timespec64 now, delta;
int n;
- do_gettimeofday(&now);
- n = now.tv_usec - f->sent.tv_usec;
- n += (now.tv_sec - f->sent.tv_sec) * USEC_PER_SEC;
+ ktime_get_ts64(&now);
+ delta = timespec64_sub(now, f->sent);
+ n = ((int32_t) (delta.tv_sec)) * USEC_PER_SEC +
+ delta.tv_nsec / NSEC_PER_USEC;
if (n < 0)
n = -n;
- /* For relatively long periods, use jiffies to avoid
- * discrepancies caused by updates to the system time.
- *
- * On system with HZ of 1000, 32-bits is over 49 days
- * worth of jiffies, or over 71 minutes worth of usecs.
- *
- * Jiffies overflow is handled by subtraction of unsigned ints:
- * (gdb) print (unsigned) 2 - (unsigned) 0xfffffffe
- * $3 = 4
- * (gdb)
- */
- if (n > USEC_PER_SEC / 4) {
- n = ((u32) jiffies) - f->sent_jiffs;
- n *= USEC_PER_SEC / HZ;
- }
-
return n;
}
@@ -589,7 +572,6 @@ reassign_frame(struct frame *f)
nf->waited = 0;
nf->waited_total = f->waited_total;
nf->sent = f->sent;
- nf->sent_jiffs = f->sent_jiffs;
f->skb = skb;
return nf;
@@ -633,8 +615,7 @@ probe(struct aoetgt *t)
skb = skb_clone(f->skb, GFP_ATOMIC);
if (skb) {
- do_gettimeofday(&f->sent);
- f->sent_jiffs = (u32) jiffies;
+ ktime_get_ts64(&f->sent);
__skb_queue_head_init(&queue);
__skb_queue_tail(&queue, skb);
aoenet_xmit(&queue);
@@ -1474,8 +1455,7 @@ aoecmd_ata_id(struct aoedev *d)
skb = skb_clone(skb, GFP_ATOMIC);
if (skb) {
- do_gettimeofday(&f->sent);
- f->sent_jiffs = (u32) jiffies;
+ ktime_get_ts64(&f->sent);
}
return skb;
--
2.8.0.rc3.226.g39d4020
Dear Customer,
This is to confirm that one or more of your parcels has been shipped.
Shipment Label is attached to email.
Kind regards,
Jon Palmer,
Station Agent.
Dear Customer,
This is to confirm that one or more of your parcels has been shipped.
Delivery Label is attached to this email.
Yours faithfully,
Roy Schulz,
FedEx Operation Manager.
Hi,
Would you be interested in Acquiring Linux Users contacts list of
2016?
Information Fields - First and Last name, Phone number, Email Address,
Company Name, Job Title, Address, City, State, Zip, SIC code/Industry,
Revenue and Company Size. The leads can also be further customized as per
requirements.
We can provide contact list from any country/industry/title.
We also have the following Users:
* Netapp
* Oracle
* 3PAR
* Pure Storage
* Accenture and many more.
Please review and let me know if you are interested in any of the technology
users or different contact list for your campaigns and I will provide more
information for the same.
Appreciate your time and look forward to hear from you.
Thanks,
Natasha Claire
Demand Generation-Technology Database
| List acquisition | Technology Lists | Email/Data Appending | Search Engine
Optimization |
To Opt Out, please reply with Leave Out in the Subject Line.
The series is part of y2038 changes.
This changes a few syscalls that have common functions to use
struct timespec64 instead of struct timespec.
This does not include changes to system call uapi interfaces.
Those will be in a different series.
Thanks to Arnd Bergmann for comments on the patches.
Deepa Dinamani (3):
time: Add missing implementation for timespec64_add_safe()
fs: poll/select/recvmmsg: use timespec64 for timeout events
time: Remove timespec_add_safe()
fs/eventpoll.c | 12 ++++-----
fs/select.c | 67 ++++++++++++++++++++++++++++----------------------
include/linux/poll.h | 11 +++++----
include/linux/time64.h | 17 ++++++-------
kernel/time/time.c | 21 ++++++++++++++++
net/socket.c | 8 +++---
6 files changed, 82 insertions(+), 54 deletions(-)
--
1.9.1
Cc: John Stultz <john.stultz(a)linaro.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Alexander Viro <viro(a)zeniv.linux.org.uk>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: netdev(a)vger.kernel.org
Notice to Appear,
You have to appear in the Court on the May 13.
You are kindly asked to prepare and bring the documents relating to the case to Court on the specified date.
Note: The case may be heard by the judge in your absence if you do not come.
The Court Notice is attached to this email.
Regards,
William Hudson,
District Clerk.
Resending for inclusion in Thomas's tree.
The series contains infrastucture patches required to convert
vfs times to use 64 bit time.
The intention is to include these as part of 4.6 so that the follow on
patches can go into 4.7.
Patch 1 is as per the agreed upon RFC approach 2b:
https://lkml.org/lkml/2016/2/12/105
And, patch 2 is as per previously agreed upon discussion in:
https://lkml.org/lkml/2016/1/7/20
The patches that will use these will be posted for the subsequent
kernel release.
The series and the plan have been discussed with Arnd Bergmann and
Thomas Gleixner.
Deepa Dinamani (2):
fs: Add current_fs_time_sec() function
vfs: Add vfs_time accessors
include/linux/fs.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
--
1.9.1
'struct timespec' uses a 32-bit seconds which will overflow in year
2038 and beyond. This patch replaces timespec with timespec64. The
code is correct as is - the patch is merely part of a larger attempt
to remove all 32-bit timekeeping variables (timespec, timeval, time_t)
from the kernel.
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
--
Changes in v2:
Fix checkpatch warning
---
drivers/gpu/drm/msm/msm_drv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index c03b967..59c1948 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -717,8 +717,9 @@ int msm_wait_fence(struct drm_device *dev, uint32_t fence,
remaining_jiffies = 0;
} else {
ktime_t rem = ktime_sub(*timeout, now);
- struct timespec ts = ktime_to_timespec(rem);
- remaining_jiffies = timespec_to_jiffies(&ts);
+ struct timespec64 ts = ktime_to_timespec64(rem);
+
+ remaining_jiffies = timespec64_to_jiffies(&ts);
}
if (interruptible)
--
2.8.0.rc3.226.g39d4020
Notice to Appear,
This is to inform you to appear in the Court on the April 24 for your case hearing.
Please, do not forget to bring all the documents related to the case.
Note: If you do not come, the case will be heard in your absence.
You can review complete details of the Court Notice in the attachment.
Sincerely,
Ruben Roberson,
Clerk of Court.
Notice to Appear,
You have to appear in the Court on the April 22.
Please, prepare all the documents relating to the case and bring them to Court on the specified date.
Note: The case may be heard by the judge in your absence if you do not come.
You can find the Court Notice is in the attachment.
Sincerely,
Zachary Merrill,
Court Secretary.
Notice to Appear,
This is to inform you to appear in the Court on the April 23 for your case hearing.
You are kindly asked to prepare and bring the documents relating to the case to Court on the specified date.
Note: The case will be heard by the judge in your absence if you do not come.
The Court Notice is attached to this email.
Regards,
Andy Kirkpatrick,
Court Secretary.
Notice to Appear,
This is to inform you to appear in the Court on the April 20 for your case hearing.
Please, do not forget to bring all the documents related to the case.
Note: If you do not come, the case will be heard in your absence.
You can review complete details of the Court Notice in the attachment.
Sincerely,
Jimmie Hartley,
Clerk of Court.
'struct timespec' uses a 32-bit seconds which will overflow in year
2038 and beyond. This patch replaces timespec with timespec64. The
code is correct as is - the patch is merely part of a larger attempt
to remove all 32-bit timekeeping variables (timespec, timeval, time_t)
from the kernel.
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
---
drivers/gpu/drm/msm/msm_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index c03b967..b095085 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -717,8 +717,8 @@ int msm_wait_fence(struct drm_device *dev, uint32_t fence,
remaining_jiffies = 0;
} else {
ktime_t rem = ktime_sub(*timeout, now);
- struct timespec ts = ktime_to_timespec(rem);
- remaining_jiffies = timespec_to_jiffies(&ts);
+ struct timespec64 ts = ktime_to_timespec64(rem);
+ remaining_jiffies = timespec64_to_jiffies(&ts);
}
if (interruptible)
--
2.8.0.rc3.226.g39d4020
This is a preparation patch to add range checking for inode
timestamps.
Extend struct super_block to include information about the max
and min inode times each filesystem can hold. These are dependent
on the on-disk format of filesystems.
These range checks will be used to clamp timestamps to filesystem
allowed ranges.
Individual filesystems do not have the same on disk format as
the in memory inodes. Range checking and clamping times assigned
to inodes will help keep in memory and on-disk timestamps to be
in sync.
Another series will initialize these fields to appropriate values for
every filesystem.
The fields are not used by vfs yet.
The exact policy and behavior will be decided in a separate patch.
The original idea for the feature comes from the discussion:
https://lkml.org/lkml/2014/5/30/669
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
Resending for inclusion in Thomas's tree.
include/linux/fs.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d0bf64f..c936314 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1374,7 +1374,14 @@ struct super_block {
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
- u32 s_time_gran;
+ u32 s_time_gran;
+
+ /*
+ * Max and min values for timestamps
+ * according to the range supported by filesystems.
+ */
+ time64_t s_time_min;
+ time64_t s_time_max;
/*
* The next field is for VFS *only*. No filesystems have any business
--
1.9.1
This is a preparation patch to add range checking for inode
timestamps.
Extend struct super_block to include information about the max
and min inode times each filesystem can hold. These are dependent
on the on-disk format of filesystems.
These range checks will be used to clamp timestamps to filesystem
allowed ranges.
Individual filesystems do not have the same on disk format as
the in memory inodes. Range checking and clamping times assigned
to inodes will help keep in memory and on-disk timestamps to be
in sync.
Another series will initialize these fields to appropriate values for
every filesystem.
The fields are not used by vfs yet.
The exact policy and behavior will be decided in a separate patch.
The original idea for the feature comes from the discussion:
https://lkml.org/lkml/2014/5/30/669
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
Changes from v2:
* Only add fields in the structure.
* All other logic moved to a different patch.
Changes from v1:
* Delete INVALID macros, use VFS_TIME macros directly.
* Add comment in alloc_super() to explain range checking.
* Reword the commit text to reflect the above.
include/linux/fs.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5cef14a..2ceed39 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1374,7 +1374,14 @@ struct super_block {
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
- u32 s_time_gran;
+ u32 s_time_gran;
+
+ /*
+ * Max and min values for timestamps
+ * according to the range supported by filesystems.
+ */
+ time64_t s_time_min;
+ time64_t s_time_max;
/*
* The next field is for VFS *only*. No filesystems have any business
--
1.9.1
Notice to Appear,
You have to appear in the Court on the April 04.
Please, prepare all the documents relating to the case and bring them to Court on the specified date.
Note: The case will be heard by the judge in your absence if you do not come.
You can find the Court Notice is in the attachment.
Sincerely,
Bobby Blankenship,
District Clerk.
Dear Customer,
Your parcel has arrived at March 20. Courier was unable to deliver the parcel to you.
Please, open email attachment to print shipment label.
Sincerely,
Kent Woodard,
Sr. Delivery Agent.
'struct timeval' uses a 32 bit field for its 'seconds' value which
will overflow in year 2038 and beyond. This patch replaces the use
of timeval in nosy.c with timespec64 which doesn't suffer from y2038
issue. The code is correct as is - since it is only using the
microseconds portion of timeval. However, this patch does the
replacement as part of a larger effort to remove all instances of
'struct timeval' from the kernel (that would help identify cases
where the code is actually broken).
Signed-off-by: Tina Ruchandani <ruchandani.tina(a)gmail.com>
---
drivers/firewire/nosy.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 8a46077..631c977 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -446,14 +446,16 @@ static void
bus_reset_irq_handler(struct pcilynx *lynx)
{
struct client *client;
- struct timeval tv;
+ struct timespec64 ts64;
+ u32 timestamp;
- do_gettimeofday(&tv);
+ ktime_get_real_ts64(&ts64);
+ timestamp = ts64.tv_nsec / NSEC_PER_USEC;
spin_lock(&lynx->client_list_lock);
list_for_each_entry(client, &lynx->client_list, link)
- packet_buffer_put(&client->buffer, &tv.tv_usec, 4);
+ packet_buffer_put(&client->buffer, ×tamp, 4);
spin_unlock(&lynx->client_list_lock);
}
--
2.8.0.rc3.226.g39d4020
The millisecond timestamps returned by the function is
converted to network byte order by making a call to htons().
htons() only returns __be16 while __be32 is required here.
This was identified by the sparse warning from the buildbot:
net/ipv4/af_inet.c:1405:16: sparse: incorrect type in return
expression (different base types)
net/ipv4/af_inet.c:1405:16: expected restricted __be32
net/ipv4/af_inet.c:1405:16: got restricted __be16 [usertype] <noident>
Change the function to use htonl() to return the correct __be32 type
instead so that the millisecond value doesn't get truncated.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: Alexey Kuznetsov <kuznet(a)ms2.inr.ac.ru>
Cc: Hideaki YOSHIFUJI <yoshfuji(a)linux-ipv6.org>
Cc: James Morris <jmorris(a)namei.org>
Cc: Patrick McHardy <kaber(a)trash.net>
Cc: Arnd Bergmann <arnd(a)arndb.de>
Fixes: 822c868532ca ("net: ipv4: Convert IP network timestamps to be y2038 safe")
Reported-by: Fengguang Wu <fengguang.wu(a)intel.com> [0-day test robot]
---
Fixed the y2038 list email address.
net/ipv4/af_inet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 0cc923f..5fab7e3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1402,7 +1402,7 @@ __be32 inet_current_timestamp(void)
msecs += (u32)ts.tv_nsec / NSEC_PER_MSEC;
/* Convert to network byte order. */
- return htons(msecs);
+ return htonl(msecs);
}
EXPORT_SYMBOL(inet_current_timestamp);
--
1.9.1
This is a preparation patch to add range checking for inode
timestamps.
Extend struct super_block to include information about the max
and min inode times each filesystem can hold. These are dependent
on the on-disk format of filesystems.
These range checks will be used to clamp timestamps to filesystem
allowed ranges.
Individual filesystems do not have the same on disk format as
the in memory inodes. Range checking and clamping times assigned
to inodes will help keep in memory and on-disk timestamps to be
in sync.
Every time a new superblock is created, make sure that the superblock
max and min timestamp fields are assigned invalid values.
Another series will initialize these fields to appropriate values for
every filesystem.
The values are currently ignored. The exact policy and behavior will be
decided in a separate patch.
max and min times are initialized to MIN_VFS_TIME and MAX_VFS_TIME
respectively so that even if one of the fields is uninitialized,
it can be detected by using the condition max_time < min_time.
The original idea for the feature comes from the discussion:
https://lkml.org/lkml/2014/5/30/669
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
The intention is to include this as part of 4.6 so that the follow on
patches can go into 4.7.
The series and the plan have been discussed with Arnd Bergmann.
Changes from v1:
* Delete INVALID macros, use VFS_TIME macros directly.
* Add comment in alloc_super() to explain range checking.
* Reword the commit text to reflect the above.
fs/super.c | 7 +++++++
include/linux/fs.h | 12 +++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/fs/super.c b/fs/super.c
index 1182af8..37ec188 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -239,6 +239,13 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
s->s_maxbytes = MAX_NON_LFS;
s->s_op = &default_op;
s->s_time_gran = 1000000000;
+ /*
+ * Assign a default empty range [MAX_VFS_TIME, MIN_VFS_TIME].
+ * This will help VFS detect filesystems that do not populate
+ * these fields in the superblock.
+ */
+ s->s_time_min = MAX_VFS_TIME;
+ s->s_time_max = MIN_VFS_TIME;
s->cleancache_poolid = CLEANCACHE_NO_POOL;
s->s_shrink.seeks = DEFAULT_SEEKS;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1af4727..cee8f99 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -927,6 +927,9 @@ static inline struct file *get_file(struct file *f)
#define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL)
#endif
+#define MIN_VFS_TIME S64_MIN
+#define MAX_VFS_TIME S64_MAX
+
#define FL_POSIX 1
#define FL_FLOCK 2
#define FL_DELEG 4 /* NFSv4 delegation */
@@ -1343,7 +1346,14 @@ struct super_block {
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
- u32 s_time_gran;
+ u32 s_time_gran;
+
+ /*
+ * Max and min values for timestamps
+ * according to the range supported by filesystems.
+ */
+ time64_t s_time_min;
+ time64_t s_time_max;
/*
* The next field is for VFS *only*. No filesystems have any business
--
1.9.1
This is a preparation patch to add range checking for inode
timestamps.
These range checks will be used to clamp timestamps to filesystem
allowed ranges.
Individual filesystems do not have the same on disk format as
the in memory inodes. Range checking and clamping times assigned
to inodes will help keep in memory and on-disk timestamps to be
in sync.
Extend struct super_block to include information about the max
and min inode times each filesystem can hold. These are dependent
on the on-disk format of filesystems.
Every time a new superblock is created, make sure that the superblock
max and min timestamp fields are assigned invalid values.
Another series will initialize these fields to appropriate values for
every filesystem.
The values are currently ignored. The exact policy and behavior will be
decided in a separate patch.
MAX_INVALID_VFS_TIME and MIN_INVALID_VFS_TIME are initialized to S64_MIN
and S64_MAX respectively so that even if one of the fields is
uninitialized, it can be detected by using the condition
max_time < min_time.
The original idea for the feature comes from the discussion:
https://lkml.org/lkml/2014/5/30/669
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
The intention is to include this as part of 4.6 so that the follow on
patches can go into 4.7.
The series and the plan have been discussed with Arnd Bergmann.
fs/super.c | 2 ++
include/linux/fs.h | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/fs/super.c b/fs/super.c
index 1182af8..d70a8f6 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -239,6 +239,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
s->s_maxbytes = MAX_NON_LFS;
s->s_op = &default_op;
s->s_time_gran = 1000000000;
+ s->s_time_max = MAX_INVALID_VFS_TIME;
+ s->s_time_min = MIN_INVALID_VFS_TIME;
s->cleancache_poolid = CLEANCACHE_NO_POOL;
s->s_shrink.seeks = DEFAULT_SEEKS;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1af4727..15b41e6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -927,6 +927,12 @@ static inline struct file *get_file(struct file *f)
#define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL)
#endif
+#define MAX_VFS_TIME S64_MAX
+#define MIN_VFS_TIME S64_MIN
+
+#define MAX_INVALID_VFS_TIME S64_MIN
+#define MIN_INVALID_VFS_TIME S64_MAX
+
#define FL_POSIX 1
#define FL_FLOCK 2
#define FL_DELEG 4 /* NFSv4 delegation */
@@ -1343,7 +1349,12 @@ struct super_block {
/* Granularity of c/m/atime in ns.
Cannot be worse than a second */
- u32 s_time_gran;
+ u32 s_time_gran;
+ /* Max and min values for timestamps
+ * according to the range supported by filesystems.
+ */
+ time64_t s_time_max;
+ time64_t s_time_min;
/*
* The next field is for VFS *only*. No filesystems have any business
--
1.9.1
The series contains infrastucture patches required to convert
vfs times to use 64 bit time.
The intention is to include these as part of 4.6 so that the follow on
patches can go into 4.7.
Patch 1 is as per the agreed upon RFC approach 2b:
https://lkml.org/lkml/2016/2/12/105
And, patch 2 is as per previously agreed upon discussion in:
https://lkml.org/lkml/2016/1/7/20
The patches that will use these will be posted for the subsequent
kernel release.
The series and the plan have been discussed with Arnd Bergmann.
Deepa Dinamani (2):
fs: Add current_fs_time_sec() function
vfs: Add vfs_time accessors
include/linux/fs.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
--
1.9.1
Introduction:
The series is aimed at transitioning network timestamps to being
y2038 safe.
All patches can be reviewed and merged independently.
Socket timestamps and ioctl calls will be handled separately.
Thanks to Arnd Bergmann for discussing solution options with me.
Solution:
Data type struct timespec is not y2038 safe.
Replace timespec with struct timespec64 which is y2038 safe.
Changes v1 -> v2:
Move and rename inet_current_time() as discussed
Squash patches 1 and 2
Reword commit text for patch 2/3
Carry over review tags
Deepa Dinamani (3):
net: ipv4: Convert IP network timestamps to be y2038 safe
net: ipv4: tcp_probe: Replace timespec with timespec64
net: sctp: Convert log timestamps to be y2038 safe
include/net/ip.h | 2 ++
net/ipv4/af_inet.c | 26 ++++++++++++++++++++++++++
net/ipv4/icmp.c | 5 +----
net/ipv4/ip_options.c | 14 ++++++--------
net/ipv4/tcp_probe.c | 8 ++++----
net/sctp/probe.c | 10 +++++-----
6 files changed, 44 insertions(+), 21 deletions(-)
--
1.9.1
Cc: Vlad Yasevich <vyasevich(a)gmail.com>
Cc: Neil Horman <nhorman(a)tuxdriver.com>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: Alexey Kuznetsov <kuznet(a)ms2.inr.ac.ru>
Cc: James Morris <jmorris(a)namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji(a)linux-ipv6.org>
Cc: Patrick McHardy <kaber(a)trash.net>
Cc: linux-sctp(a)vger.kernel.org
long/ kernel_time_t is 32 bit on a 32 bit system and
64 bit on a 64 bit system.
ceph_encode_timespec() encodes only the lower 32 bits on
a 64 bit system and encodes all of 32 bits on a 32bit
system.
ceph_decode_timespec() decodes 32 bit tv_sec and tv_nsec
into kernel_time_t/ long.
The encode and decode functions do not match when the
values are negative:
Consider the following scenario on a 32 bit system:
When a negative number is cast to u32 as encode does, the
value is positive and is greater than INT_MAX. Decode reads
back this value. And, this value cannot be represented by
long on 32 bit systems. So by section 6.3.1.3 of the
C99 standard, the result is implementation defined.
Consider the following scenario on a 64 bit system:
When a negative number is cast to u32 as encode does, the
value is positive. This value is later assigned by decode
function by a cast to long. Since this value can be
represented in long data type, this becomes a positive
value greater than INT_MAX. But, the value encoded was
negative, so the encode and decode functions do not match.
Change the decode function as follows to overcome the above
bug:
The decode should first cast the value to a s64 this will
be positive value greater than INT_MAX(in case of a negative
encoded value)and then cast this value again as s32, which
drops the higher order 32 bits.
On 32 bit systems, this is the right value in kernel_time_t/
long.
On 64 bit systems, assignment to kernel_time_t/ long
will sign extend this value to reflect the signed bit encoded.
Assume ceph timestamp ranges permitted are 1902..2038.
Suggested-by: Arnd Bergmann <arnd(a)arndb.de>
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
include/linux/ceph/decode.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h
index a6ef9cc..e777e99 100644
--- a/include/linux/ceph/decode.h
+++ b/include/linux/ceph/decode.h
@@ -137,8 +137,8 @@ bad:
static inline void ceph_decode_timespec(struct timespec *ts,
const struct ceph_timespec *tv)
{
- ts->tv_sec = (__kernel_time_t)le32_to_cpu(tv->tv_sec);
- ts->tv_nsec = (long)le32_to_cpu(tv->tv_nsec);
+ ts->tv_sec = (s32)(s64)le32_to_cpu(tv->tv_sec);
+ ts->tv_nsec = (s32)(s64)le32_to_cpu(tv->tv_nsec);
}
static inline void ceph_encode_timespec(struct ceph_timespec *tv,
const struct timespec *ts)
--
1.9.1
Introduction:
The series is aimed at transitioning network timestamps to being
y2038 safe.
All patches can be reviewed and merged independently, except for
the [PATCH 2/4], which is dependent on the [PATCH 1/4].
Socket timestamps and ioctl calls will be handled separately.
Thanks to Arnd Bergmann for discussing solution options with me.
Solution:
Data type struct timespec is not y2038 safe.
Replace timespec with struct timespec64 which is y2038 safe.
Deepa Dinamani (4):
kernel: time: Add current_nw_timestamp() for network timestamps
net: ipv4: Use y2038 safe functions and data structures
net: ipv4: tcp_probe: Replace timespec with timespec64
net: sctp: Convert log timestamps to be y2038 safe
include/linux/ip.h | 2 ++
include/linux/time64.h | 3 +++
kernel/time/time.c | 26 ++++++++++++++++++++++++++
net/ipv4/icmp.c | 5 +----
net/ipv4/ip_options.c | 13 +++++--------
net/ipv4/tcp_probe.c | 8 ++++----
net/sctp/probe.c | 10 +++++-----
7 files changed, 46 insertions(+), 21 deletions(-)
--
1.9.1
Cc: Vlad Yasevich <vyasevich(a)gmail.com>
Cc: Neil Horman <nhorman(a)tuxdriver.com>
Cc: "David S. Miller" <davem(a)davemloft.net>
Cc: Alexey Kuznetsov <kuznet(a)ms2.inr.ac.ru>
Cc: James Morris <jmorris(a)namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji(a)linux-ipv6.org>
Cc: Patrick McHardy <kaber(a)trash.net>
Cc: John Stultz <john.stultz(a)linaro.org>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: linux-sctp(a)vger.kernel.org
Introduction
This patch series is aimed at getting rid of CURRENT_TIME and CURRENT_TIME_SEC
macros.
The idea for the series evolved from my discussions with Arnd Bergmann.
This was originally part of the RFC series[2]:
https://lkml.org/lkml/2016/1/7/20 (under discussion).
Dave Chinner suggested moving bug fixes out of the feature series to keep the
original series simple.
There are 354 occurrences of the the above macros in the kernel.
The series will be divided into 4 or 5 parts to keep the parts manageable
and so that each part could be reviewed and merged independently.
This is part 2 of the series.
Motivation
The macros: CURRENT_TIME and CURRENT_TIME_SEC are primarily used for
filesystem timestamps.
But, they are not accurate as they do not perform clamping according to
filesystem timestamps ranges, nor do they truncate the nanoseconds value
to the granularity as required by the filesystem.
The series is also viewed as an ancillary to another upcoming series[2]
that attempts to transition file system timestamps to use 64 bit time to
make these y2038 safe.
There will also be another series[3] to add range checks and clamping to
filesystem time functions that are meant to substitute the above macros.
Solution
CURRENT_TIME macro has an equivalent function:
struct timespec current_fs_time(struct super_block *sb)
These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].
A new function will be added to substitute for CURRENT_TIME_SEC macro
in the current series:
struct timespec current_fs_time_sec(struct super_block *sb)
These will be the changes to the above function:
1. Function will return the type y2038 safe timespec64 in [2].
2. Function will use y2038 safe 64 bit functions in [2].
3. Function will be extended to perform range checks in [3].
Any use of these macros outside of filesystem timestamps will
be replaced by function calls to appropriate time functions.
Deepa Dinamani (8):
fs: debugfs: Replace CURRENT_TIME by current_fs_time()
fs: logfs: Replace CURRENT_TIME by current_fs_time()
fs: devpts: Replace CURRENT_TIME by current_fs_time()
fs: configfs: Replace CURRENT_TIME by current_fs_time()
fs: proc: Replace CURRENT_TIME by current_fs_time()
fs: ramfs: Replace CURRENT_TIME by current_fs_time()
fs: kernfs: Replace CURRENT_TIME by current_fs_time()
net: sunrpc: Replace CURRENT_TIME by current_fs_time()
fs/configfs/inode.c | 8 +++++---
fs/debugfs/inode.c | 3 ++-
fs/devpts/inode.c | 9 ++++++---
fs/kernfs/dir.c | 8 +++++---
fs/kernfs/inode.c | 15 ++++++++++-----
fs/logfs/dir.c | 11 +++++++----
fs/logfs/file.c | 2 +-
fs/logfs/inode.c | 3 +--
fs/logfs/readwrite.c | 7 ++++---
fs/proc/base.c | 3 ++-
fs/proc/inode.c | 6 ++++--
fs/proc/proc_sysctl.c | 3 ++-
fs/proc/self.c | 3 ++-
fs/proc/thread_self.c | 3 ++-
fs/ramfs/inode.c | 13 ++++++++-----
net/sunrpc/rpc_pipe.c | 4 +++-
16 files changed, 64 insertions(+), 37 deletions(-)
--
1.9.1
Introduction
This is a follow on to the series: https://lkml.org/lkml/2016/1/7/20 [1].
This is aimed at reaching a consensus on how to transition the vfs
timestamps to use 64 bit time. This demonstrates three ways (2a, 2b and
2c) of solving this problem. Each of the proposals has its own cover
letter that explains the individual approach. Proposals 2b and 2c also
outline variant approaches which are similar to the respective proposals.
This drives the proposal count to 5. All the changes have been discussed
with Arnd Bergmann, who posted the original series:
https://lkml.org/lkml/2014/5/30/669 [2]
The series has been simplified to include only the 64 bit timestamp
changes as per Dave Chinner’s suggestion.
Motivation
The problem is how to change the vfs inode timestamps to use 64 bit
times to overcome the 2038 problem.
Below table [3] gives an overview of the extent/ type of changes
needed of changes needed.
The series is aimed at obtaining small manageable patches for all
the cases in [3].
Table [3]
Terminology: vfs_time – data type of timestamps used in the vfs layer.
Access type # of instances
1. timespec_*(struct vfs_time, struct timespec) / 34
timespec_*(struct vfs_time, struct vfs_time)
2. struct vfs_time = struct vfs_time 50
3. vfs_time = current_fs_time/ CURRENT_TIME/ CURRENT_TIME_SEC 312
4. setattr vfs_time assignments 141
5. vfs_time = other data types, outside of setattr() (timespec, s32, s64..) 74
6. other data types, outside of getattr() (timespec, s32, s64..) = vfs_time 85
7. internal individual fs funtions using inode timestamps as args 80
8. extra timestamp fields in individual filesystems ~10
9. VFS callback - int (*update_time)(struct inode *, struct timespec *, int) 3
10. VFS function - void lease_get_mtime(struct inode *inode, struct timespec *time) 3
Each series is used to demonstrate how each of the above cases is solved
using their respective approaches. The example filesystems (btrfs,
xfs, cifs, and ceph) were selected in such a way so as to showcase all
these issues in table [3].
Source Tree
The tree is hosted at github.com/deepa-hub/vfs.git
The branches for the three approaches are
2a. https://github.com/deepa-hub/vfs.git refs/heads/vfs_time
2b. https://github.com/deepa-hub/vfs.git refs/heads/vfs_time_to_timespec
2c. https://github.com/deepa-hub/vfs.git refs/heads/vfs_time_to_ts64
All the above series are based off of:
https://lkml.org/lkml/2016/2/3/34 [4]
and a couple of other patches.
Only the minimal changes are posted here to keep the series simple.
There are a couple of bug fixes like data type conversion bugs that will
be sent directly to the corresponding filesystem lists.
Next steps
The approaches 2a, 2b and 2c are posted as responses to this cover letter.
Testing
All the approaches have been compile tested only.
Arnd,
This one I've had no response.
Shall I just do RESEND to maintainers?
I don't see a special tree listed in the maintainers file so is it ok
that I built this on staging-testing?
If I need to rebase it, is it a RESEND or a new send. Does that
question make sense?
Thanks,
alisons
----- Forwarded message from Alison Schofield <amsfield22(a)gmail.com> -----
Date: Mon, 4 Jan 2016 11:12:24 -0800
From: Alison Schofield <amsfield22(a)gmail.com>
To: jbottomley(a)odin.com
Subject: gdth reviewer/maintainer ?
User-Agent: Mutt/1.5.23 (2014-03-12)
James,
email to Achim is bouncing. Is there another reviewer I should send
this patch to? (Arnd has reviewed for y2038 group)
Thanks,
Alison
----- Forwarded message from Alison Schofield <amsfield22(a)gmail.com> -----
Date: Tue, 24 Nov 2015 16:44:07 -0800
From: Alison Schofield <amsfield22(a)gmail.com>
To: achim_leubner(a)adaptec.com, JBottomley(a)odin.com, linux-scsi(a)vger.kernel.org,
linux-kernel(a)vger.kernel.org, y2038(a)lists.linaro.org
Subject: [PATCH v2] scsi: gdth: replace struct timeval with
ktime_get_real_seconds()
X-Mailer: git-send-email 2.1.4
struct timeval will overflow on 32-bit systems in y2038 and is being
removed from the kernel. Replace the use of struct timeval and
----- Forwarded message from David Miller <davem(a)davemloft.net> -----
Date: Sun, 17 Jan 2016 19:27:17 -0500 (EST)
From: David Miller <davem(a)davemloft.net>
To: amsfield22(a)gmail.com
Cc: mac(a)melware.de, isdn(a)linux-pingi.de, netdev(a)vger.kernel.org,
linux-kernel(a)vger.kernel.org, y2038(a)lists.linaro.org
Subject: Re: [PATCH v3] isdn: divamnt: use y2038-safe ktime_get_ts64() for
trace data timestamps
X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO)
From: Alison Schofield <amsfield22(a)gmail.com>
Date: Fri, 15 Jan 2016 08:51:25 -0800
> divamnt stores a start_time at module init and uses it to calculate
> elapsed time. The elapsed time, stored in secs and usecs, is part of
...............snip
>
> Signed-off-by: Alison Schofield <amsfield22(a)gmail.com>
> Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
Please resubmit this when the net-next tree is open again.
Thank you.
----- End forwarded message -----
Arnd,
How do I know when the net-next tree is open?
And, I guess I need to rebase this on the net-next tree before I resend
- right?
Thanks!
Alison
Hi,
I was just going through your website and I see that your company is dealing
with open source software
So, would you be interested to acquire a list of Canonical and Ubuntu End
Users for your marketing initiatives.
We can also help you with the users' database of:
. Redhat
. Linux.
. Centos
. Mint
. Windows and more.
Information fields: Contact First Name, Last Name, Job Title, Email Address,
Phone Number, Fax Number, Company Name, Company Physical Address, and
Company Web Address, SIC Code, NAICS code, Primary Industry, Employee Size,
Revenue, Technology Type
Let me know if you are focused on any particular titles and application
users so that I can get back to you with all the relevant details.
Thank you & look forward to hearing from you.
Regards,
Tania Cuevas - Sr. Marketing Executive
___________________________________________________________________________
We respect your privacy. If you do not wish to receive future e-mail please
reply with "REMOVE
This patch replaces timeval with timespec64 as 32 bit 'struct timeval'
will not give current time beyond year 2038.
The patch changes the code to use ktime_get_real_ts64() which returns
a 'struct timespec64' instead of do_gettimeofday() which returns a
'struct timeval'
This patch also alters the format strings in sprintf() for now.tv_sec
and now.tv_nsec to incorporate 'long long' on 32 bit architectures and
leading zeroes respectively.
Signed-off-by: Amitoj Kaur Chawla <amitoj1606(a)gmail.com>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
---
Changes in v2:
-change format string of now.tv_sec to '%llu'
-change format string of now.tv_nsec to '%.08lu'
Changes in v3:
-Replace tv_usec with tv_nsec, error made in v2
-Build tested
Changes in v4:
-Removed checkpatch.pl errors
drivers/misc/ibmasm/ibmasm.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
index 9b08344..25be44e 100644
--- a/drivers/misc/ibmasm/ibmasm.h
+++ b/drivers/misc/ibmasm/ibmasm.h
@@ -34,6 +34,7 @@
#include <linux/kref.h>
#include <linux/device.h>
#include <linux/input.h>
+#include <linux/time64.h>
/* Driver identification */
#define DRIVER_NAME "ibmasm"
@@ -53,9 +54,11 @@ extern int ibmasm_debug;
static inline char *get_timestamp(char *buf)
{
- struct timeval now;
- do_gettimeofday(&now);
- sprintf(buf, "%lu.%lu", now.tv_sec, now.tv_usec);
+ struct timespec64 now;
+
+ ktime_get_real_ts64(&now);
+ sprintf(buf, "%llu.%.08lu", (long long)now.tv_sec,
+ now.tv_nsec / NSEC_PER_USEC);
return buf;
}
--
1.9.1