Commit 6cff5732 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Richard Weinberger

ubifs: tnc: use monotonic znode timestamp

The tnc uses get_seconds() based timestamps to check the age of a znode,
which has two problems: on 32-bit architectures this may overflow in
2038 or 2106, and it gives incorrect information when the system time
is updated using settimeofday().

Using montonic timestamps with ktime_get_seconds() solves both thes
problems.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 0eca0b80
...@@ -71,7 +71,7 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention) ...@@ -71,7 +71,7 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention)
{ {
int total_freed = 0; int total_freed = 0;
struct ubifs_znode *znode, *zprev; struct ubifs_znode *znode, *zprev;
int time = get_seconds(); time64_t time = ktime_get_seconds();
ubifs_assert(mutex_is_locked(&c->umount_mutex)); ubifs_assert(mutex_is_locked(&c->umount_mutex));
ubifs_assert(mutex_is_locked(&c->tnc_mutex)); ubifs_assert(mutex_is_locked(&c->tnc_mutex));
......
...@@ -1179,7 +1179,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, ...@@ -1179,7 +1179,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key,
{ {
int err, exact; int err, exact;
struct ubifs_znode *znode; struct ubifs_znode *znode;
unsigned long time = get_seconds(); time64_t time = ktime_get_seconds();
dbg_tnck(key, "search key "); dbg_tnck(key, "search key ");
ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY);
...@@ -1315,7 +1315,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key, ...@@ -1315,7 +1315,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key,
{ {
int err, exact; int err, exact;
struct ubifs_znode *znode; struct ubifs_znode *znode;
unsigned long time = get_seconds(); time64_t time = ktime_get_seconds();
dbg_tnck(key, "search and dirty key "); dbg_tnck(key, "search and dirty key ");
......
...@@ -435,7 +435,7 @@ struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c, ...@@ -435,7 +435,7 @@ struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c,
zbr->znode = znode; zbr->znode = znode;
znode->parent = parent; znode->parent = parent;
znode->time = get_seconds(); znode->time = ktime_get_seconds();
znode->iip = iip; znode->iip = iip;
return znode; return znode;
......
...@@ -758,7 +758,7 @@ struct ubifs_znode { ...@@ -758,7 +758,7 @@ struct ubifs_znode {
struct ubifs_znode *parent; struct ubifs_znode *parent;
struct ubifs_znode *cnext; struct ubifs_znode *cnext;
unsigned long flags; unsigned long flags;
unsigned long time; time64_t time;
int level; int level;
int child_cnt; int child_cnt;
int iip; int iip;
......
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