NetBSD Problem Report #37126

From dholland@eecs.harvard.edu  Sat Oct 13 22:40:13 2007
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 7F67763B8FE
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 13 Oct 2007 22:40:13 +0000 (UTC)
Message-Id: <20071013212234.B67A6FA39@tanaqui.eecs.harvard.edu>
Date: Sat, 13 Oct 2007 17:22:34 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@NetBSD.org
Subject: Bogus tty idle times
X-Send-Pr-Version: 3.95

>Number:         37126
>Category:       kern
>Synopsis:       Bogus tty idle times
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 13 22:45:00 +0000 2007
>Closed-Date:    Thu May 06 08:03:22 +0000 2021
>Last-Modified:  Thu May 06 08:03:22 +0000 2021
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Release:        NetBSD 2.99.something through 4.99.31 (20071005)
>Organization:
   EECS
>Environment:
System: NetBSD tanaqui 4.99.31 NetBSD 4.99.31 (TANAQUI) #19: Tue Sep 11 19:46:35 EDT 2007 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:

Tty idle times reported by w(1), finger(1), and other tools are
frequently 0 when they should not be. This results in tty messages
going to the wrong tty, and also gives false information about whether
users are around or not - this is particularly irritating on a
multiuser machine where the users know each other or work together or
the like.

This started happening sometime after 2.0 and before 3.0; I've only
just finally gotten around to digging out exactly what's wrong.

The problem is that the code for deferring atime (and mtime, but it's
atime that matters here) updates only sets a flag saying that atime
needs to be updated; it doesn't save the time to apply. When the
update is flushed later, the current time is (generally) used.

When a tty is idle, nothing much is going to cause a pending atime
update to be applied until someone goes to stat it, as is done by w(1)
for the purpose of computing idle times. The stat call flushes the
times; then the current time is applied, and poof, the tty comes up
with a zero idle time, even if the person using it went home for the
weekend hours or days previously.

>How-To-Repeat:

Log in a bunch of times, idle for a while, and use w. It's not always
easy to trigger the problem on demand, but it happens pretty regularly
if you do this a lot.

>Fix:

Deferred time updates should really store the time to be applied.
This could be done by sticking the time in memory somewhere, or by
changing the way the feature works so the time is applied to the inode
but not written to disk, or possibly other ways. None of these
alternatives is exactly trivial, so someone (else) needs to decide
what approach to take.

It might also be useful to at the same time reduce the number of
places where the time updates are flushed to disk; for example, if one
has the time values available there's no real reason to flush on stat.

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 06 May 2021 08:03:22 +0000
State-Changed-Why:
this finally got fixed (some time back) though required multiple rounds
before it fully went away.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: gnats-precook-prs,v 1.4 2018/12/21 14:20:20 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.