aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2015-12-20 18:51:01 -0500
committerNeilBrown <neilb@suse.com>2016-01-05 19:39:53 -0500
commit9ebc6ef188a0656f3620835f9be7fe22c1644c1c (patch)
tree08ac1b7cc613d6afef042e97efe281956dafe482
parent3312c951efaba55080958974047414576b9e5d63 (diff)
drivers: md: use ktime_get_real_seconds()
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 <deepa.kernel@gmail.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: NeilBrown <neilb@suse.com>
-rw-r--r--drivers/md/md.c18
-rw-r--r--drivers/md/md.h2
-rw-r--r--include/uapi/linux/raid/md_u.h4
3 files changed, 12 insertions, 12 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3d70d0d11b95..d0f0621bf9b0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1200,13 +1200,13 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev)
1200 memcpy(&sb->set_uuid2, mddev->uuid+8, 4); 1200 memcpy(&sb->set_uuid2, mddev->uuid+8, 4);
1201 memcpy(&sb->set_uuid3, mddev->uuid+12,4); 1201 memcpy(&sb->set_uuid3, mddev->uuid+12,4);
1202 1202
1203 sb->ctime = mddev->ctime; 1203 sb->ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
1204 sb->level = mddev->level; 1204 sb->level = mddev->level;
1205 sb->size = mddev->dev_sectors / 2; 1205 sb->size = mddev->dev_sectors / 2;
1206 sb->raid_disks = mddev->raid_disks; 1206 sb->raid_disks = mddev->raid_disks;
1207 sb->md_minor = mddev->md_minor; 1207 sb->md_minor = mddev->md_minor;
1208 sb->not_persistent = 0; 1208 sb->not_persistent = 0;
1209 sb->utime = mddev->utime; 1209 sb->utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
1210 sb->state = 0; 1210 sb->state = 0;
1211 sb->events_hi = (mddev->events>>32); 1211 sb->events_hi = (mddev->events>>32);
1212 sb->events_lo = (u32)mddev->events; 1212 sb->events_lo = (u32)mddev->events;
@@ -1547,8 +1547,8 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
1547 mddev->patch_version = 0; 1547 mddev->patch_version = 0;
1548 mddev->external = 0; 1548 mddev->external = 0;
1549 mddev->chunk_sectors = le32_to_cpu(sb->chunksize); 1549 mddev->chunk_sectors = le32_to_cpu(sb->chunksize);
1550 mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1); 1550 mddev->ctime = le64_to_cpu(sb->ctime);
1551 mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1); 1551 mddev->utime = le64_to_cpu(sb->utime);
1552 mddev->level = le32_to_cpu(sb->level); 1552 mddev->level = le32_to_cpu(sb->level);
1553 mddev->clevel[0] = 0; 1553 mddev->clevel[0] = 0;
1554 mddev->layout = le32_to_cpu(sb->layout); 1554 mddev->layout = le32_to_cpu(sb->layout);
@@ -2336,7 +2336,7 @@ repeat:
2336 2336
2337 spin_lock(&mddev->lock); 2337 spin_lock(&mddev->lock);
2338 2338
2339 mddev->utime = get_seconds(); 2339 mddev->utime = ktime_get_real_seconds();
2340 2340
2341 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) 2341 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
2342 force_change = 1; 2342 force_change = 1;
@@ -5843,7 +5843,7 @@ static int get_array_info(struct mddev *mddev, void __user *arg)
5843 info.major_version = mddev->major_version; 5843 info.major_version = mddev->major_version;
5844 info.minor_version = mddev->minor_version; 5844 info.minor_version = mddev->minor_version;
5845 info.patch_version = MD_PATCHLEVEL_VERSION; 5845 info.patch_version = MD_PATCHLEVEL_VERSION;
5846 info.ctime = mddev->ctime; 5846 info.ctime = clamp_t(time64_t, mddev->ctime, 0, U32_MAX);
5847 info.level = mddev->level; 5847 info.level = mddev->level;
5848 info.size = mddev->dev_sectors / 2; 5848 info.size = mddev->dev_sectors / 2;
5849 if (info.size != mddev->dev_sectors / 2) /* overflow */ 5849 if (info.size != mddev->dev_sectors / 2) /* overflow */
@@ -5853,7 +5853,7 @@ static int get_array_info(struct mddev *mddev, void __user *arg)
5853 info.md_minor = mddev->md_minor; 5853 info.md_minor = mddev->md_minor;
5854 info.not_persistent= !mddev->persistent; 5854 info.not_persistent= !mddev->persistent;
5855 5855
5856 info.utime = mddev->utime; 5856 info.utime = clamp_t(time64_t, mddev->utime, 0, U32_MAX);
5857 info.state = 0; 5857 info.state = 0;
5858 if (mddev->in_sync) 5858 if (mddev->in_sync)
5859 info.state = (1<<MD_SB_CLEAN); 5859 info.state = (1<<MD_SB_CLEAN);
@@ -6353,13 +6353,13 @@ static int set_array_info(struct mddev *mddev, mdu_array_info_t *info)
6353 /* ensure mddev_put doesn't delete this now that there 6353 /* ensure mddev_put doesn't delete this now that there
6354 * is some minimal configuration. 6354 * is some minimal configuration.
6355 */ 6355 */
6356 mddev->ctime = get_seconds(); 6356 mddev->ctime = ktime_get_real_seconds();
6357 return 0; 6357 return 0;
6358 } 6358 }
6359 mddev->major_version = MD_MAJOR_VERSION; 6359 mddev->major_version = MD_MAJOR_VERSION;
6360 mddev->minor_version = MD_MINOR_VERSION; 6360 mddev->minor_version = MD_MINOR_VERSION;
6361 mddev->patch_version = MD_PATCHLEVEL_VERSION; 6361 mddev->patch_version = MD_PATCHLEVEL_VERSION;
6362 mddev->ctime = get_seconds(); 6362 mddev->ctime = ktime_get_real_seconds();
6363 6363
6364 mddev->level = info->level; 6364 mddev->level = info->level;
6365 mddev->clevel[0] = 0; 6365 mddev->clevel[0] = 0;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 8817e623258a..e16a17c37418 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -264,7 +264,7 @@ struct mddev {
264 * managed externally */ 264 * managed externally */
265 char metadata_type[17]; /* externally set*/ 265 char metadata_type[17]; /* externally set*/
266 int chunk_sectors; 266 int chunk_sectors;
267 time_t ctime, utime; 267 time64_t ctime, utime;
268 int level, layout; 268 int level, layout;
269 char clevel[16]; 269 char clevel[16];
270 int raid_disks; 270 int raid_disks;
diff --git a/include/uapi/linux/raid/md_u.h b/include/uapi/linux/raid/md_u.h
index 1cb8aa6850b5..36cd8210a5d1 100644
--- a/include/uapi/linux/raid/md_u.h
+++ b/include/uapi/linux/raid/md_u.h
@@ -80,7 +80,7 @@ typedef struct mdu_array_info_s {
80 int major_version; 80 int major_version;
81 int minor_version; 81 int minor_version;
82 int patch_version; 82 int patch_version;
83 int ctime; 83 unsigned int ctime;
84 int level; 84 int level;
85 int size; 85 int size;
86 int nr_disks; 86 int nr_disks;
@@ -91,7 +91,7 @@ typedef struct mdu_array_info_s {
91 /* 91 /*
92 * Generic state information 92 * Generic state information
93 */ 93 */
94 int utime; /* 0 Superblock update time */ 94 unsigned int utime; /* 0 Superblock update time */
95 int state; /* 1 State bits (clean, ...) */ 95 int state; /* 1 State bits (clean, ...) */
96 int active_disks; /* 2 Number of currently active disks */ 96 int active_disks; /* 2 Number of currently active disks */
97 int working_disks; /* 3 Number of working disks */ 97 int working_disks; /* 3 Number of working disks */