Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: fix jiffies/time_t mixup in LRU list

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: 7919d0a27f1e ("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>

authored by

Arnd Bergmann and committed by
J. Bruce Fields
9594497f 2561c92b

+2 -2
+1 -1
fs/nfsd/nfs4state.c
··· 6700 6700 } 6701 6701 6702 6702 if (fl_flags & FL_SLEEP) { 6703 - nbl->nbl_time = jiffies; 6703 + nbl->nbl_time = get_seconds(); 6704 6704 spin_lock(&nn->blocked_locks_lock); 6705 6705 list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked); 6706 6706 list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru);
+1 -1
fs/nfsd/state.h
··· 626 626 struct nfsd4_blocked_lock { 627 627 struct list_head nbl_list; 628 628 struct list_head nbl_lru; 629 - unsigned long nbl_time; 629 + time_t nbl_time; 630 630 struct file_lock nbl_lock; 631 631 struct knfsd_fh nbl_fh; 632 632 struct nfsd4_callback nbl_cb;