ZFS: clock_t overflow in l2arc_feed_thread

Artem Belevich fbsdlist at src.cx
Sat Jan 29 10:30:06 UTC 2011


Hi,

I'm using ZFS v15 on RELENG_8/amd64 box. Some time back I've noticed
that after a while ZFS starts to consume 100% of CPU time on one of
the cores. After a bit of digging it appears that the problem is due
to an integer overflow.

On amd64 (as wel as most other FreeBSD platforms) clock_t is a signed
32-bit integer. On OpenSolaris clock_t is long.

In compat/opensolaris/sys/time.h LBOLT is defined as
#define      LBOLT   ((gethrtime() * hz) / NANOSEC)

With HZ=1000 LBOLT overflows clock_t variables when uptime reaches
~24days. This affects l2arc_write_interval() which calculates the time
when L2ARC feed thread should be woken up. The end result is that for
the next 24 days l2arc_feed_thread no longer sleeps as long as it
should have.

Changing clock_t to a larger type globally looks somewhat risky to me.
It's probably easier to change those few places in ZFS code that use
clock_t to uint64_t instead.

In case someone is interested, I've posted my patch here:
http://pastebin.com/Q2T3x2AB

--Artem


More information about the freebsd-fs mailing list