From patchwork Tue Jun 19 03:01:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 10473019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C87160244 for ; Tue, 19 Jun 2018 03:03:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 881291FF1E for ; Tue, 19 Jun 2018 03:03:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CA1826D05; Tue, 19 Jun 2018 03:03:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 322B11FF1E for ; Tue, 19 Jun 2018 03:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935681AbeFSDC0 (ORCPT ); Mon, 18 Jun 2018 23:02:26 -0400 Received: from icp-osb-irony-out7.external.iinet.net.au ([203.59.1.107]:50319 "EHLO icp-osb-irony-out7.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755409AbeFSDCZ (ORCPT ); Mon, 18 Jun 2018 23:02:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2CPHABicShb/6c80XZcHQEBIgEGAYMxg?= =?us-ascii?q?ToVEiiDeZRWRgEBAQEBBoENNJRgFIFkHhgBhECCYSE1FwECAQEBAQEBAm0ohVI?= =?us-ascii?q?EUigBDAIYDgJJFhOFGAyqU4FpMxoCiC2BaIELh0mBDIEHgQ8whzmDGYJVAocyF?= =?us-ascii?q?4VXP4s3CY8JiBiFI5MPATaBUk0uCoJ+kFwyMHoBAZBSAQE?= X-IPAS-Result: =?us-ascii?q?A2CPHABicShb/6c80XZcHQEBIgEGAYMxgToVEiiDeZRWRgE?= =?us-ascii?q?BAQEBBoENNJRgFIFkHhgBhECCYSE1FwECAQEBAQEBAm0ohVIEUigBDAIYDgJJF?= =?us-ascii?q?hOFGAyqU4FpMxoCiC2BaIELh0mBDIEHgQ8whzmDGYJVAocyF4VXP4s3CY8JiBi?= =?us-ascii?q?FI5MPATaBUk0uCoJ+kFwyMHoBAZBSAQE?= X-IronPort-AV: E=Sophos;i="5.51,241,1526313600"; d="scan'208";a="90294621" Received: from unknown (HELO pluto.themaw.net) ([118.209.60.167]) by icp-osb-irony-out7.iinet.net.au with ESMTP; 19 Jun 2018 11:01:58 +0800 Subject: [PATCH 1/6] autofs - fix inconsistent use of now variable From: Ian Kent To: Andrew Morton Cc: linux-fsdevel , autofs mailing list , Kernel Mailing List Date: Tue, 19 Jun 2018 11:01:57 +0800 Message-ID: <152937731702.21213.7371321165189170865.stgit@pluto.themaw.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The global variable "now" in fs/autofs/expire.c is used in an inconsistent way, sometimes using jiffies directly, and sometimes using the "now" variable, and setting it isn't done consistently either. But the autofs dentry info last_used field is only updated during path walks or during expire so jiffies can be used directly and the global variable "now" removed. Signed-off-by: Ian Kent --- fs/autofs/expire.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/autofs/expire.c b/fs/autofs/expire.c index b332d3f6e730..295feec10ea6 100644 --- a/fs/autofs/expire.c +++ b/fs/autofs/expire.c @@ -10,8 +10,6 @@ #include "autofs_i.h" -static unsigned long now; - /* Check if a dentry can be expired */ static inline int autofs_can_expire(struct dentry *dentry, unsigned long timeout, int do_now) @@ -24,7 +22,7 @@ static inline int autofs_can_expire(struct dentry *dentry, if (!do_now) { /* Too young to die */ - if (!timeout || time_after(ino->last_used + timeout, now)) + if (!timeout || time_after(ino->last_used + timeout, jiffies)) return 0; } return 1; @@ -307,7 +305,6 @@ struct dentry *autofs_expire_direct(struct super_block *sb, if (!root) return NULL; - now = jiffies; timeout = sbi->exp_timeout; if (!autofs_direct_busy(mnt, root, timeout, do_now)) { @@ -442,7 +439,6 @@ struct dentry *autofs_expire_indirect(struct super_block *sb, if (!root) return NULL; - now = jiffies; timeout = sbi->exp_timeout; dentry = NULL; @@ -575,7 +571,7 @@ int autofs_expire_run(struct super_block *sb, spin_lock(&sbi->fs_lock); ino = autofs_dentry_ino(dentry); /* avoid rapid-fire expire attempts if expiry fails */ - ino->last_used = now; + ino->last_used = jiffies; ino->flags &= ~(AUTOFS_INF_EXPIRING|AUTOFS_INF_WANT_EXPIRE); complete_all(&ino->expire_complete); spin_unlock(&sbi->fs_lock); @@ -605,7 +601,7 @@ int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, spin_lock(&sbi->fs_lock); /* avoid rapid-fire expire attempts if expiry fails */ - ino->last_used = now; + ino->last_used = jiffies; ino->flags &= ~(AUTOFS_INF_EXPIRING|AUTOFS_INF_WANT_EXPIRE); complete_all(&ino->expire_complete); spin_unlock(&sbi->fs_lock);