Re: [Y2038] [PATCH v3] scsi: pmcraid: replace struct timeval with ktime_get_real_seconds()

2015-11-11 Thread Martin K. Petersen
> "Alison" == Alison Schofield  writes:

Alison> Replace the use of struct timeval and do_gettimeofday() with 64
Alison> bit ktime_get_real_seconds. Prevents 32-bit type overflow in
Alison> year 2038 on 32-bit systems.

Applied.

-- 
Martin K. Petersen  Oracle Linux Engineering
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [RESEND PATCH] mpt2sas: Remove usage of 'struct timeval'

2015-11-11 Thread Martin K. Petersen
> "Tina" == Tina Ruchandani  writes:

Tina,

Tina> 'struct timeval' will have its tv_sec value overflow on 32-bit
Tina> systems in year 2038 and beyond. This patch replaces the use of
Tina> struct timeval for computing mpi_request.TimeStamp, and instead
Tina> uses ktime_t which provides 64-bit seconds value. The timestamp
Tina> computed remains unaffected (milliseconds since Unix epoch).

We just consolidated the mpt2sas and mpt3sas drivers into one so I'm
afraid your time tweaks will have to be rebased. I encourage you repost
in a couple of weeks after the merge window dust settles.

Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH] drivers: md: use ktime_get_real_seconds()

2015-11-11 Thread Deepa Dinamani
get_seconds() API is not y2038 safe on 32 bit systems and the API
is deprecated. Replace it with calls to ktime_get_real_seconds()
API instead. Change mddev structure types to time64_t accordingly.

32 bit signed timestamps will overflow in the year 2038.

Change the user interface mdu_array_info_s structure timestamps:
ctime and utime values used in ioctls GET_ARRAY_INFO and
SET_ARRAY_INFO to unsigned int. This will extend the field to last
until the year 2106.
The long term plan is to get rid of ctime and utime values in
this structure as this information can be read from the on-disk
meta data directly.

Clamp the tim64_t timestamps to positive values with a max of U32_MAX
when returning from GET_ARRAY_INFO ioctl to accommodate above changes
in the data type of timestamps to unsigned int.

v0.90 on disk meta data uses u32 for maintaining time stamps.
So this will also last until year 2106.
Assumption is that the usage of v0.90 will be deprecated by
year 2106.

Timestamp fields in the on disk meta data for v1.0 version already
use 64 bit data types. Remove the truncation of the bits while
writing to or reading from these from the disk.

Signed-off-by: Deepa Dinamani 
---

Notes:
A separate patch will update mdadm to obtain times from the metadata,
and to give a deprecation warning for use of v0.90 arrays

 drivers/md/md.c| 18 +-
 drivers/md/md.h|  2 +-
 include/uapi/linux/raid/md_u.h |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7ab9ed9..20763ea 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1196,13 +1196,13 @@ static void super_90_sync(struct mddev *mddev, struct 
md_rdev *rdev)
memcpy(>set_uuid2, mddev->uuid+8, 4);
memcpy(>set_uuid3, mddev->uuid+12,4);
 
-   sb->ctime = mddev->ctime;
+   sb->ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
sb->level = mddev->level;
sb->size = mddev->dev_sectors / 2;
sb->raid_disks = mddev->raid_disks;
sb->md_minor = mddev->md_minor;
sb->not_persistent = 0;
-   sb->utime = mddev->utime;
+   sb->utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
sb->state = 0;
sb->events_hi = (mddev->events>>32);
sb->events_lo = (u32)mddev->events;
@@ -1542,8 +1542,8 @@ static int super_1_validate(struct mddev *mddev, struct 
md_rdev *rdev)
mddev->patch_version = 0;
mddev->external = 0;
mddev->chunk_sectors = le32_to_cpu(sb->chunksize);
-   mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1);
-   mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1);
+   mddev->ctime = le64_to_cpu(sb->ctime);
+   mddev->utime = le64_to_cpu(sb->utime);
mddev->level = le32_to_cpu(sb->level);
mddev->clevel[0] = 0;
mddev->layout = le32_to_cpu(sb->layout);
@@ -2331,7 +2331,7 @@ repeat:
 
spin_lock(>lock);
 
-   mddev->utime = get_seconds();
+   mddev->utime = ktime_get_real_seconds();
 
if (test_and_clear_bit(MD_CHANGE_DEVS, >flags))
force_change = 1;
@@ -5828,7 +5828,7 @@ static int get_array_info(struct mddev *mddev, void 
__user *arg)
info.major_version = mddev->major_version;
info.minor_version = mddev->minor_version;
info.patch_version = MD_PATCHLEVEL_VERSION;
-   info.ctime = mddev->ctime;
+   info.ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
info.level = mddev->level;
info.size  = mddev->dev_sectors / 2;
if (info.size != mddev->dev_sectors / 2) /* overflow */
@@ -5838,7 +5838,7 @@ static int get_array_info(struct mddev *mddev, void 
__user *arg)
info.md_minor  = mddev->md_minor;
info.not_persistent= !mddev->persistent;
 
-   info.utime = mddev->utime;
+   info.utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
info.state = 0;
if (mddev->in_sync)
info.state = (1<ctime = get_seconds();
+   mddev->ctime = ktime_get_real_seconds();
return 0;
}
mddev->major_version = MD_MAJOR_VERSION;
mddev->minor_version = MD_MINOR_VERSION;
mddev->patch_version = MD_PATCHLEVEL_VERSION;
-   mddev->ctime = get_seconds();
+   mddev->ctime = ktime_get_real_seconds();
 
mddev->level = info->level;
mddev->clevel[0] = 0;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index f5b9aad..237b507 100644
--- 

Re: [Y2038] [RESEND PATCH] [SCSI] mvumi: 64bit value for seconds_since1970

2015-11-11 Thread Martin K. Petersen
> "Tina" == Tina Ruchandani  writes:

Tina> struct mvumi_hs_page2 stores a "seconds_since1970" field which is
Tina> of type u64. It is however, written to, using 'struct timeval'
Tina> which has a 32-bit seconds field and whose value will overflow in
Tina> year 2038.  This patch uses ktime_get_real_seconds() instead since
Tina> it provides a 64-bit seconds value, which is 2038 safe.

Under normal circumstances I would like a driver owner signoff but it
doesn't look like mvumi gets much attention. Applied.

-- 
Martin K. Petersen  Oracle Linux Engineering
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038