linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] bcache: stop using the deprecated get_seconds()
@ 2018-06-22 13:48 Arnd Bergmann
  2018-06-23  8:12 ` Coly Li
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2018-06-22 13:48 UTC (permalink / raw)
  To: Coly Li, Kent Overstreet
  Cc: y2038, Arnd Bergmann, Jens Axboe, Michael Lyle, Tang Junhui,
	Hannes Reinecke, linux-bcache, linux-kernel

The get_seconds function is deprecated now since it returns a 32-bit
value that will eventually overflow, and we are replacing it throughout
the kernel with ktime_get_seconds() or ktime_get_real_seconds() that
return a time64_t.

bcache uses get_seconds() to read the current system time and store it in
the superblock as well as in uuid_entry structures that are user visible.

Unfortunately, the two structures in are still limited to 32 bits, so this
won't fix any real problems but will still overflow in year 2106. Let's
at least document that properly, in case we get an updated format in the
future it can be fixed. We still have a long time before the overflow
and checking the tools at https://github.com/koverstreet/bcache-tools
reveals no access to any of them.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/md/bcache/super.c   | 12 ++++++------
 include/uapi/linux/bcache.h |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index fa4058e43202..74746d8ee05e 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -181,7 +181,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
 		goto err;
 	}
 
-	sb->last_mount = get_seconds();
+	sb->last_mount = (u32)ktime_get_real_seconds();
 	err = NULL;
 
 	get_page(bh->b_page);
@@ -701,7 +701,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((u32)ktime_get_real_seconds());
 		bch_uuid_write(d->c);
 	}
 
@@ -1027,7 +1027,7 @@ void bch_cached_dev_detach(struct cached_dev *dc)
 int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 			  uint8_t *set_uuid)
 {
-	uint32_t rtime = cpu_to_le32(get_seconds());
+	uint32_t rtime = cpu_to_le32((u32)ktime_get_real_seconds());
 	struct uuid_entry *u;
 	struct cached_dev *exist_dc, *t;
 
@@ -1070,7 +1070,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((u32)ktime_get_real_seconds());
 		u = NULL;
 	}
 
@@ -1390,7 +1390,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((u32)ktime_get_real_seconds());
 
 	SET_UUID_FLASH_ONLY(u, 1);
 	u->sectors = size >> 9;
@@ -1894,7 +1894,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 = (u32)ktime_get_real_seconds();
 	bcache_write_super(c);
 
 	list_for_each_entry_safe(dc, t, &uncached_devices, list)
diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
index 821f71a2e48f..8d19e02d752a 100644
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -195,7 +195,7 @@ struct cache_sb {
 	};
 	};
 
-	__u32			last_mount;	/* time_t */
+	__u32			last_mount;	/* time overflow in y2106 */
 
 	__u16			first_bucket;
 	union {
@@ -318,7 +318,7 @@ struct uuid_entry {
 		struct {
 			__u8	uuid[16];
 			__u8	label[32];
-			__u32	first_reg;
+			__u32	first_reg; /* time overflow in y2106 */
 			__u32	last_reg;
 			__u32	invalidated;
 
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] [v2] bcache: stop using the deprecated get_seconds()
  2018-06-22 13:48 [PATCH] [v2] bcache: stop using the deprecated get_seconds() Arnd Bergmann
@ 2018-06-23  8:12 ` Coly Li
  2018-07-13 14:20   ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Coly Li @ 2018-06-23  8:12 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Kent Overstreet, y2038, Jens Axboe, Michael Lyle, Tang Junhui,
	Hannes Reinecke, linux-bcache, linux-kernel

On 2018/6/22 9:48 PM, Arnd Bergmann wrote:
> The get_seconds function is deprecated now since it returns a 32-bit
> value that will eventually overflow, and we are replacing it throughout
> the kernel with ktime_get_seconds() or ktime_get_real_seconds() that
> return a time64_t.
> 
> bcache uses get_seconds() to read the current system time and store it in
> the superblock as well as in uuid_entry structures that are user visible.
> 
> Unfortunately, the two structures in are still limited to 32 bits, so this
> won't fix any real problems but will still overflow in year 2106. Let's
> at least document that properly, in case we get an updated format in the
> future it can be fixed. We still have a long time before the overflow
> and checking the tools at https://github.com/koverstreet/bcache-tools
> reveals no access to any of them.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Added to 4.19 for-next.

Thanks.

Coly Li

> ---
>  drivers/md/bcache/super.c   | 12 ++++++------
>  include/uapi/linux/bcache.h |  4 ++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index fa4058e43202..74746d8ee05e 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -181,7 +181,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
>  		goto err;
>  	}
>  
> -	sb->last_mount = get_seconds();
> +	sb->last_mount = (u32)ktime_get_real_seconds();
>  	err = NULL;
>  
>  	get_page(bh->b_page);
> @@ -701,7 +701,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((u32)ktime_get_real_seconds());
>  		bch_uuid_write(d->c);
>  	}
>  
> @@ -1027,7 +1027,7 @@ void bch_cached_dev_detach(struct cached_dev *dc)
>  int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
>  			  uint8_t *set_uuid)
>  {
> -	uint32_t rtime = cpu_to_le32(get_seconds());
> +	uint32_t rtime = cpu_to_le32((u32)ktime_get_real_seconds());
>  	struct uuid_entry *u;
>  	struct cached_dev *exist_dc, *t;
>  
> @@ -1070,7 +1070,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((u32)ktime_get_real_seconds());
>  		u = NULL;
>  	}
>  
> @@ -1390,7 +1390,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((u32)ktime_get_real_seconds());
>  
>  	SET_UUID_FLASH_ONLY(u, 1);
>  	u->sectors = size >> 9;
> @@ -1894,7 +1894,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 = (u32)ktime_get_real_seconds();
>  	bcache_write_super(c);
>  
>  	list_for_each_entry_safe(dc, t, &uncached_devices, list)
> diff --git a/include/uapi/linux/bcache.h b/include/uapi/linux/bcache.h
> index 821f71a2e48f..8d19e02d752a 100644
> --- a/include/uapi/linux/bcache.h
> +++ b/include/uapi/linux/bcache.h
> @@ -195,7 +195,7 @@ struct cache_sb {
>  	};
>  	};
>  
> -	__u32			last_mount;	/* time_t */
> +	__u32			last_mount;	/* time overflow in y2106 */
>  
>  	__u16			first_bucket;
>  	union {
> @@ -318,7 +318,7 @@ struct uuid_entry {
>  		struct {
>  			__u8	uuid[16];
>  			__u8	label[32];
> -			__u32	first_reg;
> +			__u32	first_reg; /* time overflow in y2106 */
>  			__u32	last_reg;
>  			__u32	invalidated;
>  
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [v2] bcache: stop using the deprecated get_seconds()
  2018-06-23  8:12 ` Coly Li
@ 2018-07-13 14:20   ` Arnd Bergmann
  2018-07-13 15:34     ` Coly Li
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2018-07-13 14:20 UTC (permalink / raw)
  To: Coly Li
  Cc: Kent Overstreet, y2038 Mailman List, Jens Axboe, Michael Lyle,
	Tang Junhui, Hannes Reinecke, linux-bcache,
	Linux Kernel Mailing List

On Sat, Jun 23, 2018 at 10:12 AM, Coly Li <colyli@suse.de> wrote:
> On 2018/6/22 9:48 PM, Arnd Bergmann wrote:
>> The get_seconds function is deprecated now since it returns a 32-bit
>> value that will eventually overflow, and we are replacing it throughout
>> the kernel with ktime_get_seconds() or ktime_get_real_seconds() that
>> return a time64_t.
>>
>> bcache uses get_seconds() to read the current system time and store it in
>> the superblock as well as in uuid_entry structures that are user visible.
>>
>> Unfortunately, the two structures in are still limited to 32 bits, so this
>> won't fix any real problems but will still overflow in year 2106. Let's
>> at least document that properly, in case we get an updated format in the
>> future it can be fixed. We still have a long time before the overflow
>> and checking the tools at https://github.com/koverstreet/bcache-tools
>> reveals no access to any of them.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Added to 4.19 for-next.

I noticed this isn't part of linux-next (yet). Did it get dropped?

      Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [v2] bcache: stop using the deprecated get_seconds()
  2018-07-13 14:20   ` Arnd Bergmann
@ 2018-07-13 15:34     ` Coly Li
  2018-07-13 18:57       ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Coly Li @ 2018-07-13 15:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Kent Overstreet, y2038 Mailman List, Jens Axboe, Michael Lyle,
	Tang Junhui, Hannes Reinecke, linux-bcache,
	Linux Kernel Mailing List

On 2018/7/13 10:20 PM, Arnd Bergmann wrote:
> On Sat, Jun 23, 2018 at 10:12 AM, Coly Li <colyli@suse.de> wrote:
>> On 2018/6/22 9:48 PM, Arnd Bergmann wrote:
>>> The get_seconds function is deprecated now since it returns a 32-bit
>>> value that will eventually overflow, and we are replacing it throughout
>>> the kernel with ktime_get_seconds() or ktime_get_real_seconds() that
>>> return a time64_t.
>>>
>>> bcache uses get_seconds() to read the current system time and store it in
>>> the superblock as well as in uuid_entry structures that are user visible.
>>>
>>> Unfortunately, the two structures in are still limited to 32 bits, so this
>>> won't fix any real problems but will still overflow in year 2106. Let's
>>> at least document that properly, in case we get an updated format in the
>>> future it can be fixed. We still have a long time before the overflow
>>> and checking the tools at https://github.com/koverstreet/bcache-tools
>>> reveals no access to any of them.
>>>
>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>
>> Added to 4.19 for-next.
> 
> I noticed this isn't part of linux-next (yet). Did it get dropped?
> 
>       Arnd
> 
Hi Arnd,

It is here,
https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-patches.git/tree/for-next/0004-bcache-stop-using-the-deprecated-get_seconds.patch

It is for Linux v4.19, the merge window is not available yet, and I
don't post them to Jens yet.

Thanks.

Coly Li

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [v2] bcache: stop using the deprecated get_seconds()
  2018-07-13 15:34     ` Coly Li
@ 2018-07-13 18:57       ` Arnd Bergmann
  2018-07-13 19:38         ` Jens Axboe
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2018-07-13 18:57 UTC (permalink / raw)
  To: Coly Li
  Cc: Kent Overstreet, y2038 Mailman List, Jens Axboe, Michael Lyle,
	Tang Junhui, Hannes Reinecke, linux-bcache,
	Linux Kernel Mailing List

On Fri, Jul 13, 2018 at 5:34 PM, Coly Li <colyli@suse.de> wrote:
> On 2018/7/13 10:20 PM, Arnd Bergmann wrote:
>> On Sat, Jun 23, 2018 at 10:12 AM, Coly Li <colyli@suse.de> wrote:

>>> Added to 4.19 for-next.
>>
>> I noticed this isn't part of linux-next (yet). Did it get dropped?
>>
>>       Arnd
>>
> Hi Arnd,
>
> It is here,
> https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-patches.git/tree/for-next/0004-bcache-stop-using-the-deprecated-get_seconds.patch

Ok, thanks for the confirmation!

> It is for Linux v4.19, the merge window is not available yet, and I
> don't post them to Jens yet.

That sounds like an odd way to handle your patches. Normally all patches
should be part of linux-next *before* the merge window so they get tested
as part of the linux-next kernel before the pull request to Linus is sent.

It's not important for me for this particular patch, but generally speaking,
the Documentation/process/2.Process.rst states:

"all patches merged during a given merge window should really have found
their way into linux-next some time before the merge window opens."

      Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] [v2] bcache: stop using the deprecated get_seconds()
  2018-07-13 18:57       ` Arnd Bergmann
@ 2018-07-13 19:38         ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2018-07-13 19:38 UTC (permalink / raw)
  To: Arnd Bergmann, Coly Li
  Cc: Kent Overstreet, y2038 Mailman List, Michael Lyle, Tang Junhui,
	Hannes Reinecke, linux-bcache, Linux Kernel Mailing List

On 7/13/18 12:57 PM, Arnd Bergmann wrote:
> On Fri, Jul 13, 2018 at 5:34 PM, Coly Li <colyli@suse.de> wrote:
>> On 2018/7/13 10:20 PM, Arnd Bergmann wrote:
>>> On Sat, Jun 23, 2018 at 10:12 AM, Coly Li <colyli@suse.de> wrote:
> 
>>>> Added to 4.19 for-next.
>>>
>>> I noticed this isn't part of linux-next (yet). Did it get dropped?
>>>
>>>       Arnd
>>>
>> Hi Arnd,
>>
>> It is here,
>> https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-patches.git/tree/for-next/0004-bcache-stop-using-the-deprecated-get_seconds.patch
> 
> Ok, thanks for the confirmation!
> 
>> It is for Linux v4.19, the merge window is not available yet, and I
>> don't post them to Jens yet.
> 
> That sounds like an odd way to handle your patches. Normally all patches
> should be part of linux-next *before* the merge window so they get tested
> as part of the linux-next kernel before the pull request to Linus is sent.
> 
> It's not important for me for this particular patch, but generally speaking,
> the Documentation/process/2.Process.rst states:
> 
> "all patches merged during a given merge window should really have found
> their way into linux-next some time before the merge window opens."

Coly does generally send before the merge window, I think the phrasing
is just a little bit off. Depending on risk, I usually tell folks to
submit their stuff for the next window at no later than -rc5 time,
so it'll be in for-next for a least two weeks before the merge window
opens.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-13 19:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22 13:48 [PATCH] [v2] bcache: stop using the deprecated get_seconds() Arnd Bergmann
2018-06-23  8:12 ` Coly Li
2018-07-13 14:20   ` Arnd Bergmann
2018-07-13 15:34     ` Coly Li
2018-07-13 18:57       ` Arnd Bergmann
2018-07-13 19:38         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).