Commit 34e06fe4 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David Howells

cachefiles: avoid deprecated get_seconds()

get_seconds() returns an unsigned long can overflow on some architectures
and is deprecated because of that. In cachefs, we cast that number to
a a 32-bit integer, which will overflow in year 2106 on all architectures.

As confirmed by David Howells, the overflow probably isn't harmful
in the end, since the timestamps are only used to make the file names
unique, but they don't strictly have to be in monotonically increasing
order since the files only exist in order to be deleted as quickly
as possible.

Moving to ktime_get_real_seconds() avoids the deprecated interface.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent b7e768b7
...@@ -338,7 +338,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache, ...@@ -338,7 +338,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
try_again: try_again:
/* first step is to make up a grave dentry in the graveyard */ /* first step is to make up a grave dentry in the graveyard */
sprintf(nbuffer, "%08x%08x", sprintf(nbuffer, "%08x%08x",
(uint32_t) get_seconds(), (uint32_t) ktime_get_real_seconds(),
(uint32_t) atomic_inc_return(&cache->gravecounter)); (uint32_t) atomic_inc_return(&cache->gravecounter));
/* do the multiway lock magic */ /* do the multiway lock magic */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment