Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:GA
mdadm.5365
0132-mdadm-Change-timestamps-to-unsigned-data-t...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0132-mdadm-Change-timestamps-to-unsigned-data-type.patch of Package mdadm.5365
From 26714713cd2bad9e0bf7f4669f6cc4659ceaab6c Mon Sep 17 00:00:00 2001 From: Deepa Dinamani <deepa.kernel@gmail.com> Date: Tue, 8 Dec 2015 15:10:21 -0800 Subject: [PATCH 187/359] mdadm: Change timestamps to unsigned data type. References: bsc#1081910 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. Add time_after/time_before and supporting typecheck from the kernel to take care of unsigned time wraparound. 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. 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. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Coly Li <colyli@suse.de> --- Grow.c | 4 ++-- md_u.h | 4 ++-- mdadm.h | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) mode change 100644 => 100755 Grow.c mode change 100644 => 100755 mdadm.h diff --git a/Grow.c b/Grow.c old mode 100644 new mode 100755 index 80d7b22..ee48c36 --- a/Grow.c +++ b/Grow.c @@ -4503,8 +4503,8 @@ int Grow_restart(struct supertype *st, struct mdinfo *info, int *fdlist, int cnt * sometimes they aren't... So allow considerable flexability in matching, and allow * this test to be overridden by an environment variable. */ - if (info->array.utime > (int)__le64_to_cpu(bsb.mtime) + 2*60*60 || - info->array.utime < (int)__le64_to_cpu(bsb.mtime) - 10*60) { + if(time_after(info->array.utime, (unsigned int)__le64_to_cpu(bsb.mtime) + 2*60*60) || + time_before(info->array.utime, (unsigned int)__le64_to_cpu(bsb.mtime) - 10*60)) { if (check_env("MDADM_GROW_ALLOW_OLD")) { pr_err("accepting backup with timestamp %lu for array with timestamp %lu\n", (unsigned long)__le64_to_cpu(bsb.mtime), diff --git a/md_u.h b/md_u.h index 76068d6..f570a34 100644 --- a/md_u.h +++ b/md_u.h @@ -59,7 +59,7 @@ typedef struct mdu_array_info_s { int major_version; int minor_version; int patch_version; - int ctime; + unsigned int ctime; int level; int size; int nr_disks; @@ -70,7 +70,7 @@ typedef struct mdu_array_info_s { /* * Generic state information */ - int utime; /* 0 Superblock update time */ + unsigned int utime; /* 0 Superblock update time */ int state; /* 1 State bits (clean, ...) */ int active_disks; /* 2 Number of currently active disks */ int working_disks; /* 3 Number of working disks */ diff --git a/mdadm.h b/mdadm.h old mode 100644 new mode 100755 index 5d5e97f..840a359 --- a/mdadm.h +++ b/mdadm.h @@ -188,6 +188,31 @@ struct dlm_lksb { #endif #endif /* __KLIBC__ */ +/* + * Check at compile time that something is of a particular type. + * Always evaluates to 1 so you may use it easily in comparisons. +*/ + +#define typecheck(type,x) \ +({ type __dummy; \ + typeof(x) __dummy2; \ + (void)(&__dummy == &__dummy2); \ + 1; \ +}) + +/* + * These inlines deal with timer wrapping correctly. + * + * time_after(a,b) returns true if the time a is after time b. +*/ + +#define time_after(a,b) \ + (typecheck(unsigned int, a) && \ + typecheck(unsigned int, b) && \ + ((int)((b) - (a)) < 0)) + +#define time_before(a,b) time_after(b,a) + /* * min()/max()/clamp() macros that also do * strict type-checking.. See the -- 2.16.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor