* [PATCH 1/2] md: bcache: Replace get_seconds with ktime_get_seconds
@ 2015-12-22 13:02 shraddha.6596
2015-12-22 13:26 ` Vojtech Pavlik
0 siblings, 1 reply; 2+ messages in thread
From: shraddha.6596 @ 2015-12-22 13:02 UTC (permalink / raw)
To: Neil Brown, Kent Overstreet; +Cc: linux-bcache, Arnd Bergmann, Shraddha Barke
From: Shraddha Barke <shraddha.6596@gmail.com>
32-bit systems using function get_seconds will break in the year 2038,
in order to avoid that replace the code with more appropriate
function ktime_get_seconds which is y2038 safe.
Function ktime_get_seconds is used since it uses monotonic instead of
real time and thus will not cause overflow.
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/md/bcache/super.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 679a093..f4bd17d 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -188,7 +188,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
goto err;
}
- sb->last_mount = get_seconds();
+ sb->last_mount = ktime_get_seconds();
err = NULL;
get_page(bh->b_page);
@@ -696,7 +696,7 @@ static void bcache_device_detach(struct bcache_device *d)
SET_UUID_FLASH_ONLY(u, 0);
memcpy(u->uuid, invalid_uuid, 16);
- u->invalidated = cpu_to_le32(get_seconds());
+ u->invalidated = cpu_to_le32(ktime_get_seconds());
bch_uuid_write(d->c);
}
@@ -927,7 +927,7 @@ void bch_cached_dev_detach(struct cached_dev *dc)
int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
{
- uint32_t rtime = cpu_to_le32(get_seconds());
+ uint32_t rtime = cpu_to_le32(ktime_get_seconds());
struct uuid_entry *u;
char buf[BDEVNAME_SIZE];
@@ -959,7 +959,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
(BDEV_STATE(&dc->sb) == BDEV_STATE_STALE ||
BDEV_STATE(&dc->sb) == BDEV_STATE_NONE)) {
memcpy(u->uuid, invalid_uuid, 16);
- u->invalidated = cpu_to_le32(get_seconds());
+ u->invalidated = cpu_to_le32(ktime_get_seconds());
u = NULL;
}
@@ -1261,7 +1261,7 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
get_random_bytes(u->uuid, 16);
memset(u->label, 0, 32);
- u->first_reg = u->last_reg = cpu_to_le32(get_seconds());
+ u->first_reg = u->last_reg = cpu_to_le32(ktime_get_seconds());
SET_UUID_FLASH_ONLY(u, 1);
u->sectors = size >> 9;
@@ -1670,7 +1670,7 @@ static void run_cache_set(struct cache_set *c)
goto err;
closure_sync(&cl);
- c->sb.last_mount = get_seconds();
+ c->sb.last_mount = ktime_get_seconds();
bcache_write_super(c);
list_for_each_entry_safe(dc, t, &uncached_devices, list)
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/2] md: bcache: Replace get_seconds with ktime_get_seconds
2015-12-22 13:02 [PATCH 1/2] md: bcache: Replace get_seconds with ktime_get_seconds shraddha.6596
@ 2015-12-22 13:26 ` Vojtech Pavlik
0 siblings, 0 replies; 2+ messages in thread
From: Vojtech Pavlik @ 2015-12-22 13:26 UTC (permalink / raw)
To: shraddha.6596; +Cc: Neil Brown, Kent Overstreet, linux-bcache, Arnd Bergmann
Hello Shraddha,
I don't think you can use ktime_get_seconds() for last_mount in the
superblock, since the superblock is persistent between reboots and the
monotonic time value doesn't make any sense on next reboot.
Vojtech
On Tue, Dec 22, 2015 at 06:32:59PM +0530, shraddha.6596@gmail.com wrote:
> From: Shraddha Barke <shraddha.6596@gmail.com>
>
> 32-bit systems using function get_seconds will break in the year 2038,
> in order to avoid that replace the code with more appropriate
> function ktime_get_seconds which is y2038 safe.
> Function ktime_get_seconds is used since it uses monotonic instead of
> real time and thus will not cause overflow.
>
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> drivers/md/bcache/super.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 679a093..f4bd17d 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -188,7 +188,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
> goto err;
> }
>
> - sb->last_mount = get_seconds();
> + sb->last_mount = ktime_get_seconds();
> err = NULL;
>
> get_page(bh->b_page);
> @@ -696,7 +696,7 @@ static void bcache_device_detach(struct bcache_device *d)
>
> SET_UUID_FLASH_ONLY(u, 0);
> memcpy(u->uuid, invalid_uuid, 16);
> - u->invalidated = cpu_to_le32(get_seconds());
> + u->invalidated = cpu_to_le32(ktime_get_seconds());
> bch_uuid_write(d->c);
> }
>
> @@ -927,7 +927,7 @@ void bch_cached_dev_detach(struct cached_dev *dc)
>
> int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
> {
> - uint32_t rtime = cpu_to_le32(get_seconds());
> + uint32_t rtime = cpu_to_le32(ktime_get_seconds());
> struct uuid_entry *u;
> char buf[BDEVNAME_SIZE];
>
> @@ -959,7 +959,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
> (BDEV_STATE(&dc->sb) == BDEV_STATE_STALE ||
> BDEV_STATE(&dc->sb) == BDEV_STATE_NONE)) {
> memcpy(u->uuid, invalid_uuid, 16);
> - u->invalidated = cpu_to_le32(get_seconds());
> + u->invalidated = cpu_to_le32(ktime_get_seconds());
> u = NULL;
> }
>
> @@ -1261,7 +1261,7 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
>
> get_random_bytes(u->uuid, 16);
> memset(u->label, 0, 32);
> - u->first_reg = u->last_reg = cpu_to_le32(get_seconds());
> + u->first_reg = u->last_reg = cpu_to_le32(ktime_get_seconds());
>
> SET_UUID_FLASH_ONLY(u, 1);
> u->sectors = size >> 9;
> @@ -1670,7 +1670,7 @@ static void run_cache_set(struct cache_set *c)
> goto err;
>
> closure_sync(&cl);
> - c->sb.last_mount = get_seconds();
> + c->sb.last_mount = ktime_get_seconds();
> bcache_write_super(c);
>
> list_for_each_entry_safe(dc, t, &uncached_devices, list)
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Vojtech Pavlik
Director SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-22 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-22 13:02 [PATCH 1/2] md: bcache: Replace get_seconds with ktime_get_seconds shraddha.6596
2015-12-22 13:26 ` Vojtech Pavlik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox