]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nfsd: fix jiffies/time_t mixup in LRU list
authorArnd Bergmann <arnd@arndb.de>
Mon, 4 Nov 2019 13:43:17 +0000 (14:43 +0100)
committerJ. Bruce Fields <bfields@redhat.com>
Thu, 19 Dec 2019 22:46:08 +0000 (17:46 -0500)
The nfsd4_blocked_lock->nbl_time timestamp is recorded in jiffies,
but then compared to a CLOCK_REALTIME timestamp later on, which makes
no sense.

For consistency with the other timestamps, change this to use a time_t.

This is a change in behavior, which may cause regressions, but the
current code is not sensible. On a system with CONFIG_HZ=1000,
the 'time_after((unsigned long)nbl->nbl_time, (unsigned long)cutoff))'
check is false for roughly the first 18 days of uptime and then true
for the next 49 days.

Fixes: ed14119eca18 ("nfsd: add a LRU list for blocked locks")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c
fs/nfsd/state.h

index 36bbb18abf7755b8dac7f40d3d066f609cfdd564..f680b1530f3842de53b678062a5d1482bf394d56 100644 (file)
@@ -6700,7 +6700,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        }
 
        if (fl_flags & FL_SLEEP) {
-               nbl->nbl_time = jiffies;
+               nbl->nbl_time = get_seconds();
                spin_lock(&nn->blocked_locks_lock);
                list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked);
                list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru);
index 6cf4420337865a93538ee34f40fbb02810d5192a..df6bd2cb257f81d96e28cdadc4a77b6094e27a3a 100644 (file)
@@ -626,7 +626,7 @@ static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b)
 struct nfsd4_blocked_lock {
        struct list_head        nbl_list;
        struct list_head        nbl_lru;
-       unsigned long           nbl_time;
+       time_t                  nbl_time;
        struct file_lock        nbl_lock;
        struct knfsd_fh         nbl_fh;
        struct nfsd4_callback   nbl_cb;